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
+7 -5
View File
@@ -115,10 +115,12 @@ 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>;
/// A sudo-able call.
type Call: Parameter + UnfilteredDispatchable<Origin = Self::Origin> + GetDispatchInfo;
type RuntimeCall: Parameter
+ UnfilteredDispatchable<Origin = Self::Origin>
+ GetDispatchInfo;
}
#[pallet::pallet]
@@ -143,7 +145,7 @@ pub mod pallet {
})]
pub fn sudo(
origin: OriginFor<T>,
call: Box<<T as Config>::Call>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;
@@ -168,7 +170,7 @@ pub mod pallet {
#[pallet::weight((*_weight, call.get_dispatch_info().class))]
pub fn sudo_unchecked_weight(
origin: OriginFor<T>,
call: Box<<T as Config>::Call>,
call: Box<<T as Config>::RuntimeCall>,
_weight: Weight,
) -> DispatchResultWithPostInfo {
// This is a public call, so we ensure that the origin is some signed account.
@@ -230,7 +232,7 @@ pub mod pallet {
pub fn sudo_as(
origin: OriginFor<T>,
who: AccountIdLookupOf<T>,
call: Box<<T as Config>::Call>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;
+8 -8
View File
@@ -40,7 +40,7 @@ pub mod logger {
#[pallet::config]
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
}
#[pallet::pallet]
@@ -114,8 +114,8 @@ parameter_types! {
}
pub struct BlockEverything;
impl Contains<Call> for BlockEverything {
fn contains(_: &Call) -> bool {
impl Contains<RuntimeCall> for BlockEverything {
fn contains(_: &RuntimeCall) -> bool {
false
}
}
@@ -126,7 +126,7 @@ impl frame_system::Config for Test {
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -134,7 +134,7 @@ impl frame_system::Config for Test {
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;
@@ -149,13 +149,13 @@ impl frame_system::Config for Test {
// Implement the logger module's `Config` on the Test runtime.
impl logger::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
}
// Implement the sudo module's `Config` on the Test runtime.
impl Config for Test {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
}
// New types for dispatchable functions.
+13 -13
View File
@@ -20,8 +20,8 @@
use super::*;
use frame_support::{assert_noop, assert_ok, weights::Weight};
use mock::{
new_test_ext, Call, Event as TestEvent, Logger, LoggerCall, Origin, Sudo, SudoCall, System,
Test,
new_test_ext, Logger, LoggerCall, Origin, RuntimeCall, RuntimeEvent as TestEvent, Sudo,
SudoCall, System, Test,
};
#[test]
@@ -39,7 +39,7 @@ fn sudo_basics() {
// Configure a default test environment and set the root `key` to 1.
new_test_ext(1).execute_with(|| {
// A privileged function should work when `sudo` is passed the root `key` as `origin`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1_000),
}));
@@ -47,7 +47,7 @@ fn sudo_basics() {
assert_eq!(Logger::i32_log(), vec![42i32]);
// A privileged function should not work when `sudo` is passed a non-root `key` as `origin`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1_000),
}));
@@ -62,7 +62,7 @@ fn sudo_emits_events_correctly() {
System::set_block_number(1);
// Should emit event to indicate success when called with the root `key` and `call` is `Ok`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1),
}));
@@ -75,7 +75,7 @@ fn sudo_emits_events_correctly() {
fn sudo_unchecked_weight_basics() {
new_test_ext(1).execute_with(|| {
// A privileged function should work when `sudo` is passed the root `key` as origin.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1_000),
}));
@@ -87,7 +87,7 @@ fn sudo_unchecked_weight_basics() {
assert_eq!(Logger::i32_log(), vec![42i32]);
// A privileged function should not work when called with a non-root `key`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1_000),
}));
@@ -99,7 +99,7 @@ fn sudo_unchecked_weight_basics() {
assert_eq!(Logger::i32_log(), vec![42i32]);
// Controls the dispatched weight.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1),
}));
@@ -117,7 +117,7 @@ fn sudo_unchecked_weight_emits_events_correctly() {
System::set_block_number(1);
// Should emit event to indicate success when called with the root `key` and `call` is `Ok`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1),
}));
@@ -164,7 +164,7 @@ fn set_key_emits_events_correctly() {
fn sudo_as_basics() {
new_test_ext(1).execute_with(|| {
// A privileged function will not work when passed to `sudo_as`.
let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log {
i: 42,
weight: Weight::from_ref_time(1_000),
}));
@@ -173,14 +173,14 @@ fn sudo_as_basics() {
assert!(Logger::account_log().is_empty());
// A non-privileged function should not work when called with a non-root `key`.
let call = Box::new(Call::Logger(LoggerCall::non_privileged_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log {
i: 42,
weight: Weight::from_ref_time(1),
}));
assert_noop!(Sudo::sudo_as(Origin::signed(3), 2, call), Error::<Test>::RequireSudo);
// A non-privileged function will work when passed to `sudo_as` with the root `key`.
let call = Box::new(Call::Logger(LoggerCall::non_privileged_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log {
i: 42,
weight: Weight::from_ref_time(1),
}));
@@ -198,7 +198,7 @@ fn sudo_as_emits_events_correctly() {
System::set_block_number(1);
// A non-privileged function will work when passed to `sudo_as` with the root `key`.
let call = Box::new(Call::Logger(LoggerCall::non_privileged_log {
let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log {
i: 42,
weight: Weight::from_ref_time(1),
}));