Skip to content

Commit

Permalink
Merge pull request #79 from movemntdev/big-merge-0
Browse files Browse the repository at this point in the history
feat: hotfix on #78 and faucet does the same.
  • Loading branch information
l-monninger authored Nov 13, 2023
2 parents 3ec647b + affd253 commit 83c5c9b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
13 changes: 10 additions & 3 deletions m1/movement/src/account/fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,17 +46,24 @@ impl CliCommand<String> for FundWithFaucet {
}

async fn execute(self) -> CliTypedResult<String> {
// 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
));
}
}
2 changes: 1 addition & 1 deletion m1/movement/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub async fn fund_account(
) -> CliTypedResult<Vec<HashValue>> {
let response = reqwest::Client::new()
.post(format!(
"{}mint?amount={}&auth_key={}",
"{}v1/mint?amount={}&auth_key={}",
faucet_url, num_octas, address
))
.body("{}")
Expand Down
19 changes: 15 additions & 4 deletions m1/movement/src/faucet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ use clap::Parser;
#[derive(Debug, Parser)]
pub struct FaucetTool {
#[clap(long)]
pub_key: String,
pub_key: Option<String>,
#[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<String> {
match &self.pub_key {
Some(pub_key) => Ok(pub_key.clone()),
None => Ok((profile.public_key()?).to_string()),
}
}
}

#[async_trait]
Expand All @@ -26,15 +37,15 @@ impl CliCommand<String> for FaucetTool {
}

async fn execute(self) -> CliTypedResult<String> {
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)?
));
}
}
Expand Down

0 comments on commit 83c5c9b

Please sign in to comment.