Skip to content

Commit

Permalink
Adds H160 account (paritytech#78)
Browse files Browse the repository at this point in the history
* Adds H160 account

* Check in Cargo.lock

* Fix no_std build

* Fixes token-dealer account id

* Setup chain_specs for H160 AccountId

* Adds license

* Cleans H160 account.rs

* Clean warnings

* Fixes account reference

* format rust files

* More rust format fixes

* Fixes genesis spec for H160

* Adds test for polkadotjs balance check

* Fixes test specs

* Restore AccountId logic

* Replace AccountId20 by H160 + fix tests

* Clean formatting

* Fix extra whitespace

* Fixes warning messages

* Fixes errors in merge

* Adds dev/ops account to alphanet specs

Co-authored-by: Alan <alan@ip-172-31-37-206.us-east-2.compute.internal>
Co-authored-by: Joshy Orndorff <admin@joshyorndorff.com>
Co-authored-by: Alan Sapede <alan@scg-moonbuild-1.dev.purestake.tech>
  • Loading branch information
4 people authored Nov 12, 2020
1 parent 1cd6fbb commit b9a1151
Show file tree
Hide file tree
Showing 20 changed files with 5,810 additions and 950 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 5 additions & 34 deletions node/parachain/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,18 @@

use cumulus_primitives::ParaId;
use moonbeam_runtime::{
AccountId, BalancesConfig, GenesisConfig, Signature, SudoConfig, SystemConfig,
ParachainInfoConfig, WASM_BINARY, EthereumChainIdConfig, EVMConfig, EthereumConfig,
AccountId, BalancesConfig, GenesisConfig, SudoConfig, SystemConfig,
ParachainInfoConfig, WASM_BINARY, EthereumChainIdConfig, EVMConfig, EthereumConfig
};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use std::collections::BTreeMap;
use std::str::FromStr;

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

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}

/// The extensions for the [`ChainSpec`].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
#[serde(deny_unknown_fields)]
Expand All @@ -53,16 +45,6 @@ impl Extensions {
}
}

type AccountPublic = <Signature as Verify>::Signer;

/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}

pub fn get_chain_spec(para_id: ParaId) -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;
Ok(ChainSpec::from_genesis(
Expand All @@ -72,20 +54,9 @@ pub fn get_chain_spec(para_id: ParaId) -> Result<ChainSpec, String> {
move || {
testnet_genesis(
wasm_binary,
get_account_id_from_seed::<sr25519::Public>("Alice"),
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
],
para_id,
1280, //ChainId
Expand Down
Loading

0 comments on commit b9a1151

Please sign in to comment.