diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index 1a28480188..9e02786b70 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -11,9 +11,9 @@ pub struct Coin { } impl Coin { - pub fn new(amount: u128, denom: impl Into) -> Self { + pub fn new(amount: impl Into, denom: impl Into) -> Self { Coin { - amount: Uint128::new(amount), + amount: amount.into(), denom: denom.into(), } } @@ -195,16 +195,16 @@ mod tests { #[test] fn parse_coin() { - let expected = Coin::new(123, "ucosm"); + let expected = Coin::new(123u128, "ucosm"); assert_eq!("123ucosm".parse::().unwrap(), expected); // leading zeroes should be ignored assert_eq!("00123ucosm".parse::().unwrap(), expected); // 0 amount parses correctly - assert_eq!("0ucosm".parse::().unwrap(), Coin::new(0, "ucosm")); + assert_eq!("0ucosm".parse::().unwrap(), Coin::new(0u128, "ucosm")); // ibc denom should work let ibc_str = "11111ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; let ibc_coin = Coin::new( - 11111, + 11111u128, "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", ); assert_eq!(ibc_str.parse::().unwrap(), ibc_coin); @@ -244,7 +244,7 @@ mod tests { #[test] fn debug_coin() { - let coin = Coin::new(123, "ucosm"); + let coin = Coin::new(123u128, "ucosm"); assert_eq!(format!("{coin:?}"), r#"Coin { 123 "ucosm" }"#); } } diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 1ad33e3667..1a732f3e55 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -791,7 +791,7 @@ mod tests { let msg = IbcMsg::Transfer { channel_id: "channel-123".to_string(), to_address: "my-special-addr".into(), - amount: Coin::new(12345678, "uatom"), + amount: Coin::new(12345678u128, "uatom"), timeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(1234567890)), }; let encoded = to_string(&msg).unwrap(); diff --git a/packages/std/src/query/bank.rs b/packages/std/src/query/bank.rs index 95cf616e2a..7980760f4a 100644 --- a/packages/std/src/query/bank.rs +++ b/packages/std/src/query/bank.rs @@ -106,11 +106,11 @@ mod tests { #[test] fn private_constructor_works() { - let response = AllBalanceResponse::new(vec![Coin::new(1234, "uatom")]); + let response = AllBalanceResponse::new(vec![Coin::new(1234u128, "uatom")]); assert_eq!( response, AllBalanceResponse { - amount: vec![Coin::new(1234, "uatom")] + amount: vec![Coin::new(1234u128, "uatom")] } ); }