-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add new RPC method to get the chain type #5576
Conversation
This adds a new RPC method to get the chain type of the running chain. The chain type needs to be specified in the chain spec. This should make it easier for tools/UI to display extra information without needing to rely on parsing the chain name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to get rid sc
dependency in rpc-api
. Actually I think we should add a rule to the rule enforcement script to prevent bringing non-primitive dependencies there.
fn system_type_works() { | ||
assert_eq!( | ||
api(None).system_type().unwrap(), | ||
Default::default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer something more explicit, but can live with that :)
client/rpc-api/Cargo.toml
Outdated
@@ -21,6 +21,7 @@ parking_lot = "0.10.0" | |||
sp-core = { version = "2.0.0-alpha.5", path = "../../primitives/core" } | |||
sp-version = { version = "2.0.0-alpha.5", path = "../../primitives/version" } | |||
sp-runtime = { path = "../../primitives/runtime" , version = "2.0.0-alpha.5"} | |||
sc-chain-spec = { path = "../chain-spec" , version = "2.0.0-alpha.5"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rpc-api
should not depend on client
stuff. The whole point of this crate is to avoid brining in 90% of substrate when just needing the APIs. Can we move the type to some primitives?
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, small grumbles.
client/rpc/Cargo.toml
Outdated
@@ -30,6 +30,7 @@ sp-state-machine = { version = "0.8.0-alpha.5", path = "../../primitives/state-m | |||
sc-executor = { version = "0.8.0-alpha.5", path = "../executor" } | |||
sc-block-builder = { version = "0.8.0-alpha.5", path = "../../client/block-builder" } | |||
sc-keystore = { version = "2.0.0-alpha.5", path = "../keystore" } | |||
sc-chain-spec = { version = "2.0.0-alpha.5", path = "../chain-spec" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be sp-chain-spec
now it seems.
client/rpc-api/src/system/mod.rs
Outdated
pub use self::gen_client::Client as SystemClient; | ||
use sp_chain_spec::Properties; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth to either consistently import both Properties
and ChainType
or use full path in both places.
This adds a new RPC method to get the chain type of the running chain.
The chain type needs to be specified in the chain spec. This should make
it easier for tools/UI to display extra information without needing to
rely on parsing the chain name.
Let's keep @jacogr sane :)