mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
BREAKING: Rename Origin (#12258)
* BREAKING: Rename Origin * more renaming * a bit more renaming * fix * more fixing * fix in frame_support * even more fixes * fix * small fix * ... * update .stderr * docs * update docs * update docs * docs
This commit is contained in:
@@ -49,7 +49,7 @@ mod module1 {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config<I>, I: Instance = DefaultInstance> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
where origin: <T as system::Config>::RuntimeOrigin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -89,7 +89,7 @@ mod module2 {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
where origin: <T as system::Config>::RuntimeOrigin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -134,7 +134,7 @@ mod nested {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
where origin: <T as system::Config>::RuntimeOrigin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -180,7 +180,7 @@ pub mod module3 {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
where origin: <T as system::Config>::RuntimeOrigin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -247,7 +247,7 @@ fn test_pub() -> AccountId {
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type BlockNumber = BlockNumber;
|
||||
type AccountId = AccountId;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
|
||||
@@ -12,7 +12,7 @@ impl test_pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ mod pallet_old {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -21,7 +21,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -21,7 +21,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -21,7 +21,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -21,7 +21,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -46,39 +46,6 @@ help: if you import `Origin`, refer to it directly
|
||||
58 - }
|
||||
|
|
||||
|
||||
error[E0412]: cannot find type `Origin` in module `pallet`
|
||||
--> tests/construct_runtime_ui/undefined_origin_part.rs:49:1
|
||||
|
|
||||
49 | / construct_runtime! {
|
||||
50 | | pub enum Runtime where
|
||||
51 | | Block = Block,
|
||||
52 | | NodeBlock = Block,
|
||||
... |
|
||||
57 | | }
|
||||
58 | | }
|
||||
| |_^ not found in `pallet`
|
||||
|
|
||||
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider importing one of these items
|
||||
|
|
||||
1 | use crate::Origin;
|
||||
|
|
||||
1 | use frame_system::Origin;
|
||||
|
|
||||
help: if you import `Origin`, refer to it directly
|
||||
|
|
||||
49 - construct_runtime! {
|
||||
50 - pub enum Runtime where
|
||||
51 - Block = Block,
|
||||
52 - NodeBlock = Block,
|
||||
53 - UncheckedExtrinsic = UncheckedExtrinsic
|
||||
54 - {
|
||||
55 - System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
|
||||
56 - Pallet: pallet::{Pallet, Origin},
|
||||
57 - }
|
||||
58 - }
|
||||
|
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> tests/construct_runtime_ui/undefined_origin_part.rs:49:1
|
||||
|
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ impl pallet::Config for Runtime {}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=self {
|
||||
fn integrity_test() {}
|
||||
|
||||
fn integrity_test() {}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ error: `integrity_test` can only be passed once as input.
|
||||
--> tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs:1:1
|
||||
|
|
||||
1 | / frame_support::decl_module! {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=self {
|
||||
3 | | fn integrity_test() {}
|
||||
4 | |
|
||||
5 | | fn integrity_test() {}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=self {
|
||||
fn on_initialize() -> Weight {
|
||||
0
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ error: `on_initialize` can only be passed once as input.
|
||||
--> $DIR/reserved_keyword_two_times_on_initialize.rs:1:1
|
||||
|
|
||||
1 | / frame_support::decl_module! {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=self {
|
||||
3 | | fn on_initialize() -> Weight {
|
||||
4 | | 0
|
||||
... |
|
||||
|
||||
@@ -23,7 +23,7 @@ mod tests {
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
pub trait Config: frame_support_test::Config {
|
||||
@@ -94,7 +94,7 @@ mod tests {
|
||||
struct TraitImpl {}
|
||||
|
||||
impl frame_support_test::Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type RuntimeOrigin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = frame_support_test::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
@@ -617,7 +617,7 @@ mod test2 {
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
type PairOf<T> = (T, T);
|
||||
@@ -639,7 +639,7 @@ mod test2 {
|
||||
struct TraitImpl {}
|
||||
|
||||
impl frame_support_test::Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type RuntimeOrigin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = frame_support_test::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
@@ -695,7 +695,7 @@ mod test3 {
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
@@ -708,7 +708,7 @@ mod test3 {
|
||||
struct TraitImpl {}
|
||||
|
||||
impl frame_support_test::Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type RuntimeOrigin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = frame_support_test::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
@@ -726,7 +726,7 @@ mod test_append_and_len {
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, scale_info::TypeInfo)]
|
||||
@@ -753,7 +753,7 @@ mod test_append_and_len {
|
||||
struct Test {}
|
||||
|
||||
impl frame_support_test::Config for Test {
|
||||
type Origin = u32;
|
||||
type RuntimeOrigin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = frame_support_test::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
|
||||
@@ -28,7 +28,7 @@ mod no_instance {
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
@@ -53,7 +53,7 @@ mod instance {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config<I>, I: Instance = DefaultInstance>
|
||||
for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
@@ -31,7 +31,7 @@ struct Test;
|
||||
|
||||
impl frame_support_test::Config for Test {
|
||||
type BlockNumber = u32;
|
||||
type Origin = ();
|
||||
type RuntimeOrigin = ();
|
||||
type PalletInfo = frame_support_test::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ mod module1 {
|
||||
<Self as system::Config>::BlockNumber: From<u32>,
|
||||
{
|
||||
type RuntimeEvent: From<Event<Self, I>> + Into<<Self as system::Config>::RuntimeEvent>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
type RuntimeOrigin: From<Origin<Self, I>>;
|
||||
type SomeParameter: Get<u32>;
|
||||
type GenericType: Default + Clone + Codec + EncodeLike + TypeInfo;
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config<I>, I: Instance> for enum Call where
|
||||
origin: <T as system::Config>::Origin,
|
||||
origin: <T as system::Config>::RuntimeOrigin,
|
||||
system = system,
|
||||
T::BlockNumber: From<u32>
|
||||
{
|
||||
@@ -155,14 +155,14 @@ mod module2 {
|
||||
pub trait Config<I = DefaultInstance>: system::Config {
|
||||
type Amount: Parameter + Default;
|
||||
type RuntimeEvent: From<Event<Self, I>> + Into<<Self as system::Config>::RuntimeEvent>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
type RuntimeOrigin: From<Origin<Self, I>>;
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: Instance> Currency for Module<T, I> {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config<I>, I: Instance=DefaultInstance> for enum Call where
|
||||
origin: <T as system::Config>::Origin,
|
||||
origin: <T as system::Config>::RuntimeOrigin,
|
||||
system = system
|
||||
{
|
||||
fn deposit_event() = default;
|
||||
@@ -228,41 +228,41 @@ mod module3 {
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: <T as system::Config>::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: <T as system::Config>::RuntimeOrigin, system=system {}
|
||||
}
|
||||
}
|
||||
|
||||
impl module1::Config<module1::Instance1> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type SomeParameter = ConstU32<100>;
|
||||
type GenericType = u32;
|
||||
}
|
||||
impl module1::Config<module1::Instance2> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type SomeParameter = ConstU32<100>;
|
||||
type GenericType = u32;
|
||||
}
|
||||
impl module2::Config for Runtime {
|
||||
type Amount = u16;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
}
|
||||
impl module2::Config<module2::Instance1> for Runtime {
|
||||
type Amount = u32;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
}
|
||||
impl module2::Config<module2::Instance2> for Runtime {
|
||||
type Amount = u32;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
}
|
||||
impl module2::Config<module2::Instance3> for Runtime {
|
||||
type Amount = u64;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
}
|
||||
impl module3::Config for Runtime {
|
||||
type Currency = Module2_2;
|
||||
@@ -277,7 +277,7 @@ pub type Index = u64;
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type BlockNumber = BlockNumber;
|
||||
type AccountId = AccountId;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
|
||||
@@ -86,7 +86,7 @@ mod module {
|
||||
pub trait Config: system::Config + TypeInfo {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=system {}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Serialize, Deserialize)]
|
||||
@@ -160,7 +160,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<u32, RuntimeCall, Sign
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type BlockNumber = BlockNumber;
|
||||
type AccountId = AccountId;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Origin tests for construct_runtime macro
|
||||
//! RuntimeOrigin tests for construct_runtime macro
|
||||
|
||||
#![recursion_limit = "128"]
|
||||
|
||||
@@ -38,7 +38,7 @@ mod nested {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
where origin: <T as system::Config>::RuntimeOrigin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -80,7 +80,7 @@ pub mod module {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
where origin: <T as system::Config>::RuntimeOrigin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -146,7 +146,7 @@ impl Contains<RuntimeCall> for BaseCallFilter {
|
||||
impl system::Config for RuntimeOriginTest {
|
||||
type BaseCallFilter = BaseCallFilter;
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type BlockNumber = BlockNumber;
|
||||
type AccountId = u32;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
@@ -178,40 +178,40 @@ fn origin_default_filter() {
|
||||
let accepted_call = nested::module::Call::fail {}.into();
|
||||
let rejected_call = module::Call::fail {}.into();
|
||||
|
||||
assert_eq!(Origin::root().filter_call(&accepted_call), true);
|
||||
assert_eq!(Origin::root().filter_call(&rejected_call), true);
|
||||
assert_eq!(Origin::none().filter_call(&accepted_call), true);
|
||||
assert_eq!(Origin::none().filter_call(&rejected_call), false);
|
||||
assert_eq!(Origin::signed(0).filter_call(&accepted_call), true);
|
||||
assert_eq!(Origin::signed(0).filter_call(&rejected_call), false);
|
||||
assert_eq!(Origin::from(Some(0)).filter_call(&accepted_call), true);
|
||||
assert_eq!(Origin::from(Some(0)).filter_call(&rejected_call), false);
|
||||
assert_eq!(Origin::from(None).filter_call(&accepted_call), true);
|
||||
assert_eq!(Origin::from(None).filter_call(&rejected_call), false);
|
||||
assert_eq!(Origin::from(nested::module::Origin).filter_call(&accepted_call), true);
|
||||
assert_eq!(Origin::from(nested::module::Origin).filter_call(&rejected_call), false);
|
||||
assert_eq!(RuntimeOrigin::root().filter_call(&accepted_call), true);
|
||||
assert_eq!(RuntimeOrigin::root().filter_call(&rejected_call), true);
|
||||
assert_eq!(RuntimeOrigin::none().filter_call(&accepted_call), true);
|
||||
assert_eq!(RuntimeOrigin::none().filter_call(&rejected_call), false);
|
||||
assert_eq!(RuntimeOrigin::signed(0).filter_call(&accepted_call), true);
|
||||
assert_eq!(RuntimeOrigin::signed(0).filter_call(&rejected_call), false);
|
||||
assert_eq!(RuntimeOrigin::from(Some(0)).filter_call(&accepted_call), true);
|
||||
assert_eq!(RuntimeOrigin::from(Some(0)).filter_call(&rejected_call), false);
|
||||
assert_eq!(RuntimeOrigin::from(None).filter_call(&accepted_call), true);
|
||||
assert_eq!(RuntimeOrigin::from(None).filter_call(&rejected_call), false);
|
||||
assert_eq!(RuntimeOrigin::from(nested::module::Origin).filter_call(&accepted_call), true);
|
||||
assert_eq!(RuntimeOrigin::from(nested::module::Origin).filter_call(&rejected_call), false);
|
||||
|
||||
let mut origin = Origin::from(Some(0));
|
||||
let mut origin = RuntimeOrigin::from(Some(0));
|
||||
origin.add_filter(|c| matches!(c, RuntimeCall::Module(_)));
|
||||
assert_eq!(origin.filter_call(&accepted_call), false);
|
||||
assert_eq!(origin.filter_call(&rejected_call), false);
|
||||
|
||||
// Now test for root origin and filters:
|
||||
let mut origin = Origin::from(Some(0));
|
||||
origin.set_caller_from(Origin::root());
|
||||
let mut origin = RuntimeOrigin::from(Some(0));
|
||||
origin.set_caller_from(RuntimeOrigin::root());
|
||||
assert!(matches!(origin.caller, OriginCaller::system(system::RawOrigin::Root)));
|
||||
|
||||
// Root origin bypass all filter.
|
||||
assert_eq!(origin.filter_call(&accepted_call), true);
|
||||
assert_eq!(origin.filter_call(&rejected_call), true);
|
||||
|
||||
origin.set_caller_from(Origin::from(Some(0)));
|
||||
origin.set_caller_from(RuntimeOrigin::from(Some(0)));
|
||||
|
||||
// Back to another signed origin, the filtered are now effective again
|
||||
assert_eq!(origin.filter_call(&accepted_call), true);
|
||||
assert_eq!(origin.filter_call(&rejected_call), false);
|
||||
|
||||
origin.set_caller_from(Origin::root());
|
||||
origin.set_caller_from(RuntimeOrigin::root());
|
||||
origin.reset_filter();
|
||||
|
||||
// Root origin bypass all filter, even when they are reset.
|
||||
|
||||
@@ -552,8 +552,10 @@ pub mod pallet2 {
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet3 {
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config<Origin = <Self as Config>::Origin> {
|
||||
type Origin;
|
||||
pub trait Config:
|
||||
frame_system::Config<RuntimeOrigin = <Self as Config>::RuntimeOrigin>
|
||||
{
|
||||
type RuntimeOrigin;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
@@ -578,7 +580,7 @@ frame_support::parameter_types!(
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
@@ -618,7 +620,7 @@ impl pallet4::Config for Runtime {}
|
||||
|
||||
#[cfg(feature = "frame-feature-testing")]
|
||||
impl pallet3::Config for Runtime {
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
}
|
||||
|
||||
pub type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;
|
||||
|
||||
@@ -70,7 +70,7 @@ mod pallet_old {
|
||||
);
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin {
|
||||
type Error = Error<T>;
|
||||
fn deposit_event() = default;
|
||||
const SomeConst: T::Balance = T::SomeConst::get();
|
||||
@@ -226,7 +226,7 @@ pub mod pallet {
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -56,7 +56,7 @@ mod pallet_old {
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Config<I>, I: Instance = DefaultInstance> for enum Call
|
||||
where origin: T::Origin
|
||||
where origin: T::RuntimeOrigin
|
||||
{
|
||||
type Error = Error<T, I>;
|
||||
fn deposit_event() = default;
|
||||
@@ -210,7 +210,7 @@ impl frame_system::Config for Runtime {
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -286,7 +286,7 @@ pub mod pallet2 {
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -43,7 +43,7 @@ frame_support::decl_error!(
|
||||
);
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::RuntimeOrigin {
|
||||
fn deposit_event() = default;
|
||||
type Error = Error<T>;
|
||||
const Foo: u32 = u32::MAX;
|
||||
@@ -126,7 +126,7 @@ mod tests {
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = sp_core::H256;
|
||||
|
||||
@@ -59,7 +59,7 @@ pub mod decl_pallet {
|
||||
pub trait Config: frame_system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin {
|
||||
#[weight = 0]
|
||||
pub fn set_value(_origin, value: u32) {
|
||||
DeclValue::put(value);
|
||||
@@ -86,7 +86,7 @@ impl frame_system::Config for Runtime {
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u32;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
@@ -256,11 +256,11 @@ fn storage_layer_in_pallet_call() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
use sp_runtime::traits::Dispatchable;
|
||||
let call1 = RuntimeCall::MyPallet(pallet::Call::set_value { value: 2 });
|
||||
assert_ok!(call1.dispatch(Origin::signed(0)));
|
||||
assert_ok!(call1.dispatch(RuntimeOrigin::signed(0)));
|
||||
assert_eq!(Value::<Runtime>::get(), 2);
|
||||
|
||||
let call2 = RuntimeCall::MyPallet(pallet::Call::set_value { value: 1 });
|
||||
assert_noop!(call2.dispatch(Origin::signed(0)), Error::<Runtime>::Revert);
|
||||
assert_noop!(call2.dispatch(RuntimeOrigin::signed(0)), Error::<Runtime>::Revert);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -271,12 +271,15 @@ fn storage_layer_in_decl_pallet_call() {
|
||||
use sp_runtime::traits::Dispatchable;
|
||||
|
||||
let call1 = RuntimeCall::DeclPallet(decl_pallet::Call::set_value { value: 2 });
|
||||
assert_ok!(call1.dispatch(Origin::signed(0)));
|
||||
assert_ok!(call1.dispatch(RuntimeOrigin::signed(0)));
|
||||
assert_eq!(decl_pallet::DeclValue::get(), 2);
|
||||
|
||||
let call2 = RuntimeCall::DeclPallet(decl_pallet::Call::set_value { value: 1 });
|
||||
assert_noop!(call2.dispatch(Origin::signed(0)), "Revert!");
|
||||
assert_noop!(call2.dispatch(RuntimeOrigin::signed(0)), "Revert!");
|
||||
// Calling the function directly also works with storage layers.
|
||||
assert_noop!(decl_pallet::Module::<Runtime>::set_value(Origin::signed(1), 1), "Revert!");
|
||||
assert_noop!(
|
||||
decl_pallet::Module::<Runtime>::set_value(RuntimeOrigin::signed(1), 1),
|
||||
"Revert!"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ use sp_std::result;
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {
|
||||
#[weight = 0]
|
||||
#[transactional]
|
||||
fn value_commits(_origin, v: u32) {
|
||||
@@ -57,7 +57,7 @@ frame_support::decl_storage! {
|
||||
struct Runtime;
|
||||
|
||||
impl frame_support_test::Config for Runtime {
|
||||
type Origin = u32;
|
||||
type RuntimeOrigin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = frame_support_test::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
|
||||
@@ -22,7 +22,7 @@ use frame_support::{
|
||||
};
|
||||
|
||||
pub trait Config: 'static + Eq + Clone {
|
||||
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
||||
type RuntimeOrigin: Into<Result<RawOrigin<Self::AccountId>, Self::RuntimeOrigin>>
|
||||
+ From<RawOrigin<Self::AccountId>>;
|
||||
|
||||
type BaseCallFilter: frame_support::traits::Contains<Self::RuntimeCall>;
|
||||
@@ -36,7 +36,7 @@ pub trait Config: 'static + Eq + Clone {
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin, system=self {
|
||||
#[weight = 0]
|
||||
fn noop(_origin) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user