Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9d98d15
initial impl
shawntabrizi Jun 12, 2021
989d02b
expose in pallet_prelude
shawntabrizi Jun 12, 2021
a6321b1
temp test
shawntabrizi Jun 12, 2021
9ce58da
Apply suggestions from code review
gui1117 Jun 14, 2021
899eea4
implement with macro help.
gui1117 Jun 14, 2021
b5b74a1
Merge remote-tracking branch 'origin/master' into shawntabrizi-counte…
gui1117 Jun 15, 2021
43e635f
test for macro generation
gui1117 Jun 15, 2021
9885891
add iterable functions, some test and fixes
gui1117 Jun 15, 2021
2406021
Merge remote-tracking branch 'origin/master' into shawntabrizi-counte…
gui1117 Jun 16, 2021
4f31878
fix merge
gui1117 Jun 16, 2021
c588233
doc
gui1117 Jun 16, 2021
9c362a6
Update frame/support/src/storage/types/counted_map.rs
gui1117 Jul 5, 2021
ed44b79
Merge remote-tracking branch 'origin/master' into gui-shawntabrizi-co…
gui1117 Aug 6, 2021
cdb3fa3
fix merge
gui1117 Aug 6, 2021
f7417cf
fmt
gui1117 Aug 6, 2021
61208a4
fix spelling
gui1117 Aug 6, 2021
30da101
improve on removal
gui1117 Aug 6, 2021
c546c2e
fix partial storage info
gui1117 Aug 6, 2021
1e11c16
fmt
gui1117 Aug 6, 2021
497bc69
add license
gui1117 Aug 7, 2021
cc249fb
suggested renames
gui1117 Aug 7, 2021
4d6de59
fix typo
gui1117 Aug 7, 2021
3313f73
Merge remote-tracking branch 'origin/master' into gui-shawntabrizi-co…
gui1117 Sep 15, 2021
a4c7f3f
fix test
gui1117 Sep 15, 2021
4841dbb
fmt
gui1117 Sep 15, 2021
b3d2111
fix ui tests
gui1117 Sep 16, 2021
4b62aab
clearer doc
gui1117 Sep 16, 2021
448937d
better doc
gui1117 Sep 16, 2021
cc13432
add metadata test
gui1117 Sep 16, 2021
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
Prev Previous commit
Next Next commit
fix partial storage info
  • Loading branch information
gui1117 committed Aug 6, 2021
commit c546c2e1f712b13d6f0c24f04987c2b969fe5354
24 changes: 23 additions & 1 deletion frame/support/src/storage/types/counted_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
},
StorageAppend, StorageDecodeLength, StorageTryAppend,
},
traits::{Get, GetDefault, StorageInfo, StorageInstance},
traits::{Get, GetDefault, StorageInfo, StorageInstance, StorageInfoTrait},
Never,
};
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref};
Expand Down Expand Up @@ -432,6 +432,28 @@ where
}
}

/// It doesn't require to implement `MaxEncodedLen` and give no information for `max_size`.
impl<Prefix, Hasher, Key, Value, QueryKind, OnEmpty, MaxValues>
crate::traits::PartialStorageInfoTrait
for CountedStorageMap<Prefix, Hasher, Key, Value, QueryKind, OnEmpty, MaxValues>
where
Prefix: CountedStorageMapInstance,
Hasher: crate::hash::StorageHasher,
Key: FullCodec,
Value: FullCodec,
QueryKind: QueryKindTrait<Value, OnEmpty>,
OnEmpty: Get<QueryKind::Query> + 'static,
MaxValues: Get<Option<u32>>,
{
fn partial_storage_info() -> Vec<StorageInfo> {
[
<Self as Helper>::Map::partial_storage_info(),
CounterFor::<Prefix>::storage_info(),
].concat()
}
}


#[cfg(test)]
mod test {
use super::*;
Expand Down
35 changes: 28 additions & 7 deletions frame/support/test/tests/pallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ pub mod pallet {
}

// Test that a pallet with non generic event and generic genesis_config is correctly handled
// and that a pallet without the attribute generate_storage_info is correctly handled.
#[frame_support::pallet]
pub mod pallet2 {
use super::{SomeAssociation1, SomeType1};
Expand Down Expand Up @@ -449,6 +450,10 @@ pub mod pallet2 {
#[pallet::storage]
pub type SomeValue<T: Config> = StorageValue<_, Vec<u32>>;

#[pallet::storage]
pub type SomeCountedStorageMap<T> =
CountedStorageMap<Hasher = Twox64Concat, Key = u8, Value = u32>;

#[pallet::event]
pub enum Event {
/// Something
Expand Down Expand Up @@ -1445,12 +1450,28 @@ fn test_storage_info() {

assert_eq!(
Example2::storage_info(),
vec![StorageInfo {
pallet_name: b"Example2".to_vec(),
storage_name: b"SomeValue".to_vec(),
prefix: prefix(b"Example2", b"SomeValue").to_vec(),
max_values: Some(1),
max_size: None,
},],
vec![
StorageInfo {
pallet_name: b"Example2".to_vec(),
storage_name: b"SomeValue".to_vec(),
prefix: prefix(b"Example2", b"SomeValue").to_vec(),
max_values: Some(1),
max_size: None,
},
StorageInfo {
pallet_name: b"Example2".to_vec(),
storage_name: b"SomeCountedStorageMap".to_vec(),
prefix: prefix(b"Example2", b"SomeCountedStorageMap").to_vec(),
max_values: None,
max_size: None,
},
StorageInfo {
pallet_name: b"Example2".to_vec(),
storage_name: b"CounterForSomeCountedStorageMap".to_vec(),
prefix: prefix(b"Example2", b"CounterForSomeCountedStorageMap").to_vec(),
max_values: Some(1),
max_size: Some(4),
},
],
);
}