1use crate::{asm, storage::Value};
3
4pub trait Storage {
6 #[cfg(not(target_family = "wasm"))]
7 const STORAGE_KEY: [u8; 32];
8 const STORAGE_SLOT: i32;
9
10 type Value: Value;
11
12 fn get() -> Self::Value {
14 Value::push(Self::STORAGE_SLOT);
15 Self::Value::sload()
16 }
17
18 fn set(value: Self::Value) {
20 value.push();
21 Value::push(Self::STORAGE_SLOT);
22 unsafe {
23 asm::evm::sstore();
24 }
25 }
26}
27
28pub trait TransientStorage {
30 #[cfg(not(target_family = "wasm"))]
31 const STORAGE_KEY: [u8; 32];
32 const STORAGE_SLOT: i32;
33
34 type Value: Value;
35
36 fn get() -> Self::Value {
38 Value::push(Self::STORAGE_SLOT);
39 Self::Value::tload()
40 }
41
42 fn set(value: Self::Value) {
44 value.push();
45 Value::push(Self::STORAGE_SLOT);
46 unsafe {
47 asm::evm::tstore();
48 }
49 }
50}