mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base * Second run * Add CI check * Fix compilation * More unnecessary braces * Handle weights * Use --all * Use correct attributes... * Fix UI tests * AHHHHHHHHH * 🤦 * Docs * Fix compilation * 🤷 * Please stop * 🤦 x 2 * More * make rustfmt.toml consistent with polkadot Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -19,12 +19,16 @@
|
||||
//! * error declareed with decl_error works
|
||||
//! * integrity test is generated
|
||||
|
||||
#![recursion_limit="128"]
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
use sp_runtime::{generic, traits::{BlakeTwo256, Verify}, DispatchError};
|
||||
use sp_core::{H256, sr25519};
|
||||
use sp_std::cell::RefCell;
|
||||
use frame_support::traits::PalletInfo as _;
|
||||
use sp_core::{sr25519, H256};
|
||||
use sp_runtime::{
|
||||
generic,
|
||||
traits::{BlakeTwo256, Verify},
|
||||
DispatchError,
|
||||
};
|
||||
use sp_std::cell::RefCell;
|
||||
|
||||
mod system;
|
||||
|
||||
@@ -51,7 +55,7 @@ mod module1 {
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode)]
|
||||
pub struct Origin<T, I: Instance = DefaultInstance>(pub core::marker::PhantomData::<(T, I)>);
|
||||
pub struct Origin<T, I: Instance = DefaultInstance>(pub core::marker::PhantomData<(T, I)>);
|
||||
|
||||
frame_support::decl_event! {
|
||||
pub enum Event<T, I: Instance = DefaultInstance> where
|
||||
@@ -263,8 +267,8 @@ pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<u32, Call, Signature, ()>;
|
||||
|
||||
mod origin_test {
|
||||
use frame_support::traits::{Filter, OriginTrait};
|
||||
use super::{module3, nested, system, Block, UncheckedExtrinsic};
|
||||
use frame_support::traits::{Filter, OriginTrait};
|
||||
|
||||
impl nested::module3::Config for RuntimeOriginTest {}
|
||||
impl module3::Config for RuntimeOriginTest {}
|
||||
@@ -556,10 +560,22 @@ fn get_call_names() {
|
||||
fn get_module_names() {
|
||||
use frame_support::dispatch::GetCallMetadata;
|
||||
let module_names = Call::get_module_names();
|
||||
assert_eq!([
|
||||
"System", "Module1_1", "Module2", "Module1_2", "NestedModule3", "Module3",
|
||||
"Module1_4", "Module1_6", "Module1_7", "Module1_8", "Module1_9",
|
||||
], module_names);
|
||||
assert_eq!(
|
||||
[
|
||||
"System",
|
||||
"Module1_1",
|
||||
"Module2",
|
||||
"Module1_2",
|
||||
"NestedModule3",
|
||||
"Module3",
|
||||
"Module1_4",
|
||||
"Module1_6",
|
||||
"Module1_7",
|
||||
"Module1_8",
|
||||
"Module1_9",
|
||||
],
|
||||
module_names
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -583,28 +599,32 @@ fn test_metadata() {
|
||||
ModuleMetadata {
|
||||
name: DecodeDifferent::Encode("System"),
|
||||
storage: None,
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("noop"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Encode("ExtrinsicSuccess"),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("noop"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Encode("ExtrinsicFailed"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Encode("Ignore"),
|
||||
arguments: DecodeDifferent::Encode(&["BlockNumber"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Encode("ExtrinsicSuccess"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Encode("ExtrinsicFailed"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Encode("Ignore"),
|
||||
arguments: DecodeDifferent::Encode(&["BlockNumber"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 30,
|
||||
@@ -615,18 +635,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Instance1Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
FunctionMetadata {
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 31,
|
||||
@@ -637,20 +659,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
FunctionMetadata {
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
EventMetadata {
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 32,
|
||||
@@ -661,16 +683,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Instance2Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 33,
|
||||
@@ -681,20 +707,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
FunctionMetadata {
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
EventMetadata {
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 34,
|
||||
@@ -705,68 +731,68 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_1"),
|
||||
arguments: DecodeDifferent::Encode(&[
|
||||
FunctionArgumentMetadata {
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_1"),
|
||||
arguments: DecodeDifferent::Encode(&[FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data"),
|
||||
ty: DecodeDifferent::Encode("Compact<u32>"),
|
||||
},
|
||||
]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_2"),
|
||||
arguments: DecodeDifferent::Encode(&[
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data"),
|
||||
ty: DecodeDifferent::Encode("i32"),
|
||||
},
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data2"),
|
||||
ty: DecodeDifferent::Encode("Compact<u32>"),
|
||||
},
|
||||
]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_3"),
|
||||
arguments: DecodeDifferent::Encode(&[
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data"),
|
||||
ty: DecodeDifferent::Encode("i32"),
|
||||
},
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data2"),
|
||||
ty: DecodeDifferent::Encode("String"),
|
||||
},
|
||||
]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_4"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("operational"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[
|
||||
EventMetadata {
|
||||
}]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_2"),
|
||||
arguments: DecodeDifferent::Encode(&[
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data"),
|
||||
ty: DecodeDifferent::Encode("i32"),
|
||||
},
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data2"),
|
||||
ty: DecodeDifferent::Encode("Compact<u32>"),
|
||||
},
|
||||
]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_3"),
|
||||
arguments: DecodeDifferent::Encode(&[
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data"),
|
||||
ty: DecodeDifferent::Encode("i32"),
|
||||
},
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Encode("_data2"),
|
||||
ty: DecodeDifferent::Encode("String"),
|
||||
},
|
||||
]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("aux_4"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("operational"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]))),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 35,
|
||||
@@ -786,11 +812,13 @@ fn test_metadata() {
|
||||
ModuleMetadata {
|
||||
name: DecodeDifferent::Encode("Module1_4"),
|
||||
storage: None,
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
event: None,
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
@@ -800,11 +828,13 @@ fn test_metadata() {
|
||||
name: DecodeDifferent::Encode("Module1_5"),
|
||||
storage: None,
|
||||
calls: None,
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 4,
|
||||
@@ -815,16 +845,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Instance6Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 1,
|
||||
@@ -835,16 +869,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Instance7Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 2,
|
||||
@@ -855,16 +893,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Instance8Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 12,
|
||||
@@ -875,16 +917,20 @@ fn test_metadata() {
|
||||
prefix: DecodeDifferent::Encode("Instance9Module"),
|
||||
entries: DecodeDifferent::Encode(&[]),
|
||||
}))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| &[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]))),
|
||||
calls: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[FunctionMetadata {
|
||||
name: DecodeDifferent::Encode("fail"),
|
||||
arguments: DecodeDifferent::Encode(&[]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
event: Some(DecodeDifferent::Encode(FnEncode(|| {
|
||||
&[EventMetadata {
|
||||
name: DecodeDifferent::Encode("A"),
|
||||
arguments: DecodeDifferent::Encode(&["AccountId"]),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}]
|
||||
}))),
|
||||
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
errors: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||
index: 13,
|
||||
|
||||
@@ -28,8 +28,7 @@ mod tests {
|
||||
}
|
||||
|
||||
pub trait Config: frame_support_test::Config {
|
||||
type Origin2: codec::Codec + codec::EncodeLike + Default
|
||||
+ codec::MaxEncodedLen;
|
||||
type Origin2: codec::Codec + codec::EncodeLike + Default + codec::MaxEncodedLen;
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
@@ -104,329 +103,334 @@ mod tests {
|
||||
|
||||
const EXPECTED_METADATA: StorageMetadata = StorageMetadata {
|
||||
prefix: DecodeDifferent::Encode("TestStorage"),
|
||||
entries: DecodeDifferent::Encode(
|
||||
&[
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("U32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[ " Hello, this is doc!" ]),
|
||||
entries: DecodeDifferent::Encode(&[
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("U32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[" Hello, this is doc!"]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBU32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructPUBU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("U32MYDEF"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructU32MYDEF(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructPUBU32MYDEF(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("T::Origin2")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructGETU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructPUBGETU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32WITHCONFIG"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructGETU32WITHCONFIG(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIG"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructPUBGETU32WITHCONFIG(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructGETU32MYDEF(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructPUBGETU32MYDEF(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32WITHCONFIGMYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructPUBGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEFOPT"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructPUBGETU32WITHCONFIGMYDEFOPT(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetU32WithBuilder"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructGetU32WithBuilder(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetOptU32WithBuilderSome"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructGetOptU32WithBuilderSome(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetOptU32WithBuilderNone"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructGetOptU32WithBuilderNone(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("MAPU32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBU32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructMAPU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBMAPU32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("U32MYDEF"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructU32MYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructPUBMAPU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETMAPU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBU32MYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructGETMAPU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETMAPU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("T::Origin2")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGETU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructPUBGETMAPU32(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETMAPU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructGETMAPU32MYDEF(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETMAPU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32WITHCONFIG"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGETU32WITHCONFIG(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&__GetByteStructPUBGETMAPU32MYDEF(PhantomData::<TraitImpl>),
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DOUBLEMAP"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key1: DecodeDifferent::Encode("u32"),
|
||||
key2: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
key2_hasher: StorageHasher::Blake2_128Concat,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIG"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIG(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructDOUBLEMAP(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DOUBLEMAP2"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key1: DecodeDifferent::Encode("u32"),
|
||||
key2: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
key2_hasher: StorageHasher::Blake2_128Concat,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGETU32MYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructDOUBLEMAP2(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE1"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode(
|
||||
"(::std::option::Option<T::Origin2>,)",
|
||||
)),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructCOMPLEXTYPE1(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE2"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode(
|
||||
"([[(u16, Option<()>); 32]; 12], u32)",
|
||||
)),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructCOMPLEXTYPE2(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE3"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("[u32; 25]")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructCOMPLEXTYPE3(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("NMAP"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Encode(&["u32", "u16"]),
|
||||
hashers: DecodeDifferent::Encode(&[
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat,
|
||||
]),
|
||||
value: DecodeDifferent::Encode("u8"),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETU32MYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructNMAP(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("NMAP2"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Encode(&["u32"]),
|
||||
hashers: DecodeDifferent::Encode(&[StorageHasher::Blake2_128Concat]),
|
||||
value: DecodeDifferent::Encode("u8"),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETU32WITHCONFIGMYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEFOPT"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIGMYDEFOPT(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetU32WithBuilder"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGetU32WithBuilder(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetOptU32WithBuilderSome"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGetOptU32WithBuilderSome(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GetOptU32WithBuilderNone"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGetOptU32WithBuilderNone(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("MAPU32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructMAPU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBMAPU32"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBMAPU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETMAPU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGETMAPU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETMAPU32"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETMAPU32(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("GETMAPU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructGETMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("PUBGETMAPU32MYDEF"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructPUBGETMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DOUBLEMAP"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key1: DecodeDifferent::Encode("u32"),
|
||||
key2: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
key2_hasher: StorageHasher::Blake2_128Concat,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructDOUBLEMAP(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DOUBLEMAP2"),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
hasher: StorageHasher::Blake2_128Concat,
|
||||
key1: DecodeDifferent::Encode("u32"),
|
||||
key2: DecodeDifferent::Encode("u32"),
|
||||
value: DecodeDifferent::Encode("[u8; 4]"),
|
||||
key2_hasher: StorageHasher::Blake2_128Concat,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructDOUBLEMAP2(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE1"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("(::std::option::Option<T::Origin2>,)")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE1(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE2"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("([[(u16, Option<()>); 32]; 12], u32)")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE2(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE3"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("[u32; 25]")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE3(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("NMAP"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Encode(&["u32", "u16"]),
|
||||
hashers: DecodeDifferent::Encode(&[StorageHasher::Blake2_128Concat, StorageHasher::Twox64Concat]),
|
||||
value: DecodeDifferent::Encode("u8"),
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructNMAP(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("NMAP2"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Encode(&["u32"]),
|
||||
hashers: DecodeDifferent::Encode(&[StorageHasher::Blake2_128Concat]),
|
||||
value: DecodeDifferent::Encode("u8"),
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructNMAP(PhantomData::<TraitImpl>))
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]
|
||||
),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&__GetByteStructNMAP(
|
||||
PhantomData::<TraitImpl>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]),
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn storage_info() {
|
||||
use frame_support::{
|
||||
StorageHasher,
|
||||
traits::{StorageInfoTrait, StorageInfo},
|
||||
pallet_prelude::*,
|
||||
traits::{StorageInfo, StorageInfoTrait},
|
||||
StorageHasher,
|
||||
};
|
||||
let prefix = |pallet_name, storage_name| {
|
||||
let mut res = [0u8; 32];
|
||||
@@ -713,9 +717,9 @@ mod test2 {
|
||||
#[test]
|
||||
fn storage_info() {
|
||||
use frame_support::{
|
||||
StorageHasher,
|
||||
traits::{StorageInfoTrait, StorageInfo},
|
||||
pallet_prelude::*,
|
||||
traits::{StorageInfo, StorageInfoTrait},
|
||||
StorageHasher,
|
||||
};
|
||||
let prefix = |pallet_name, storage_name| {
|
||||
let mut res = [0u8; 32];
|
||||
@@ -757,7 +761,6 @@ mod test2 {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -791,8 +794,8 @@ mod test3 {
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod test_append_and_len {
|
||||
use codec::{Decode, Encode};
|
||||
use sp_io::TestExternalities;
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! RuntimeDebugNoBound
|
||||
|
||||
use frame_support::{
|
||||
DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound, DefaultNoBound,
|
||||
CloneNoBound, DebugNoBound, DefaultNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
|
||||
};
|
||||
|
||||
#[derive(RuntimeDebugNoBound)]
|
||||
@@ -59,7 +59,7 @@ fn test_struct_named() {
|
||||
phantom: Default::default(),
|
||||
};
|
||||
|
||||
let a_default: StructNamed::<Runtime, ImplNone, ImplNone> = Default::default();
|
||||
let a_default: StructNamed<Runtime, ImplNone, ImplNone> = Default::default();
|
||||
assert_eq!(a_default.a, 0);
|
||||
assert_eq!(a_default.b, 0);
|
||||
assert_eq!(a_default.c, 0);
|
||||
@@ -90,14 +90,9 @@ struct StructUnnamed<T: Config, U, V>(u32, u64, T::C, core::marker::PhantomData<
|
||||
|
||||
#[test]
|
||||
fn test_struct_unnamed() {
|
||||
let a_1 = StructUnnamed::<Runtime, ImplNone, ImplNone>(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
Default::default(),
|
||||
);
|
||||
let a_1 = StructUnnamed::<Runtime, ImplNone, ImplNone>(1, 2, 3, Default::default());
|
||||
|
||||
let a_default: StructUnnamed::<Runtime, ImplNone, ImplNone> = Default::default();
|
||||
let a_default: StructUnnamed<Runtime, ImplNone, ImplNone> = Default::default();
|
||||
assert_eq!(a_default.0, 0);
|
||||
assert_eq!(a_default.1, 0);
|
||||
assert_eq!(a_default.2, 0);
|
||||
@@ -108,17 +103,9 @@ fn test_struct_unnamed() {
|
||||
assert_eq!(a_2.1, 2);
|
||||
assert_eq!(a_2.2, 3);
|
||||
assert_eq!(a_2, a_1);
|
||||
assert_eq!(
|
||||
format!("{:?}", a_1),
|
||||
String::from("StructUnnamed(1, 2, 3, PhantomData)")
|
||||
);
|
||||
assert_eq!(format!("{:?}", a_1), String::from("StructUnnamed(1, 2, 3, PhantomData)"));
|
||||
|
||||
let b = StructUnnamed::<Runtime, ImplNone, ImplNone>(
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
Default::default(),
|
||||
);
|
||||
let b = StructUnnamed::<Runtime, ImplNone, ImplNone>(1, 2, 4, Default::default());
|
||||
|
||||
assert!(b != a_1);
|
||||
}
|
||||
@@ -126,12 +113,7 @@ fn test_struct_unnamed() {
|
||||
#[derive(DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound, DefaultNoBound)]
|
||||
enum Enum<T: Config, U, V> {
|
||||
VariantUnnamed(u32, u64, T::C, core::marker::PhantomData<(U, V)>),
|
||||
VariantNamed {
|
||||
a: u32,
|
||||
b: u64,
|
||||
c: T::C,
|
||||
phantom: core::marker::PhantomData<(U, V)>,
|
||||
},
|
||||
VariantNamed { a: u32, b: u64, c: T::C, phantom: core::marker::PhantomData<(U, V)> },
|
||||
VariantUnit,
|
||||
VariantUnit2,
|
||||
}
|
||||
@@ -139,11 +121,7 @@ enum Enum<T: Config, U, V> {
|
||||
// enum that will have a named default.
|
||||
#[derive(DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound, DefaultNoBound)]
|
||||
enum Enum2<T: Config> {
|
||||
VariantNamed {
|
||||
a: u32,
|
||||
b: u64,
|
||||
c: T::C,
|
||||
},
|
||||
VariantNamed { a: u32, b: u64, c: T::C },
|
||||
VariantUnnamed(u32, u64, T::C),
|
||||
VariantUnit,
|
||||
VariantUnit2,
|
||||
@@ -153,18 +131,14 @@ enum Enum2<T: Config> {
|
||||
#[derive(DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound, DefaultNoBound)]
|
||||
enum Enum3<T: Config> {
|
||||
VariantUnit,
|
||||
VariantNamed {
|
||||
a: u32,
|
||||
b: u64,
|
||||
c: T::C,
|
||||
},
|
||||
VariantNamed { a: u32, b: u64, c: T::C },
|
||||
VariantUnnamed(u32, u64, T::C),
|
||||
VariantUnit2,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum() {
|
||||
type TestEnum = Enum::<Runtime, ImplNone, ImplNone>;
|
||||
type TestEnum = Enum<Runtime, ImplNone, ImplNone>;
|
||||
let variant_0 = TestEnum::VariantUnnamed(1, 2, 3, Default::default());
|
||||
let variant_0_bis = TestEnum::VariantUnnamed(1, 2, 4, Default::default());
|
||||
let variant_1 = TestEnum::VariantNamed { a: 1, b: 2, c: 3, phantom: Default::default() };
|
||||
@@ -179,14 +153,8 @@ fn test_enum() {
|
||||
TestEnum::VariantUnnamed(0, 0, 0, Default::default())
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
Enum2::<Runtime>::default(),
|
||||
Enum2::<Runtime>::VariantNamed { a: 0, b: 0, c: 0},
|
||||
);
|
||||
assert_eq!(
|
||||
Enum3::<Runtime>::default(),
|
||||
Enum3::<Runtime>::VariantUnit,
|
||||
);
|
||||
assert_eq!(Enum2::<Runtime>::default(), Enum2::<Runtime>::VariantNamed { a: 0, b: 0, c: 0 },);
|
||||
assert_eq!(Enum3::<Runtime>::default(), Enum3::<Runtime>::VariantUnit,);
|
||||
|
||||
assert!(variant_0 != variant_0_bis);
|
||||
assert!(variant_1 != variant_1_bis);
|
||||
@@ -216,12 +184,6 @@ fn test_enum() {
|
||||
format!("{:?}", variant_1),
|
||||
String::from("Enum::VariantNamed { a: 1, b: 2, c: 3, phantom: PhantomData }"),
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{:?}", variant_2),
|
||||
String::from("Enum::VariantUnit"),
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{:?}", variant_3),
|
||||
String::from("Enum::VariantUnit2"),
|
||||
);
|
||||
assert_eq!(format!("{:?}", variant_2), String::from("Enum::VariantUnit"),);
|
||||
assert_eq!(format!("{:?}", variant_3), String::from("Enum::VariantUnit2"),);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_support::storage::unhashed;
|
||||
use codec::Encode;
|
||||
use frame_support::{StorageDoubleMap, StorageMap, StorageValue, StoragePrefixedMap};
|
||||
use sp_io::{TestExternalities, hashing::{twox_64, twox_128, blake2_128}};
|
||||
use frame_support::{
|
||||
storage::unhashed, StorageDoubleMap, StorageMap, StoragePrefixedMap, StorageValue,
|
||||
};
|
||||
use sp_io::{
|
||||
hashing::{blake2_128, twox_128, twox_64},
|
||||
TestExternalities,
|
||||
};
|
||||
|
||||
mod no_instance {
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
@@ -27,7 +31,7 @@ mod no_instance {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Config> as FinalKeysNone {
|
||||
pub Value config(value): u32;
|
||||
|
||||
@@ -52,7 +56,7 @@ mod instance {
|
||||
for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Config<I>, I: Instance = DefaultInstance>
|
||||
as FinalKeysSome
|
||||
{
|
||||
|
||||
@@ -40,7 +40,5 @@ impl Config for Test {}
|
||||
|
||||
#[test]
|
||||
fn init_genesis_config() {
|
||||
GenesisConfig::<Test> {
|
||||
t: Default::default(),
|
||||
};
|
||||
GenesisConfig::<Test> { t: Default::default() };
|
||||
}
|
||||
|
||||
@@ -15,20 +15,25 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#![recursion_limit="128"]
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
use codec::{Codec, EncodeLike, Encode, Decode};
|
||||
use sp_runtime::{generic, BuildStorage, traits::{BlakeTwo256, Verify}};
|
||||
use codec::{Codec, Decode, Encode, EncodeLike};
|
||||
use frame_support::{
|
||||
Parameter, traits::Get, parameter_types,
|
||||
inherent::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent},
|
||||
metadata::{
|
||||
DecodeDifferent, StorageMetadata, StorageEntryModifier, StorageEntryType, DefaultByteGetter,
|
||||
StorageEntryMetadata, StorageHasher,
|
||||
DecodeDifferent, DefaultByteGetter, StorageEntryMetadata, StorageEntryModifier,
|
||||
StorageEntryType, StorageHasher, StorageMetadata,
|
||||
},
|
||||
StorageValue, StorageMap, StorageDoubleMap,
|
||||
inherent::{ProvideInherent, InherentData, InherentIdentifier, MakeFatalError},
|
||||
parameter_types,
|
||||
traits::Get,
|
||||
Parameter, StorageDoubleMap, StorageMap, StorageValue,
|
||||
};
|
||||
use sp_core::{sr25519, H256};
|
||||
use sp_runtime::{
|
||||
generic,
|
||||
traits::{BlakeTwo256, Verify},
|
||||
BuildStorage,
|
||||
};
|
||||
use sp_core::{H256, sr25519};
|
||||
|
||||
mod system;
|
||||
|
||||
@@ -41,7 +46,10 @@ mod module1 {
|
||||
use super::*;
|
||||
use sp_std::ops::Add;
|
||||
|
||||
pub trait Config<I>: system::Config where <Self as system::Config>::BlockNumber: From<u32> {
|
||||
pub trait Config<I>: system::Config
|
||||
where
|
||||
<Self as system::Config>::BlockNumber: From<u32>,
|
||||
{
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
type SomeParameter: Get<u32>;
|
||||
@@ -101,15 +109,19 @@ mod module1 {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode)]
|
||||
pub enum Origin<T: Config<I>, I> where T::BlockNumber: From<u32> {
|
||||
pub enum Origin<T: Config<I>, I>
|
||||
where
|
||||
T::BlockNumber: From<u32>,
|
||||
{
|
||||
Members(u32),
|
||||
_Phantom(std::marker::PhantomData<(T, I)>),
|
||||
}
|
||||
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678";
|
||||
|
||||
impl<T: Config<I>, I: Instance> ProvideInherent for Module<T, I> where
|
||||
T::BlockNumber: From<u32>
|
||||
impl<T: Config<I>, I: Instance> ProvideInherent for Module<T, I>
|
||||
where
|
||||
T::BlockNumber: From<u32>,
|
||||
{
|
||||
type Call = Call<T, I>;
|
||||
type Error = MakeFatalError<()>;
|
||||
@@ -119,7 +131,10 @@ mod module1 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn check_inherent(_: &Self::Call, _: &InherentData) -> std::result::Result<(), Self::Error> {
|
||||
fn check_inherent(
|
||||
_: &Self::Call,
|
||||
_: &InherentData,
|
||||
) -> std::result::Result<(), Self::Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
@@ -135,7 +150,7 @@ mod module1 {
|
||||
mod module2 {
|
||||
use super::*;
|
||||
|
||||
pub trait Config<I=DefaultInstance>: system::Config {
|
||||
pub trait Config<I = DefaultInstance>: system::Config {
|
||||
type Amount: Parameter + Default;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
@@ -167,7 +182,7 @@ mod module2 {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode)]
|
||||
pub enum Origin<T: Config<I>, I=DefaultInstance> {
|
||||
pub enum Origin<T: Config<I>, I = DefaultInstance> {
|
||||
Members(u32),
|
||||
_Phantom(std::marker::PhantomData<(T, I)>),
|
||||
}
|
||||
@@ -183,7 +198,10 @@ mod module2 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn check_inherent(_call: &Self::Call, _data: &InherentData) -> std::result::Result<(), Self::Error> {
|
||||
fn check_inherent(
|
||||
_call: &Self::Call,
|
||||
_data: &InherentData,
|
||||
) -> std::result::Result<(), Self::Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
@@ -198,7 +216,9 @@ mod module2 {
|
||||
mod module3 {
|
||||
use super::*;
|
||||
|
||||
pub trait Config: module2::Config + module2::Config<module2::Instance1> + system::Config {
|
||||
pub trait Config:
|
||||
module2::Config + module2::Config<module2::Instance1> + system::Config
|
||||
{
|
||||
type Currency: Currency;
|
||||
type Currency2: Currency;
|
||||
}
|
||||
@@ -255,7 +275,7 @@ pub type BlockNumber = u64;
|
||||
pub type Index = u64;
|
||||
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter= frame_support::traits::AllowAll;
|
||||
type BaseCallFilter = frame_support::traits::AllowAll;
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
type BlockNumber = BlockNumber;
|
||||
@@ -298,15 +318,9 @@ pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<u32, Call, Signature, ()>;
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
GenesisConfig{
|
||||
module_1_1: module1::GenesisConfig {
|
||||
value: 3,
|
||||
test: 2,
|
||||
},
|
||||
module_1_2: module1::GenesisConfig {
|
||||
value: 4,
|
||||
test: 5,
|
||||
},
|
||||
GenesisConfig {
|
||||
module_1_1: module1::GenesisConfig { value: 3, test: 2 },
|
||||
module_1_2: module1::GenesisConfig { value: 4, test: 5 },
|
||||
module_2: module2::GenesisConfig {
|
||||
value: 4,
|
||||
map: vec![(0, 0)],
|
||||
@@ -319,14 +333,17 @@ fn new_test_ext() -> sp_io::TestExternalities {
|
||||
},
|
||||
module_2_2: Default::default(),
|
||||
module_2_3: Default::default(),
|
||||
}.build_storage().unwrap().into()
|
||||
}
|
||||
.build_storage()
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn storage_instance_independence() {
|
||||
let mut storage = sp_core::storage::Storage {
|
||||
top: std::collections::BTreeMap::new(),
|
||||
children_default: std::collections::HashMap::new()
|
||||
children_default: std::collections::HashMap::new(),
|
||||
};
|
||||
sp_state_machine::BasicExternalities::execute_with_storage(&mut storage, || {
|
||||
module2::Value::<Runtime>::put(0);
|
||||
@@ -359,7 +376,7 @@ fn storage_with_instance_basic_operation() {
|
||||
assert_eq!(Value::get(), 1);
|
||||
assert_eq!(Value::take(), 1);
|
||||
assert_eq!(Value::get(), 0);
|
||||
Value::mutate(|a| *a=2);
|
||||
Value::mutate(|a| *a = 2);
|
||||
assert_eq!(Value::get(), 2);
|
||||
Value::kill();
|
||||
assert_eq!(Value::exists(), false);
|
||||
@@ -372,7 +389,7 @@ fn storage_with_instance_basic_operation() {
|
||||
assert_eq!(Map::get(key), 1);
|
||||
assert_eq!(Map::take(key), 1);
|
||||
assert_eq!(Map::get(key), 0);
|
||||
Map::mutate(key, |a| *a=2);
|
||||
Map::mutate(key, |a| *a = 2);
|
||||
assert_eq!(Map::get(key), 2);
|
||||
Map::remove(key);
|
||||
assert_eq!(Map::contains_key(key), false);
|
||||
@@ -386,7 +403,7 @@ fn storage_with_instance_basic_operation() {
|
||||
assert_eq!(DoubleMap::get(&key1, &key2), 1);
|
||||
assert_eq!(DoubleMap::take(&key1, &key2), 1);
|
||||
assert_eq!(DoubleMap::get(&key1, &key2), 0);
|
||||
DoubleMap::mutate(&key1, &key2, |a| *a=2);
|
||||
DoubleMap::mutate(&key1, &key2, |a| *a = 2);
|
||||
assert_eq!(DoubleMap::get(&key1, &key2), 2);
|
||||
DoubleMap::remove(&key1, &key2);
|
||||
assert_eq!(DoubleMap::get(&key1, &key2), 0);
|
||||
@@ -395,60 +412,48 @@ fn storage_with_instance_basic_operation() {
|
||||
|
||||
const EXPECTED_METADATA: StorageMetadata = StorageMetadata {
|
||||
prefix: DecodeDifferent::Encode("Instance2Module2"),
|
||||
entries: DecodeDifferent::Encode(
|
||||
&[
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("Value"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("T::Amount")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(
|
||||
&module2::__GetByteStructValue(
|
||||
std::marker::PhantomData::<(Runtime, module2::Instance2)>
|
||||
)
|
||||
)
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
entries: DecodeDifferent::Encode(&[
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("Value"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("T::Amount")),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&module2::__GetByteStructValue(
|
||||
std::marker::PhantomData::<(Runtime, module2::Instance2)>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("Map"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Identity,
|
||||
key: DecodeDifferent::Encode("u64"),
|
||||
value: DecodeDifferent::Encode("u64"),
|
||||
unused: false,
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("Map"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hasher: StorageHasher::Identity,
|
||||
key: DecodeDifferent::Encode("u64"),
|
||||
value: DecodeDifferent::Encode("u64"),
|
||||
unused: false,
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(
|
||||
&module2::__GetByteStructMap(
|
||||
std::marker::PhantomData::<(Runtime, module2::Instance2)>
|
||||
)
|
||||
)
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(&module2::__GetByteStructMap(
|
||||
std::marker::PhantomData::<(Runtime, module2::Instance2)>,
|
||||
))),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DoubleMap"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
hasher: StorageHasher::Identity,
|
||||
key2_hasher: StorageHasher::Identity,
|
||||
key1: DecodeDifferent::Encode("u64"),
|
||||
key2: DecodeDifferent::Encode("u64"),
|
||||
value: DecodeDifferent::Encode("u64"),
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("DoubleMap"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
hasher: StorageHasher::Identity,
|
||||
key2_hasher: StorageHasher::Identity,
|
||||
key1: DecodeDifferent::Encode("u64"),
|
||||
key2: DecodeDifferent::Encode("u64"),
|
||||
value: DecodeDifferent::Encode("u64"),
|
||||
},
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(
|
||||
&module2::__GetByteStructDoubleMap(
|
||||
std::marker::PhantomData::<(Runtime, module2::Instance2)>
|
||||
)
|
||||
)
|
||||
default: DecodeDifferent::Encode(DefaultByteGetter(
|
||||
&module2::__GetByteStructDoubleMap(
|
||||
std::marker::PhantomData::<(Runtime, module2::Instance2)>,
|
||||
),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
}
|
||||
]
|
||||
)
|
||||
)),
|
||||
documentation: DecodeDifferent::Encode(&[]),
|
||||
},
|
||||
]),
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -15,22 +15,23 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_support::sp_runtime::generic;
|
||||
use frame_support::sp_runtime::traits::{BlakeTwo256, Verify};
|
||||
use frame_support::codec::{Encode, Decode};
|
||||
use sp_core::{H256, sr25519};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use frame_support::{
|
||||
codec::{Decode, Encode},
|
||||
sp_runtime::{
|
||||
generic,
|
||||
traits::{BlakeTwo256, Verify},
|
||||
},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_core::{sr25519, H256};
|
||||
|
||||
mod system;
|
||||
|
||||
mod module {
|
||||
use super::*;
|
||||
|
||||
pub type Request<T> = (
|
||||
<T as system::Config>::AccountId,
|
||||
Role,
|
||||
<T as system::Config>::BlockNumber,
|
||||
);
|
||||
pub type Request<T> =
|
||||
(<T as system::Config>::AccountId, Role, <T as system::Config>::BlockNumber);
|
||||
pub type Requests<T> = Vec<Request<T>>;
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Debug)]
|
||||
@@ -89,14 +90,12 @@ mod module {
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Serialize, Deserialize)]
|
||||
pub struct Data<T: Config> {
|
||||
pub data: T::BlockNumber,
|
||||
pub data: T::BlockNumber,
|
||||
}
|
||||
|
||||
impl<T: Config> Default for Data<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
data: T::BlockNumber::default(),
|
||||
}
|
||||
Self { data: T::BlockNumber::default() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +184,6 @@ frame_support::construct_runtime!(
|
||||
#[test]
|
||||
fn create_genesis_config() {
|
||||
GenesisConfig {
|
||||
module: module::GenesisConfig {
|
||||
request_life_time: 0,
|
||||
enable_storage_role: true,
|
||||
}
|
||||
module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,48 +16,87 @@
|
||||
// limitations under the License.
|
||||
|
||||
use frame_support::{
|
||||
weights::{DispatchInfo, DispatchClass, Pays, GetDispatchInfo},
|
||||
traits::{
|
||||
GetCallName, OnInitialize, OnFinalize, OnRuntimeUpgrade, GetPalletVersion, OnGenesis,
|
||||
},
|
||||
dispatch::{UnfilteredDispatchable, Parameter},
|
||||
dispatch::{Parameter, UnfilteredDispatchable},
|
||||
storage::unhashed,
|
||||
traits::{
|
||||
GetCallName, GetPalletVersion, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade,
|
||||
},
|
||||
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays},
|
||||
};
|
||||
use sp_io::{
|
||||
hashing::{blake2_128, twox_128, twox_64},
|
||||
TestExternalities,
|
||||
};
|
||||
use sp_runtime::DispatchError;
|
||||
use sp_io::{TestExternalities, hashing::{twox_64, twox_128, blake2_128}};
|
||||
|
||||
pub struct SomeType1;
|
||||
impl From<SomeType1> for u64 { fn from(_t: SomeType1) -> Self { 0u64 } }
|
||||
impl From<SomeType1> for u64 {
|
||||
fn from(_t: SomeType1) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeType2;
|
||||
impl From<SomeType2> for u64 { fn from(_t: SomeType2) -> Self { 100u64 } }
|
||||
impl From<SomeType2> for u64 {
|
||||
fn from(_t: SomeType2) -> Self {
|
||||
100u64
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeType3;
|
||||
impl From<SomeType3> for u64 { fn from(_t: SomeType3) -> Self { 0u64 } }
|
||||
impl From<SomeType3> for u64 {
|
||||
fn from(_t: SomeType3) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeType4;
|
||||
impl From<SomeType4> for u64 { fn from(_t: SomeType4) -> Self { 0u64 } }
|
||||
impl From<SomeType4> for u64 {
|
||||
fn from(_t: SomeType4) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeType5;
|
||||
impl From<SomeType5> for u64 { fn from(_t: SomeType5) -> Self { 0u64 } }
|
||||
impl From<SomeType5> for u64 {
|
||||
fn from(_t: SomeType5) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeType6;
|
||||
impl From<SomeType6> for u64 { fn from(_t: SomeType6) -> Self { 0u64 } }
|
||||
impl From<SomeType6> for u64 {
|
||||
fn from(_t: SomeType6) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeType7;
|
||||
impl From<SomeType7> for u64 { fn from(_t: SomeType7) -> Self { 0u64 } }
|
||||
impl From<SomeType7> for u64 {
|
||||
fn from(_t: SomeType7) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SomeAssociation1 { type _1: Parameter + codec::MaxEncodedLen; }
|
||||
impl SomeAssociation1 for u64 { type _1 = u64; }
|
||||
pub trait SomeAssociation1 {
|
||||
type _1: Parameter + codec::MaxEncodedLen;
|
||||
}
|
||||
impl SomeAssociation1 for u64 {
|
||||
type _1 = u64;
|
||||
}
|
||||
|
||||
pub trait SomeAssociation2 { type _2: Parameter + codec::MaxEncodedLen; }
|
||||
impl SomeAssociation2 for u64 { type _2 = u64; }
|
||||
pub trait SomeAssociation2 {
|
||||
type _2: Parameter + codec::MaxEncodedLen;
|
||||
}
|
||||
impl SomeAssociation2 for u64 {
|
||||
type _2 = u64;
|
||||
}
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::{
|
||||
SomeType1, SomeType2, SomeType3, SomeType4, SomeType5, SomeType6, SomeType7,
|
||||
SomeAssociation1, SomeAssociation2,
|
||||
SomeAssociation1, SomeAssociation2, SomeType1, SomeType2, SomeType3, SomeType4, SomeType5,
|
||||
SomeType6, SomeType7,
|
||||
};
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
@@ -66,7 +105,8 @@ pub mod pallet {
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config
|
||||
where <Self as frame_system::Config>::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
where
|
||||
<Self as frame_system::Config>::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
/// Some comment
|
||||
/// Some comment
|
||||
@@ -88,14 +128,19 @@ pub mod pallet {
|
||||
|
||||
#[pallet::extra_constants]
|
||||
impl<T: Config> Pallet<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType2>,
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType2>,
|
||||
{
|
||||
/// Some doc
|
||||
/// Some doc
|
||||
fn some_extra() -> T::AccountId { SomeType2.into() }
|
||||
fn some_extra() -> T::AccountId {
|
||||
SomeType2.into()
|
||||
}
|
||||
|
||||
/// Some doc
|
||||
fn some_extra_extra() -> T::AccountId { SomeType1.into() }
|
||||
fn some_extra_extra() -> T::AccountId {
|
||||
SomeType1.into()
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
@@ -105,7 +150,8 @@ pub mod pallet {
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T>
|
||||
where T::AccountId: From<SomeType2> + From<SomeType1> + SomeAssociation1,
|
||||
where
|
||||
T::AccountId: From<SomeType2> + From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
||||
T::AccountId::from(SomeType1); // Test for where clause
|
||||
@@ -132,7 +178,8 @@ pub mod pallet {
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T>
|
||||
where T::AccountId: From<SomeType1> + From<SomeType3> + SomeAssociation1
|
||||
where
|
||||
T::AccountId: From<SomeType1> + From<SomeType3> + SomeAssociation1,
|
||||
{
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::weight(Weight::from(*_foo))]
|
||||
@@ -165,9 +212,7 @@ pub mod pallet {
|
||||
|
||||
// Test for DispatchResult return type
|
||||
#[pallet::weight(1)]
|
||||
pub fn foo_no_post_info(
|
||||
_origin: OriginFor<T>,
|
||||
) -> DispatchResult {
|
||||
pub fn foo_no_post_info(_origin: OriginFor<T>) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -181,7 +226,10 @@ pub mod pallet {
|
||||
#[pallet::event]
|
||||
#[pallet::metadata(BalanceOf<T> = "Balance", u32 = "Other")]
|
||||
#[pallet::generate_deposit(fn deposit_event)]
|
||||
pub enum Event<T: Config> where T::AccountId: SomeAssociation1 + From<SomeType1>{
|
||||
pub enum Event<T: Config>
|
||||
where
|
||||
T::AccountId: SomeAssociation1 + From<SomeType1>,
|
||||
{
|
||||
/// doc comment put in metadata
|
||||
Proposed(<T as frame_system::Config>::AccountId),
|
||||
/// doc
|
||||
@@ -191,8 +239,10 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
pub type ValueWhereClause<T: Config> where T::AccountId: SomeAssociation2 =
|
||||
StorageValue<_, <T::AccountId as SomeAssociation2>::_2>;
|
||||
pub type ValueWhereClause<T: Config>
|
||||
where
|
||||
T::AccountId: SomeAssociation2,
|
||||
= StorageValue<_, <T::AccountId as SomeAssociation2>::_2>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type Value<T> = StorageValue<Value = u32>;
|
||||
@@ -203,28 +253,32 @@ pub mod pallet {
|
||||
|
||||
#[pallet::type_value]
|
||||
pub fn MyDefault<T: Config>() -> u16
|
||||
where T::AccountId: From<SomeType7> + From<SomeType1> + SomeAssociation1
|
||||
where
|
||||
T::AccountId: From<SomeType7> + From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
T::AccountId::from(SomeType7); // Test where clause works
|
||||
4u16
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
pub type Map<T: Config> where T::AccountId: From<SomeType7> =
|
||||
StorageMap<_, Blake2_128Concat, u8, u16, ValueQuery, MyDefault<T>>;
|
||||
pub type Map<T: Config>
|
||||
where
|
||||
T::AccountId: From<SomeType7>,
|
||||
= StorageMap<_, Blake2_128Concat, u8, u16, ValueQuery, MyDefault<T>>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type Map2<T> = StorageMap<
|
||||
Hasher = Twox64Concat, Key = u16, Value = u32, MaxValues = ConstU32<3>
|
||||
>;
|
||||
pub type Map2<T> =
|
||||
StorageMap<Hasher = Twox64Concat, Key = u16, Value = u32, MaxValues = ConstU32<3>>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type DoubleMap<T> = StorageDoubleMap<_, Blake2_128Concat, u8, Twox64Concat, u16, u32>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type DoubleMap2<T> = StorageDoubleMap<
|
||||
Hasher1 = Twox64Concat, Key1 = u16,
|
||||
Hasher2 = Blake2_128Concat, Key2 = u32,
|
||||
Hasher1 = Twox64Concat,
|
||||
Key1 = u16,
|
||||
Hasher2 = Blake2_128Concat,
|
||||
Key2 = u32,
|
||||
Value = u64,
|
||||
MaxValues = ConstU32<5>,
|
||||
>;
|
||||
@@ -255,26 +309,14 @@ pub mod pallet {
|
||||
#[cfg(feature = "conditional-storage")]
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn conditional_double_map)]
|
||||
pub type ConditionalDoubleMap<T> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
u8,
|
||||
Twox64Concat,
|
||||
u16,
|
||||
u32,
|
||||
>;
|
||||
pub type ConditionalDoubleMap<T> =
|
||||
StorageDoubleMap<_, Blake2_128Concat, u8, Twox64Concat, u16, u32>;
|
||||
|
||||
#[cfg(feature = "conditional-storage")]
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn conditional_nmap)]
|
||||
pub type ConditionalNMap<T> = StorageNMap<
|
||||
_,
|
||||
(
|
||||
storage::Key<Blake2_128Concat, u8>,
|
||||
storage::Key<Twox64Concat, u16>,
|
||||
),
|
||||
u32,
|
||||
>;
|
||||
pub type ConditionalNMap<T> =
|
||||
StorageNMap<_, (storage::Key<Blake2_128Concat, u8>, storage::Key<Twox64Concat, u16>), u32>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[derive(Default)]
|
||||
@@ -284,7 +326,8 @@ pub mod pallet {
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> GenesisBuild<T> for GenesisConfig
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType4>
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType4>,
|
||||
{
|
||||
fn build(&self) {
|
||||
T::AccountId::from(SomeType1); // Test for where clause
|
||||
@@ -298,17 +341,15 @@ pub mod pallet {
|
||||
|
||||
#[pallet::validate_unsigned]
|
||||
impl<T: Config> ValidateUnsigned for Pallet<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType5> + From<SomeType3>
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType5> + From<SomeType3>,
|
||||
{
|
||||
type Call = Call<T>;
|
||||
fn validate_unsigned(
|
||||
_source: TransactionSource,
|
||||
call: &Self::Call
|
||||
) -> TransactionValidity {
|
||||
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
T::AccountId::from(SomeType1); // Test for where clause
|
||||
T::AccountId::from(SomeType5); // Test for where clause
|
||||
if matches!(call, Call::foo_transactional(_)) {
|
||||
return Ok(ValidTransaction::default());
|
||||
return Ok(ValidTransaction::default())
|
||||
}
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
|
||||
}
|
||||
@@ -316,7 +357,8 @@ pub mod pallet {
|
||||
|
||||
#[pallet::inherent]
|
||||
impl<T: Config> ProvideInherent for Pallet<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType6> + From<SomeType3>
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1 + From<SomeType6> + From<SomeType3>,
|
||||
{
|
||||
type Call = Call<T>;
|
||||
type Error = InherentError;
|
||||
@@ -369,13 +411,14 @@ pub mod pallet {
|
||||
// Test that a pallet with non generic event and generic genesis_config is correctly handled
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet2 {
|
||||
use super::{SomeType1, SomeAssociation1};
|
||||
use super::{SomeAssociation1, SomeType1};
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config
|
||||
where <Self as frame_system::Config>::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
where
|
||||
<Self as frame_system::Config>::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
type Event: From<Event> + IsType<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
@@ -385,16 +428,13 @@ pub mod pallet2 {
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1
|
||||
{
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
}
|
||||
impl<T: Config> Pallet<T> where T::AccountId: From<SomeType1> + SomeAssociation1 {}
|
||||
|
||||
#[pallet::storage]
|
||||
pub type SomeValue<T: Config> = StorageValue<_, Vec<u32>>;
|
||||
@@ -407,24 +447,25 @@ pub mod pallet2 {
|
||||
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Config> Default for GenesisConfig<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
fn default() -> Self {
|
||||
GenesisConfig {
|
||||
phantom: Default::default(),
|
||||
}
|
||||
GenesisConfig { phantom: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> GenesisBuild<T> for GenesisConfig<T>
|
||||
where T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
fn build(&self) {}
|
||||
}
|
||||
@@ -441,9 +482,9 @@ pub mod pallet3 {
|
||||
}
|
||||
|
||||
frame_support::parameter_types!(
|
||||
pub const MyGetParam: u32= 10;
|
||||
pub const MyGetParam2: u32= 11;
|
||||
pub const MyGetParam3: u32= 12;
|
||||
pub const MyGetParam: u32 = 10;
|
||||
pub const MyGetParam2: u32 = 11;
|
||||
pub const MyGetParam3: u32 = 12;
|
||||
pub const BlockHashCount: u32 = 250;
|
||||
);
|
||||
|
||||
@@ -505,13 +546,20 @@ fn transactional_works() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
frame_system::Pallet::<Runtime>::set_block_number(1);
|
||||
|
||||
pallet::Call::<Runtime>::foo_transactional(0).dispatch_bypass_filter(None.into())
|
||||
.err().unwrap();
|
||||
pallet::Call::<Runtime>::foo_transactional(0)
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.err()
|
||||
.unwrap();
|
||||
assert!(frame_system::Pallet::<Runtime>::events().is_empty());
|
||||
|
||||
pallet::Call::<Runtime>::foo_transactional(1).dispatch_bypass_filter(None.into()).unwrap();
|
||||
pallet::Call::<Runtime>::foo_transactional(1)
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
frame_system::Pallet::<Runtime>::events().iter().map(|e| &e.event).collect::<Vec<_>>(),
|
||||
frame_system::Pallet::<Runtime>::events()
|
||||
.iter()
|
||||
.map(|e| &e.event)
|
||||
.collect::<Vec<_>>(),
|
||||
vec![&Event::Example(pallet::Event::Something(0))],
|
||||
);
|
||||
})
|
||||
@@ -522,11 +570,7 @@ fn call_expand() {
|
||||
let call_foo = pallet::Call::<Runtime>::foo(3, 0);
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: 3,
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes,
|
||||
}
|
||||
DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }
|
||||
);
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
@@ -547,11 +591,7 @@ fn error_expand() {
|
||||
);
|
||||
assert_eq!(
|
||||
DispatchError::from(pallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
DispatchError::Module {
|
||||
index: 1,
|
||||
error: 0,
|
||||
message: Some("InsufficientProposersBalance"),
|
||||
},
|
||||
DispatchError::Module { index: 1, error: 0, message: Some("InsufficientProposersBalance") },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -568,13 +608,17 @@ fn inherent_expand() {
|
||||
traits::EnsureInherentsAreFirst,
|
||||
};
|
||||
use sp_core::Hasher;
|
||||
use sp_runtime::{traits::{BlakeTwo256, Header}, Digest};
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, Header},
|
||||
Digest,
|
||||
};
|
||||
|
||||
let inherents = InherentData::new().create_extrinsics();
|
||||
|
||||
let expected = vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_no_post_info()), signature: None },
|
||||
];
|
||||
let expected = vec![UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_no_post_info()),
|
||||
signature: None,
|
||||
}];
|
||||
assert_eq!(expected, inherents);
|
||||
|
||||
let block = Block::new(
|
||||
@@ -586,8 +630,14 @@ fn inherent_expand() {
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_no_post_info()), signature: None },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo(1, 0)), signature: None },
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_no_post_info()),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo(1, 0)),
|
||||
signature: None,
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
@@ -602,8 +652,14 @@ fn inherent_expand() {
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_no_post_info()), signature: None },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo(0, 0)), signature: None },
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_no_post_info()),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo(0, 0)),
|
||||
signature: None,
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
@@ -617,9 +673,28 @@ fn inherent_expand() {
|
||||
BlakeTwo256::hash(b"test"),
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_transactional(0)), signature: None },
|
||||
],
|
||||
vec![UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_transactional(0)),
|
||||
signature: None,
|
||||
}],
|
||||
);
|
||||
|
||||
let mut inherent = InherentData::new();
|
||||
inherent.put_data(*b"required", &true).unwrap();
|
||||
assert!(inherent.check_extrinsics(&block).fatal_error());
|
||||
|
||||
let block = Block::new(
|
||||
Header::new(
|
||||
1,
|
||||
BlakeTwo256::hash(b"test"),
|
||||
BlakeTwo256::hash(b"test"),
|
||||
BlakeTwo256::hash(b"test"),
|
||||
Digest::default(),
|
||||
),
|
||||
vec![UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_no_post_info()),
|
||||
signature: Some((1, (), ())),
|
||||
}],
|
||||
);
|
||||
|
||||
let mut inherent = InherentData::new();
|
||||
@@ -635,25 +710,14 @@ fn inherent_expand() {
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_no_post_info()), signature: Some((1, (), ())) },
|
||||
],
|
||||
);
|
||||
|
||||
let mut inherent = InherentData::new();
|
||||
inherent.put_data(*b"required", &true).unwrap();
|
||||
assert!(inherent.check_extrinsics(&block).fatal_error());
|
||||
|
||||
let block = Block::new(
|
||||
Header::new(
|
||||
1,
|
||||
BlakeTwo256::hash(b"test"),
|
||||
BlakeTwo256::hash(b"test"),
|
||||
BlakeTwo256::hash(b"test"),
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo(1, 1)), signature: None },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_transactional(0)), signature: None },
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo(1, 1)),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_transactional(0)),
|
||||
signature: None,
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
@@ -668,9 +732,18 @@ fn inherent_expand() {
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo(1, 1)), signature: None },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_transactional(0)), signature: None },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_no_post_info()), signature: None },
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo(1, 1)),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_transactional(0)),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_no_post_info()),
|
||||
signature: None,
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
@@ -685,9 +758,18 @@ fn inherent_expand() {
|
||||
Digest::default(),
|
||||
),
|
||||
vec![
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo(1, 1)), signature: None },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo(1, 0)), signature: Some((1, (), ())) },
|
||||
UncheckedExtrinsic { function: Call::Example(pallet::Call::foo_no_post_info()), signature: None },
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo(1, 1)),
|
||||
signature: None,
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo(1, 0)),
|
||||
signature: Some((1, (), ())),
|
||||
},
|
||||
UncheckedExtrinsic {
|
||||
function: Call::Example(pallet::Call::foo_no_post_info()),
|
||||
signature: None,
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
@@ -697,7 +779,8 @@ fn inherent_expand() {
|
||||
#[test]
|
||||
fn validate_unsigned_expand() {
|
||||
use frame_support::pallet_prelude::{
|
||||
InvalidTransaction, TransactionSource, TransactionValidityError, ValidTransaction, ValidateUnsigned,
|
||||
InvalidTransaction, TransactionSource, TransactionValidityError, ValidTransaction,
|
||||
ValidateUnsigned,
|
||||
};
|
||||
let call = pallet::Call::<Runtime>::foo_no_post_info();
|
||||
|
||||
@@ -733,8 +816,7 @@ fn pallet_expand_deposit_event() {
|
||||
|
||||
#[test]
|
||||
fn storage_expand() {
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_support::storage::StoragePrefixedMap;
|
||||
use frame_support::{pallet_prelude::*, storage::StoragePrefixedMap};
|
||||
|
||||
fn twox_64_concat(d: &[u8]) -> Vec<u8> {
|
||||
let mut v = twox_64(d).to_vec();
|
||||
@@ -850,8 +932,8 @@ fn pallet_on_genesis() {
|
||||
|
||||
#[test]
|
||||
fn metadata() {
|
||||
use frame_metadata::*;
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::*;
|
||||
|
||||
let expected_pallet_metadata = ModuleMetadata {
|
||||
index: 1,
|
||||
@@ -862,11 +944,9 @@ fn metadata() {
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Decoded("ValueWhereClause".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(
|
||||
DecodeDifferent::Decoded(
|
||||
"<T::AccountId as SomeAssociation2>::_2".to_string()
|
||||
),
|
||||
),
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Decoded(
|
||||
"<T::AccountId as SomeAssociation2>::_2".to_string(),
|
||||
)),
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
@@ -939,9 +1019,7 @@ fn metadata() {
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Decoded(vec!["u8".to_string()]),
|
||||
hashers: DecodeDifferent::Decoded(vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
]),
|
||||
hashers: DecodeDifferent::Decoded(vec![StorageHasher::Blake2_128Concat]),
|
||||
value: DecodeDifferent::Decoded("u32".to_string()),
|
||||
},
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
@@ -951,10 +1029,7 @@ fn metadata() {
|
||||
name: DecodeDifferent::Decoded("NMap2".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Decoded(vec![
|
||||
"u16".to_string(),
|
||||
"u32".to_string(),
|
||||
]),
|
||||
keys: DecodeDifferent::Decoded(vec!["u16".to_string(), "u32".to_string()]),
|
||||
hashers: DecodeDifferent::Decoded(vec![
|
||||
StorageHasher::Twox64Concat,
|
||||
StorageHasher::Blake2_128Concat,
|
||||
@@ -964,14 +1039,16 @@ fn metadata() {
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
#[cfg(feature = "conditional-storage")] StorageEntryMetadata {
|
||||
#[cfg(feature = "conditional-storage")]
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Decoded("ConditionalValue".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Decoded("u32".to_string())),
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
#[cfg(feature = "conditional-storage")] StorageEntryMetadata {
|
||||
#[cfg(feature = "conditional-storage")]
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Decoded("ConditionalMap".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
@@ -983,7 +1060,8 @@ fn metadata() {
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
#[cfg(feature = "conditional-storage")] StorageEntryMetadata {
|
||||
#[cfg(feature = "conditional-storage")]
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Decoded("ConditionalDoubleMap".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::DoubleMap {
|
||||
@@ -996,7 +1074,8 @@ fn metadata() {
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
#[cfg(feature = "conditional-storage")] StorageEntryMetadata {
|
||||
#[cfg(feature = "conditional-storage")]
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Decoded("ConditionalNMap".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::NMap {
|
||||
@@ -1023,22 +1102,20 @@ fn metadata() {
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("_bar".to_string()),
|
||||
ty: DecodeDifferent::Decoded("u32".to_string()),
|
||||
}
|
||||
},
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" Doc comment put in metadata".to_string(),
|
||||
" Doc comment put in metadata".to_string()
|
||||
]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Decoded("foo_transactional".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec![
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("foo".to_string()),
|
||||
ty: DecodeDifferent::Decoded("Compact<u32>".to_string()),
|
||||
}
|
||||
]),
|
||||
arguments: DecodeDifferent::Decoded(vec![FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("foo".to_string()),
|
||||
ty: DecodeDifferent::Decoded("Compact<u32>".to_string()),
|
||||
}]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" Doc comment put in metadata".to_string(),
|
||||
" Doc comment put in metadata".to_string()
|
||||
]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
@@ -1050,7 +1127,9 @@ fn metadata() {
|
||||
event: Some(DecodeDifferent::Decoded(vec![
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("Proposed".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec!["<T as frame_system::Config>::AccountId".to_string()]),
|
||||
arguments: DecodeDifferent::Decoded(vec![
|
||||
"<T as frame_system::Config>::AccountId".to_string()
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc comment put in metadata".to_string()
|
||||
]),
|
||||
@@ -1058,9 +1137,7 @@ fn metadata() {
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("Spending".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec!["Balance".to_string()]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc".to_string()
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![" doc".to_string()]),
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("Something".to_string()),
|
||||
@@ -1069,7 +1146,9 @@ fn metadata() {
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("SomethingElse".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec!["<T::AccountId as SomeAssociation1>::_1".to_string()]),
|
||||
arguments: DecodeDifferent::Decoded(vec![
|
||||
"<T::AccountId as SomeAssociation1>::_1".to_string()
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
])),
|
||||
@@ -1111,19 +1190,15 @@ fn metadata() {
|
||||
name: DecodeDifferent::Decoded("some_extra_extra".to_string()),
|
||||
ty: DecodeDifferent::Decoded("T::AccountId".to_string()),
|
||||
value: DecodeDifferent::Decoded(vec![0, 0, 0, 0, 0, 0, 0, 0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" Some doc".to_string(),
|
||||
]),
|
||||
},
|
||||
]),
|
||||
errors: DecodeDifferent::Decoded(vec![
|
||||
ErrorMetadata {
|
||||
name: DecodeDifferent::Decoded("InsufficientProposersBalance".to_string()),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc comment put into metadata".to_string(),
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![" Some doc".to_string()]),
|
||||
},
|
||||
]),
|
||||
errors: DecodeDifferent::Decoded(vec![ErrorMetadata {
|
||||
name: DecodeDifferent::Decoded("InsufficientProposersBalance".to_string()),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc comment put into metadata".to_string()
|
||||
]),
|
||||
}]),
|
||||
};
|
||||
|
||||
let metadata = match Runtime::metadata().1 {
|
||||
@@ -1155,9 +1230,9 @@ fn test_pallet_info_access() {
|
||||
#[test]
|
||||
fn test_storage_info() {
|
||||
use frame_support::{
|
||||
StorageHasher,
|
||||
traits::{StorageInfoTrait, StorageInfo},
|
||||
pallet_prelude::*,
|
||||
traits::{StorageInfo, StorageInfoTrait},
|
||||
StorageHasher,
|
||||
};
|
||||
|
||||
let prefix = |pallet_name, storage_name| {
|
||||
@@ -1278,14 +1353,12 @@ 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,
|
||||
},],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,15 +23,19 @@ impl SomeAssociation for u64 {
|
||||
}
|
||||
|
||||
mod pallet_old {
|
||||
use super::SomeAssociation;
|
||||
use frame_support::{
|
||||
decl_storage, decl_error, decl_event, decl_module, weights::Weight, traits::Get, Parameter
|
||||
decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter,
|
||||
};
|
||||
use frame_system::ensure_root;
|
||||
use super::SomeAssociation;
|
||||
|
||||
pub trait Config: frame_system::Config {
|
||||
type SomeConst: Get<Self::Balance>;
|
||||
type Balance: Parameter + codec::HasCompact + From<u32> + Into<Weight> + Default
|
||||
type Balance: Parameter
|
||||
+ codec::HasCompact
|
||||
+ From<u32>
|
||||
+ Into<Weight>
|
||||
+ Default
|
||||
+ SomeAssociation;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
@@ -50,7 +54,10 @@ mod pallet_old {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where Balance = <T as Config>::Balance {
|
||||
pub enum Event<T>
|
||||
where
|
||||
Balance = <T as Config>::Balance,
|
||||
{
|
||||
/// Dummy event, just here so there's a generic type that's used.
|
||||
Dummy(Balance),
|
||||
}
|
||||
@@ -93,13 +100,17 @@ mod pallet_old {
|
||||
pub mod pallet {
|
||||
use super::SomeAssociation;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
use frame_system::ensure_root;
|
||||
use frame_system::{ensure_root, pallet_prelude::*};
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
type Balance: Parameter + codec::HasCompact + From<u32> + Into<Weight> + Default
|
||||
+ MaybeSerializeDeserialize + SomeAssociation;
|
||||
type Balance: Parameter
|
||||
+ codec::HasCompact
|
||||
+ From<u32>
|
||||
+ Into<Weight>
|
||||
+ Default
|
||||
+ MaybeSerializeDeserialize
|
||||
+ SomeAssociation;
|
||||
#[pallet::constant]
|
||||
type SomeConst: Get<Self::Balance>;
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
@@ -125,7 +136,7 @@ pub mod pallet {
|
||||
#[pallet::weight(<T::Balance as Into<Weight>>::into(new_value.clone()))]
|
||||
pub fn set_dummy(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] new_value: T::Balance
|
||||
#[pallet::compact] new_value: T::Balance,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -157,13 +168,22 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
type Bar<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance, ValueQuery>;
|
||||
|
||||
#[pallet::type_value] pub fn OnFooEmpty<T: Config>() -> T::Balance { 3.into() }
|
||||
#[pallet::type_value]
|
||||
pub fn OnFooEmpty<T: Config>() -> T::Balance {
|
||||
3.into()
|
||||
}
|
||||
#[pallet::storage]
|
||||
type Foo<T: Config> = StorageValue<_, T::Balance, ValueQuery, OnFooEmpty<T>>;
|
||||
|
||||
#[pallet::storage]
|
||||
type Double<T: Config> = StorageDoubleMap<
|
||||
_, Blake2_128Concat, u32, Twox64Concat, u64, <T::Balance as SomeAssociation>::A, ValueQuery
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
u32,
|
||||
Twox64Concat,
|
||||
u64,
|
||||
<T::Balance as SomeAssociation>::A,
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
@@ -257,9 +277,7 @@ frame_support::construct_runtime!(
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Runtime;
|
||||
use super::pallet;
|
||||
use super::pallet_old;
|
||||
use super::{pallet, pallet_old, Runtime};
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
#[test]
|
||||
@@ -284,14 +302,16 @@ mod test {
|
||||
assert_eq!(
|
||||
pallet_old::Event::<Runtime>::decode(
|
||||
&mut &pallet::Event::<Runtime>::Dummy(10).encode()[..]
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
pallet_old::Event::<Runtime>::Dummy(10),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
pallet_old::Call::<Runtime>::decode(
|
||||
&mut &pallet::Call::<Runtime>::set_dummy(10).encode()[..]
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
pallet_old::Call::<Runtime>::set_dummy(10),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
mod pallet_old {
|
||||
use frame_support::{
|
||||
decl_storage, decl_error, decl_event, decl_module, weights::Weight, traits::Get, Parameter
|
||||
decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter,
|
||||
};
|
||||
use frame_system::ensure_root;
|
||||
|
||||
@@ -39,7 +39,10 @@ mod pallet_old {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I = DefaultInstance> where Balance = <T as Config<I>>::Balance {
|
||||
pub enum Event<T, I = DefaultInstance>
|
||||
where
|
||||
Balance = <T as Config<I>>::Balance,
|
||||
{
|
||||
/// Dummy event, just here so there's a generic type that's used.
|
||||
Dummy(Balance),
|
||||
}
|
||||
@@ -83,12 +86,15 @@ mod pallet_old {
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
use frame_system::ensure_root;
|
||||
use frame_system::{ensure_root, pallet_prelude::*};
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config<I: 'static = ()>: frame_system::Config {
|
||||
type Balance: Parameter + codec::HasCompact + From<u32> + Into<Weight> + Default
|
||||
type Balance: Parameter
|
||||
+ codec::HasCompact
|
||||
+ From<u32>
|
||||
+ Into<Weight>
|
||||
+ Default
|
||||
+ MaybeSerializeDeserialize;
|
||||
#[pallet::constant]
|
||||
type SomeConst: Get<Self::Balance>;
|
||||
@@ -115,7 +121,7 @@ pub mod pallet {
|
||||
#[pallet::weight(<T::Balance as Into<Weight>>::into(new_value.clone()))]
|
||||
pub fn set_dummy(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] new_value: T::Balance
|
||||
#[pallet::compact] new_value: T::Balance,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -151,12 +157,14 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
type Foo<T: Config<I>, I: 'static = ()> =
|
||||
StorageValue<_, T::Balance, ValueQuery, OnFooEmpty<T, I>>;
|
||||
#[pallet::type_value] pub fn OnFooEmpty<T: Config<I>, I: 'static>() -> T::Balance { 3.into() }
|
||||
#[pallet::type_value]
|
||||
pub fn OnFooEmpty<T: Config<I>, I: 'static>() -> T::Balance {
|
||||
3.into()
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
type Double<T, I = ()> = StorageDoubleMap<
|
||||
_, Blake2_128Concat, u32, Twox64Concat, u64, u16, ValueQuery
|
||||
>;
|
||||
type Double<T, I = ()> =
|
||||
StorageDoubleMap<_, Blake2_128Concat, u32, Twox64Concat, u64, u16, ValueQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
|
||||
@@ -272,9 +280,7 @@ frame_support::construct_runtime!(
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Runtime;
|
||||
use super::pallet;
|
||||
use super::pallet_old;
|
||||
use super::{pallet, pallet_old, Runtime};
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
#[test]
|
||||
@@ -288,11 +294,11 @@ mod test {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
for i in vec![1, 3, 5].into_iter() {
|
||||
pretty_assertions::assert_eq!(modules[i].storage, modules[i+1].storage);
|
||||
pretty_assertions::assert_eq!(modules[i].calls, modules[i+1].calls);
|
||||
pretty_assertions::assert_eq!(modules[i].event, modules[i+1].event);
|
||||
pretty_assertions::assert_eq!(modules[i].constants, modules[i+1].constants);
|
||||
pretty_assertions::assert_eq!(modules[i].errors, modules[i+1].errors);
|
||||
pretty_assertions::assert_eq!(modules[i].storage, modules[i + 1].storage);
|
||||
pretty_assertions::assert_eq!(modules[i].calls, modules[i + 1].calls);
|
||||
pretty_assertions::assert_eq!(modules[i].event, modules[i + 1].event);
|
||||
pretty_assertions::assert_eq!(modules[i].constants, modules[i + 1].constants);
|
||||
pretty_assertions::assert_eq!(modules[i].errors, modules[i + 1].errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,14 +307,16 @@ mod test {
|
||||
assert_eq!(
|
||||
pallet_old::Event::<Runtime>::decode(
|
||||
&mut &pallet::Event::<Runtime>::Dummy(10).encode()[..]
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
pallet_old::Event::<Runtime>::Dummy(10),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
pallet_old::Call::<Runtime>::decode(
|
||||
&mut &pallet::Call::<Runtime>::set_dummy(10).encode()[..]
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
pallet_old::Call::<Runtime>::set_dummy(10),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,21 +16,24 @@
|
||||
// limitations under the License.
|
||||
|
||||
use frame_support::{
|
||||
weights::{DispatchInfo, DispatchClass, Pays, GetDispatchInfo},
|
||||
traits::{
|
||||
GetCallName, GetPalletVersion, OnInitialize, OnFinalize, OnRuntimeUpgrade, OnGenesis,
|
||||
},
|
||||
dispatch::UnfilteredDispatchable,
|
||||
storage::unhashed,
|
||||
traits::{
|
||||
GetCallName, GetPalletVersion, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade,
|
||||
},
|
||||
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays},
|
||||
};
|
||||
use sp_io::{
|
||||
hashing::{blake2_128, twox_128, twox_64},
|
||||
TestExternalities,
|
||||
};
|
||||
use sp_runtime::DispatchError;
|
||||
use sp_io::{TestExternalities, hashing::{twox_64, twox_128, blake2_128}};
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use sp_std::any::TypeId;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
use sp_std::any::TypeId;
|
||||
|
||||
type BalanceOf<T, I> = <T as Config<I>>::Balance;
|
||||
|
||||
@@ -73,15 +76,17 @@ pub mod pallet {
|
||||
31
|
||||
}
|
||||
}
|
||||
fn integrity_test() {
|
||||
}
|
||||
fn integrity_test() {}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Doc comment put in metadata
|
||||
#[pallet::weight(Weight::from(*_foo))]
|
||||
pub fn foo(origin: OriginFor<T>, #[pallet::compact] _foo: u32) -> DispatchResultWithPostInfo {
|
||||
pub fn foo(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] _foo: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let _ = origin;
|
||||
Self::deposit_event(Event::Something(3));
|
||||
Ok(().into())
|
||||
@@ -92,14 +97,13 @@ pub mod pallet {
|
||||
#[frame_support::transactional]
|
||||
pub fn foo_transactional(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] _foo: u32
|
||||
#[pallet::compact] _foo: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let _ = origin;
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T, I = ()> {
|
||||
/// doc comment put into metadata
|
||||
@@ -140,14 +144,8 @@ pub mod pallet {
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn nmap2)]
|
||||
pub type NMap2<T, I = ()> = StorageNMap<
|
||||
_,
|
||||
(
|
||||
storage::Key<Twox64Concat, u16>,
|
||||
storage::Key<Blake2_128Concat, u32>,
|
||||
),
|
||||
u64,
|
||||
>;
|
||||
pub type NMap2<T, I = ()> =
|
||||
StorageNMap<_, (storage::Key<Twox64Concat, u16>, storage::Key<Blake2_128Concat, u32>), u64>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[derive(Default)]
|
||||
@@ -156,7 +154,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config<I>, I:'static> GenesisBuild<T, I> for GenesisConfig {
|
||||
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig {
|
||||
fn build(&self) {}
|
||||
}
|
||||
|
||||
@@ -169,7 +167,7 @@ pub mod pallet {
|
||||
type Call = Call<T, I>;
|
||||
fn validate_unsigned(
|
||||
_source: TransactionSource,
|
||||
_call: &Self::Call
|
||||
_call: &Self::Call,
|
||||
) -> TransactionValidity {
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
|
||||
}
|
||||
@@ -193,8 +191,7 @@ pub mod pallet {
|
||||
|
||||
#[derive(codec::Encode, sp_runtime::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(codec::Decode))]
|
||||
pub enum InherentError {
|
||||
}
|
||||
pub enum InherentError {}
|
||||
|
||||
impl frame_support::inherent::IsFatalError for InherentError {
|
||||
fn is_fatal_error(&self) -> bool {
|
||||
@@ -232,9 +229,7 @@ pub mod pallet2 {
|
||||
|
||||
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
|
||||
fn default() -> Self {
|
||||
GenesisConfig {
|
||||
phantom: Default::default(),
|
||||
}
|
||||
GenesisConfig { phantom: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +240,7 @@ pub mod pallet2 {
|
||||
}
|
||||
|
||||
frame_support::parameter_types!(
|
||||
pub const MyGetParam: u32= 10;
|
||||
pub const MyGetParam: u32 = 10;
|
||||
pub const BlockHashCount: u32 = 250;
|
||||
);
|
||||
|
||||
@@ -276,12 +271,12 @@ impl frame_system::Config for Runtime {
|
||||
}
|
||||
impl pallet::Config for Runtime {
|
||||
type Event = Event;
|
||||
type MyGetParam= MyGetParam;
|
||||
type MyGetParam = MyGetParam;
|
||||
type Balance = u64;
|
||||
}
|
||||
impl pallet::Config<pallet::Instance1> for Runtime {
|
||||
type Event = Event;
|
||||
type MyGetParam= MyGetParam;
|
||||
type MyGetParam = MyGetParam;
|
||||
type Balance = u64;
|
||||
}
|
||||
impl pallet2::Config for Runtime {
|
||||
@@ -316,26 +311,15 @@ fn call_expand() {
|
||||
let call_foo = pallet::Call::<Runtime>::foo(3);
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: 3,
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes,
|
||||
}
|
||||
DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }
|
||||
);
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
pallet::Call::<Runtime>::get_call_names(),
|
||||
&["foo", "foo_transactional"],
|
||||
);
|
||||
assert_eq!(pallet::Call::<Runtime>::get_call_names(), &["foo", "foo_transactional"],);
|
||||
|
||||
let call_foo = pallet::Call::<Runtime, pallet::Instance1>::foo(3);
|
||||
assert_eq!(
|
||||
call_foo.get_dispatch_info(),
|
||||
DispatchInfo {
|
||||
weight: 3,
|
||||
class: DispatchClass::Normal,
|
||||
pays_fee: Pays::Yes,
|
||||
}
|
||||
DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: Pays::Yes }
|
||||
);
|
||||
assert_eq!(call_foo.get_call_name(), "foo");
|
||||
assert_eq!(
|
||||
@@ -356,11 +340,7 @@ fn error_expand() {
|
||||
);
|
||||
assert_eq!(
|
||||
DispatchError::from(pallet::Error::<Runtime>::InsufficientProposersBalance),
|
||||
DispatchError::Module {
|
||||
index: 1,
|
||||
error: 0,
|
||||
message: Some("InsufficientProposersBalance"),
|
||||
},
|
||||
DispatchError::Module { index: 1, error: 0, message: Some("InsufficientProposersBalance") },
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
@@ -368,16 +348,16 @@ fn error_expand() {
|
||||
String::from("InsufficientProposersBalance"),
|
||||
);
|
||||
assert_eq!(
|
||||
<&'static str>::from(pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance),
|
||||
<&'static str>::from(
|
||||
pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance
|
||||
),
|
||||
"InsufficientProposersBalance",
|
||||
);
|
||||
assert_eq!(
|
||||
DispatchError::from(pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance),
|
||||
DispatchError::Module {
|
||||
index: 2,
|
||||
error: 0,
|
||||
message: Some("InsufficientProposersBalance"),
|
||||
},
|
||||
DispatchError::from(
|
||||
pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance
|
||||
),
|
||||
DispatchError::Module { index: 2, error: 0, message: Some("InsufficientProposersBalance") },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -400,7 +380,9 @@ fn pallet_expand_deposit_event() {
|
||||
|
||||
TestExternalities::default().execute_with(|| {
|
||||
frame_system::Pallet::<Runtime>::set_block_number(1);
|
||||
pallet::Call::<Runtime, pallet::Instance1>::foo(3).dispatch_bypass_filter(None.into()).unwrap();
|
||||
pallet::Call::<Runtime, pallet::Instance1>::foo(3)
|
||||
.dispatch_bypass_filter(None.into())
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
frame_system::Pallet::<Runtime>::events()[0].event,
|
||||
Event::Instance1Example(pallet::Event::Something(3)),
|
||||
@@ -410,8 +392,7 @@ fn pallet_expand_deposit_event() {
|
||||
|
||||
#[test]
|
||||
fn storage_expand() {
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_support::storage::StoragePrefixedMap;
|
||||
use frame_support::{pallet_prelude::*, storage::StoragePrefixedMap};
|
||||
|
||||
fn twox_64_concat(d: &[u8]) -> Vec<u8> {
|
||||
let mut v = twox_64(d).to_vec();
|
||||
@@ -585,8 +566,8 @@ fn pallet_on_genesis() {
|
||||
|
||||
#[test]
|
||||
fn metadata() {
|
||||
use frame_metadata::*;
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::*;
|
||||
|
||||
let expected_pallet_metadata = ModuleMetadata {
|
||||
index: 1,
|
||||
@@ -656,9 +637,7 @@ fn metadata() {
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Decoded(vec!["u8".to_string()]),
|
||||
hashers: DecodeDifferent::Decoded(vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
]),
|
||||
hashers: DecodeDifferent::Decoded(vec![StorageHasher::Blake2_128Concat]),
|
||||
value: DecodeDifferent::Decoded("u32".to_string()),
|
||||
},
|
||||
default: DecodeDifferent::Decoded(vec![0]),
|
||||
@@ -668,10 +647,7 @@ fn metadata() {
|
||||
name: DecodeDifferent::Decoded("NMap2".to_string()),
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::NMap {
|
||||
keys: DecodeDifferent::Decoded(vec![
|
||||
"u16".to_string(),
|
||||
"u32".to_string(),
|
||||
]),
|
||||
keys: DecodeDifferent::Decoded(vec!["u16".to_string(), "u32".to_string()]),
|
||||
hashers: DecodeDifferent::Decoded(vec![
|
||||
StorageHasher::Twox64Concat,
|
||||
StorageHasher::Blake2_128Concat,
|
||||
@@ -686,33 +662,31 @@ fn metadata() {
|
||||
calls: Some(DecodeDifferent::Decoded(vec![
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Decoded("foo".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec![
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("_foo".to_string()),
|
||||
ty: DecodeDifferent::Decoded("Compact<u32>".to_string()),
|
||||
}
|
||||
]),
|
||||
arguments: DecodeDifferent::Decoded(vec![FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("_foo".to_string()),
|
||||
ty: DecodeDifferent::Decoded("Compact<u32>".to_string()),
|
||||
}]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" Doc comment put in metadata".to_string(),
|
||||
" Doc comment put in metadata".to_string()
|
||||
]),
|
||||
},
|
||||
FunctionMetadata {
|
||||
name: DecodeDifferent::Decoded("foo_transactional".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec![
|
||||
FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("_foo".to_string()),
|
||||
ty: DecodeDifferent::Decoded("Compact<u32>".to_string()),
|
||||
}
|
||||
]),
|
||||
arguments: DecodeDifferent::Decoded(vec![FunctionArgumentMetadata {
|
||||
name: DecodeDifferent::Decoded("_foo".to_string()),
|
||||
ty: DecodeDifferent::Decoded("Compact<u32>".to_string()),
|
||||
}]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" Doc comment put in metadata".to_string(),
|
||||
" Doc comment put in metadata".to_string()
|
||||
]),
|
||||
},
|
||||
])),
|
||||
event: Some(DecodeDifferent::Decoded(vec![
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("Proposed".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec!["<T as frame_system::Config>::AccountId".to_string()]),
|
||||
arguments: DecodeDifferent::Decoded(vec![
|
||||
"<T as frame_system::Config>::AccountId".to_string()
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc comment put in metadata".to_string()
|
||||
]),
|
||||
@@ -720,9 +694,7 @@ fn metadata() {
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("Spending".to_string()),
|
||||
arguments: DecodeDifferent::Decoded(vec!["Balance".to_string()]),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc".to_string()
|
||||
]),
|
||||
documentation: DecodeDifferent::Decoded(vec![" doc".to_string()]),
|
||||
},
|
||||
EventMetadata {
|
||||
name: DecodeDifferent::Decoded("Something".to_string()),
|
||||
@@ -730,26 +702,23 @@ fn metadata() {
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
])),
|
||||
constants: DecodeDifferent::Decoded(vec![
|
||||
ModuleConstantMetadata {
|
||||
name: DecodeDifferent::Decoded("MyGetParam".to_string()),
|
||||
ty: DecodeDifferent::Decoded("u32".to_string()),
|
||||
value: DecodeDifferent::Decoded(vec![10, 0, 0, 0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
},
|
||||
]),
|
||||
errors: DecodeDifferent::Decoded(vec![
|
||||
ErrorMetadata {
|
||||
name: DecodeDifferent::Decoded("InsufficientProposersBalance".to_string()),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc comment put into metadata".to_string(),
|
||||
]),
|
||||
},
|
||||
]),
|
||||
constants: DecodeDifferent::Decoded(vec![ModuleConstantMetadata {
|
||||
name: DecodeDifferent::Decoded("MyGetParam".to_string()),
|
||||
ty: DecodeDifferent::Decoded("u32".to_string()),
|
||||
value: DecodeDifferent::Decoded(vec![10, 0, 0, 0]),
|
||||
documentation: DecodeDifferent::Decoded(vec![]),
|
||||
}]),
|
||||
errors: DecodeDifferent::Decoded(vec![ErrorMetadata {
|
||||
name: DecodeDifferent::Decoded("InsufficientProposersBalance".to_string()),
|
||||
documentation: DecodeDifferent::Decoded(vec![
|
||||
" doc comment put into metadata".to_string()
|
||||
]),
|
||||
}]),
|
||||
};
|
||||
|
||||
let mut expected_pallet_instance1_metadata = expected_pallet_metadata.clone();
|
||||
expected_pallet_instance1_metadata.name = DecodeDifferent::Decoded("Instance1Example".to_string());
|
||||
expected_pallet_instance1_metadata.name =
|
||||
DecodeDifferent::Decoded("Instance1Example".to_string());
|
||||
expected_pallet_instance1_metadata.index = 2;
|
||||
match expected_pallet_instance1_metadata.storage {
|
||||
Some(DecodeDifferent::Decoded(ref mut storage_meta)) => {
|
||||
@@ -758,7 +727,6 @@ fn metadata() {
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
|
||||
let metadata = match Runtime::metadata().1 {
|
||||
RuntimeMetadata::V13(metadata) => metadata,
|
||||
_ => panic!("metadata has been bump, test needs to be updated"),
|
||||
@@ -781,9 +749,15 @@ fn metadata() {
|
||||
fn test_pallet_info_access() {
|
||||
assert_eq!(<System as frame_support::traits::PalletInfoAccess>::name(), "System");
|
||||
assert_eq!(<Example as frame_support::traits::PalletInfoAccess>::name(), "Example");
|
||||
assert_eq!(<Instance1Example as frame_support::traits::PalletInfoAccess>::name(), "Instance1Example");
|
||||
assert_eq!(
|
||||
<Instance1Example as frame_support::traits::PalletInfoAccess>::name(),
|
||||
"Instance1Example"
|
||||
);
|
||||
assert_eq!(<Example2 as frame_support::traits::PalletInfoAccess>::name(), "Example2");
|
||||
assert_eq!(<Instance1Example2 as frame_support::traits::PalletInfoAccess>::name(), "Instance1Example2");
|
||||
assert_eq!(
|
||||
<Instance1Example2 as frame_support::traits::PalletInfoAccess>::name(),
|
||||
"Instance1Example2"
|
||||
);
|
||||
|
||||
assert_eq!(<System as frame_support::traits::PalletInfoAccess>::index(), 0);
|
||||
assert_eq!(<Example as frame_support::traits::PalletInfoAccess>::index(), 1);
|
||||
|
||||
@@ -6,5 +6,5 @@ error[E0277]: the trait bound `pallet::GenesisConfig: std::default::Default` is
|
||||
|
|
||||
::: $WORKSPACE/frame/support/src/traits/hooks.rs
|
||||
|
|
||||
| pub trait GenesisBuild<T, I=()>: Default + MaybeSerializeDeserialize {
|
||||
| ------- required by this bound in `GenesisBuild`
|
||||
| pub trait GenesisBuild<T, I = ()>: Default + MaybeSerializeDeserialize {
|
||||
| ------- required by this bound in `GenesisBuild`
|
||||
|
||||
@@ -5,9 +5,9 @@ error[E0107]: missing generics for trait `Hooks`
|
||||
| ^^^^^ expected 1 type argument
|
||||
|
|
||||
note: trait defined here, with 1 type parameter: `BlockNumber`
|
||||
--> $DIR/hooks.rs:206:11
|
||||
--> $DIR/hooks.rs:212:11
|
||||
|
|
||||
206 | pub trait Hooks<BlockNumber> {
|
||||
212 | pub trait Hooks<BlockNumber> {
|
||||
| ^^^^^ -----------
|
||||
help: use angle brackets to add missing type argument
|
||||
|
|
||||
|
||||
@@ -17,15 +17,22 @@
|
||||
|
||||
//! Tests related to the pallet version.
|
||||
|
||||
#![recursion_limit="128"]
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use sp_runtime::{generic, traits::{BlakeTwo256, Verify}, BuildStorage};
|
||||
use frame_support::{
|
||||
traits::{PALLET_VERSION_STORAGE_KEY_POSTFIX, PalletVersion, OnRuntimeUpgrade, GetPalletVersion},
|
||||
crate_to_pallet_version, weights::Weight,
|
||||
crate_to_pallet_version,
|
||||
traits::{
|
||||
GetPalletVersion, OnRuntimeUpgrade, PalletVersion, PALLET_VERSION_STORAGE_KEY_POSTFIX,
|
||||
},
|
||||
weights::Weight,
|
||||
};
|
||||
use sp_core::{sr25519, H256};
|
||||
use sp_runtime::{
|
||||
generic,
|
||||
traits::{BlakeTwo256, Verify},
|
||||
BuildStorage,
|
||||
};
|
||||
use sp_core::{H256, sr25519};
|
||||
|
||||
/// A version that we will check for in the tests
|
||||
const SOME_TEST_VERSION: PalletVersion = PalletVersion { major: 3000, minor: 30, patch: 13 };
|
||||
@@ -47,7 +54,7 @@ mod module1 {
|
||||
mod module2 {
|
||||
use super::*;
|
||||
|
||||
pub trait Config<I=DefaultInstance>: frame_system::Config {}
|
||||
pub trait Config<I = DefaultInstance>: frame_system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config<I>, I: Instance=DefaultInstance> for enum Call where
|
||||
@@ -82,8 +89,7 @@ mod pallet3 {
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
}
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
@@ -91,13 +97,12 @@ mod pallet3 {
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
return 3;
|
||||
return 3
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
}
|
||||
impl<T: Config> Pallet<T> {}
|
||||
}
|
||||
|
||||
#[frame_support::pallet]
|
||||
@@ -106,22 +111,20 @@ mod pallet4 {
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config<I: 'static = ()>: frame_system::Config {
|
||||
}
|
||||
pub trait Config<I: 'static = ()>: frame_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T, I=()>(PhantomData<(T, I)>);
|
||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
return 3;
|
||||
return 3
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
}
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {}
|
||||
}
|
||||
|
||||
impl module1::Config for Runtime {}
|
||||
@@ -210,8 +213,8 @@ fn get_pallet_version_storage_key_for_pallet(pallet: &str) -> [u8; 32] {
|
||||
fn check_pallet_version(pallet: &str) {
|
||||
let key = get_pallet_version_storage_key_for_pallet(pallet);
|
||||
let value = sp_io::storage::get(&key).expect("Pallet version exists");
|
||||
let version = PalletVersion::decode(&mut &value[..])
|
||||
.expect("Pallet version is encoded correctly");
|
||||
let version =
|
||||
PalletVersion::decode(&mut &value[..]).expect("Pallet version is encoded correctly");
|
||||
|
||||
assert_eq!(crate_to_pallet_version!(), version);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ frame_support::decl_storage! {
|
||||
}
|
||||
|
||||
frame_support::decl_event!(
|
||||
pub enum Event<T> where B = <T as Trait>::Balance {
|
||||
pub enum Event<T>
|
||||
where
|
||||
B = <T as Trait>::Balance,
|
||||
{
|
||||
Dummy(B),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
// limitations under the License.
|
||||
|
||||
use frame_support::{
|
||||
assert_ok, assert_noop, transactional, StorageMap, StorageValue,
|
||||
dispatch::{DispatchError, DispatchResult}, storage::{with_transaction, TransactionOutcome::*},
|
||||
assert_noop, assert_ok,
|
||||
dispatch::{DispatchError, DispatchResult},
|
||||
storage::{with_transaction, TransactionOutcome::*},
|
||||
transactional, StorageMap, StorageValue,
|
||||
};
|
||||
use sp_io::TestExternalities;
|
||||
use sp_std::result;
|
||||
@@ -41,7 +43,7 @@ frame_support::decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Config> as StorageTransactions {
|
||||
pub Value: u32;
|
||||
pub Map: map hasher(twox_64_concat) String => u32;
|
||||
@@ -62,7 +64,6 @@ impl Config for Runtime {}
|
||||
#[test]
|
||||
fn storage_transaction_basic_commit() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
|
||||
assert_eq!(Value::get(), 0);
|
||||
assert!(!Map::contains_key("val0"));
|
||||
|
||||
@@ -82,7 +83,6 @@ fn storage_transaction_basic_commit() {
|
||||
#[test]
|
||||
fn storage_transaction_basic_rollback() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
|
||||
assert_eq!(Value::get(), 0);
|
||||
assert_eq!(Map::get("val0"), 0);
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
// limitations under the License.
|
||||
|
||||
use frame_support::{
|
||||
codec::{Encode, Decode, EncodeLike}, traits::Get, weights::RuntimeDbWeight,
|
||||
codec::{Decode, Encode, EncodeLike},
|
||||
traits::Get,
|
||||
weights::RuntimeDbWeight,
|
||||
};
|
||||
|
||||
pub trait Config: 'static + Eq + Clone {
|
||||
@@ -45,7 +47,10 @@ impl<T: Config> Module<T> {
|
||||
}
|
||||
|
||||
frame_support::decl_event!(
|
||||
pub enum Event<T> where BlockNumber = <T as Config>::BlockNumber {
|
||||
pub enum Event<T>
|
||||
where
|
||||
BlockNumber = <T as Config>::BlockNumber,
|
||||
{
|
||||
ExtrinsicSuccess,
|
||||
ExtrinsicFailed,
|
||||
Ignore(BlockNumber),
|
||||
@@ -83,7 +88,8 @@ pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), &'static str>
|
||||
where OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>
|
||||
where
|
||||
OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>,
|
||||
{
|
||||
o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user