From fa785a93222547576dfa5bc7d9c4a650c665e175 Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 30 Aug 2024 17:03:48 +0200 Subject: [PATCH] Adds expiration to `gen_ibc_shielding_transfer` --- crates/apps_lib/src/cli.rs | 35 +++++++++++++++++++++++++++++++++++ crates/sdk/src/args.rs | 2 ++ crates/sdk/src/tx.rs | 3 +-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/apps_lib/src/cli.rs b/crates/apps_lib/src/cli.rs index 6781374b978..071e7e101f0 100644 --- a/crates/apps_lib/src/cli.rs +++ b/crates/apps_lib/src/cli.rs @@ -6805,6 +6805,7 @@ pub mod args { target: chain_ctx.get(&self.target), token: self.token, amount: self.amount, + expiration: self.expiration, port_id: self.port_id, channel_id: self.channel_id, }) @@ -6818,14 +6819,26 @@ pub mod args { let target = TRANSFER_TARGET.parse(matches); let token = TOKEN_STR.parse(matches); let amount = InputAmount::Unvalidated(AMOUNT.parse(matches)); + let expiration = EXPIRATION_OPT.parse(matches); let port_id = PORT_ID.parse(matches); let channel_id = CHANNEL_ID.parse(matches); + let no_expiration = NO_EXPIRATION.parse(matches); + let expiration = if no_expiration { + TxExpiration::NoExpiration + } else { + match expiration { + Some(exp) => TxExpiration::Custom(exp), + None => TxExpiration::Default, + } + }; + Self { query, output_folder, target, token, amount, + expiration, port_id, channel_id, } @@ -6843,6 +6856,28 @@ pub mod args { .def() .help(wrap!("The amount to transfer in decimal.")), ) + .arg( + EXPIRATION_OPT + .def() + .help(wrap!( + "The expiration datetime of the masp transaction, \ + after which the tx won't be accepted anymore. If \ + not provided, a default will be set. All of \ + these examples are \ + equivalent:\n2012-12-12T12:12:12Z\n2012-12-12 \ + 12:12:12Z\n2012- 12-12T12: 12:12Z" + )) + .conflicts_with_all([NO_EXPIRATION.name]), + ) + .arg( + NO_EXPIRATION + .def() + .help(wrap!( + "Force the construction of the transaction \ + without an expiration (highly discouraged)." + )) + .conflicts_with_all([EXPIRATION_OPT.name]), + ) .arg(PORT_ID.def().help(wrap!( "The port ID via which the token is received." ))) diff --git a/crates/sdk/src/args.rs b/crates/sdk/src/args.rs index 5949a16ba4c..5dd0aee13c8 100644 --- a/crates/sdk/src/args.rs +++ b/crates/sdk/src/args.rs @@ -2892,6 +2892,8 @@ pub struct GenIbcShieldingTransfer { pub token: String, /// Transferred token amount pub amount: InputAmount, + /// The optional expiration of the masp shielding transaction + pub expiration: TxExpiration, /// Port ID via which the token is received pub port_id: PortId, /// Channel ID via which the token is received diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index 0e54a135eac..3ee7ffcf819 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -3783,8 +3783,7 @@ pub async fn gen_ibc_shielding_transfer( // Fees are paid from the transparent balance of the relayer None, true, - // Expiration can be set directly on the ibc transaction - None, + args.expiration.to_datetime(), ) .await .map_err(|err| TxSubmitError::MaspError(err.to_string()))?;