mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 06:41:02 +00:00
rpc: Implement chainSpec RPC API (#12261)
* rpc/chain_spec: Add traits for `chainSpec` API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/chain_spec: Implement `chainSpec` RPC methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/chain_spec: Add tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * bin/node: Enable `chainSpec` API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/chain_spec: Assume `genesis_hash` as non-empty Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update client/rpc-spec/Cargo.toml Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Update client/rpc-spec/src/lib.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * client/rpc_spec: Rename crate to `rpc_spec_v2` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc-servers: Remove the `version` field from `rpc_methods` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/chain_spec: Fix copyright years Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -124,6 +124,7 @@ where
|
||||
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
|
||||
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
|
||||
use sc_rpc::dev::{Dev, DevApiServer};
|
||||
use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer};
|
||||
use sc_sync_state_rpc::{SyncState, SyncStateApiServer};
|
||||
use substrate_frame_rpc_system::{System, SystemApiServer};
|
||||
use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer};
|
||||
@@ -140,6 +141,11 @@ where
|
||||
finality_provider,
|
||||
} = grandpa;
|
||||
|
||||
let chain_name = chain_spec.name().to_string();
|
||||
let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");
|
||||
let properties = chain_spec.properties();
|
||||
io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?;
|
||||
|
||||
io.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
||||
// Making synchronous calls in light client freezes the browser currently,
|
||||
// more context: https://github.com/paritytech/substrate/pull/3480
|
||||
|
||||
Reference in New Issue
Block a user