Skip to content

Commit

Permalink
add aga testnet config
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaGamingArcade committed Dec 11, 2024
1 parent e1fc3b1 commit 45cbd96
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
64 changes: 60 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ use aga_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY, Balan
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, Pair, Public};
use sp_core::{ed25519, sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use std::str::FromStr;
use serde_json::json;

// The URL for the telemetry server.
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

pub fn aga_config() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../../resources/aga-chain-spec-raw.json")[..])
}
// pub fn aga_config() -> Result<ChainSpec, String> {
// ChainSpec::from_json_bytes(&include_bytes!("../../resources/aga-chain-spec-raw.json")[..])
// }

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -57,6 +59,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_protocol_id("aga")
.with_genesis_config_patch(testnet_genesis(
// Initial PoA authorities
vec![authority_keys_from_seed("Alice")],
Expand All @@ -71,6 +74,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
],
true,
))
.with_properties(default_properties())
.build())
}

Expand All @@ -82,6 +86,7 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
.with_name("Local Testnet")
.with_id("local_testnet")
.with_chain_type(ChainType::Local)
.with_protocol_id("aga")
.with_genesis_config_patch(testnet_genesis(
// Initial PoA authorities
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
Expand All @@ -104,6 +109,50 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
],
true,
))
.with_properties(default_properties())
.build())
}

pub fn aga_testnet_config() -> Result<ChainSpec, String> {
const ROOT_PUBLIC_SR25519: &str = "5HTjThDzsZuY7neTGTZrgJGKADHjyW9R4W3emZYJwZPa91gS";

const NODE1_PUBLIC_SR25519: &str = "5GNJEdcdXmMyN7c95ZbeWtJsiZoSv7kVVVDvxfA5TnL7qA9k";
const NODE1_PUBLIC_ED25519: &str = "5F7wpC4yLPC5pymEDKwSvmkfuqbKLFdwB9qbg8E4UEvqkoBE";

const NODE2_PUBLIC_SR25519: &str = "5H9Pr92kVX4wAmuuAEbVHHoDnccF4jZthaTcrfrYR2Q8Yh1u";
const NODE2_PUBLIC_ED25519: &str = "5DJxo9qjo7o5Ses674Pe7aVojDqtWLYH4D5d8K5JmEoShDri";

Ok(ChainSpec::builder(
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
None,
)
.with_name("Aga Testnet")
.with_id("aga_testnet")
.with_chain_type(ChainType::Live)
.with_protocol_id("aga")
.with_genesis_config_patch(testnet_genesis(
// Initial PoA authorities
vec![
(
AccountId::from_str(NODE1_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE1_PUBLIC_SR25519).unwrap()),
GrandpaId::from(ed25519::Public::from_str(NODE1_PUBLIC_ED25519).unwrap()),
),
(
AccountId::from_str(NODE2_PUBLIC_SR25519).unwrap(),
AuraId::from(sr25519::Public::from_str(NODE2_PUBLIC_SR25519).unwrap()),
GrandpaId::from(ed25519::Public::from_str(NODE2_PUBLIC_ED25519).unwrap()),
)
],
// Sudo account
AccountId::from_str(ROOT_PUBLIC_SR25519).unwrap(),
// Pre-funded accounts
vec![
AccountId::from_str(ROOT_PUBLIC_SR25519).unwrap()
],
true,
))
.with_properties(default_properties())
.build())
}

Expand Down Expand Up @@ -144,4 +193,11 @@ fn testnet_genesis(
"key": Some(root_key),
}
})
}

fn default_properties() -> sc_service::Properties {
let mut props : sc_service::Properties = sc_service::Properties::new();
props.insert("tokenSymbol".to_string(), json!("AGAT"));
props.insert("tokenDecimals".to_string(), json!(18));
return props;
}
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl SubstrateCli for Cli {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()?),
"" | "local" => Box::new(chain_spec::local_testnet_config()?),
"aga" => Box::new(chain_spec::aga_config()?),
"aga" => Box::new(chain_spec::aga_testnet_config()?),
path => {
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
},
Expand Down

0 comments on commit 45cbd96

Please sign in to comment.