Small fixes to the `storage_map` example
Small fix to storage_map example
@@ -16,11 +16,11 @@ storage {
abi StorageMapExample {
#[storage(write)]fn insert_into_map1(key: u64, value: u64);
- #[storage(write)]fn get_from_map1(key: u64, value: u64);
+ #[storage(read)]fn get_from_map1(key: u64, value: u64) -> u64;
- #[storage(read)]fn insert_into_map2(key: (b256, bool), value: Data);
+ #[storage(write)]fn insert_into_map2(key: (b256, bool), value: Data);
- #[storage(read)]fn get_from_map2(key: (b256, bool), value: Data);
+ #[storage(read)]fn get_from_map2(key: (b256, bool), value: Data) -> Data;
}
impl StorageMapExample for Contract {
@@ -28,15 +28,15 @@ impl StorageMapExample for Contract {
storage.map1.insert(key, value);
}
- #[storage(write)]fn get_from_map1(key: u64, value: u64) {
- storage.map1.insert(key, value);
+ #[storage(read)]fn get_from_map1(key: u64, value: u64) -> u64 {
+ storage.map1.get(key)
}
- #[storage(read)]fn insert_into_map2(key: (b256, bool), value: Data) {
- storage.map2.get(key);
+ #[storage(write)]fn insert_into_map2(key: (b256, bool), value: Data) {
+ storage.map2.insert(key, value);
}
- #[storage(read)]fn get_from_map2(key: (b256, bool), value: Data) {
- storage.map2.get(key);
+ #[storage(read)]fn get_from_map2(key: (b256, bool), value: Data) -> Data {
+ storage.map2.get(key)
}
}
