mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 13:51:11 +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:
@@ -26,6 +26,7 @@ sc-finality-grandpa = { version = "0.10.0-dev", path = "../../../client/finality
|
||||
sc-finality-grandpa-rpc = { version = "0.10.0-dev", path = "../../../client/finality-grandpa/rpc" }
|
||||
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
|
||||
sc-rpc-api = { version = "0.10.0-dev", path = "../../../client/rpc-api" }
|
||||
sc-rpc-spec-v2 = { version = "0.10.0-dev", path = "../../../client/rpc-spec-v2" }
|
||||
sc-sync-state-rpc = { version = "0.10.0-dev", path = "../../../client/sync-state-rpc" }
|
||||
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
|
||||
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
|
||||
|
||||
@@ -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