You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is currently impossible to insert into a StorageMap that is within a struct if using a helper function.
Within the example contract, you may call storage.my_struct.map_map.insert(0, 0), however if passing the StorageKey<MyStruct>, the StorageKey<StorageMap<u64, u64>> becomes inaccessible.
Example Contract:
contract;
usestd::hash::Hash;
pubstructMyStruct {
my_map:StorageMap<u64, u64>,
}
storage {
my_struct:MyStruct=MyStruct {
my_map:StorageMap {},
},
}
abiMyContract {
#[storage(read, write)]
fnwrite();
}
implMyContractforContract {
#[storage(read, write)]
fnwrite() {
// Possible to insert into mapstorage.my_struct.my_map.insert(1, 1);
// No longer possible to insert into mapwrite(storage.my_struct);
}
}
// Inserts into a StorageMap
#[storage(read, write)]
pubfnwrite(struct_key:StorageKey<MyStruct>) {
letmy_struct=struct_key.read();
// This is now a `StorageMap` and not a `StorageKey<StorageMap>`my_struct.my_map.insert(3, 3);
}
The text was updated successfully, but these errors were encountered:
bitzoic
added
bug
Something isn't working
compiler
General compiler. Should eventually become more specific as the issue is triaged
labels
May 23, 2024
It is currently impossible to insert into a
StorageMap
that is within a struct if using a helper function.Within the example contract, you may call
storage.my_struct.map_map.insert(0, 0)
, however if passing theStorageKey<MyStruct>
, theStorageKey<StorageMap<u64, u64>>
becomes inaccessible.Example Contract:
The text was updated successfully, but these errors were encountered: