diff --git a/packages/std/src/coins.rs b/packages/std/src/coins.rs index 1c8c263673..87cda52a65 100644 --- a/packages/std/src/coins.rs +++ b/packages/std/src/coins.rs @@ -52,6 +52,14 @@ impl TryFrom<&[Coin]> for Coins { } } +impl TryFrom<[Coin; N]> for Coins { + type Error = StdError; + + fn try_from(slice: [Coin; N]) -> StdResult { + slice.to_vec().try_into() + } +} + impl TryFrom for Coins { type Error = StdError; @@ -62,6 +70,12 @@ impl TryFrom for Coins { } } +impl From for Vec { + fn from(value: Coins) -> Self { + value.into_vec() + } +} + impl FromStr for Coins { type Err = StdError; @@ -111,6 +125,12 @@ impl fmt::Display for Coins { } } +impl PartialEq for Coins { + fn eq(&self, other: &Coin) -> bool { + self.0.len() == 1 && self.amount_of(&other.denom) == other.amount + } +} + impl Coins { /// Cast to Vec, while NOT consuming the original object pub fn to_vec(&self) -> Vec {