mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
Fix linked map for trait types and Option (#1809)
* Fix linked map for traits. * Fix Option<_> variant. * Improve naming a tad * Rebuild runtime * Encapsulate private data in the inner module. * Bump impl version. * Fix deriving codec in srml-example. * Fix derivation without importing parity-codec-derive. * Fix config() for map.
This commit is contained in:
@@ -136,11 +136,12 @@ macro_rules! for_each_tuple {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use parity_codec::Codec;
|
||||
use runtime_io::{with_externalities, Blake2Hasher};
|
||||
use runtime_primitives::BuildStorage;
|
||||
|
||||
pub trait Trait {
|
||||
type BlockNumber;
|
||||
type BlockNumber: Codec + Default;
|
||||
type Origin;
|
||||
}
|
||||
|
||||
@@ -160,6 +161,8 @@ mod tests {
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Example {
|
||||
pub Data get(data) build(|_| vec![(15u32, 42u64)]): linked_map u32 => u64;
|
||||
pub GenericData get(generic_data): linked_map T::BlockNumber => T::BlockNumber;
|
||||
pub GenericData2 get(generic_data2): linked_map T::BlockNumber => Option<T::BlockNumber>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ pub trait EnumerableStorageMap<K: codec::Codec, V: codec::Codec>: StorageMap<K,
|
||||
fn head<S: Storage>(storage: &S) -> Option<K>;
|
||||
|
||||
/// Enumerate all elements in the map.
|
||||
fn enumerate<'a, S: Storage>(storage: &'a S) -> Box<dyn Iterator<Item = (K, V)> + 'a>;
|
||||
fn enumerate<'a, S: Storage>(storage: &'a S) -> Box<dyn Iterator<Item = (K, V)> + 'a> where K: 'a, V: 'a;
|
||||
}
|
||||
|
||||
// FIXME #1466 Remove this in favour of `decl_storage` macro.
|
||||
|
||||
@@ -345,7 +345,7 @@ pub trait EnumerableStorageMap<K: Codec, V: Codec>: StorageMap<K, V> {
|
||||
fn head() -> Option<K>;
|
||||
|
||||
/// Enumerate all elements in the map.
|
||||
fn enumerate() -> Box<dyn Iterator<Item = (K, V)>>;
|
||||
fn enumerate() -> Box<dyn Iterator<Item = (K, V)>> where K: 'static, V: 'static;
|
||||
}
|
||||
|
||||
impl<K: Codec, V: Codec, U> EnumerableStorageMap<K, V> for U where U: generator::EnumerableStorageMap<K, V> {
|
||||
@@ -353,7 +353,7 @@ impl<K: Codec, V: Codec, U> EnumerableStorageMap<K, V> for U where U: generator:
|
||||
<U as generator::EnumerableStorageMap<K, V>>::head(&RuntimeStorage)
|
||||
}
|
||||
|
||||
fn enumerate() -> Box<dyn Iterator<Item = (K, V)>> {
|
||||
fn enumerate() -> Box<dyn Iterator<Item = (K, V)>> where K: 'static, V: 'static {
|
||||
<U as generator::EnumerableStorageMap<K, V>>::enumerate(&RuntimeStorage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user