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
+43 -41
View File
@@ -282,7 +282,7 @@ 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>;
/// Handler for withdrawing, refunding and depositing the transaction fee.
/// Transaction fees are withdrawn before the transaction is executed.
@@ -440,7 +440,7 @@ where
len: u32,
) -> RuntimeDispatchInfo<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
{
// NOTE: we can actually make it understand `ChargeTransactionPayment`, but would be some
// hassle for sure. We have to make it aware of the index of `ChargeTransactionPayment` in
@@ -467,7 +467,7 @@ where
len: u32,
) -> FeeDetails<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
{
let dispatch_info = <Extrinsic as GetDispatchInfo>::get_dispatch_info(&unchecked_extrinsic);
@@ -482,11 +482,11 @@ where
}
/// Query information of a dispatch class, weight, and fee of a given encoded `Call`.
pub fn query_call_info(call: T::Call, len: u32) -> RuntimeDispatchInfo<BalanceOf<T>>
pub fn query_call_info(call: T::RuntimeCall, len: u32) -> RuntimeDispatchInfo<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
T::RuntimeCall: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
{
let dispatch_info = <T::Call as GetDispatchInfo>::get_dispatch_info(&call);
let dispatch_info = <T::RuntimeCall as GetDispatchInfo>::get_dispatch_info(&call);
let DispatchInfo { weight, class, .. } = dispatch_info;
RuntimeDispatchInfo {
@@ -497,20 +497,24 @@ where
}
/// Query fee details of a given encoded `Call`.
pub fn query_call_fee_details(call: T::Call, len: u32) -> FeeDetails<BalanceOf<T>>
pub fn query_call_fee_details(call: T::RuntimeCall, len: u32) -> FeeDetails<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
T::RuntimeCall: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
{
let dispatch_info = <T::Call as GetDispatchInfo>::get_dispatch_info(&call);
let dispatch_info = <T::RuntimeCall as GetDispatchInfo>::get_dispatch_info(&call);
let tip = 0u32.into();
Self::compute_fee_details(len, &dispatch_info, tip)
}
/// Compute the final fee value for a particular transaction.
pub fn compute_fee(len: u32, info: &DispatchInfoOf<T::Call>, tip: BalanceOf<T>) -> BalanceOf<T>
pub fn compute_fee(
len: u32,
info: &DispatchInfoOf<T::RuntimeCall>,
tip: BalanceOf<T>,
) -> BalanceOf<T>
where
T::Call: Dispatchable<Info = DispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
{
Self::compute_fee_details(len, info, tip).final_fee()
}
@@ -518,11 +522,11 @@ where
/// Compute the fee details for a particular transaction.
pub fn compute_fee_details(
len: u32,
info: &DispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
tip: BalanceOf<T>,
) -> FeeDetails<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
{
Self::compute_fee_raw(len, info.weight, tip, info.pays_fee, info.class)
}
@@ -533,12 +537,12 @@ where
/// weight is used for the weight fee calculation.
pub fn compute_actual_fee(
len: u32,
info: &DispatchInfoOf<T::Call>,
post_info: &PostDispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
tip: BalanceOf<T>,
) -> BalanceOf<T>
where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
{
Self::compute_actual_fee_details(len, info, post_info, tip).final_fee()
}
@@ -546,12 +550,12 @@ where
/// Compute the actual post dispatch fee details for a particular transaction.
pub fn compute_actual_fee_details(
len: u32,
info: &DispatchInfoOf<T::Call>,
post_info: &PostDispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
tip: BalanceOf<T>,
) -> FeeDetails<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
{
Self::compute_fee_raw(
len,
@@ -632,7 +636,7 @@ pub struct ChargeTransactionPayment<T: Config>(#[codec(compact)] BalanceOf<T>);
impl<T: Config> ChargeTransactionPayment<T>
where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
BalanceOf<T>: Send + Sync + FixedPointOperand,
{
/// utility constructor. Used only in client/factory code.
@@ -648,8 +652,8 @@ where
fn withdraw_fee(
&self,
who: &T::AccountId,
call: &T::Call,
info: &DispatchInfoOf<T::Call>,
call: &T::RuntimeCall,
info: &DispatchInfoOf<T::RuntimeCall>,
len: usize,
) -> Result<
(
@@ -681,7 +685,7 @@ where
/// state of-the-art blockchains, number of per-block transactions is expected to be in a
/// range reasonable enough to not saturate the `Balance` type while multiplying by the tip.
pub fn get_priority(
info: &DispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
len: usize,
tip: BalanceOf<T>,
final_fee: BalanceOf<T>,
@@ -755,11 +759,11 @@ impl<T: Config> sp_std::fmt::Debug for ChargeTransactionPayment<T> {
impl<T: Config> SignedExtension for ChargeTransactionPayment<T>
where
BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
{
const IDENTIFIER: &'static str = "ChargeTransactionPayment";
type AccountId = T::AccountId;
type Call = T::Call;
type Call = T::RuntimeCall;
type AdditionalSigned = ();
type Pre = (
// tip
@@ -821,7 +825,7 @@ impl<T: Config, AnyCall: GetDispatchInfo + Encode> EstimateCallFee<AnyCall, Bala
for Pallet<T>
where
BalanceOf<T>: FixedPointOperand,
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
{
fn estimate_call_fee(call: &AnyCall, post_info: PostDispatchInfo) -> BalanceOf<T> {
let len = call.encoded_size() as u32;
@@ -870,8 +874,8 @@ mod tests {
}
);
const CALL: &<Runtime as frame_system::Config>::Call =
&Call::Balances(BalancesCall::transfer { dest: 2, value: 69 });
const CALL: &<Runtime as frame_system::Config>::RuntimeCall =
&RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 });
parameter_types! {
static ExtrinsicBaseWeight: Weight = Weight::zero();
@@ -906,13 +910,13 @@ mod tests {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Hash = H256;
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;
@@ -927,7 +931,7 @@ mod tests {
impl pallet_balances::Config for Runtime {
type Balance = u64;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
@@ -975,7 +979,7 @@ mod tests {
}
impl Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = WeightToFee;
@@ -1238,7 +1242,7 @@ mod tests {
#[test]
fn query_info_and_fee_details_works() {
let call = Call::Balances(BalancesCall::transfer { dest: 2, value: 69 });
let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 });
let origin = 111111;
let extra = ();
let xt = TestXt::new(call.clone(), Some((origin, extra)));
@@ -1301,7 +1305,7 @@ mod tests {
#[test]
fn query_call_info_and_fee_details_works() {
let call = Call::Balances(BalancesCall::transfer { dest: 2, value: 69 });
let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 });
let info = call.get_dispatch_info();
let encoded_call = call.encode();
let len = encoded_call.len() as u32;
@@ -1495,13 +1499,11 @@ mod tests {
));
assert_eq!(Balances::free_balance(2), 0);
// Transfer Event
System::assert_has_event(Event::Balances(pallet_balances::Event::Transfer {
from: 2,
to: 3,
amount: 80,
}));
System::assert_has_event(RuntimeEvent::Balances(
pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80 },
));
// Killed Event
System::assert_has_event(Event::System(system::Event::KilledAccount {
System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount {
account: 2,
}));
});
@@ -1560,7 +1562,7 @@ mod tests {
));
assert_eq!(Balances::total_balance(&user), 0);
// TransactionFeePaid Event
System::assert_has_event(Event::TransactionPayment(
System::assert_has_event(RuntimeEvent::TransactionPayment(
pallet_transaction_payment::Event::TransactionFeePaid {
who: user,
actual_fee: 0,
@@ -37,8 +37,8 @@ pub trait OnChargeTransaction<T: Config> {
/// Note: The `fee` already includes the `tip`.
fn withdraw_fee(
who: &T::AccountId,
call: &T::Call,
dispatch_info: &DispatchInfoOf<T::Call>,
call: &T::RuntimeCall,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
fee: Self::Balance,
tip: Self::Balance,
) -> Result<Self::LiquidityInfo, TransactionValidityError>;
@@ -50,8 +50,8 @@ pub trait OnChargeTransaction<T: Config> {
/// Note: The `fee` already includes the `tip`.
fn correct_and_deposit_fee(
who: &T::AccountId,
dispatch_info: &DispatchInfoOf<T::Call>,
post_info: &PostDispatchInfoOf<T::Call>,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
corrected_fee: Self::Balance,
tip: Self::Balance,
already_withdrawn: Self::LiquidityInfo,
@@ -92,8 +92,8 @@ where
/// Note: The `fee` already includes the `tip`.
fn withdraw_fee(
who: &T::AccountId,
_call: &T::Call,
_info: &DispatchInfoOf<T::Call>,
_call: &T::RuntimeCall,
_info: &DispatchInfoOf<T::RuntimeCall>,
fee: Self::Balance,
tip: Self::Balance,
) -> Result<Self::LiquidityInfo, TransactionValidityError> {
@@ -120,8 +120,8 @@ where
/// Note: The `corrected_fee` already includes the `tip`.
fn correct_and_deposit_fee(
who: &T::AccountId,
_dispatch_info: &DispatchInfoOf<T::Call>,
_post_info: &PostDispatchInfoOf<T::Call>,
_dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
_post_info: &PostDispatchInfoOf<T::RuntimeCall>,
corrected_fee: Self::Balance,
tip: Self::Balance,
already_withdrawn: Self::LiquidityInfo,