mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 06:17:56 +00:00
Explicitly declare decl_storage! getters as functions (#3870)
* parse decl_storage getters with fn keyword * test for get in decl_storage * update all decl_storage! getters * bump version * adjust missed doc line
This commit is contained in:
committed by
Bastian Köcher
parent
1111d79ac1
commit
5d5e71028e
@@ -260,10 +260,11 @@ mod tests {
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Example {
|
||||
pub Data get(data) build(|_| vec![(15u32, 42u64)]): linked_map hasher(twox_64_concat) u32 => u64;
|
||||
pub Data get(fn data) build(|_| vec![(15u32, 42u64)]): linked_map hasher(twox_64_concat) u32 => u64;
|
||||
pub OptionLinkedMap: linked_map u32 => Option<u32>;
|
||||
pub GenericData get(generic_data): linked_map hasher(twox_128) T::BlockNumber => T::BlockNumber;
|
||||
pub GenericData2 get(generic_data2): linked_map T::BlockNumber => Option<T::BlockNumber>;
|
||||
pub GenericData get(fn generic_data): linked_map hasher(twox_128) T::BlockNumber => T::BlockNumber;
|
||||
pub GenericData2 get(fn generic_data2): linked_map T::BlockNumber => Option<T::BlockNumber>;
|
||||
pub GetterNoFnKeyword get(no_fn): Option<u32>;
|
||||
|
||||
pub DataDM config(test_config) build(|_| vec![(15u32, 16u32, 42u64)]):
|
||||
double_map hasher(twox_64_concat) u32, blake2_256(u32) => u64;
|
||||
@@ -516,6 +517,15 @@ mod tests {
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetterNoFnKeyword"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGetterNoFnKeyword(PhantomData::<Test>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DataDM"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
|
||||
@@ -307,15 +307,15 @@ mod tests {
|
||||
|
||||
// getters: pub / $default
|
||||
// we need at least one type which uses T, otherwise GenesisConfig will complain.
|
||||
GETU32 get(u32_getter): T::Origin;
|
||||
pub PUBGETU32 get(pub_u32_getter) build(|config: &GenesisConfig| config.u32_getter_with_config): u32;
|
||||
GETU32WITHCONFIG get(u32_getter_with_config) config(): u32;
|
||||
pub PUBGETU32WITHCONFIG get(pub_u32_getter_with_config) config(): u32;
|
||||
GETU32MYDEF get(u32_getter_mydef): Option<u32>;
|
||||
pub PUBGETU32MYDEF get(pub_u32_getter_mydef) config(): u32 = 3;
|
||||
GETU32WITHCONFIGMYDEF get(u32_getter_with_config_mydef) config(): u32 = 2;
|
||||
pub PUBGETU32WITHCONFIGMYDEF get(pub_u32_getter_with_config_mydef) config(): u32 = 1;
|
||||
PUBGETU32WITHCONFIGMYDEFOPT get(pub_u32_getter_with_config_mydef_opt) config(): Option<u32>;
|
||||
GETU32 get(fn u32_getter): T::Origin;
|
||||
pub PUBGETU32 get(fn pub_u32_getter) build(|config: &GenesisConfig| config.u32_getter_with_config): u32;
|
||||
GETU32WITHCONFIG get(fn u32_getter_with_config) config(): u32;
|
||||
pub PUBGETU32WITHCONFIG get(fn pub_u32_getter_with_config) config(): u32;
|
||||
GETU32MYDEF get(fn u32_getter_mydef): Option<u32>;
|
||||
pub PUBGETU32MYDEF get(fn pub_u32_getter_mydef) config(): u32 = 3;
|
||||
GETU32WITHCONFIGMYDEF get(fn u32_getter_with_config_mydef) config(): u32 = 2;
|
||||
pub PUBGETU32WITHCONFIGMYDEF get(fn pub_u32_getter_with_config_mydef) config(): u32 = 1;
|
||||
PUBGETU32WITHCONFIGMYDEFOPT get(fn pub_u32_getter_with_config_mydef_opt) config(): Option<u32>;
|
||||
|
||||
// map non-getters: pub / $default
|
||||
MAPU32 : map u32 => Option<String>;
|
||||
@@ -324,17 +324,17 @@ mod tests {
|
||||
pub PUBMAPU32MYDEF : map u32 => Option<String>;
|
||||
|
||||
// map getters: pub / $default
|
||||
GETMAPU32 get(map_u32_getter): map u32 => String;
|
||||
pub PUBGETMAPU32 get(pub_map_u32_getter): map u32 => String;
|
||||
GETMAPU32 get(fn map_u32_getter): map u32 => String;
|
||||
pub PUBGETMAPU32 get(fn pub_map_u32_getter): map u32 => String;
|
||||
|
||||
GETMAPU32MYDEF get(map_u32_getter_mydef): map u32 => String = "map".into();
|
||||
pub PUBGETMAPU32MYDEF get(pub_map_u32_getter_mydef): map u32 => String = "pubmap".into();
|
||||
GETMAPU32MYDEF get(fn map_u32_getter_mydef): map u32 => String = "map".into();
|
||||
pub PUBGETMAPU32MYDEF get(fn pub_map_u32_getter_mydef): map u32 => String = "pubmap".into();
|
||||
|
||||
// linked map
|
||||
LINKEDMAPU32 : linked_map u32 => Option<String>;
|
||||
pub PUBLINKEDMAPU32MYDEF : linked_map u32 => Option<String>;
|
||||
GETLINKEDMAPU32 get(linked_map_u32_getter): linked_map u32 => String;
|
||||
pub PUBGETLINKEDMAPU32MYDEF get(pub_linked_map_u32_getter_mydef): linked_map u32 => String = "pubmap".into();
|
||||
GETLINKEDMAPU32 get(fn linked_map_u32_getter): linked_map u32 => String;
|
||||
pub PUBGETLINKEDMAPU32MYDEF get(fn pub_linked_map_u32_getter_mydef): linked_map u32 => String = "pubmap".into();
|
||||
|
||||
COMPLEXTYPE1: ::std::vec::Vec<<T as Trait>::Origin>;
|
||||
COMPLEXTYPE2: (Vec<Vec<(u16,Box<( )>)>>, u32);
|
||||
@@ -741,7 +741,7 @@ mod test3 {
|
||||
}
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
Foo get(foo) config(initial_foo): u32;
|
||||
Foo get(fn foo) config(initial_foo): u32;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user