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

Define HostError type #1331

Merged
merged 113 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
1928901
Define DecodingError in ibc-primitives
seanchen1991 Aug 26, 2024
527aa8f
Utilize DecodingError in ics721
seanchen1991 Aug 26, 2024
7d24ab5
Start using DecodingError in ClientError
seanchen1991 Aug 26, 2024
fb923d4
Define StatusError type
seanchen1991 Aug 26, 2024
529163d
Wire up StatusError
seanchen1991 Aug 26, 2024
e68cb54
Wiring up DecodingError
seanchen1991 Aug 27, 2024
56816c4
Add DecodingError to RouterError
seanchen1991 Aug 27, 2024
c06e06b
Remove unused From impl
seanchen1991 Aug 27, 2024
098ba0f
Change format of an import
seanchen1991 Aug 27, 2024
27e8389
Change format of an import
seanchen1991 Aug 27, 2024
9f69bf0
Change format of an import
seanchen1991 Aug 27, 2024
b02bfa4
Merge branch 'error-handling' of https://github.com/cosmos/ibc-rs int…
seanchen1991 Aug 27, 2024
b98ab29
Move DecodingError into ics24
seanchen1991 Aug 27, 2024
4e1c9e3
Cargo nightly fmt
seanchen1991 Aug 28, 2024
d186015
Use DecodingError in more places
seanchen1991 Aug 28, 2024
12056b3
cargo fmt
seanchen1991 Aug 28, 2024
1252cd5
cargo fmt
seanchen1991 Aug 28, 2024
66ded64
Update cw-check Cargo.lock
seanchen1991 Aug 28, 2024
8e0a3c0
Add necessary wasm-client feature attribute
seanchen1991 Aug 28, 2024
906dc95
Move InvalidUri error variant back to NftTransferError
seanchen1991 Aug 28, 2024
98fb942
Regenerate cw hcheck cargo.lock
seanchen1991 Aug 28, 2024
8a7074a
Add serde feature attribute
seanchen1991 Aug 28, 2024
691887f
Remove ClientError::InvalidClientIdentifier error variant in favor of…
seanchen1991 Aug 29, 2024
ea9c83d
Add derive_more::From on NftTransferError
seanchen1991 Aug 29, 2024
d79d9ea
Stashing changes
seanchen1991 Aug 29, 2024
33ff246
Revert "Add derive_more::From on NftTransferError"
seanchen1991 Aug 29, 2024
77b42b1
Remove RouterError::UnknownMessageTypeUrl
seanchen1991 Aug 29, 2024
8024622
Add derive_more::From on TokenTransferError
seanchen1991 Aug 29, 2024
bfbc79e
Add derive_more to NftTransferError
seanchen1991 Aug 29, 2024
531587c
Remove tendermint-proto dependency from ibc-primitives
seanchen1991 Aug 29, 2024
dc5906e
Remove StatusError
seanchen1991 Aug 30, 2024
f414ff7
Remove unnecessary ClientError::Decoding wrappings
seanchen1991 Aug 30, 2024
b4ae4b8
Clean up TendermintClientError
seanchen1991 Aug 30, 2024
05be8b6
Regenerate cw-check cargo.lock
seanchen1991 Aug 30, 2024
b7ba000
taplo fmt
seanchen1991 Aug 30, 2024
aeb80fc
Apply PR feedback
seanchen1991 Aug 30, 2024
b10ee71
Use ibc_proto::Error type instead of tendermint_proto::Error
seanchen1991 Sep 3, 2024
bff57f6
Change FailedToParseType fields to make them more clear
seanchen1991 Sep 3, 2024
2952291
Revert InvalidTrace and InvalidCoin TokenTransferError variants
seanchen1991 Sep 3, 2024
3ffdf2f
Remove NftTransferError variants in favor of DecodingError::InvalidJson
seanchen1991 Sep 3, 2024
b326f45
cargo fmt
seanchen1991 Sep 3, 2024
6e04864
Regenerate cw-check cargo.lock
seanchen1991 Sep 3, 2024
6f92e55
Separate out error variants that need to be moved to host-relevant er…
seanchen1991 Sep 4, 2024
2d8bbd6
Consolidate TendermintClientError decoding errors
seanchen1991 Sep 4, 2024
4877a7e
Consolidate Connection and Packet decoding errors
seanchen1991 Sep 4, 2024
cd95fa5
Remove WasmClientError
seanchen1991 Sep 4, 2024
a427988
Consolidate Identifier variant naming
seanchen1991 Sep 4, 2024
5da4717
Remove HostError annotations in doc comments
seanchen1991 Sep 4, 2024
3a0365d
Consolidate CommitmentError variants
seanchen1991 Sep 5, 2024
ca7e3a3
Consolidate ConnectionError variants
seanchen1991 Sep 5, 2024
231b3cd
Revert some CommitmentError variants
seanchen1991 Sep 5, 2024
dd49a78
Change TryFrom<Any> for MsgEnvelope Error type to DecodingError
seanchen1991 Sep 5, 2024
4ee9515
Define HostError type
seanchen1991 Sep 5, 2024
ca664ad
Rename ContextError to HandlerError
seanchen1991 Sep 5, 2024
d30ffaf
Change `pick_version` impl
seanchen1991 Sep 6, 2024
61f5645
Update ValidationContext trait methods to return HostError type
seanchen1991 Sep 9, 2024
2ef5b66
Rename HandlerError variants throughout the code base
seanchen1991 Sep 9, 2024
cec5f79
Remove match arm that is no longer relevant
seanchen1991 Sep 9, 2024
fa2a7cd
Change ClientValidationContext trait methods to return HostErrors
seanchen1991 Sep 9, 2024
27a8233
Change TokenTransferValidationContext and NftTransferValidationContex…
seanchen1991 Sep 9, 2024
2a4fea5
Updating validation contexts to return HostError types
seanchen1991 Sep 9, 2024
6f1db7b
Map errors to HostError variants
seanchen1991 Sep 10, 2024
e714eb9
Update ValidateSelfClientContext trait
seanchen1991 Sep 10, 2024
286e666
Update Upgrade validation and execution contexts to return HostErrors
seanchen1991 Sep 10, 2024
c0695a2
Merge branch 'error-handling' of https://github.com/cosmos/ibc-rs int…
seanchen1991 Sep 10, 2024
799e21a
Fix merge conflicts
seanchen1991 Sep 10, 2024
84c7329
Fix merge conflicts
seanchen1991 Sep 10, 2024
1310c0c
Revert execute_upgrade_client_proposal error type to UpgradeClientError
seanchen1991 Sep 11, 2024
d6a44b1
cargo fmt
seanchen1991 Sep 11, 2024
2252786
Remove unused alloc::string::ToString
seanchen1991 Sep 11, 2024
4e85573
Import ibc_core::primitives::prelude into handler/mod.rs
seanchen1991 Sep 11, 2024
b9cae6c
cargo fmt
seanchen1991 Sep 11, 2024
d0c07a8
Attempt to fix failing testkit test
seanchen1991 Sep 11, 2024
7133763
Remove RouterError::UnknownPort variant
seanchen1991 Sep 11, 2024
49229a3
Remove some uses of ClientError::Other variants
seanchen1991 Sep 11, 2024
a461318
Fix recv_packet_validate_happy_path test
seanchen1991 Sep 11, 2024
357e0ea
Fix conn_open_ack_no_connection test
seanchen1991 Sep 11, 2024
4049045
cargo fmt
seanchen1991 Sep 11, 2024
b229224
fix conn_open_ack_no_connection test without adding new HostError var…
seanchen1991 Sep 11, 2024
ca0eb97
fix test_create_client_try_from test
seanchen1991 Sep 11, 2024
8e2cab7
Remove unnecessary import
seanchen1991 Sep 11, 2024
a7f5795
Fix test_create_client_try_from
seanchen1991 Sep 12, 2024
a2d0205
cargo fmt
seanchen1991 Sep 12, 2024
5747b9b
Fix merge conflicts
seanchen1991 Sep 12, 2024
9cae17b
Merge branch 'error-handling' into imp/define-host-error
seanchen1991 Sep 12, 2024
4b36444
fix: remove now unneeded with_packet_receipt
Farhad-Shabani Sep 13, 2024
761959a
fix: revert unintended ack status changes in ICS-20
Farhad-Shabani Sep 13, 2024
80597b0
fix: revert unintended ack status changes in ICS-721
Farhad-Shabani Sep 13, 2024
bd86220
fix: remove unintended tendermint-proto
Farhad-Shabani Sep 13, 2024
ac0e5be
fix: update Cargo.lock for cw-check
Farhad-Shabani Sep 13, 2024
40c24dd
Merge branch 'error-handling' into imp/define-host-error
seanchen1991 Sep 13, 2024
9abffa7
Fix lingering issues from merge conflicts
seanchen1991 Sep 13, 2024
f4d034b
Fix lingering issues from merge conflicts
seanchen1991 Sep 13, 2024
88c8bf8
Remove From<Infallible> for ClientError impl
seanchen1991 Sep 13, 2024
35f7844
cargo fmt
seanchen1991 Sep 13, 2024
126f874
Rename HostError InvalidData and MissingData variants
seanchen1991 Sep 13, 2024
96b4797
Define helper functions for HostError
seanchen1991 Sep 13, 2024
ee93e43
Use newly-define HostError helpers
seanchen1991 Sep 13, 2024
2a53a7d
Remove HostError::AppModule variant
seanchen1991 Sep 13, 2024
a1926e2
Prune some HostError variants
seanchen1991 Sep 13, 2024
3604b3b
Consolidate some HostError variants
seanchen1991 Sep 13, 2024
817fa33
Remove HostError::NonexistentType variant
seanchen1991 Sep 13, 2024
579e817
Remove HostError::UnexpectedState variant
seanchen1991 Sep 13, 2024
6db8f1f
Consolidate HostError::UnknownResource variant
seanchen1991 Sep 13, 2024
33972e0
cargo fmt
seanchen1991 Sep 13, 2024
c5bb0af
Remove unnecessary to_string calls
seanchen1991 Sep 16, 2024
29fbe1c
Revert `pick_version` method's documentation
seanchen1991 Sep 16, 2024
c8ad6e5
Remove some more HostError variants
seanchen1991 Sep 16, 2024
1912395
Remove From<DecodingError> for StatusValue impl
seanchen1991 Sep 16, 2024
d9b0786
Fix AcknowledgementStatus tests
seanchen1991 Sep 16, 2024
63a1e5c
fix: revert errors in ICS721 callbacks
Farhad-Shabani Sep 16, 2024
da81e63
Change references to HandlerError in docs to refer to HostError where…
seanchen1991 Sep 16, 2024
f094b4b
Merge branch 'imp/define-host-error' of https://github.com/cosmos/ibc…
seanchen1991 Sep 16, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Defined a new `HostError` type in ics24 to draw distinction between protocol errors and host errors
([\1320](https://github.com/cosmos/ibc-rs/issues/1320))
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- Modify `validate_self_client` error type to return `ContextError` instead of
`ConnectionError`
([#482](https://github.com/cosmos/ibc-rs/issues/482))
- Modify `validate_self_client` error type to return `HandlerError` instead of
`ConnectionError`
([#482](https://github.com/cosmos/ibc-rs/issues/482))
2 changes: 1 addition & 1 deletion .changelog/v0.33.0/improvement/547-error-strings.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- Fix ContextError Display output
- Fix HandlerError Display output
([#547](https://github.com/cosmos/ibc-rs/issues/547))
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- Allow hosts to handle overflow cases in `increase_*_counter` methods by
returning `Result<(),ContextError>` type.
returning `Result<(),HandlerError>` type.
([#857](https://github.com/cosmos/ibc-rs/issues/857))
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- logger and event emitter methods return `Result<(), ContextError>` type.
- logger and event emitter methods return `Result<(), HandlerError>` type.
([#859](https://github.com/cosmos/ibc-rs/issues/859))
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,9 @@ There are no consensus-breaking changes.
- Bump ibc-proto-rs to v0.34.0
([#790](https://github.com/cosmos/ibc-rs/issues/790))
- Allow hosts to handle overflow cases in `increase_*_counter` methods by
returning `Result<(),ContextError>` type.
returning `Result<(),HandlerError>` type.
([#857](https://github.com/cosmos/ibc-rs/issues/857))
- logger and event emitter methods return `Result<(), ContextError>` type.
- logger and event emitter methods return `Result<(), HandlerError>` type.
([#859](https://github.com/cosmos/ibc-rs/issues/859))
- Bump `ibc-proto-rs` to v0.35.0 along with some other minor dependency updates
([#873](https://github.com/cosmos/ibc-rs/issues/873))
Expand Down Expand Up @@ -1042,7 +1042,7 @@ There are no consensus-breaking changes.

### IMPROVEMENT

- Fix `ContextError` Display output
- Fix `HandlerError` Display output
([#547](https://github.com/cosmos/ibc-rs/issues/547))

## v0.32.0
Expand Down Expand Up @@ -1099,7 +1099,7 @@ There are no consensus-breaking changes.
([#479](https://github.com/cosmos/ibc-rs/issues/479))
- Remove Send + Sync supertraits on the Module trait
([#480](https://github.com/cosmos/ibc-rs/issues/480))
- Modify `validate_self_client` error type to return `ContextError` instead of
- Modify `validate_self_client` error type to return `HandlerError` instead of
`ConnectionError`
([#482](https://github.com/cosmos/ibc-rs/issues/482))

Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/adr-006-upgrade-client-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ supported by `IBC-rs`:
negotiated on connection handshake.
10. (U) Changing parameters that are customizable by relayers like `TrustLevel`
and `TrustingPeriod`, `max_clock_drift`

#### Upgrade Process Step-by-step

An IBC-connected Tendermint chain will take the following steps to completely
Expand Down Expand Up @@ -250,7 +250,7 @@ previous section as mentioned:

1. ```rust
if old_client_state.is_frozen() {
return Err(ContextError::ClientError(ClientError::ClientFrozen {
return Err(HandlerError::ClientError(ClientError::ClientFrozen {
client_id,
}));
}
Expand Down
6 changes: 3 additions & 3 deletions docs/architecture/adr-007-light-client-contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ pub trait ClientExecutionContext: Sized {
/// Called upon successful client creation and update
fn store_client_state(
...
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;

/// Called upon successful client creation and update
fn store_consensus_state(
...
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;
}
```

Expand All @@ -120,7 +120,7 @@ pub trait ValidationContext: Router {
type ClientValidationContext;
type ClientExecutionContext;
/// Enum that can contain a `ConsensusState` object of any supported light client
type AnyConsensusState: ConsensusState<EncodeError = ContextError>;
type AnyConsensusState: ConsensusState<EncodeError = HandlerError>;
/// Enum that can contain a `ClientState` object of any supported light client
type AnyClientState: ClientState<
Self::AnyConsensusState,
Expand Down
42 changes: 21 additions & 21 deletions docs/architecture/adr-010-enable-standalone-ics02-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,26 @@ pub trait ValidationContext {
fn get_client_validation_context(&self) -> &Self::V;

// This method will be removed and replaced by a `ClientStateDecoder` trait that will encapsulate the ability to decode a client state from an `Any`
- fn decode_client_state(&self, client_state: Any) -> Result<Self::AnyClientState, ContextError>;
- fn decode_client_state(&self, client_state: Any) -> Result<Self::AnyClientState, HandlerError>;

- fn client_state(&self, client_id: &ClientId) -> Result<Self::AnyClientState, ContextError>;
- fn client_state(&self, client_id: &ClientId) -> Result<Self::AnyClientState, HandlerError>;

- fn consensus_state(
- &self,
- client_cons_state_path: &ClientConsensusStatePath,
- ) -> Result<Self::AnyConsensusState, ContextError>;
- ) -> Result<Self::AnyConsensusState, HandlerError>;

fn host_consensus_state(
&self,
height: &Height,
- ) -> Result<Self::AnyConsensusState, ContextError>;
+ ) -> Result<Self::HostConsensusState, ContextError>;
- ) -> Result<Self::AnyConsensusState, HandlerError>;
+ ) -> Result<Self::HostConsensusState, HandlerError>;

fn validate_self_client(
&self,
- client_state_of_host_on_counterparty: Any,
+ client_state_of_host_on_counterparty: Self::HostClientState,
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;

... // other methods
}
Expand Down Expand Up @@ -200,18 +200,18 @@ pub trait ClientValidationContext: Sized {
+ type ClientStateRef: ClientStateValidation<Self>;
+ type ConsensusStateRef: ConsensusState;

+ fn client_state(&self, client_id: &ClientId) -> Result<Self::ClientStateRef, ContextError>;
+ fn client_state(&self, client_id: &ClientId) -> Result<Self::ClientStateRef, HandlerError>;

+ fn consensus_state(
+ &self,
+ client_cons_state_path: &ClientConsensusStatePath,
+ ) -> Result<Self::ConsensusStateRef, ContextError>;
+ ) -> Result<Self::ConsensusStateRef, HandlerError>;

fn client_update_meta(
&self,
client_id: &ClientId,
height: &Height,
) -> Result<(Timestamp, Height), ContextError>;
) -> Result<(Timestamp, Height), HandlerError>;
}

pub trait ClientExecutionContext:
Expand All @@ -222,40 +222,40 @@ pub trait ClientExecutionContext:
- type AnyConsensusState: ConsensusState;
+ type ClientStateMut: ClientStateExecution<Self>;

+ fn client_state_mut(&self, client_id: &ClientId) -> Result<Self::ClientStateMut, ContextError> {
+ fn client_state_mut(&self, client_id: &ClientId) -> Result<Self::ClientStateMut, HandlerError> {
+ self.client_state(client_id)
+ }

fn store_client_state(
&mut self,
client_state_path: ClientStatePath,
client_state: Self::ClientStateMut,
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;

fn store_consensus_state(
&mut self,
consensus_state_path: ClientConsensusStatePath,
consensus_state: Self::ConsensusStateRef,
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;

fn delete_consensus_state(
&mut self,
consensus_state_path: ClientConsensusStatePath,
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;

fn store_update_meta(
&mut self,
client_id: ClientId,
height: Height,
host_timestamp: Timestamp,
host_height: Height,
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;

fn delete_update_meta(
&mut self,
client_id: ClientId,
height: Height,
) -> Result<(), ContextError>;
) -> Result<(), HandlerError>;
}
```

Expand Down Expand Up @@ -306,28 +306,28 @@ pub trait ExtClientValidationContext:
+ type ConversionError: ToString;
+ type AnyConsensusState: TryInto<TmConsensusState, Error = Self::ConversionError>;

+ fn host_timestamp(&self) -> Result<Timestamp, ContextError>;
+ fn host_timestamp(&self) -> Result<Timestamp, HandlerError>;

+ fn host_height(&self) -> Result<Height, ContextError>;
+ fn host_height(&self) -> Result<Height, HostError>;

- fn consensus_state(
- &self,
- client_cons_state_path: &ClientConsensusStatePath,
- ) -> Result<Self::AnyConsensusState, ContextError>;
- ) -> Result<Self::AnyConsensusState, HandlerError>;

+ fn consensus_state_heights(&self, client_id: &ClientId) -> Result<Vec<Height>, ContextError>;
+ fn consensus_state_heights(&self, client_id: &ClientId) -> Result<Vec<Height>, HandlerError>;

fn next_consensus_state(
&self,
client_id: &ClientId,
height: &Height,
) -> Result<Option<Self::AnyConsensusState>, ContextError>;
) -> Result<Option<Self::AnyConsensusState>, HandlerError>;

fn prev_consensus_state(
&self,
client_id: &ClientId,
height: &Height,
) -> Result<Option<Self::AnyConsensusState>, ContextError>;
) -> Result<Option<Self::AnyConsensusState>, HandlerError>;
}

-impl<T> ExecutionContext for T where T: CommonContext + ClientExecutionContext {}
Expand Down
24 changes: 12 additions & 12 deletions ibc-apps/ics20-transfer/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Defines the main context traits and IBC module callbacks

use ibc_app_transfer_types::error::TokenTransferError;
use ibc_app_transfer_types::{Memo, PrefixedCoin, PrefixedDenom};
use ibc_core::host::types::error::HostError;
use ibc_core::host::types::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::Signer;
Expand All @@ -11,13 +11,13 @@ pub trait TokenTransferValidationContext {
type AccountId: TryFrom<Signer>;

/// get_port returns the portID for the transfer module.
fn get_port(&self) -> Result<PortId, TokenTransferError>;
fn get_port(&self) -> Result<PortId, HostError>;

/// Returns Ok() if the host chain supports sending coins.
fn can_send_coins(&self) -> Result<(), TokenTransferError>;
fn can_send_coins(&self) -> Result<(), HostError>;

/// Returns Ok() if the host chain supports receiving coins.
fn can_receive_coins(&self) -> Result<(), TokenTransferError>;
fn can_receive_coins(&self) -> Result<(), HostError>;

/// Validates that the tokens can be escrowed successfully.
///
Expand All @@ -30,7 +30,7 @@ pub trait TokenTransferValidationContext {
channel_id: &ChannelId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Validates that the tokens can be unescrowed successfully.
fn unescrow_coins_validate(
Expand All @@ -39,14 +39,14 @@ pub trait TokenTransferValidationContext {
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Validates the receiver account and the coin input
fn mint_coins_validate(
&self,
account: &Self::AccountId,
coin: &PrefixedCoin,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Validates the sender account and the coin input before burning.
///
Expand All @@ -57,7 +57,7 @@ pub trait TokenTransferValidationContext {
account: &Self::AccountId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Returns a hash of the prefixed denom.
/// Implement only if the host chain supports hashed denominations.
Expand All @@ -79,7 +79,7 @@ pub trait TokenTransferExecutionContext: TokenTransferValidationContext {
channel_id: &ChannelId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Executes the unescrow of the tokens in a user account.
fn unescrow_coins_execute(
Expand All @@ -88,14 +88,14 @@ pub trait TokenTransferExecutionContext: TokenTransferValidationContext {
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Executes minting of the tokens in a user account.
fn mint_coins_execute(
&mut self,
account: &Self::AccountId,
coin: &PrefixedCoin,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;

/// Executes burning of the tokens in a user account.
///
Expand All @@ -106,5 +106,5 @@ pub trait TokenTransferExecutionContext: TokenTransferValidationContext {
account: &Self::AccountId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), TokenTransferError>;
) -> Result<(), HostError>;
}
22 changes: 14 additions & 8 deletions ibc-apps/ics20-transfer/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use ibc_app_transfer_types::is_sender_chain_source;
use ibc_app_transfer_types::packet::PacketData;
use ibc_core::channel::types::packet::Packet;
use ibc_core::host::types::error::HostError;
use ibc_core::primitives::prelude::*;
pub use on_recv_packet::*;
pub use send_transfer::*;

Expand All @@ -20,23 +22,25 @@
.sender
.clone()
.try_into()
.map_err(|_| TokenTransferError::FailedToParseAccount)?;
.map_err(|_| HostError::FailedToParse {
description: "invalid signer".to_string(),
})?;

Check warning on line 27 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#L25-L27

Added lines #L25 - L27 were not covered by tests

if is_sender_chain_source(
packet.port_id_on_a.clone(),
packet.chan_id_on_a.clone(),
&data.token.denom,
) {
ctx_a.unescrow_coins_execute(
Ok(ctx_a.unescrow_coins_execute(

Check warning on line 34 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#L34

Added line #L34 was not covered by tests
&sender,
&packet.port_id_on_a,
&packet.chan_id_on_a,
&data.token,
)
)?)

Check warning on line 39 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#L39

Added line #L39 was not covered by tests
}
// mint vouchers back to sender
else {
ctx_a.mint_coins_execute(&sender, &data.token)
Ok(ctx_a.mint_coins_execute(&sender, &data.token)?)

Check warning on line 43 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#L43

Added line #L43 was not covered by tests
}
}

Expand All @@ -49,20 +53,22 @@
.sender
.clone()
.try_into()
.map_err(|_| TokenTransferError::FailedToParseAccount)?;
.map_err(|_| HostError::FailedToParse {
description: "invalid signer".to_string(),
})?;

Check warning on line 58 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#L56-L58

Added lines #L56 - L58 were not covered by tests

if is_sender_chain_source(
packet.port_id_on_a.clone(),
packet.chan_id_on_a.clone(),
&data.token.denom,
) {
ctx_a.unescrow_coins_validate(
Ok(ctx_a.unescrow_coins_validate(

Check warning on line 65 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#L65

Added line #L65 was not covered by tests
&sender,
&packet.port_id_on_a,
&packet.chan_id_on_a,
&data.token,
)
)?)

Check warning on line 70 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#L70

Added line #L70 was not covered by tests
} else {
ctx_a.mint_coins_validate(&sender, &data.token)
Ok(ctx_a.mint_coins_validate(&sender, &data.token)?)

Check warning on line 72 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#L72

Added line #L72 was not covered by tests
}
}
Loading
Loading