Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:grindytech/gafi into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mutobui committed Oct 11, 2023
2 parents e85eea8 + 8b1a43c commit 7c31be2
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ jobs:
run: make check

- name: Check Build for Benchmarking
run: >
run: |
if [ ! -d "node" ]; then
mkdir node # Create the "node" directory
fi
pushd node &&
make check-benchmark
shell: bash
5 changes: 3 additions & 2 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::cli::{Cli, Subcommand};
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
use gafi_service::{
local_config, inherent_benchmark_data, testnet_config , new_full, new_partial,
ChainSpec, RemarkBuilder, TransferKeepAliveBuilder,
development_config, inherent_benchmark_data, local_config, new_full, new_partial,
testnet_config, ChainSpec, RemarkBuilder, TransferKeepAliveBuilder,
};
use polkadot_core_primitives::Block;
use sc_cli::SubstrateCli;
Expand Down Expand Up @@ -39,6 +39,7 @@ impl SubstrateCli for Cli {

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(development_config()?),
"" | "local" => Box::new(local_config()?),
"testnet" => Box::new(testnet_config()?),
path => Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
Expand Down
72 changes: 71 additions & 1 deletion node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,79 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
(get_from_seed::<AuraId>(s), get_from_seed::<GrandpaId>(s))
}

pub fn development_config() -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;

let mut props: Properties = Properties::new();
let token = GafiCurrency::token_info(GAFI);
let symbol = json!(String::from_utf8(token.symbol).unwrap_or("GAFI".to_string()));
let name = json!(String::from_utf8(token.name).unwrap_or("GAFI Token".to_string()));
let decimals = json!(token.decimals);
props.insert("tokenSymbol".to_string(), symbol);
props.insert("tokenName".to_string(), name);
props.insert("tokenDecimals".to_string(), decimals);

Ok(ChainSpec::from_genesis(
// Name
"Development",
// ID
"dev",
ChainType::Development,
move || {
test_genesis(
wasm_binary,
// Initial PoA authorities
vec![authority_keys_from_seed("Alice")],
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
1_000_000_u128 * unit(GAFI),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
1_000_000_u128 * unit(GAFI),
),
(
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
1_000_000_u128 * unit(GAFI),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
1_000_000_u128 * unit(GAFI),
),
],
true,
)
},
// Bootnodes
vec![],
// Telemetry
None,
// Protocol ID
None,
None,
// Properties
Some(props),
// Extensions
None,
))
}

pub fn local_config() -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;

let mut props: Properties = Properties::new();
let token = GafiCurrency::token_info(GAFI);
let symbol = json!(String::from_utf8(token.symbol).unwrap_or("GAFI".to_string()));
let name = json!(String::from_utf8(token.name).unwrap_or("GAFI Token".to_string()));
let decimals = json!(token.decimals);
props.insert("tokenSymbol".to_string(), symbol);
props.insert("tokenName".to_string(), name);
props.insert("tokenDecimals".to_string(), decimals);

Ok(ChainSpec::from_genesis(
// Name
"Local Testnet",
Expand Down Expand Up @@ -132,7 +202,7 @@ pub fn local_config() -> Result<ChainSpec, String> {
None,
// Properties
None,
None,
Some(props),
// Extensions
None,
))
Expand Down
2 changes: 1 addition & 1 deletion runtime/devnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl pallet_insecure_randomness_collective_flip::Config for Runtime {}

parameter_types! {
pub FaucetCleanTime: u128 = 24 * (HOURS as u128);
pub FaucetAmount: u128 = 1500 * unit(GAFI);
pub FaucetAmount: u128 = 100 * unit(GAFI);
}

// cache for pallet faucet only for testnet
Expand Down

0 comments on commit 7c31be2

Please sign in to comment.