mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
* rename StorageMap::exists(key) to ::contains_key(key) * bump impl_version
This commit is contained in:
@@ -110,7 +110,7 @@ where
|
||||
Self::storage_double_map_final_key(k1, k2)
|
||||
}
|
||||
|
||||
fn exists<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool
|
||||
fn contains_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool
|
||||
where
|
||||
KArg1: EncodeLike<K1>,
|
||||
KArg2: EncodeLike<K2>,
|
||||
|
||||
@@ -326,7 +326,7 @@ where
|
||||
|
||||
type Enumerator = Enumerator<K, V, G::KeyFormat>;
|
||||
|
||||
fn exists<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool {
|
||||
fn contains_key<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool {
|
||||
unhashed::exists(Self::storage_linked_map_final_key(key).as_ref())
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ impl<K: FullEncode, V: FullCodec, G: StorageMap<K, V>> storage::StorageMap<K, V>
|
||||
}
|
||||
}
|
||||
|
||||
fn exists<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool {
|
||||
fn contains_key<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool {
|
||||
unhashed::exists(Self::storage_map_final_key(key).as_ref())
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ pub trait StorageMap<K: FullEncode, V: FullCodec> {
|
||||
fn hashed_key_for<KeyArg: EncodeLike<K>>(key: KeyArg) -> Vec<u8>;
|
||||
|
||||
/// Does the value (explicitly) exist in storage?
|
||||
fn exists<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool;
|
||||
fn contains_key<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool;
|
||||
|
||||
/// Load the value associated with the given key from the map.
|
||||
fn get<KeyArg: EncodeLike<K>>(key: KeyArg) -> Self::Query;
|
||||
@@ -176,7 +176,7 @@ pub trait StorageMap<K: FullEncode, V: FullCodec> {
|
||||
/// `T` is required to implement `Codec::DecodeLength`.
|
||||
///
|
||||
/// Note that `0` is returned as the default value if no encoded value exists at the given key.
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::exists()`
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::contains_key()`
|
||||
/// function for this purpose.
|
||||
fn decode_len<KeyArg: EncodeLike<K>>(key: KeyArg) -> Result<usize, &'static str>
|
||||
where V: codec::DecodeLength + Len;
|
||||
@@ -196,7 +196,7 @@ pub trait StorageLinkedMap<K: FullCodec, V: FullCodec> {
|
||||
type Enumerator: Iterator<Item = (K, V)>;
|
||||
|
||||
/// Does the value (explicitly) exist in storage?
|
||||
fn exists<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool;
|
||||
fn contains_key<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool;
|
||||
|
||||
/// Load the value associated with the given key from the map.
|
||||
fn get<KeyArg: EncodeLike<K>>(key: KeyArg) -> Self::Query;
|
||||
@@ -227,7 +227,7 @@ pub trait StorageLinkedMap<K: FullCodec, V: FullCodec> {
|
||||
/// `T` is required to implement `Codec::DecodeLength`.
|
||||
///
|
||||
/// Note that `0` is returned as the default value if no encoded value exists at the given key.
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::exists()`
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::contains_key()`
|
||||
/// function for this purpose.
|
||||
fn decode_len<KeyArg: EncodeLike<K>>(key: KeyArg) -> Result<usize, &'static str>
|
||||
where V: codec::DecodeLength + Len;
|
||||
@@ -270,7 +270,7 @@ pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
|
||||
KArg1: EncodeLike<K1>,
|
||||
KArg2: EncodeLike<K2>;
|
||||
|
||||
fn exists<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool
|
||||
fn contains_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool
|
||||
where
|
||||
KArg1: EncodeLike<K1>,
|
||||
KArg2: EncodeLike<K2>;
|
||||
@@ -348,7 +348,7 @@ pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
|
||||
/// `V` is required to implement `Codec::DecodeLength`.
|
||||
///
|
||||
/// Note that `0` is returned as the default value if no encoded value exists at the given key.
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::exists()`
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::contains_key()`
|
||||
/// function for this purpose.
|
||||
fn decode_len<KArg1, KArg2>(key1: KArg1, key2: KArg2) -> Result<usize, &'static str>
|
||||
where
|
||||
|
||||
@@ -348,8 +348,8 @@ fn storage_with_instance_basic_operation() {
|
||||
assert_eq!(Value::get(), 0);
|
||||
|
||||
let key = 1;
|
||||
assert_eq!(Map::exists(0), true);
|
||||
assert_eq!(Map::exists(key), false);
|
||||
assert_eq!(Map::contains_key(0), true);
|
||||
assert_eq!(Map::contains_key(key), false);
|
||||
Map::insert(key, 1);
|
||||
assert_eq!(Map::get(key), 1);
|
||||
assert_eq!(Map::take(key), 1);
|
||||
@@ -357,11 +357,11 @@ fn storage_with_instance_basic_operation() {
|
||||
Map::mutate(key, |a| *a=2);
|
||||
assert_eq!(Map::get(key), 2);
|
||||
Map::remove(key);
|
||||
assert_eq!(Map::exists(key), false);
|
||||
assert_eq!(Map::contains_key(key), false);
|
||||
assert_eq!(Map::get(key), 0);
|
||||
|
||||
assert_eq!(LinkedMap::exists(0), true);
|
||||
assert_eq!(LinkedMap::exists(key), false);
|
||||
assert_eq!(LinkedMap::contains_key(0), true);
|
||||
assert_eq!(LinkedMap::contains_key(key), false);
|
||||
LinkedMap::insert(key, vec![1]);
|
||||
assert_eq!(LinkedMap::enumerate().count(), 2);
|
||||
assert_eq!(LinkedMap::get(key), vec![1]);
|
||||
@@ -373,17 +373,17 @@ fn storage_with_instance_basic_operation() {
|
||||
assert_eq!(LinkedMap::get(key), vec![2]);
|
||||
LinkedMap::remove(key);
|
||||
assert_eq!(LinkedMap::enumerate().count(), 1);
|
||||
assert_eq!(LinkedMap::exists(key), false);
|
||||
assert_eq!(LinkedMap::contains_key(key), false);
|
||||
assert_eq!(LinkedMap::get(key), vec![]);
|
||||
assert_eq!(LinkedMap::exists(key), false);
|
||||
assert_eq!(LinkedMap::contains_key(key), false);
|
||||
assert_eq!(LinkedMap::enumerate().count(), 1);
|
||||
LinkedMap::insert(key, &vec![1]);
|
||||
assert_eq!(LinkedMap::enumerate().count(), 2);
|
||||
|
||||
let key1 = 1;
|
||||
let key2 = 1;
|
||||
assert_eq!(DoubleMap::exists(&0, &0), true);
|
||||
assert_eq!(DoubleMap::exists(&key1, &key2), false);
|
||||
assert_eq!(DoubleMap::contains_key(&0, &0), true);
|
||||
assert_eq!(DoubleMap::contains_key(&key1, &key2), false);
|
||||
DoubleMap::insert(&key1, &key2, &1);
|
||||
assert_eq!(DoubleMap::get(&key1, &key2), 1);
|
||||
assert_eq!(DoubleMap::take(&key1, &key2), 1);
|
||||
|
||||
Reference in New Issue
Block a user