Skip to content

Commit

Permalink
Add NUT cmdline flag for Bridge pool transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Jul 13, 2023
1 parent 15206c2 commit bc04121
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@ pub mod args {
pub const NET_ADDRESS: Arg<SocketAddr> = arg("net-address");
pub const NAMADA_START_TIME: ArgOpt<DateTimeUtc> = arg_opt("time");
pub const NO_CONVERSIONS: ArgFlag = flag("no-conversions");
pub const NUT: ArgFlag = flag("nut");
pub const OUT_FILE_PATH_OPT: ArgOpt<PathBuf> = arg_opt("out-file-path");
pub const OWNER: Arg<WalletAddress> = arg("owner");
pub const OWNER_OPT: ArgOpt<WalletAddress> = OWNER.opt();
Expand Down Expand Up @@ -2613,6 +2614,7 @@ pub mod args {
impl CliToSdk<EthereumBridgePool<SdkTypes>> for EthereumBridgePool<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> EthereumBridgePool<SdkTypes> {
EthereumBridgePool::<SdkTypes> {
nut: self.nut,
tx: self.tx.to_sdk(ctx),
asset: self.asset,
recipient: self.recipient,
Expand All @@ -2635,6 +2637,7 @@ pub mod args {
let gas_amount = FEE_AMOUNT.parse(matches).amount;
let gas_payer = FEE_PAYER.parse(matches);
let code_path = PathBuf::from(TX_BRIDGE_POOL_WASM);
let nut = NUT.parse(matches);
Self {
tx,
asset,
Expand All @@ -2644,6 +2647,7 @@ pub mod args {
gas_amount,
gas_payer,
code_path,
nut,
}
}

Expand Down Expand Up @@ -2678,6 +2682,10 @@ pub mod args {
"The Namada address of the account paying the fee.",
),
)
.arg(NUT.def().help(
"Add Non Usable Tokens (NUTs) to the Bridge pool. These \
are usually obtained from invalid transfers to Namada.",
))
}
}

Expand Down
5 changes: 5 additions & 0 deletions shared/src/ledger/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@ pub struct RecommendBatch<C: NamadaTypes = SdkTypes> {
/// A transfer to be added to the Ethereum bridge pool.
#[derive(Clone, Debug)]
pub struct EthereumBridgePool<C: NamadaTypes = SdkTypes> {
/// Whether the transfer is for a NUT.
///
/// By default, we add wrapped ERC20s onto the
/// Bridge pool.
pub nut: bool,
/// The args for building a tx to the bridge pool
pub tx: Tx<C>,
/// The type of token
Expand Down
9 changes: 6 additions & 3 deletions shared/src/ledger/eth_bridge/bridge_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub async fn build_bridge_pool_tx<
args: args::EthereumBridgePool,
) -> Result<(Tx, Option<Address>, common::PublicKey), Error> {
let args::EthereumBridgePool {
nut,
ref tx,
asset,
recipient,
Expand All @@ -66,9 +67,11 @@ pub async fn build_bridge_pool_tx<
recipient,
sender,
amount,
// TODO: dispatch on the transfer kind, based
// on CLI arguments
kind: TransferToEthereumKind::Erc20,
kind: if nut {
TransferToEthereumKind::Nut
} else {
TransferToEthereumKind::Erc20
},
},
gas_fee: GasFee {
amount: gas_amount,
Expand Down

0 comments on commit bc04121

Please sign in to comment.