Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdk/base/src/types/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<V: Into<Word> + From<Word>> ValueAccess<V> for Value {

pub trait StorageMapAccess<K, V> {
/// Returns a map item value for `key` from the account storage.
fn get(&self, key: &K) -> V;
fn get(&self, key: &K) -> Option<V>;
/// Sets a map item `value` for `key` in the account storage and returns (old_root, old_value)
fn set(&self, key: K, value: V) -> (StorageCommitmentRoot, V);
}
Expand All @@ -44,8 +44,8 @@ impl<K: Into<Word> + AsRef<Word>, V: From<Word> + Into<Word>> StorageMapAccess<K
{
/// Returns a map item value from the account storage.
#[inline(always)]
fn get(&self, key: &K) -> V {
storage::get_map_item(self.slot, key.as_ref()).into()
fn get(&self, key: &K) -> Option<V> {
Some(storage::get_map_item(self.slot, key.as_ref()).into())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to test if get_map_item returns zero word and if so - return None. See the Why section in #673.

}

/// Sets a map item `value` in the account storage and returns (old_root, old_value)
Expand Down