Skip to content

Commit

Permalink
Adds expiration to gen_ibc_shielding_transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Sep 2, 2024
1 parent 78e77c1 commit fa785a9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
35 changes: 35 additions & 0 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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,
}
Expand All @@ -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."
)))
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,8 @@ pub struct GenIbcShieldingTransfer<C: NamadaTypes = SdkTypes> {
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
Expand Down
3 changes: 1 addition & 2 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3783,8 +3783,7 @@ pub async fn gen_ibc_shielding_transfer<N: Namada>(
// 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()))?;
Expand Down

0 comments on commit fa785a9

Please sign in to comment.