Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add coin argument to get_escrow_account method #986

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/unreleased/breaking-change/985-escrow-account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Added `coin` argument to `get_escrow_account` method to support chains
where escrow account depends on the coin.
([#985](https://github.com/cosmos/ibc-rs/issues/985))
1 change: 1 addition & 0 deletions ibc-apps/ics20-transfer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub trait TokenTransferValidationContext {
&self,
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
) -> Result<Self::AccountId, TokenTransferError>;

/// Returns Ok() if the host chain supports sending coins.
Expand Down
4 changes: 2 additions & 2 deletions ibc-apps/ics20-transfer/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
) {
// unescrow tokens back to sender
let escrow_address =
ctx_a.get_escrow_account(&packet.port_id_on_a, &packet.chan_id_on_a)?;
ctx_a.get_escrow_account(&packet.port_id_on_a, &packet.chan_id_on_a, &data.token)?;

Check warning on line 32 in ibc-apps/ics20-transfer/src/handler/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/handler/mod.rs#L32

Added line #L32 was not covered by tests

ctx_a.send_coins_execute(&escrow_address, &sender, &data.token)
}
Expand All @@ -56,7 +56,7 @@
&data.token.denom,
) {
let escrow_address =
ctx_a.get_escrow_account(&packet.port_id_on_a, &packet.chan_id_on_a)?;
ctx_a.get_escrow_account(&packet.port_id_on_a, &packet.chan_id_on_a, &data.token)?;

Check warning on line 59 in ibc-apps/ics20-transfer/src/handler/mod.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/handler/mod.rs#L59

Added line #L59 was not covered by tests

ctx_a.send_coins_validate(&escrow_address, &sender, &data.token)
} else {
Expand Down
2 changes: 1 addition & 1 deletion ibc-apps/ics20-transfer/src/handler/on_recv_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
};

let escrow_address = ctx_b
.get_escrow_account(&packet.port_id_on_b, &packet.chan_id_on_b)
.get_escrow_account(&packet.port_id_on_b, &packet.chan_id_on_b, &coin)

Check warning on line 47 in ibc-apps/ics20-transfer/src/handler/on_recv_packet.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/handler/on_recv_packet.rs#L47

Added line #L47 was not covered by tests
.map_err(|token_err| (ModuleExtras::empty(), token_err))?;

// Note: it is correct to do the validation here because `recv_packet()`
Expand Down
4 changes: 2 additions & 2 deletions ibc-apps/ics20-transfer/src/handler/send_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ where
&token.denom,
) {
let escrow_address =
token_ctx_a.get_escrow_account(&msg.port_id_on_a, &msg.chan_id_on_a)?;
token_ctx_a.get_escrow_account(&msg.port_id_on_a, &msg.chan_id_on_a, token)?;
token_ctx_a.send_coins_validate(&sender, &escrow_address, token)?;
} else {
token_ctx_a.burn_coins_validate(&sender, token)?;
Expand Down Expand Up @@ -138,7 +138,7 @@ where
&token.denom,
) {
let escrow_address =
token_ctx_a.get_escrow_account(&msg.port_id_on_a, &msg.chan_id_on_a)?;
token_ctx_a.get_escrow_account(&msg.port_id_on_a, &msg.chan_id_on_a, token)?;
token_ctx_a.send_coins_execute(&sender, &escrow_address, token)?;
} else {
token_ctx_a.burn_coins_execute(&sender, token)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ impl TokenTransferValidationContext for DummyTransferModule {
&self,
port_id: &PortId,
channel_id: &ChannelId,
_coin: &PrefixedCoin,
) -> Result<Self::AccountId, TokenTransferError> {
let addr = cosmos_adr028_escrow_address(port_id, channel_id);
Ok(bech32::encode("cosmos", addr).into())
Expand Down
Loading