Skip to content

Commit

Permalink
client: refactor client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Jul 25, 2023
1 parent 39113c6 commit d5c8251
Show file tree
Hide file tree
Showing 29 changed files with 1,597 additions and 1,682 deletions.
69 changes: 40 additions & 29 deletions apps/src/bin/namada-client/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use color_eyre::eyre::{eyre, Report, Result};
use namada::ledger::eth_bridge::bridge_pool;
use namada::ledger::rpc::wait_until_node_is_synched;
use namada::ledger::tx::dump_tx;
use namada::ledger::{signing, tx as sdk_tx};
use namada::types::control_flow::ProceedOrElse;
use namada_apps::cli;
Expand Down Expand Up @@ -215,41 +216,51 @@ pub async fn main() -> Result<()> {
.proceed_or_else(error)?;
let args = args.to_sdk(&mut ctx);
let tx_args = args.tx.clone();
let (mut tx, addr, public_keys) =
bridge_pool::build_bridge_pool_tx(
&client,
&mut ctx.wallet,
args,
)
.await
.unwrap();
tx::submit_reveal_aux(

let default_signer =
signing::signer_from_address(Some(args.sender.clone()));
let signing_data = signing::aux_signing_data(
&client,
&mut ctx,
&tx_args,
addr.clone(),
&public_keys,
&mut tx,
&mut ctx.wallet,
&args.tx,
&args.sender,
default_signer,
)
.await?;
let (account_public_keys_map, threshold) =
signing::aux_signing_data(
&client,
addr,
public_keys.clone(),
)
.await;
signing::sign_tx(
&mut ctx.wallet,
&mut tx,
&tx_args,
&account_public_keys_map,
&public_keys,
threshold,

let tx_builder = bridge_pool::build_bridge_pool_tx(
&client,
args.clone(),
signing_data.fee_payer.clone(),
)
.await?;
sdk_tx::process_tx(&client, &mut ctx.wallet, &tx_args, tx)

if args.tx.dump_tx {
dump_tx(&args.tx, tx_builder);
} else {
tx::submit_reveal_aux(
&client,
&mut ctx,
tx_args.clone(),
&args.sender,
)
.await?;

let tx_builder = signing::sign_tx(
&mut ctx.wallet,
&tx_args,
tx_builder,
signing_data,
)?;

sdk_tx::process_tx(
&client,
&mut ctx.wallet,
&tx_args,
tx_builder,
)
.await?;
}
}
// Ledger queries
Sub::QueryEpoch(QueryEpoch(mut args)) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,7 @@ pub mod args {
amount: self.amount,
gas_amount: self.gas_amount,
gas_payer: ctx.get(&self.gas_payer),
code_path: ctx.read_wasm(self.code_path),
code_path: self.code_path,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/src/lib/client/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
/// signer. Return the given signing key or public key of the given signer if
/// possible. If no explicit signer given, use the `default`. If no `default`
/// is given, panics.
pub async fn tx_signer<C, U>(
pub async fn tx_signers<C, U>(
client: &C,
wallet: &mut Wallet<U>,
args: &args::Tx,
Expand All @@ -42,7 +42,7 @@ where
C::Error: std::fmt::Display,
U: WalletUtils,
{
namada::ledger::signing::tx_signer::<C, U>(client, wallet, args, default)
namada::ledger::signing::tx_signers::<C, U>(client, wallet, args, default)
.await
}

Expand Down
Loading

0 comments on commit d5c8251

Please sign in to comment.