mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Define ss58 prefix inside the runtime (#7810)
* Add SS58Prefix type to the frame_system config trait * Remove unused chain_id runtime interface
This commit is contained in:
committed by
GitHub
parent
bd48ff310d
commit
ec2c70396e
@@ -952,6 +952,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -42,6 +42,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -66,6 +66,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Config for Test {
|
||||
|
||||
@@ -164,6 +164,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl_outer_origin! {
|
||||
|
||||
@@ -438,6 +438,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -86,6 +86,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
|
||||
|
||||
@@ -77,6 +77,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const TransactionByteFee: u64 = 1;
|
||||
|
||||
@@ -78,6 +78,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = Module<Test>;
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const TransactionByteFee: u64 = 1;
|
||||
|
||||
@@ -94,6 +94,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
|
||||
@@ -82,6 +82,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -996,6 +996,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl Config<Instance1> for Test {
|
||||
type Origin = Origin;
|
||||
|
||||
@@ -130,6 +130,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl pallet_balances::Config for Test {
|
||||
type MaxLocks = ();
|
||||
|
||||
@@ -113,6 +113,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
|
||||
|
||||
@@ -1099,6 +1099,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -57,6 +57,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -76,6 +76,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
type Extrinsic = TestXt<Call<Test>, ()>;
|
||||
|
||||
@@ -59,6 +59,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -764,6 +764,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -618,6 +618,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
type Balance = u64;
|
||||
|
||||
@@ -100,6 +100,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
|
||||
|
||||
@@ -63,6 +63,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -130,6 +130,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -69,6 +69,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -321,6 +321,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
ord_parameter_types! {
|
||||
pub const One: u64 = 1;
|
||||
|
||||
@@ -63,6 +63,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
|
||||
@@ -80,6 +80,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -283,6 +283,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -472,6 +472,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
ord_parameter_types! {
|
||||
|
||||
@@ -63,6 +63,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = (Balances,);
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 10;
|
||||
|
||||
@@ -116,6 +116,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -82,6 +82,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -180,6 +180,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
type System = frame_system::Module<Test>;
|
||||
|
||||
@@ -78,6 +78,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -837,6 +837,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl logger::Config for Test {
|
||||
type Event = ();
|
||||
|
||||
@@ -68,6 +68,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl pallet_balances::Config for Test {
|
||||
|
||||
@@ -67,6 +67,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = Balances;
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 10;
|
||||
|
||||
@@ -218,6 +218,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Config for Test {
|
||||
|
||||
@@ -78,6 +78,7 @@ impl frame_system::Config for Test {
|
||||
type OnKilledAccount = ();
|
||||
type AccountData = pallet_balances::AccountData<u64>;
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl pallet_balances::Config for Test {
|
||||
|
||||
@@ -65,6 +65,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = (Balances,);
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 10;
|
||||
|
||||
@@ -166,6 +166,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl pallet_balances::Config for Test {
|
||||
type MaxLocks = MaxLocks;
|
||||
|
||||
@@ -139,6 +139,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
// Implement the logger module's `Config` on the Test runtime.
|
||||
|
||||
@@ -364,6 +364,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl pallet::Config for Runtime {
|
||||
type Event = Event;
|
||||
|
||||
@@ -226,6 +226,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl pallet::Config for Runtime {
|
||||
type Event = Event;
|
||||
|
||||
@@ -218,6 +218,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl pallet::Config for Runtime {
|
||||
type Event = Event;
|
||||
|
||||
@@ -259,6 +259,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
impl pallet::Config for Runtime {
|
||||
type Event = Event;
|
||||
|
||||
@@ -165,6 +165,7 @@ impl frame_system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
|
||||
@@ -141,6 +141,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl pallet_test::Trait for Runtime {
|
||||
|
||||
@@ -87,6 +87,7 @@ impl system::Config for Runtime {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl module::Config for Runtime {
|
||||
|
||||
@@ -72,6 +72,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
impl crate::Config for Test {}
|
||||
|
||||
@@ -257,6 +257,13 @@ pub trait Config: 'static + Eq + Clone {
|
||||
type OnKilledAccount: OnKilledAccount<Self::AccountId>;
|
||||
|
||||
type SystemWeightInfo: WeightInfo;
|
||||
|
||||
/// The designated SS85 prefix of this chain.
|
||||
///
|
||||
/// This replaces the "ss58Format" property declared in the chain spec. Reason is
|
||||
/// that the runtime should know about the prefix in order to make use of it as
|
||||
/// an identifier of the chain.
|
||||
type SS58Prefix: Get<u8>;
|
||||
}
|
||||
|
||||
pub type DigestOf<T> = generic::Digest<<T as Config>::Hash>;
|
||||
@@ -516,6 +523,13 @@ decl_module! {
|
||||
/// The weight configuration (limits & base values) for each class of extrinsics and block.
|
||||
const BlockWeights: limits::BlockWeights = T::BlockWeights::get();
|
||||
|
||||
/// The designated SS85 prefix of this chain.
|
||||
///
|
||||
/// This replaces the "ss58Format" property declared in the chain spec. Reason is
|
||||
/// that the runtime should know about the prefix in order to make use of it as
|
||||
/// an identifier of the chain.
|
||||
const SS58Prefix: u8 = T::SS58Prefix::get();
|
||||
|
||||
fn on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
if !UpgradedToU32RefCount::get() {
|
||||
Account::<T>::translate::<(T::Index, u8, T::AccountData), _>(|_key, (nonce, rc, data)|
|
||||
|
||||
@@ -117,6 +117,7 @@ impl Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = RecordKilled;
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
pub type System = Module<Test>;
|
||||
|
||||
@@ -335,6 +335,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 5;
|
||||
|
||||
@@ -81,6 +81,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
@@ -292,28 +293,28 @@ fn slash_tip_works() {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
|
||||
assert_eq!(Balances::reserved_balance(0), 0);
|
||||
assert_eq!(Balances::free_balance(0), 100);
|
||||
|
||||
|
||||
assert_ok!(TipsModTestInst::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||
|
||||
|
||||
assert_eq!(Balances::reserved_balance(0), 12);
|
||||
assert_eq!(Balances::free_balance(0), 88);
|
||||
|
||||
|
||||
let h = tip_hash();
|
||||
assert_eq!(last_event(), RawEvent::NewTip(h));
|
||||
|
||||
|
||||
// can't remove from any origin
|
||||
assert_noop!(
|
||||
TipsModTestInst::slash_tip(Origin::signed(0), h.clone()),
|
||||
BadOrigin,
|
||||
);
|
||||
|
||||
|
||||
// can remove from root.
|
||||
assert_ok!(TipsModTestInst::slash_tip(Origin::root(), h.clone()));
|
||||
assert_eq!(last_event(), RawEvent::TipSlashed(h, 0, 12));
|
||||
|
||||
|
||||
// tipper slashed
|
||||
assert_eq!(Balances::reserved_balance(0), 0);
|
||||
assert_eq!(Balances::free_balance(0), 88);
|
||||
|
||||
@@ -662,6 +662,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -80,6 +80,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -118,6 +118,7 @@ impl frame_system::Config for Test {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
|
||||
@@ -433,6 +433,7 @@ mod tests {
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
parameter_types! {
|
||||
pub const MaxLocks: u32 = 10;
|
||||
|
||||
Reference in New Issue
Block a user