From 59b2d461c587d50a762e84016983e90c708ba87c Mon Sep 17 00:00:00 2001 From: Squirrel Date: Mon, 25 Apr 2022 18:17:11 +0100 Subject: [PATCH] polkadot-like testnets should be 10 decimal places (#5369) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * polkadot is 10 decimal places * cargo fmt * Update node/service/src/chain_spec.rs Co-authored-by: Bastian Köcher * name change * update test also Co-authored-by: Bastian Köcher --- Cargo.lock | 1 + node/service/Cargo.toml | 1 + node/service/src/chain_spec.rs | 16 +++++++++++++--- node/test/service/src/chain_spec.rs | 6 ++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99c3842b94db..c193a836128b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7560,6 +7560,7 @@ dependencies = [ "sc-telemetry", "sc-transaction-pool", "serde", + "serde_json", "sp-api", "sp-authority-discovery", "sp-block-builder", diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml index c07df95e9a4d..bc997bc111af 100644 --- a/node/service/Cargo.toml +++ b/node/service/Cargo.toml @@ -64,6 +64,7 @@ futures = "0.3.21" hex-literal = "0.3.4" gum = { package = "tracing-gum", path = "../gum/" } serde = { version = "1.0.136", features = ["derive"] } +serde_json = "1.0.59" thiserror = "1.0.30" kvdb = "0.11.0" kvdb-rocksdb = { version = "0.15.2", optional = true } diff --git a/node/service/src/chain_spec.rs b/node/service/src/chain_spec.rs index 2456640e2279..f87ad97c2e86 100644 --- a/node/service/src/chain_spec.rs +++ b/node/service/src/chain_spec.rs @@ -1085,6 +1085,16 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime:: } } +/// Returns the properties for the [`PolkadotChainSpec`]. +pub fn polkadot_chain_spec_properties() -> serde_json::map::Map { + serde_json::json!({ + "tokenDecimals": 10, + }) + .as_object() + .expect("Map given; qed") + .clone() +} + /// Polkadot staging testnet config. #[cfg(feature = "polkadot-native")] pub fn polkadot_staging_testnet_config() -> Result { @@ -1103,7 +1113,7 @@ pub fn polkadot_staging_testnet_config() -> Result { ), Some(DEFAULT_PROTOCOL_ID), None, - None, + Some(polkadot_chain_spec_properties()), Default::default(), )) } @@ -1653,7 +1663,7 @@ pub fn polkadot_development_config() -> Result { None, Some(DEFAULT_PROTOCOL_ID), None, - None, + Some(polkadot_chain_spec_properties()), Default::default(), )) } @@ -1793,7 +1803,7 @@ pub fn polkadot_local_testnet_config() -> Result { None, Some(DEFAULT_PROTOCOL_ID), None, - None, + Some(polkadot_chain_spec_properties()), Default::default(), )) } diff --git a/node/test/service/src/chain_spec.rs b/node/test/service/src/chain_spec.rs index 5e81522994a3..1d8b300e4e27 100644 --- a/node/test/service/src/chain_spec.rs +++ b/node/test/service/src/chain_spec.rs @@ -20,7 +20,9 @@ use babe_primitives::AuthorityId as BabeId; use grandpa::AuthorityId as GrandpaId; use pallet_staking::Forcing; use polkadot_primitives::v2::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE}; -use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions}; +use polkadot_service::chain_spec::{ + get_account_id_from_seed, get_from_seed, polkadot_chain_spec_properties, Extensions, +}; use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG; use sc_chain_spec::{ChainSpec, ChainType}; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -45,7 +47,7 @@ pub fn polkadot_local_testnet_config() -> PolkadotChainSpec { None, Some(DEFAULT_PROTOCOL_ID), None, - None, + Some(polkadot_chain_spec_properties()), Default::default(), ) }