Skip to content

Commit

Permalink
remove --refund
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Jul 4, 2024
1 parent ca79554 commit 7212f7e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 37 deletions.
7 changes: 0 additions & 7 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3349,7 +3349,6 @@ pub mod args {
pub const RAW_PUBLIC_KEY_HASH_OPT: ArgOpt<String> =
RAW_PUBLIC_KEY_HASH.opt();
pub const RECEIVER: Arg<String> = arg("receiver");
pub const REFUND: ArgFlag = flag("refund");
pub const REFUND_TARGET: ArgOpt<WalletTransferTarget> =
arg_opt("refund-target");
pub const RELAYER: Arg<Address> = arg("relayer");
Expand Down Expand Up @@ -6480,7 +6479,6 @@ pub mod args {
amount: self.amount,
port_id: self.port_id,
channel_id: self.channel_id,
refund: self.refund,
})
}
}
Expand All @@ -6494,7 +6492,6 @@ pub mod args {
let amount = InputAmount::Unvalidated(AMOUNT.parse(matches));
let port_id = PORT_ID.parse(matches);
let channel_id = CHANNEL_ID.parse(matches);
let refund = REFUND.parse(matches);
Self {
query,
output_folder,
Expand All @@ -6503,7 +6500,6 @@ pub mod args {
amount,
port_id,
channel_id,
refund,
}
}

Expand All @@ -6525,9 +6521,6 @@ pub mod args {
.arg(CHANNEL_ID.def().help(wrap!(
"The channel ID via which the token is received."
)))
.arg(REFUND.def().help(wrap!(
"Generate the shielding transfer for refunding."
)))
}
}

Expand Down
2 changes: 0 additions & 2 deletions crates/sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2662,6 +2662,4 @@ pub struct GenIbcShieldingTransfer<C: NamadaTypes = SdkTypes> {
pub port_id: PortId,
/// Channel ID via which the token is received
pub channel_id: ChannelId,
/// Generate the shielding transfer for refunding
pub refund: bool,
}
4 changes: 2 additions & 2 deletions crates/sdk/src/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
let mut masp_txs = Vec::new();
for cmt in &tx.header.batch {
let tx_data = tx.data(cmt).ok_or_else(|| {
Error::Other("Missing expected masp transaction".to_string())
Error::Other("Missing transaction data".to_string())
})?;
let ibc_msg = decode_message(&tx_data)
.map_err(|_| Error::Other("Invalid IBC message".to_string()))?;
Expand All @@ -890,7 +890,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
Ok(masp_txs)
} else {
Err(Error::Other(
"IBC meesage doesn't have masp transaction".to_string(),
"IBC message doesn't have masp transaction".to_string(),
))
}
}
Expand Down
29 changes: 12 additions & 17 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use namada_governance::storage::proposal::{
};
use namada_governance::storage::vote::ProposalVote;
use namada_ibc::storage::channel_key;
use namada_ibc::trace::{convert_to_address, is_nft_trace};
use namada_ibc::trace::is_nft_trace;
use namada_ibc::{
decode_masp_tx_from_memo, IbcShieldingData, MsgNftTransfer, MsgTransfer,
};
Expand Down Expand Up @@ -3526,22 +3526,17 @@ pub async fn gen_ibc_shielding_transfer<N: Namada>(
.await?;
let ibc_denom =
rpc::query_ibc_denom(context, &args.token, Some(&source)).await;
let token = if args.refund {
convert_to_address(ibc_denom)
.map_err(|e| Error::Other(format!("Invalid token: {e}")))?
} else {
// Need to check the prefix
namada_ibc::received_ibc_token(
&ibc_denom,
&src_port_id,
&src_channel_id,
&args.port_id,
&args.channel_id,
)
.map_err(|e| {
Error::Other(format!("Getting IBC Token failed: error {e}"))
})?
};
// Need to check the prefix
let token = namada_ibc::received_ibc_token(
&ibc_denom,
&src_port_id,
&src_channel_id,
&args.port_id,
&args.channel_id,
)
.map_err(|e| {
Error::Other(format!("Getting IBC Token failed: error {e}"))
})?;
let validated_amount =
validate_amount(context, args.amount, &token, false).await?;

Expand Down
10 changes: 1 addition & 9 deletions crates/tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ fn run_ledger_ibc_with_hermes() -> Result<()> {
1_000_000_000,
&port_id_b,
&channel_id_b,
false,
)?;
transfer(
&test_a,
Expand Down Expand Up @@ -492,7 +491,6 @@ fn ibc_namada_gaia() -> Result<()> {
100,
&port_id_namada,
&channel_id_namada,
false,
)?;
transfer_from_gaia(
&test_gaia,
Expand Down Expand Up @@ -695,7 +693,6 @@ fn proposal_ibc_token_inflation() -> Result<()> {
1_000_000,
&port_id_b,
&channel_id_b,
false,
)?;
transfer(
&test_a,
Expand Down Expand Up @@ -2685,14 +2682,13 @@ fn gen_masp_tx(
amount: u64,
port_id: &PortId,
channel_id: &ChannelId,
is_refund: bool,
) -> Result<PathBuf> {
std::env::set_var(ENV_VAR_CHAIN_ID, dst_test.net.chain_id.to_string());
let rpc = get_actor_rpc(dst_test, Who::Validator(0));
let output_folder = dst_test.test_dir.path().to_string_lossy();

let amount = amount.to_string();
let mut args = vec![
let args = vec![
"ibc-gen-shielding",
"--output-folder-path",
&output_folder,
Expand All @@ -2710,10 +2706,6 @@ fn gen_masp_tx(
&rpc,
];

if is_refund {
args.push("--refund");
}

let mut client = run!(dst_test, Bin::Client, args, Some(120))?;
let (_unread, matched) =
client.exp_regex("Output IBC shielding transfer .*")?;
Expand Down

0 comments on commit 7212f7e

Please sign in to comment.