mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-25 10:41:08 +00:00
Adds try_get for StorageMap and StorageDoubleMap (#7774)
* Adds `try_get` for `StorageMap` and `StorageDoubleMap` * Switch to Value as return type
This commit is contained in:
@@ -153,6 +153,13 @@ impl<K1, K2, V, G> storage::StorageDoubleMap<K1, K2, V> for G where
|
||||
G::from_optional_value_to_query(unhashed::get(&Self::storage_double_map_final_key(k1, k2)))
|
||||
}
|
||||
|
||||
fn try_get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Result<V, ()>
|
||||
where
|
||||
KArg1: EncodeLike<K1>,
|
||||
KArg2: EncodeLike<K2> {
|
||||
unhashed::get(&Self::storage_double_map_final_key(k1, k2)).ok_or(())
|
||||
}
|
||||
|
||||
fn take<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query where
|
||||
KArg1: EncodeLike<K1>,
|
||||
KArg2: EncodeLike<K2>,
|
||||
|
||||
@@ -226,6 +226,10 @@ impl<K: FullEncode, V: FullCodec, G: StorageMap<K, V>> storage::StorageMap<K, V>
|
||||
G::from_optional_value_to_query(unhashed::get(Self::storage_map_final_key(key).as_ref()))
|
||||
}
|
||||
|
||||
fn try_get<KeyArg: EncodeLike<K>>(key: KeyArg) -> Result<V, ()> {
|
||||
unhashed::get(Self::storage_map_final_key(key).as_ref()).ok_or(())
|
||||
}
|
||||
|
||||
fn insert<KeyArg: EncodeLike<K>, ValArg: EncodeLike<V>>(key: KeyArg, val: ValArg) {
|
||||
unhashed::put(Self::storage_map_final_key(key).as_ref(), &val)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user