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:
Sergej Sakac
2022-09-21 00:13:09 +02:00
committed by GitHub
parent 986d20b352
commit e4b6f4a66d
221 changed files with 5233 additions and 4200 deletions
@@ -33,7 +33,7 @@ benchmarks! {
whitelist_call {
let origin = T::WhitelistOrigin::successful_origin();
let call_hash = Default::default();
}: _<T::Origin>(origin, call_hash)
}: _<T::RuntimeOrigin>(origin, call_hash)
verify {
ensure!(
WhitelistedCall::<T>::contains_key(call_hash),
@@ -50,7 +50,7 @@ benchmarks! {
let call_hash = Default::default();
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
.expect("whitelisting call must be successful");
}: _<T::Origin>(origin, call_hash)
}: _<T::RuntimeOrigin>(origin, call_hash)
verify {
ensure!(
!WhitelistedCall::<T>::contains_key(call_hash),
@@ -82,7 +82,7 @@ benchmarks! {
let encoded_call = encoded_call.try_into().expect("encoded_call must be small enough");
T::PreimageProvider::note_preimage(encoded_call);
}: _<T::Origin>(origin, call_hash, call_weight)
}: _<T::RuntimeOrigin>(origin, call_hash, call_weight)
verify {
ensure!(
!WhitelistedCall::<T>::contains_key(call_hash),
@@ -105,7 +105,7 @@ benchmarks! {
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
.expect("whitelisting call must be successful");
}: _<T::Origin>(origin, Box::new(call))
}: _<T::RuntimeOrigin>(origin, Box::new(call))
verify {
ensure!(
!WhitelistedCall::<T>::contains_key(call_hash),
+3 -3
View File
@@ -66,7 +66,7 @@ pub mod pallet {
/// The overarching call type.
type RuntimeCall: IsType<<Self as frame_system::Config>::RuntimeCall>
+ Dispatchable<Origin = Self::Origin, PostInfo = PostDispatchInfo>
+ Dispatchable<RuntimeOrigin = Self::RuntimeOrigin, PostInfo = PostDispatchInfo>
+ GetDispatchInfo
+ FullCodec
+ TypeInfo
@@ -74,10 +74,10 @@ pub mod pallet {
+ Parameter;
/// Required origin for whitelisting a call.
type WhitelistOrigin: EnsureOrigin<Self::Origin>;
type WhitelistOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Required origin for dispatching whitelisted call with root origin.
type DispatchWhitelistedOrigin: EnsureOrigin<Self::Origin>;
type DispatchWhitelistedOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The handler of pre-images.
// NOTE: recipient is only needed for benchmarks.
+1 -1
View File
@@ -58,7 +58,7 @@ impl frame_system::Config for Test {
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
+32 -24
View File
@@ -32,35 +32,35 @@ fn test_whitelist_call_and_remove() {
let call_hash = <Test as frame_system::Config>::Hashing::hash(&encoded_call[..]);
assert_noop!(
Whitelist::remove_whitelisted_call(Origin::root(), call_hash),
Whitelist::remove_whitelisted_call(RuntimeOrigin::root(), call_hash),
crate::Error::<Test>::CallIsNotWhitelisted,
);
assert_noop!(
Whitelist::whitelist_call(Origin::signed(1), call_hash),
Whitelist::whitelist_call(RuntimeOrigin::signed(1), call_hash),
DispatchError::BadOrigin,
);
assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash));
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
assert!(Preimage::preimage_requested(&call_hash));
assert_noop!(
Whitelist::whitelist_call(Origin::root(), call_hash),
Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash),
crate::Error::<Test>::CallAlreadyWhitelisted,
);
assert_noop!(
Whitelist::remove_whitelisted_call(Origin::signed(1), call_hash),
Whitelist::remove_whitelisted_call(RuntimeOrigin::signed(1), call_hash),
DispatchError::BadOrigin,
);
assert_ok!(Whitelist::remove_whitelisted_call(Origin::root(), call_hash));
assert_ok!(Whitelist::remove_whitelisted_call(RuntimeOrigin::root(), call_hash));
assert!(!Preimage::preimage_requested(&call_hash));
assert_noop!(
Whitelist::remove_whitelisted_call(Origin::root(), call_hash),
Whitelist::remove_whitelisted_call(RuntimeOrigin::root(), call_hash),
crate::Error::<Test>::CallIsNotWhitelisted,
);
});
@@ -75,41 +75,45 @@ fn test_whitelist_call_and_execute() {
let call_hash = <Test as frame_system::Config>::Hashing::hash(&encoded_call[..]);
assert_noop!(
Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight),
Whitelist::dispatch_whitelisted_call(RuntimeOrigin::root(), call_hash, call_weight),
crate::Error::<Test>::CallIsNotWhitelisted,
);
assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash));
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
assert_noop!(
Whitelist::dispatch_whitelisted_call(Origin::signed(1), call_hash, call_weight),
Whitelist::dispatch_whitelisted_call(RuntimeOrigin::signed(1), call_hash, call_weight),
DispatchError::BadOrigin,
);
assert_noop!(
Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight),
Whitelist::dispatch_whitelisted_call(RuntimeOrigin::root(), call_hash, call_weight),
crate::Error::<Test>::UnavailablePreImage,
);
assert_ok!(Preimage::note_preimage(Origin::root(), encoded_call));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::root(), encoded_call));
assert!(Preimage::preimage_requested(&call_hash));
assert_noop!(
Whitelist::dispatch_whitelisted_call(
Origin::root(),
RuntimeOrigin::root(),
call_hash,
call_weight - Weight::from_ref_time(1)
),
crate::Error::<Test>::InvalidCallWeightWitness,
);
assert_ok!(Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight));
assert_ok!(Whitelist::dispatch_whitelisted_call(
RuntimeOrigin::root(),
call_hash,
call_weight
));
assert!(!Preimage::preimage_requested(&call_hash));
assert_noop!(
Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight),
Whitelist::dispatch_whitelisted_call(RuntimeOrigin::root(), call_hash, call_weight),
crate::Error::<Test>::CallIsNotWhitelisted,
);
});
@@ -126,10 +130,14 @@ fn test_whitelist_call_and_execute_failing_call() {
let encoded_call = call.encode();
let call_hash = <Test as frame_system::Config>::Hashing::hash(&encoded_call[..]);
assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash));
assert_ok!(Preimage::note_preimage(Origin::root(), encoded_call));
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::root(), encoded_call));
assert!(Preimage::preimage_requested(&call_hash));
assert_ok!(Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight));
assert_ok!(Whitelist::dispatch_whitelisted_call(
RuntimeOrigin::root(),
call_hash,
call_weight
));
assert!(!Preimage::preimage_requested(&call_hash));
});
}
@@ -142,18 +150,18 @@ fn test_whitelist_call_and_execute_without_note_preimage() {
}));
let call_hash = <Test as frame_system::Config>::Hashing::hash_of(&call);
assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash));
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
assert!(Preimage::preimage_requested(&call_hash));
assert_ok!(Whitelist::dispatch_whitelisted_call_with_preimage(
Origin::root(),
RuntimeOrigin::root(),
call.clone()
));
assert!(!Preimage::preimage_requested(&call_hash));
assert_noop!(
Whitelist::dispatch_whitelisted_call_with_preimage(Origin::root(), call),
Whitelist::dispatch_whitelisted_call_with_preimage(RuntimeOrigin::root(), call),
crate::Error::<Test>::CallIsNotWhitelisted,
);
});
@@ -171,11 +179,11 @@ fn test_whitelist_call_and_execute_decode_consumes_all() {
let call_hash = <Test as frame_system::Config>::Hashing::hash(&call[..]);
assert_ok!(Preimage::note_preimage(Origin::root(), call));
assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash));
assert_ok!(Preimage::note_preimage(RuntimeOrigin::root(), call));
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
assert_noop!(
Whitelist::dispatch_whitelisted_call(Origin::root(), call_hash, call_weight),
Whitelist::dispatch_whitelisted_call(RuntimeOrigin::root(), call_hash, call_weight),
crate::Error::<Test>::UndecodableCall,
);
});