Skip to content

Commit

Permalink
Return back the "Output Bech32Address for initial accounts" change. (#…
Browse files Browse the repository at this point in the history
…921)

[This change](#594) was done
at the same time as moving this file into another place, so during
conflict resolution, we missed it.

Closes #593
  • Loading branch information
xgreenx authored Jan 20, 2023
1 parent 2301e15 commit 5350b8b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions crates/chain-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description = "Fuel Chain config types"

[dependencies]
anyhow = "1.0"
bech32 = "0.9.0"
bincode = "1.3"
fuel-core-poa = { path = "../services/consensus_module/poa", version = "0.15.1" }
fuel-core-storage = { path = "../storage", version = "0.15.1" }
Expand Down
26 changes: 19 additions & 7 deletions crates/chain-config/src/config/chain.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use bech32::{
ToBase32,
Variant::Bech32m,
};
use fuel_core_storage::MerkleRoot;
use fuel_core_types::{
fuel_crypto::Hasher,
fuel_tx::ConsensusParameters,
fuel_types::{
Address,
AssetId,
Bytes32,
},
};
use itertools::Itertools;
Expand All @@ -17,20 +22,22 @@ use serde::{
Serialize,
};
use serde_with::skip_serializing_none;

use std::{
io::ErrorKind,
path::PathBuf,
str::FromStr,
};

use crate::GenesisCommitment;

use super::{
coin::CoinConfig,
state::StateConfig,
use crate::{
config::{
coin::CoinConfig,
state::StateConfig,
},
genesis::GenesisCommitment,
};

// Fuel Network human-readable part for bech32 encoding
pub const FUEL_BECH32_HRP: &str = "fuel";
pub const LOCAL_TESTNET: &str = "local_testnet";
pub const TESTNET_INITIAL_BALANCE: u64 = 10_000_000;

Expand Down Expand Up @@ -72,10 +79,15 @@ impl ChainConfig {
.map(|_| {
let secret = fuel_core_types::fuel_crypto::SecretKey::random(&mut rng);
let address = Address::from(*secret.public_key().hash());
let bech32_data = Bytes32::new(*address).to_base32();
let bech32_encoding =
bech32::encode(FUEL_BECH32_HRP, bech32_data, Bech32m).unwrap();

tracing::info!(
"PrivateKey({:#x}), Address({:#x}), Balance({})",
"PrivateKey({:#x}), Address({:#x} [bech32: {}]), Balance({})",
secret,
address,
bech32_encoding,
TESTNET_INITIAL_BALANCE
);
CoinConfig {
Expand Down

0 comments on commit 5350b8b

Please sign in to comment.