Skip to content

Commit 499009d

Browse files
committed
Don't hardcode the network id for the account CLI
1 parent a3fd922 commit 499009d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

codechain/codechain.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ subcommands:
200200
value_name: PATH
201201
help: Specify the path for JSON key files to be found
202202
takes_value: true
203+
- chain:
204+
short: c
205+
long: chain
206+
help: Set the blockchain type out of solo, solo_authority, tendermint, cuckoo, blake_pow, husky or a path to chain scheme file.
207+
takes_value: true
203208
subcommands:
204209
- create:
205210
about: create account

codechain/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use cnetwork::{NetworkConfig, SocketAddr};
2727
use rpc::{RpcHttpConfig, RpcIpcConfig};
2828
use toml;
2929

30-
use self::chain_type::ChainType;
30+
pub use self::chain_type::ChainType;
3131
use super::constants::DEFAULT_CONFIG_PATH;
3232

3333
#[derive(Deserialize)]

codechain/subcommand/account_command.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use clap::ArgMatches;
2727
use clogger::{self, LoggerConfig};
2828
use primitives::clean_0x;
2929

30+
use super::super::config::ChainType;
3031
use super::super::constants::DEFAULT_KEYS_PATH;
3132

3233
pub fn run_account_command(matches: ArgMatches) -> Result<(), String> {
@@ -41,8 +42,8 @@ pub fn run_account_command(matches: ArgMatches) -> Result<(), String> {
4142
let dir = RootDiskDirectory::create(keys_path).expect("Cannot read key path directory");
4243
let keystore = KeyStore::open(Box::new(dir)).unwrap();
4344
let ap = AccountProvider::new(keystore);
44-
// FIXME: Don't hardcode network_id.
45-
let network_id: NetworkId = "tc".into();
45+
let chain = matches.value_of("chain").unwrap_or("solo");
46+
let network_id: NetworkId = ChainType::from_str(chain)?.scheme().map(|scheme| scheme.params().network_id)?;
4647

4748
match matches.subcommand() {
4849
("create", _) => create(&ap, network_id),

0 commit comments

Comments
 (0)