Skip to content

Commit

Permalink
Add relay chain suffix to chain name (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb authored Jun 7, 2024
1 parent 7cfee3b commit 41cf396
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ pub fn bajun_chain_spec(
#[allow(deprecated)]
ChainSpec::builder(
bajun_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
Extensions { relay_chain: relay_chain.id().to_string(), para_id: para_id.into() },
)
.with_name("Bajun")
.with_id(&format!("bajun-{}", relay_chain))
.with_name(&format!("Bajun {}", relay_chain.name()))
.with_id(&format!("bajun-{}", relay_chain.id()))
.with_protocol_id(relay_chain.protocol_id())
.with_chain_type(relay_chain.chain_type())
.with_properties(properties)
Expand Down
25 changes: 17 additions & 8 deletions node/src/chain_spec_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bajun_runtime::{AccountId, AuraId};
use sc_chain_spec::ChainType;
use sp_core::{crypto::Ss58Codec, sr25519, Public};
use sp_keyring::AccountKeyring::{Alice, Bob, Charlie, Dave, Eve, Ferdie};
use std::{fmt::Display, str::FromStr};
use std::str::FromStr;

pub fn pub_sr25519(ss58: &str) -> sr25519::Public {
public_from_ss58::<sr25519::Public>(ss58)
Expand Down Expand Up @@ -114,22 +114,31 @@ pub enum RelayChain {
WestendLocal,
}

impl Display for RelayChain {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
impl RelayChain {
pub fn id(&self) -> &'static str {
match self {
RelayChain::Kusama => "kusama",
RelayChain::Paseo => "paseo",
RelayChain::Westend => "westend",
RelayChain::KusamaLocal => "kusama-local",
RelayChain::PaseoLocal => "paseo-local",
RelayChain::RococoLocal => "rococo-local",
RelayChain::WestendLocal => "westend-local",
};
write!(f, "{}", str)
}
}

pub fn name(&self) -> &'static str {
match self {
RelayChain::Kusama => "Kusama",
RelayChain::Paseo => "Paseo",
RelayChain::Westend => "Westend",
RelayChain::KusamaLocal => "Kusama-local",
RelayChain::PaseoLocal => "Paseo-local",
RelayChain::RococoLocal => "Rococo-local",
RelayChain::WestendLocal => "Westend-local",
}
}
}

impl RelayChain {
pub(crate) fn chain_type(&self) -> ChainType {
match self {
RelayChain::Kusama => ChainType::Live,
Expand Down
2 changes: 1 addition & 1 deletion resources/bajun/paseo/bajun-paseo-raw-unsorted.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Bajun",
"name": "Bajun Paseo",
"id": "bajun-paseo",
"chainType": "Live",
"bootNodes": [
Expand Down
2 changes: 1 addition & 1 deletion resources/bajun/paseo/bajun-paseo-raw.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
}
},
"id": "bajun-paseo",
"name": "Bajun",
"name": "Bajun Paseo",
"para_id": 2119,
"properties": {
"ss58Format": 1337,
Expand Down
2 changes: 1 addition & 1 deletion resources/bajun/paseo/bajun-paseo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Bajun",
"name": "Bajun Paseo",
"id": "bajun-paseo",
"chainType": "Live",
"bootNodes": [
Expand Down
2 changes: 1 addition & 1 deletion resources/bajun/westend/bajun-westend-raw.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}
},
"id": "bajun-westend",
"name": "Bajun",
"name": "Bajun Westend",
"para_id": 2138,
"properties": {
"ss58Format": 1337,
Expand Down
2 changes: 1 addition & 1 deletion resources/bajun/westend/bajun-westend.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Bajun",
"name": "Bajun Westend",
"id": "bajun-westend",
"chainType": "Live",
"bootNodes": [
Expand Down

0 comments on commit 41cf396

Please sign in to comment.