Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return back the "Output Bech32Address for initial accounts" change. #921

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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