Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #160 from pontem-network/parachain-id
Browse files Browse the repository at this point in the history
Default parachain id
  • Loading branch information
boozook authored Dec 15, 2021
2 parents a1fb210 + 0fa2be4 commit ad80e3d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/// SS58 PREFIX.
pub const SS58_PREFIX: u8 = 105;

/// Default parachain ID.
pub const PARACHAIN_ID: u32 = 2103;

/// Module contains time constants.
pub mod time;

Expand Down
16 changes: 13 additions & 3 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ impl SubstrateCli for Cli {
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id, self.parachain_id.unwrap_or(200).into())
load_spec(
id,
self.parachain_id.unwrap_or(constants::PARACHAIN_ID).into(),
)
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
Expand Down Expand Up @@ -210,7 +213,10 @@ pub fn run() -> sc_cli::Result<()> {

let block: Block = generate_genesis_block(&load_spec(
&params.chain.clone().unwrap_or_default(),
params.parachain_id.unwrap_or(200).into(),
params
.parachain_id
.unwrap_or(constants::PARACHAIN_ID)
.into(),
)?)?;
let raw_header = block.header().encode();
let output_buf = if params.raw {
Expand Down Expand Up @@ -262,7 +268,11 @@ pub fn run() -> sc_cli::Result<()> {

let polkadot_cli = RelayChainCli::new(&config, cli.relaychain_args.into_iter());

let id = ParaId::from(cli.parachain_id.or(para_id).unwrap_or(200));
let id = ParaId::from(
cli.parachain_id
.or(para_id)
.unwrap_or(constants::PARACHAIN_ID),
);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl RuntimeBuilder {

<parachain_info::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&parachain_info::GenesisConfig {
parachain_id: self.parachain_id.unwrap_or(200).into(),
parachain_id: self.parachain_id.unwrap_or(constants::PARACHAIN_ID).into(),
},
&mut t,
)
Expand Down

0 comments on commit ad80e3d

Please sign in to comment.