@@ -418,7 +418,8 @@ impl NodeConfig {
418
418
impl Default for NodeConfig {
419
419
fn default ( ) -> Self {
420
420
// generate some random wallets
421
- let genesis_accounts = AccountGenerator :: new ( 10 ) . phrase ( DEFAULT_MNEMONIC ) . gen ( ) ;
421
+ let genesis_accounts =
422
+ AccountGenerator :: new ( 10 ) . phrase ( DEFAULT_MNEMONIC ) . gen ( ) . expect ( "Invalid mnemonic." ) ;
422
423
Self {
423
424
chain_id : None ,
424
425
gas_limit : None ,
@@ -693,11 +694,10 @@ impl NodeConfig {
693
694
694
695
/// Sets both the genesis accounts and the signer accounts
695
696
/// so that `genesis_accounts == accounts`
696
- #[ must_use]
697
- pub fn with_account_generator ( mut self , generator : AccountGenerator ) -> Self {
698
- let accounts = generator. gen ( ) ;
697
+ pub fn with_account_generator ( mut self , generator : AccountGenerator ) -> eyre:: Result < Self > {
698
+ let accounts = generator. gen ( ) ?;
699
699
self . account_generator = Some ( generator) ;
700
- self . with_signer_accounts ( accounts. clone ( ) ) . with_genesis_accounts ( accounts)
700
+ Ok ( self . with_signer_accounts ( accounts. clone ( ) ) . with_genesis_accounts ( accounts) )
701
701
}
702
702
703
703
/// Sets the balance of the genesis accounts in the genesis block
@@ -1496,7 +1496,7 @@ impl AccountGenerator {
1496
1496
}
1497
1497
1498
1498
impl AccountGenerator {
1499
- pub fn gen ( & self ) -> Vec < PrivateKeySigner > {
1499
+ pub fn gen ( & self ) -> eyre :: Result < Vec < PrivateKeySigner > > {
1500
1500
let builder = MnemonicBuilder :: < English > :: default ( ) . phrase ( self . phrase . as_str ( ) ) ;
1501
1501
1502
1502
// use the derivation path
@@ -1506,10 +1506,10 @@ impl AccountGenerator {
1506
1506
for idx in 0 ..self . amount {
1507
1507
let builder =
1508
1508
builder. clone ( ) . derivation_path ( format ! ( "{derivation_path}{idx}" ) ) . unwrap ( ) ;
1509
- let wallet = builder. build ( ) . unwrap ( ) . with_chain_id ( Some ( self . chain_id ) ) ;
1509
+ let wallet = builder. build ( ) ? . with_chain_id ( Some ( self . chain_id ) ) ;
1510
1510
wallets. push ( wallet)
1511
1511
}
1512
- wallets
1512
+ Ok ( wallets)
1513
1513
}
1514
1514
}
1515
1515
0 commit comments