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
+1 -1
View File
@@ -35,7 +35,7 @@ const SEED: u32 = 0;
const MAX_BYTES: u32 = 1_024;
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::Event) {
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}
+3 -2
View File
@@ -240,7 +240,8 @@ pub mod pallet {
#[pallet::config]
pub trait Config<I: 'static = ()>: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The outer call dispatch type.
type Proposal: Parameter
@@ -249,7 +250,7 @@ pub mod pallet {
+ From<Call<Self, I>>
+ GetDispatchInfo
+ IsSubType<Call<Self, I>>
+ IsType<<Self as frame_system::Config>::Call>;
+ IsType<<Self as frame_system::Config>::RuntimeCall>;
/// Origin for admin-level operations, like setting the Alliance's rules.
type AdminOrigin: EnsureOrigin<Self::Origin>;
+18 -18
View File
@@ -48,7 +48,7 @@ impl frame_system::Config for Test {
type BlockWeights = ();
type BlockLength = ();
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256;
@@ -56,7 +56,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 = BlockHashCount;
type DbWeight = ();
type Version = ();
@@ -77,7 +77,7 @@ parameter_types! {
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
@@ -96,8 +96,8 @@ parameter_types! {
type AllianceCollective = pallet_collective::Instance1;
impl pallet_collective::Config<AllianceCollective> for Test {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = MotionDuration;
type MaxProposals = MaxProposals;
type MaxMembers = MaxMembers;
@@ -124,7 +124,7 @@ type EnsureOneOrRoot = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<One, u64>
type EnsureTwoOrRoot = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<Two, u64>>;
impl pallet_identity::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BasicDeposit = BasicDeposit;
type FieldDeposit = FieldDeposit;
@@ -162,11 +162,11 @@ impl IdentityVerifier<u64> for AllianceIdentityVerifier {
}
pub struct AllianceProposalProvider;
impl ProposalProvider<u64, H256, Call> for AllianceProposalProvider {
impl ProposalProvider<u64, H256, RuntimeCall> for AllianceProposalProvider {
fn propose_proposal(
who: u64,
threshold: u32,
proposal: Box<Call>,
proposal: Box<RuntimeCall>,
length_bound: u32,
) -> Result<(u32, u32), DispatchError> {
AllianceMotion::do_propose_proposed(who, threshold, proposal, length_bound)
@@ -194,7 +194,7 @@ impl ProposalProvider<u64, H256, Call> for AllianceProposalProvider {
AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound)
}
fn proposal_of(proposal_hash: H256) -> Option<Call> {
fn proposal_of(proposal_hash: H256) -> Option<RuntimeCall> {
AllianceMotion::proposal_of(proposal_hash)
}
}
@@ -207,8 +207,8 @@ parameter_types! {
pub const RetirementPeriod: BlockNumber = MOTION_DURATION_IN_BLOCKS + 1;
}
impl Config for Test {
type Event = Event;
type Proposal = Call;
type RuntimeEvent = RuntimeEvent;
type Proposal = RuntimeCall;
type AdminOrigin = EnsureSignedBy<One, u64>;
type MembershipManager = EnsureSignedBy<Two, u64>;
type AnnouncementOrigin = EnsureSignedBy<Three, u64>;
@@ -380,19 +380,19 @@ pub fn test_cid() -> Cid {
Cid::new_v0(&*result)
}
pub fn make_remark_proposal(value: u64) -> (Call, u32, H256) {
make_proposal(Call::System(frame_system::Call::remark { remark: value.encode() }))
pub fn make_remark_proposal(value: u64) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::System(frame_system::Call::remark { remark: value.encode() }))
}
pub fn make_set_rule_proposal(rule: Cid) -> (Call, u32, H256) {
make_proposal(Call::Alliance(pallet_alliance::Call::set_rule { rule }))
pub fn make_set_rule_proposal(rule: Cid) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::Alliance(pallet_alliance::Call::set_rule { rule }))
}
pub fn make_kick_member_proposal(who: u64) -> (Call, u32, H256) {
make_proposal(Call::Alliance(pallet_alliance::Call::kick_member { who }))
pub fn make_kick_member_proposal(who: u64) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::Alliance(pallet_alliance::Call::kick_member { who }))
}
pub fn make_proposal(proposal: Call) -> (Call, u32, H256) {
pub fn make_proposal(proposal: RuntimeCall) -> (RuntimeCall, u32, H256) {
let len: u32 = proposal.using_encoded(|p| p.len() as u32);
let hash = BlakeTwo256::hash_of(&proposal);
(proposal, len, hash)
+26 -24
View File
@@ -63,7 +63,7 @@ fn init_members_works() {
// assert a retiring member from previous Alliance not removed
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
System::assert_last_event(mock::Event::Alliance(crate::Event::MembersInitialized {
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MembersInitialized {
founders: vec![5, 8],
fellows: vec![4],
allies: vec![2],
@@ -117,7 +117,7 @@ fn disband_works() {
// deposit unreserved
assert_eq!(Balances::free_balance(9), 40);
System::assert_last_event(mock::Event::Alliance(crate::Event::AllianceDisbanded {
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::AllianceDisbanded {
voting_members: 2,
ally_members: 1,
unreserved: 1,
@@ -154,7 +154,7 @@ fn propose_works() {
System::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: mock::Event::AllianceMotion(AllianceMotionEvent::Proposed {
event: mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 0,
proposal_hash: hash,
@@ -182,13 +182,13 @@ fn vote_works() {
assert_eq!(
System::events(),
vec![
record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 0,
proposal_hash: hash,
threshold: 3
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
account: 2,
proposal_hash: hash,
voted: true,
@@ -236,19 +236,19 @@ fn veto_works() {
assert_eq!(
System::events(),
vec![
record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 0,
proposal_hash: hash,
threshold: 3
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 1,
proposal_hash: vetoable_hash,
threshold: 3
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Disapproved {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Disapproved {
proposal_hash: vetoable_hash
})),
]
@@ -276,42 +276,42 @@ fn close_works() {
assert_eq!(
System::events(),
vec![
record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 0,
proposal_hash: hash,
threshold: 3
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
account: 1,
proposal_hash: hash,
voted: true,
yes: 1,
no: 0,
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
account: 2,
proposal_hash: hash,
voted: true,
yes: 2,
no: 0,
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted {
account: 3,
proposal_hash: hash,
voted: true,
yes: 3,
no: 0,
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Closed {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Closed {
proposal_hash: hash,
yes: 3,
no: 0,
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Approved {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Approved {
proposal_hash: hash
})),
record(mock::Event::AllianceMotion(AllianceMotionEvent::Executed {
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Executed {
proposal_hash: hash,
result: Err(DispatchError::BadOrigin),
}))
@@ -327,7 +327,9 @@ fn set_rule_works() {
assert_ok!(Alliance::set_rule(Origin::signed(1), cid.clone()));
assert_eq!(Alliance::rule(), Some(cid.clone()));
System::assert_last_event(mock::Event::Alliance(crate::Event::NewRuleSet { rule: cid }));
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet {
rule: cid,
}));
});
}
@@ -341,7 +343,7 @@ fn announce_works() {
assert_ok!(Alliance::announce(Origin::signed(3), cid.clone()));
assert_eq!(Alliance::announcements(), vec![cid.clone()]);
System::assert_last_event(mock::Event::Alliance(crate::Event::Announced {
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced {
announcement: cid,
}));
});
@@ -353,7 +355,7 @@ fn remove_announcement_works() {
let cid = test_cid();
assert_ok!(Alliance::announce(Origin::signed(3), cid.clone()));
assert_eq!(Alliance::announcements(), vec![cid.clone()]);
System::assert_last_event(mock::Event::Alliance(crate::Event::Announced {
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced {
announcement: cid.clone(),
}));
@@ -361,9 +363,9 @@ fn remove_announcement_works() {
assert_ok!(Alliance::remove_announcement(Origin::signed(3), cid.clone()));
assert_eq!(Alliance::announcements(), vec![]);
System::assert_last_event(mock::Event::Alliance(crate::Event::AnnouncementRemoved {
announcement: cid,
}));
System::assert_last_event(mock::RuntimeEvent::Alliance(
crate::Event::AnnouncementRemoved { announcement: cid },
));
});
}
@@ -498,7 +500,7 @@ fn give_retirement_notice_work() {
assert_ok!(Alliance::give_retirement_notice(Origin::signed(3)));
assert_eq!(Alliance::members(MemberRole::Fellow), Vec::<u64>::new());
assert_eq!(Alliance::members(MemberRole::Retiring), vec![3]);
System::assert_last_event(mock::Event::Alliance(
System::assert_last_event(mock::RuntimeEvent::Alliance(
crate::Event::MemberRetirementPeriodStarted { member: (3) },
));
@@ -531,7 +533,7 @@ fn retire_works() {
System::set_block_number(System::block_number() + RetirementPeriod::get());
assert_ok!(Alliance::retire(Origin::signed(3)));
assert_eq!(Alliance::members(MemberRole::Fellow), Vec::<u64>::new());
System::assert_last_event(mock::Event::Alliance(crate::Event::MemberRetired {
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberRetired {
member: (3),
unreserved: None,
}));
@@ -585,7 +587,7 @@ fn kick_member_works() {
assert_ok!(Alliance::kick_member(Origin::signed(2), 2));
assert_eq!(Alliance::members(MemberRole::Founder), vec![1]);
assert_eq!(<DepositOf<Test, ()>>::get(2), None);
System::assert_last_event(mock::Event::Alliance(crate::Event::MemberKicked {
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberKicked {
member: (2),
slashed: Some(25),
}));