Skip to content

Commit

Permalink
native token config loader function
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaos Dymitriadis <[email protected]>
  • Loading branch information
AmbientTea committed Aug 28, 2024
1 parent bf6da83 commit 74c3737
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
11 changes: 10 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sidechain_domain::PolicyId;
use sidechain_domain::{AssetName, MainchainAddress, PolicyId};
use sidechain_runtime::CrossChainPublic;
use sidechain_runtime::{opaque::SessionKeys, AccountId, Signature, WASM_BINARY};
use sp_core::{Pair, Public};
Expand Down Expand Up @@ -82,3 +82,12 @@ pub fn read_mainchain_scripts_from_env() -> Result<MainChainScripts, EnvVarReadE
permissioned_candidates_policy,
})
}

pub fn read_native_token_main_chain_scripts_from_env(
) -> Result<sp_native_token_management::MainChainScripts, EnvVarReadError> {
Ok(sp_native_token_management::MainChainScripts {
native_token_policy: from_var::<PolicyId>("NATIVE_TOKEN_POLICY_ID")?,
native_token_asset_name: from_var::<AssetName>("NATIVE_TOKEN_ASSET_NAME")?,
illiquid_supply_address: from_var::<MainchainAddress>("ILLIQUID_SUPPLY_VALIDATOR_ADDRESS")?,
})
}
8 changes: 1 addition & 7 deletions node/src/staging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,7 @@ pub fn staging_genesis(
main_chain_scripts: read_mainchain_scripts_from_env()?,
},
native_token_management: NativeTokenManagementConfig {
main_chain_scripts: sp_native_token_management::MainChainScripts {
native_token_policy: from_var::<PolicyId>("NATIVE_TOKEN_POLICY_ID")?,
native_token_asset_name: from_var::<AssetName>("NATIVE_TOKEN_ASSET_NAME")?,
illiquid_supply_address: from_var::<MainchainAddress>(
"ILLIQUID_SUPPLY_VALIDATOR_ADDRESS",
)?,
},
main_chain_scripts: read_native_token_main_chain_scripts_from_env()?,
..Default::default()
},
};
Expand Down
10 changes: 2 additions & 8 deletions node/src/template_chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::chain_spec::*;
use chain_params::SidechainParams;
use sc_service::ChainType;
use sidechain_domain::{AssetName, MainchainAddress, MainchainAddressHash, PolicyId, UtxoId};
use sidechain_domain::{MainchainAddressHash, UtxoId};
use sidechain_runtime::{
AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig, RuntimeGenesisConfig,
SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig,
Expand Down Expand Up @@ -45,13 +45,7 @@ pub fn chain_spec() -> Result<ChainSpec, EnvVarReadError> {
main_chain_scripts: read_mainchain_scripts_from_env()?,
},
native_token_management: NativeTokenManagementConfig {
main_chain_scripts: sp_native_token_management::MainChainScripts {
native_token_policy: from_var::<PolicyId>("NATIVE_TOKEN_POLICY_ID")?,
native_token_asset_name: from_var::<AssetName>("NATIVE_TOKEN_ASSET_NAME")?,
illiquid_supply_address: from_var::<MainchainAddress>(
"ILLIQUID_SUPPLY_VALIDATOR_ADDRESS",
)?,
},
main_chain_scripts: read_native_token_main_chain_scripts_from_env()?,
..Default::default()
},
};
Expand Down
8 changes: 1 addition & 7 deletions node/src/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,7 @@ pub fn testnet_genesis(
main_chain_scripts: read_mainchain_scripts_from_env()?,
},
native_token_management: NativeTokenManagementConfig {
main_chain_scripts: sp_native_token_management::MainChainScripts {
native_token_policy: from_var::<PolicyId>("NATIVE_TOKEN_POLICY_ID")?,
native_token_asset_name: from_var::<AssetName>("NATIVE_TOKEN_ASSET_NAME")?,
illiquid_supply_address: from_var::<MainchainAddress>(
"ILLIQUID_SUPPLY_VALIDATOR_ADDRESS",
)?,
},
main_chain_scripts: read_native_token_main_chain_scripts_from_env()?,
..Default::default()
},
};
Expand Down

0 comments on commit 74c3737

Please sign in to comment.