Skip to content

Commit

Permalink
cumulus: Enable ChainSpec for polkadot-parachain
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Aug 1, 2024
1 parent 2675d44 commit cc90001
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cumulus/polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ sp-block-builder = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sc-chain-spec = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
sc-rpc-spec-v2 = { workspace = true, default-features = true }
sp-version = { workspace = true, default-features = true }
sc-tracing = { workspace = true, default-features = true }
sp-offchain = { workspace = true, default-features = true }
Expand Down
7 changes: 7 additions & 0 deletions cumulus/polkadot-parachain/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use sc_rpc::{
dev::{Dev, DevApiServer},
DenyUnsafe,
};
use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer};
use std::{marker::PhantomData, sync::Arc};
use substrate_frame_rpc_system::{System, SystemApiServer};
use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer};
Expand Down Expand Up @@ -95,6 +96,12 @@ where
module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?;
module.merge(Dev::new(client, deny_unsafe).into_rpc())?;

// RPC spec v2 method.
let chain_name = chain_spec.name().to_string();
let genesis_hash = client.hash(0).ok().flatten().expect("Genesis block exists; qed");
let properties = chain_spec.properties();
module.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?;

Ok(module)
};
build().map_err(Into::into)
Expand Down

0 comments on commit cc90001

Please sign in to comment.