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

Public PrefixedDenom inner type and add as_str func for BaseDenom #161

Merged
merged 7 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions crates/ibc/src/applications/transfer/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ impl Amount {
pub fn checked_sub(self, rhs: Self) -> Option<Self> {
self.0.checked_sub(rhs.0).map(Self)
}

pub fn as_u256(&self) -> &U256 {
hu55a1n1 marked this conversation as resolved.
Show resolved Hide resolved
&self.0
}
}

impl FromStr for Amount {
Expand Down
14 changes: 14 additions & 0 deletions crates/ibc/src/applications/transfer/denom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ use crate::serializers::serde_string;
#[serde(transparent)]
pub struct BaseDenom(String);

impl BaseDenom {
pub fn as_str(&self) -> &str {
&self.0
}
}

impl FromStr for BaseDenom {
type Err = Error;

Expand Down Expand Up @@ -153,6 +159,14 @@ impl PrefixedDenom {
pub fn add_trace_prefix(&mut self, prefix: TracePrefix) {
self.trace_path.add_prefix(prefix)
}

pub fn trace_path(&self) -> &TracePath {
hu55a1n1 marked this conversation as resolved.
Show resolved Hide resolved
&self.trace_path
}

pub fn base_denom(&self) -> &BaseDenom {
&self.base_denom
}
}

/// Returns true if the denomination originally came from the sender chain and
Expand Down
7 changes: 6 additions & 1 deletion crates/ibc/src/core/ics04_channel/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::packet::Sequence;
use super::timeout::TimeoutHeight;
use crate::applications::transfer::error as transfer_error;
use crate::core::ics02_client::error as client_error;
use crate::core::ics03_connection::error as connection_error;
use crate::core::ics04_channel::channel::State;
Expand All @@ -12,7 +13,7 @@ use crate::signer::SignerError;
use crate::timestamp::Timestamp;
use crate::Height;

use flex_error::{define_error, TraceError};
use flex_error::{define_error, TraceError, DisplayOnly};
use ibc_proto::protobuf::Error as TendermintError;

define_error! {
Expand All @@ -26,6 +27,10 @@ define_error! {
[ port_error::Error ]
| _ | { "ics05 port error" },

Ics20Transfer
plafer marked this conversation as resolved.
Show resolved Hide resolved
[DisplayOnly<transfer_error::Error> ]
| _| { "ics20 transfer error" },

UnknownState
{ state: i32 }
| e | { format_args!("channel state unknown: {}", e.state) },
Expand Down