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
@@ -71,7 +71,7 @@ benchmarks! {
let remark_len = <T::PreimageProvider as PreimageRecipient<_>>::MaxSize::get() - 10;
let remark = sp_std::vec![1u8; remark_len as usize];
let call: <T as Config>::Call = frame_system::Call::remark { remark }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark }.into();
let call_weight = call.get_dispatch_info().weight;
let encoded_call = call.encode();
let call_hash = T::Hashing::hash(&encoded_call[..]);
@@ -100,7 +100,7 @@ benchmarks! {
let origin = T::DispatchWhitelistedOrigin::successful_origin();
let remark = sp_std::vec![1u8; n as usize];
let call: <T as Config>::Call = frame_system::Call::remark { remark }.into();
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark }.into();
let call_hash = T::Hashing::hash_of(&call);
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
+5 -5
View File
@@ -61,10 +61,10 @@ 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: IsType<<Self as frame_system::Config>::Call>
type RuntimeCall: IsType<<Self as frame_system::Config>::RuntimeCall>
+ Dispatchable<Origin = Self::Origin, PostInfo = PostDispatchInfo>
+ GetDispatchInfo
+ FullCodec
@@ -165,7 +165,7 @@ pub mod pallet {
let call = T::PreimageProvider::get_preimage(&call_hash)
.ok_or(Error::<T>::UnavailablePreImage)?;
let call = <T as Config>::Call::decode_all_with_depth_limit(
let call = <T as Config>::RuntimeCall::decode_all_with_depth_limit(
sp_api::MAX_EXTRINSIC_DEPTH,
&mut &call[..],
)
@@ -191,7 +191,7 @@ pub mod pallet {
})]
pub fn dispatch_whitelisted_call_with_preimage(
origin: OriginFor<T>,
call: Box<<T as Config>::Call>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo {
T::DispatchWhitelistedOrigin::ensure_origin(origin)?;
@@ -216,7 +216,7 @@ impl<T: Config> Pallet<T> {
/// Clean whitelisting/preimage and dispatch call.
///
/// Return the call actual weight of the dispatched call if there is some.
fn clean_and_dispatch(call_hash: T::Hash, call: <T as Config>::Call) -> Option<Weight> {
fn clean_and_dispatch(call_hash: T::Hash, call: <T as Config>::RuntimeCall) -> Option<Weight> {
WhitelistedCall::<T>::remove(call_hash);
T::PreimageProvider::unrequest_preimage(&call_hash);
+6 -6
View File
@@ -62,12 +62,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;
@@ -85,7 +85,7 @@ 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;
@@ -93,7 +93,7 @@ impl pallet_balances::Config for Test {
}
impl pallet_preimage::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<Self::AccountId>;
type MaxSize = ConstU32<{ 4096 * 1024 }>; // PreimageMaxSize Taken from Polkadot as reference.
@@ -103,8 +103,8 @@ impl pallet_preimage::Config for Test {
}
impl pallet_whitelist::Config for Test {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WhitelistOrigin = EnsureRoot<Self::AccountId>;
type DispatchWhitelistedOrigin = EnsureRoot<Self::AccountId>;
type PreimageProvider = Preimage;
+7 -6
View File
@@ -27,7 +27,7 @@ use sp_runtime::{traits::Hash, DispatchError};
#[test]
fn test_whitelist_call_and_remove() {
new_test_ext().execute_with(|| {
let call = Call::System(frame_system::Call::remark { remark: vec![] });
let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let encoded_call = call.encode();
let call_hash = <Test as frame_system::Config>::Hashing::hash(&encoded_call[..]);
@@ -69,7 +69,7 @@ fn test_whitelist_call_and_remove() {
#[test]
fn test_whitelist_call_and_execute() {
new_test_ext().execute_with(|| {
let call = Call::System(frame_system::Call::remark_with_event { remark: vec![1] });
let call = RuntimeCall::System(frame_system::Call::remark_with_event { remark: vec![1] });
let call_weight = call.get_dispatch_info().weight;
let encoded_call = call.encode();
let call_hash = <Test as frame_system::Config>::Hashing::hash(&encoded_call[..]);
@@ -118,7 +118,7 @@ fn test_whitelist_call_and_execute() {
#[test]
fn test_whitelist_call_and_execute_failing_call() {
new_test_ext().execute_with(|| {
let call = Call::Whitelist(crate::Call::dispatch_whitelisted_call {
let call = RuntimeCall::Whitelist(crate::Call::dispatch_whitelisted_call {
call_hash: Default::default(),
call_weight_witness: Weight::zero(),
});
@@ -137,8 +137,9 @@ fn test_whitelist_call_and_execute_failing_call() {
#[test]
fn test_whitelist_call_and_execute_without_note_preimage() {
new_test_ext().execute_with(|| {
let call =
Box::new(Call::System(frame_system::Call::remark_with_event { remark: vec![1] }));
let call = Box::new(RuntimeCall::System(frame_system::Call::remark_with_event {
remark: vec![1],
}));
let call_hash = <Test as frame_system::Config>::Hashing::hash_of(&call);
assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash));
@@ -161,7 +162,7 @@ fn test_whitelist_call_and_execute_without_note_preimage() {
#[test]
fn test_whitelist_call_and_execute_decode_consumes_all() {
new_test_ext().execute_with(|| {
let call = Call::System(frame_system::Call::remark_with_event { remark: vec![1] });
let call = RuntimeCall::System(frame_system::Call::remark_with_event { remark: vec![1] });
let call_weight = call.get_dispatch_info().weight;
let mut call = call.encode();
// Appending something does not make the encoded call invalid.