diff --git a/m1/movement/src/account/fund.rs b/m1/movement/src/account/fund.rs index b8167180..c3846aad 100644 --- a/m1/movement/src/account/fund.rs +++ b/m1/movement/src/account/fund.rs @@ -5,7 +5,7 @@ use crate::{ account::create::DEFAULT_FUNDED_COINS, common::{ types::{CliCommand, CliTypedResult, FaucetOptions, ProfileOptions, RestOptions}, - utils::{fund_account, wait_for_transactions}, + utils::{fund_account, wait_for_transactions, fund_pub_key}, }, }; use aptos_types::account_address::AccountAddress; @@ -46,17 +46,24 @@ impl CliCommand for FundWithFaucet { } async fn execute(self) -> CliTypedResult { + // todo: the below is a hotfix. Determine why the auth_key parameter in the rpc is not working + /* let hashes = fund_account( self.faucet_options.faucet_url(&self.profile_options)?, self.amount, self.account, ) .await?; + */ + let hashes = fund_pub_key( + self.faucet_options.faucet_url(&self.profile_options)?, + (self.profile_options.public_key()?).to_string() + ).await?; let client = self.rest_options.client(&self.profile_options)?; wait_for_transactions(&client, hashes).await?; return Ok(format!( - "Added {} Octas to account {}", - self.amount, self.account + "Added 10 MOV to account {}", + self.account )); } } diff --git a/m1/movement/src/common/utils.rs b/m1/movement/src/common/utils.rs index 601ae684..126afde0 100644 --- a/m1/movement/src/common/utils.rs +++ b/m1/movement/src/common/utils.rs @@ -406,7 +406,7 @@ pub async fn fund_account( ) -> CliTypedResult> { let response = reqwest::Client::new() .post(format!( - "{}mint?amount={}&auth_key={}", + "{}v1/mint?amount={}&auth_key={}", faucet_url, num_octas, address )) .body("{}") diff --git a/m1/movement/src/faucet/mod.rs b/m1/movement/src/faucet/mod.rs index 9564fb9c..4b4a6d91 100644 --- a/m1/movement/src/faucet/mod.rs +++ b/m1/movement/src/faucet/mod.rs @@ -12,11 +12,22 @@ use clap::Parser; #[derive(Debug, Parser)] pub struct FaucetTool { #[clap(long)] - pub_key: String, + pub_key: Option, #[clap(flatten)] pub(crate) faucet_options: FaucetOptions, #[clap(flatten)] pub(crate) rest_options: RestOptions, + #[clap(flatten)] + pub(crate) profile_options: ProfileOptions, +} + +impl FaucetTool { + fn pub_key(&self, profile: &ProfileOptions) -> CliTypedResult { + match &self.pub_key { + Some(pub_key) => Ok(pub_key.clone()), + None => Ok((profile.public_key()?).to_string()), + } + } } #[async_trait] @@ -26,15 +37,15 @@ impl CliCommand for FaucetTool { } async fn execute(self) -> CliTypedResult { - let profile = ProfileOptions::default(); + let profile = &self.profile_options; let hashes = fund_pub_key( self.faucet_options.faucet_url(&profile)?, - self.pub_key.clone(), + self.pub_key(&profile)?, ).await?; let client = self.rest_options.client_raw(self.faucet_options.faucet_url(&profile)?)?; wait_for_transactions(&client, hashes).await?; return Ok(format!( - "Added 1000_000_000 Octas to account {}", self.pub_key + "Added 10 MOV to account {}", self.pub_key(&profile)? )); } }