Skip to content

Commit b72e33e

Browse files
authored
Define ss58 prefix inside the runtime (#7810)
* Add SS58Prefix type to the frame_system config trait * Remove unused chain_id runtime interface
1 parent 44003e8 commit b72e33e

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

benches/bench.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ impl system::Config for Runtime {
8787
type OnNewAccount = ();
8888
type OnKilledAccount = ();
8989
type SystemWeightInfo = ();
90+
type SS58Prefix = ();
9091
}
9192

9293
impl module::Config for Runtime {

benchmarking/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl frame_system::Config for Test {
7272
type OnNewAccount = ();
7373
type OnKilledAccount = ();
7474
type SystemWeightInfo = ();
75+
type SS58Prefix = ();
7576
}
7677

7778
impl crate::Config for Test {}

src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ pub trait Config: 'static + Eq + Clone {
257257
type OnKilledAccount: OnKilledAccount<Self::AccountId>;
258258

259259
type SystemWeightInfo: WeightInfo;
260+
261+
/// The designated SS85 prefix of this chain.
262+
///
263+
/// This replaces the "ss58Format" property declared in the chain spec. Reason is
264+
/// that the runtime should know about the prefix in order to make use of it as
265+
/// an identifier of the chain.
266+
type SS58Prefix: Get<u8>;
260267
}
261268

262269
pub type DigestOf<T> = generic::Digest<<T as Config>::Hash>;
@@ -516,6 +523,13 @@ decl_module! {
516523
/// The weight configuration (limits & base values) for each class of extrinsics and block.
517524
const BlockWeights: limits::BlockWeights = T::BlockWeights::get();
518525

526+
/// The designated SS85 prefix of this chain.
527+
///
528+
/// This replaces the "ss58Format" property declared in the chain spec. Reason is
529+
/// that the runtime should know about the prefix in order to make use of it as
530+
/// an identifier of the chain.
531+
const SS58Prefix: u8 = T::SS58Prefix::get();
532+
519533
fn on_runtime_upgrade() -> frame_support::weights::Weight {
520534
if !UpgradedToU32RefCount::get() {
521535
Account::<T>::translate::<(T::Index, u8, T::AccountData), _>(|_key, (nonce, rc, data)|

src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl Config for Test {
117117
type OnNewAccount = ();
118118
type OnKilledAccount = RecordKilled;
119119
type SystemWeightInfo = ();
120+
type SS58Prefix = ();
120121
}
121122

122123
pub type System = Module<Test>;

0 commit comments

Comments
 (0)