BREAKING: Rename Call & Event (#11981)

* rename Event to RuntimeEvent

* rename Call

* rename in runtimes

* small fix

* rename Event

* small fix & rename RuntimeCall back to Call for now

* small fixes

* more renaming

* a bit more renaming

* fmt

* small fix

* commit

* prep for renaming associated types

* fix

* rename associated Event type

* rename to RuntimeEvent

* commit

* merge conflict fixes & fmt

* additional renaming

* fix.

* fix decl_event

* rename in tests

* remove warnings

* remove accidental rename

* .

* commit

* update .stderr

* fix in test

* update .stderr

* TRYBUILD=overwrite

* docs

* fmt

* small change in docs

* rename PalletEvent to Event

* rename Call to RuntimeCall

* renamed at wrong places :P

* rename Call

* rename

* rename associated type

* fix

* fix & fmt

* commit

* frame-support-test

* passing tests

* update docs

* rustdoc fix

* update .stderr

* wrong code in docs

* merge fix

* fix in error message

* update .stderr

* docs & error message

* .

* merge fix

* merge fix

* fmt

* fmt

* merge fix

* more fixing

* fmt

* remove unused

* fmt

* fix

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Sergej Sakac
2022-09-13 00:03:31 +02:00
committed by GitHub
parent 472b5746e5
commit 6e8795afe6
228 changed files with 1791 additions and 1672 deletions
+6 -6
View File
@@ -27,7 +27,7 @@ use sp_runtime::traits::Bounded;
const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}
@@ -88,7 +88,7 @@ benchmarks! {
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real);
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::<T>::remark { remark: vec![] }.into();
}: _(RawOrigin::Signed(caller), real_lookup, Some(T::ProxyType::default()), Box::new(call))
verify {
assert_last_event::<T>(Event::ProxyExecuted { result: Ok(()) }.into())
@@ -105,7 +105,7 @@ benchmarks! {
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real);
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::<T>::remark { remark: vec![] }.into();
Proxy::<T>::announce(
RawOrigin::Signed(delegate.clone()).into(),
real_lookup.clone(),
@@ -126,7 +126,7 @@ benchmarks! {
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real);
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::<T>::remark { remark: vec![] }.into();
Proxy::<T>::announce(
RawOrigin::Signed(caller.clone()).into(),
real_lookup.clone(),
@@ -149,7 +149,7 @@ benchmarks! {
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real.clone());
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::<T>::remark { remark: vec![] }.into();
Proxy::<T>::announce(
RawOrigin::Signed(caller.clone()).into(),
real_lookup,
@@ -172,7 +172,7 @@ benchmarks! {
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real.clone());
add_announcements::<T>(a, Some(caller.clone()), None)?;
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::<T>::remark { remark: vec![] }.into();
let call_hash = T::CallHasher::hash_of(&call);
}: _(RawOrigin::Signed(caller.clone()), real_lookup, call_hash)
verify {
+9 -9
View File
@@ -110,15 +110,15 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The overarching call type.
type Call: Parameter
type RuntimeCall: Parameter
+ Dispatchable<Origin = Self::Origin>
+ GetDispatchInfo
+ From<frame_system::Call<Self>>
+ IsSubType<Call<Self>>
+ IsType<<Self as frame_system::Config>::Call>;
+ IsType<<Self as frame_system::Config>::RuntimeCall>;
/// The currency mechanism.
type Currency: ReservableCurrency<Self::AccountId>;
@@ -131,7 +131,7 @@ pub mod pallet {
+ Member
+ Ord
+ PartialOrd
+ InstanceFilter<<Self as Config>::Call>
+ InstanceFilter<<Self as Config>::RuntimeCall>
+ Default
+ MaxEncodedLen;
@@ -208,7 +208,7 @@ pub mod pallet {
origin: OriginFor<T>,
real: AccountIdLookupOf<T>,
force_proxy_type: Option<T::ProxyType>,
call: Box<<T as Config>::Call>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let real = T::Lookup::lookup(real)?;
@@ -539,7 +539,7 @@ pub mod pallet {
delegate: AccountIdLookupOf<T>,
real: AccountIdLookupOf<T>,
force_proxy_type: Option<T::ProxyType>,
call: Box<<T as Config>::Call>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResult {
ensure_signed(origin)?;
let delegate = T::Lookup::lookup(delegate)?;
@@ -817,12 +817,12 @@ impl<T: Config> Pallet<T> {
fn do_proxy(
def: ProxyDefinition<T::AccountId, T::ProxyType, T::BlockNumber>,
real: T::AccountId,
call: <T as Config>::Call,
call: <T as Config>::RuntimeCall,
) {
// This is a freshly authenticated new account, the origin restrictions doesn't apply.
let mut origin: T::Origin = frame_system::RawOrigin::Signed(real).into();
origin.add_filter(move |c: &<T as frame_system::Config>::Call| {
let c = <T as Config>::Call::from_ref(c);
origin.add_filter(move |c: &<T as frame_system::Config>::RuntimeCall| {
let c = <T as Config>::RuntimeCall::from_ref(c);
// We make sure the proxy call does access this pallet to change modify proxies.
match c.is_sub_type() {
// Proxy call cannot add or remove a proxy with more permissions than it already
+38 -31
View File
@@ -65,12 +65,12 @@ impl frame_system::Config for Test {
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
@@ -88,15 +88,15 @@ impl pallet_balances::Config for Test {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type Balance = u64;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
impl pallet_utility::Config for Test {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
}
@@ -124,14 +124,14 @@ impl Default for ProxyType {
Self::Any
}
}
impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool {
impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::JustTransfer => {
matches!(c, Call::Balances(pallet_balances::Call::transfer { .. }))
matches!(c, RuntimeCall::Balances(pallet_balances::Call::transfer { .. }))
},
ProxyType::JustUtility => matches!(c, Call::Utility { .. }),
ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }),
}
}
fn is_superset(&self, o: &Self) -> bool {
@@ -139,19 +139,19 @@ impl InstanceFilter<Call> for ProxyType {
}
}
pub struct BaseFilter;
impl Contains<Call> for BaseFilter {
fn contains(c: &Call) -> bool {
impl Contains<RuntimeCall> for BaseFilter {
fn contains(c: &RuntimeCall) -> bool {
match *c {
// Remark is used as a no-op call in the benchmarking
Call::System(SystemCall::remark { .. }) => true,
Call::System(_) => false,
RuntimeCall::System(SystemCall::remark { .. }) => true,
RuntimeCall::System(_) => false,
_ => true,
}
}
}
impl Config for Test {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = ConstU64<1>;
@@ -183,7 +183,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
ext
}
fn last_events(n: usize) -> Vec<Event> {
fn last_events(n: usize) -> Vec<RuntimeEvent> {
system::Pallet::<Test>::events()
.into_iter()
.rev()
@@ -193,12 +193,12 @@ fn last_events(n: usize) -> Vec<Event> {
.collect()
}
fn expect_events(e: Vec<Event>) {
fn expect_events(e: Vec<RuntimeEvent>) {
assert_eq!(last_events(e.len()), e);
}
fn call_transfer(dest: u64, value: u64) -> Call {
Call::Balances(BalancesCall::transfer { dest, value })
fn call_transfer(dest: u64, value: u64) -> RuntimeCall {
RuntimeCall::Balances(BalancesCall::transfer { dest, value })
}
#[test]
@@ -346,8 +346,10 @@ fn filtering_works() {
assert!(Balances::mutate_account(&derivative_id, |a| a.free = 1000).is_ok());
let inner = Box::new(call_transfer(6, 1));
let call =
Box::new(Call::Utility(UtilityCall::as_derivative { index: 0, call: inner.clone() }));
let call = Box::new(RuntimeCall::Utility(UtilityCall::as_derivative {
index: 0,
call: inner.clone(),
}));
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
@@ -359,7 +361,7 @@ fn filtering_works() {
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] }));
let call = Box::new(RuntimeCall::Utility(UtilityCall::batch { calls: vec![*inner] }));
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
expect_events(vec![
UtilityEvent::BatchCompleted.into(),
@@ -376,9 +378,12 @@ fn filtering_works() {
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
let inner =
Box::new(Call::Proxy(ProxyCall::new_call_variant_add_proxy(5, ProxyType::Any, 0)));
let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] }));
let inner = Box::new(RuntimeCall::Proxy(ProxyCall::new_call_variant_add_proxy(
5,
ProxyType::Any,
0,
)));
let call = Box::new(RuntimeCall::Utility(UtilityCall::batch { calls: vec![*inner] }));
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
expect_events(vec![
UtilityEvent::BatchCompleted.into(),
@@ -395,7 +400,7 @@ fn filtering_works() {
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
let call = Box::new(Call::Proxy(ProxyCall::remove_proxies {}));
let call = Box::new(RuntimeCall::Proxy(ProxyCall::remove_proxies {}));
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
@@ -517,15 +522,17 @@ fn proxying_works() {
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_eq!(Balances::free_balance(6), 1);
let call = Box::new(Call::System(SystemCall::set_code { code: vec![] }));
let call = Box::new(RuntimeCall::System(SystemCall::set_code { code: vec![] }));
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
let call =
Box::new(Call::Balances(BalancesCall::transfer_keep_alive { dest: 6, value: 1 }));
assert_ok!(Call::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone()))
let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_keep_alive {
dest: 6,
value: 1,
}));
assert_ok!(RuntimeCall::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone()))
.dispatch(Origin::signed(2)));
System::assert_last_event(
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
@@ -572,7 +579,7 @@ fn anonymous_works() {
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_eq!(Balances::free_balance(6), 1);
let call = Box::new(Call::Proxy(ProxyCall::new_call_variant_kill_anonymous(
let call = Box::new(RuntimeCall::Proxy(ProxyCall::new_call_variant_kill_anonymous(
1,
ProxyType::Any,
0,