Skip to content

Commit 3737f51

Browse files
committed
feat(tap-aggregator): add default for key derive path arg
Adds default argument matching the default of mnemonicBuilder library to simplify code. Signed-off-by: Bryan Cole <[email protected]>
1 parent aec0a66 commit 3737f51

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

tap_aggregator/src/main.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use alloy_primitives::{Address, FixedBytes, U256};
99
use alloy_sol_types::Eip712Domain;
1010
use anyhow::Result;
1111
use clap::Parser;
12-
use ethers_signers::{coins_bip39::English, MnemonicBuilder};
12+
use ethers_signers::{coins_bip39::English, MnemonicBuilder, Signer};
1313
use tokio::signal::unix::{signal, SignalKind};
1414

1515
use log::{debug, info};
@@ -29,8 +29,8 @@ struct Args {
2929
mnemonic: String,
3030

3131
/// Gateway key derive path to be used to generate key for signing Receipt Aggregate Vouchers.
32-
#[arg(long, env = "TAP_KEY_DERIVE_PATH")]
33-
key_derive_path: Option<String>,
32+
#[arg(long, default_value = "m/44'/60'/0'/0/0", env = "TAP_KEY_DERIVE_PATH")]
33+
key_derive_path: String,
3434

3535
/// Maximum request body size in bytes.
3636
/// Defaults to 10MB.
@@ -90,18 +90,12 @@ async fn main() -> Result<()> {
9090
tokio::spawn(metrics::run_server(args.metrics_port));
9191

9292
// Create a wallet from the mnemonic.
93-
let wallet = if let Some(key_derive_path) = args.key_derive_path.as_deref() {
94-
info!("Creating wallet from mnemonic and key derive path...");
95-
MnemonicBuilder::<English>::default()
96-
.phrase(args.mnemonic.as_str())
97-
.derivation_path(key_derive_path)?
98-
.build()?
99-
} else {
100-
info!("Creating wallet from mnemonic...");
101-
MnemonicBuilder::<English>::default()
102-
.phrase(args.mnemonic.as_str())
103-
.build()?
104-
};
93+
let wallet = MnemonicBuilder::<English>::default()
94+
.phrase(args.mnemonic.as_str())
95+
.derivation_path(&args.key_derive_path)?
96+
.build()?;
97+
98+
info!("Wallet address: {:#40x}", wallet.address());
10599

106100
// Create the EIP-712 domain separator.
107101
let domain_separator = create_eip712_domain(&args)?;

0 commit comments

Comments
 (0)