Skip to content

Commit

Permalink
Make Bridge pool gas payer CLI arg optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Aug 9, 2023
1 parent 3ebd92d commit 31e948b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,8 @@ pub mod args {
denom: NATIVE_MAX_DECIMAL_PLACES.into(),
}),
);
pub const BRIDGE_POOL_GAS_PAYER: Arg<WalletAddress> = arg("pool-gas-payer");
pub const BRIDGE_POOL_GAS_PAYER: ArgOpt<WalletAddress> =
arg_opt("pool-gas-payer");
pub const BRIDGE_POOL_GAS_TOKEN: ArgDefaultFromCtx<WalletAddress> =
arg_default_from_ctx(
"pool-gas-token",
Expand Down Expand Up @@ -2711,7 +2712,7 @@ pub mod args {
sender: ctx.get(&self.sender),
amount: self.amount,
gas_amount: self.gas_amount,
gas_payer: ctx.get(&self.gas_payer),
gas_payer: self.gas_payer.map(|gas_payer| ctx.get(&gas_payer)),
gas_token: ctx.get(&self.gas_token),
code_path: ctx.read_wasm(self.code_path),
}
Expand Down Expand Up @@ -2768,11 +2769,10 @@ pub mod args {
"The amount of gas you wish to pay to have this transfer \
relayed to Ethereum.",
))
.arg(
BRIDGE_POOL_GAS_PAYER.def().help(
"The Namada address of the account paying the gas.",
),
)
.arg(BRIDGE_POOL_GAS_PAYER.def().help(
"The Namada address of the account paying the gas. By \
default, it is the same as the source.",
))
.arg(BRIDGE_POOL_GAS_TOKEN.def().help(
"The token for paying the Bridge pool gas fees. Defaults \
to NAM.",
Expand Down
4 changes: 3 additions & 1 deletion shared/src/ledger/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,9 @@ pub struct EthereumBridgePool<C: NamadaTypes = SdkTypes> {
/// The amount of fees (in NAM)
pub gas_amount: token::Amount,
/// The account of fee payer.
pub gas_payer: C::Address,
///
/// If unset, it is the same as the sender.
pub gas_payer: Option<C::Address>,
/// The token in which the gas is being paid
pub gas_token: C::Address,
/// Path to the tx WASM code file
Expand Down
1 change: 1 addition & 0 deletions shared/src/ledger/eth_bridge/bridge_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub async fn build_bridge_pool_tx<
gas_token,
code_path: wasm_code,
} = args;
let gas_payer = gas_payer.unwrap_or_else(|| sender.clone());
let DenominatedAmount { amount, .. } =
validate_amount(client, amount, &BRIDGE_ADDRESS, tx.force)
.await
Expand Down

0 comments on commit 31e948b

Please sign in to comment.