Skip to content

Commit

Permalink
BREAKING: Rename Call & Event (paritytech#11981)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
2 people authored and ark0f committed Feb 27, 2023
1 parent 0f3fa29 commit 5d69f2a
Show file tree
Hide file tree
Showing 228 changed files with 1,792 additions and 1,673 deletions.
2 changes: 1 addition & 1 deletion bin/node-template/node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
pub fn create_benchmark_extrinsic(
client: &FullClient,
sender: sp_core::sr25519::Pair,
call: runtime::Call,
call: runtime::RuntimeCall,
nonce: u32,
) -> runtime::UncheckedExtrinsic {
let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
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 pallet's runtime storage items.
Expand Down
6 changes: 3 additions & 3 deletions bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ impl 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;
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;
Expand All @@ -50,7 +50,7 @@ impl system::Config for Test {
}

impl pallet_template::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
}

// Build genesis storage according to the mock runtime.
Expand Down
29 changes: 15 additions & 14 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
type Call = Call;
type RuntimeCall = RuntimeCall;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// The index type for storing how many extrinsics an account has signed.
Expand All @@ -172,7 +172,7 @@ impl frame_system::Config for Runtime {
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// The ubiquitous event type.
type Event = Event;
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
type Origin = Origin;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
Expand Down Expand Up @@ -209,8 +209,7 @@ impl pallet_aura::Config for Runtime {
}

impl pallet_grandpa::Config for Runtime {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;

type KeyOwnerProofSystem = ();

Expand Down Expand Up @@ -246,7 +245,7 @@ impl pallet_balances::Config for Runtime {
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type AccountStore = System;
Expand All @@ -258,7 +257,7 @@ parameter_types! {
}

impl pallet_transaction_payment::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
Expand All @@ -267,13 +266,13 @@ impl pallet_transaction_payment::Config for Runtime {
}

impl pallet_sudo::Config for Runtime {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
}

/// Configure the pallet-template in pallets/template.
impl pallet_template::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down Expand Up @@ -314,10 +313,12 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Expand Down Expand Up @@ -473,17 +474,17 @@ impl_runtime_apis! {
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, Call>
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
for Runtime
{
fn query_call_info(
call: Call,
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(
call: Call,
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_call_fee_details(call, len)
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
fn extrinsic_set_time(now: u64) -> OpaqueExtrinsic {
kitchensink_runtime::UncheckedExtrinsic {
signature: None,
function: kitchensink_runtime::Call::Timestamp(pallet_timestamp::Call::set { now }),
function: kitchensink_runtime::RuntimeCall::Timestamp(pallet_timestamp::Call::set { now }),
}
.into()
}
Expand Down
10 changes: 6 additions & 4 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn fetch_nonce(client: &FullClient, account: sp_core::sr25519::Pair) -> u32
pub fn create_extrinsic(
client: &FullClient,
sender: sp_core::sr25519::Pair,
function: impl Into<kitchensink_runtime::Call>,
function: impl Into<kitchensink_runtime::RuntimeCall>,
nonce: Option<u32>,
) -> kitchensink_runtime::UncheckedExtrinsic {
let function = function.into();
Expand Down Expand Up @@ -570,7 +570,7 @@ mod tests {
use codec::Encode;
use kitchensink_runtime::{
constants::{currency::CENTS, time::SLOT_DURATION},
Address, BalancesCall, Call, UncheckedExtrinsic,
Address, BalancesCall, RuntimeCall, UncheckedExtrinsic,
};
use node_primitives::{Block, DigestItem, Signature};
use sc_client_api::BlockBackend;
Expand Down Expand Up @@ -759,8 +759,10 @@ mod tests {
};
let signer = charlie.clone();

let function =
Call::Balances(BalancesCall::transfer { dest: to.into(), value: amount });
let function = RuntimeCall::Balances(BalancesCall::transfer {
dest: to.into(),
value: amount,
});

let check_non_zero_sender = frame_system::CheckNonZeroSender::new();
let check_spec_version = frame_system::CheckSpecVersion::new();
Expand Down
8 changes: 4 additions & 4 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use codec::{Decode, Encode};
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use frame_support::Hashable;
use kitchensink_runtime::{
constants::currency::*, Block, BuildStorage, Call, CheckedExtrinsic, GenesisConfig, Header,
UncheckedExtrinsic,
constants::currency::*, Block, BuildStorage, CheckedExtrinsic, GenesisConfig, Header,
RuntimeCall, UncheckedExtrinsic,
};
use node_executor::ExecutorDispatch;
use node_primitives::{BlockNumber, Hash};
Expand Down Expand Up @@ -141,11 +141,11 @@ fn test_blocks(
let mut test_ext = new_test_ext(genesis_config);
let mut block1_extrinsics = vec![CheckedExtrinsic {
signed: None,
function: Call::Timestamp(pallet_timestamp::Call::set { now: 0 }),
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: 0 }),
}];
block1_extrinsics.extend((0..20).map(|i| CheckedExtrinsic {
signed: Some((alice(), signed_extra(i, 0))),
function: Call::Balances(pallet_balances::Call::transfer {
function: RuntimeCall::Balances(pallet_balances::Call::transfer {
dest: bob().into(),
value: 1 * DOLLARS,
}),
Expand Down
Loading

0 comments on commit 5d69f2a

Please sign in to comment.