@@ -3,7 +3,7 @@ use core::fmt;
33use core:: str:: FromStr ;
44
55use crate :: prelude:: * ;
6- use crate :: { Coin , CoinsError , OverflowError , OverflowOperation , StdError , StdResult , Uint128 } ;
6+ use crate :: { Coin , CoinsError , OverflowError , OverflowOperation , StdError , StdResult , Uint256 } ;
77
88/// A collection of coins, similar to Cosmos SDK's `sdk.Coins` struct.
99///
@@ -133,11 +133,11 @@ impl Coins {
133133 }
134134
135135 /// Returns the amount of the given denom or zero if the denom is not present.
136- pub fn amount_of ( & self , denom : & str ) -> Uint128 {
136+ pub fn amount_of ( & self , denom : & str ) -> Uint256 {
137137 self . 0
138138 . get ( denom)
139139 . map ( |c| c. amount )
140- . unwrap_or_else ( Uint128 :: zero)
140+ . unwrap_or_else ( Uint256 :: zero)
141141 }
142142
143143 /// Returns the amount of the given denom if and only if this collection contains only
@@ -159,7 +159,7 @@ impl Coins {
159159 /// let coins: Coins = [coin(100, "uatom"), coin(200, "uusd")].try_into().unwrap();
160160 /// assert_eq!(coins.contains_only("uatom"), None);
161161 /// ```
162- pub fn contains_only ( & self , denom : & str ) -> Option < Uint128 > {
162+ pub fn contains_only ( & self , denom : & str ) -> Option < Uint256 > {
163163 if self . len ( ) == 1 {
164164 self . 0 . get ( denom) . map ( |c| c. amount )
165165 } else {
@@ -222,11 +222,11 @@ impl Coins {
222222 ///
223223 /// let uatom = iterator.next().unwrap();
224224 /// assert_eq!(uatom.denom, "uatom");
225- /// assert_eq!(uatom.amount.u128(), 1000);
225+ /// assert_eq!(uatom.amount, Uint256::new( 1000) );
226226 ///
227227 /// let uluna = iterator.next().unwrap();
228228 /// assert_eq!(uluna.denom, "uluna");
229- /// assert_eq!(uluna.amount.u128(), 500);
229+ /// assert_eq!(uluna.amount, Uint256::new( 500) );
230230 ///
231231 /// assert_eq!(iterator.next(), None);
232232 /// ```
@@ -398,14 +398,14 @@ mod tests {
398398 fn handling_zero_amount ( ) {
399399 // create a Vec<Coin> that contains zero amounts
400400 let mut vec = mock_vec ( ) ;
401- vec[ 0 ] . amount = Uint128 :: zero ( ) ;
401+ vec[ 0 ] . amount = Uint256 :: zero ( ) ;
402402
403403 let coins = Coins :: try_from ( vec) . unwrap ( ) ;
404404 assert_eq ! ( coins. len( ) , 2 ) ;
405- assert_ne ! ( coins. amount_of( "ibc/1234ABCD" ) , Uint128 :: zero( ) ) ;
405+ assert_ne ! ( coins. amount_of( "ibc/1234ABCD" ) , Uint256 :: zero( ) ) ;
406406 assert_ne ! (
407407 coins. amount_of( "factory/osmo1234abcd/subdenom" ) ,
408- Uint128 :: zero( )
408+ Uint256 :: zero( )
409409 ) ;
410410
411411 // adding a coin with zero amount should not be added
@@ -432,15 +432,15 @@ mod tests {
432432 // existing denom
433433 coins. add ( coin ( 12345 , "uatom" ) ) . unwrap ( ) ;
434434 assert_eq ! ( coins. len( ) , 3 ) ;
435- assert_eq ! ( coins. amount_of( "uatom" ) . u128 ( ) , 24690 ) ;
435+ assert_eq ! ( coins. amount_of( "uatom" ) , Uint256 :: new ( 24690 ) ) ;
436436
437437 // new denom
438438 coins. add ( coin ( 123 , "uusd" ) ) . unwrap ( ) ;
439439 assert_eq ! ( coins. len( ) , 4 ) ;
440440
441441 // zero amount
442442 coins. add ( coin ( 0 , "uusd" ) ) . unwrap ( ) ;
443- assert_eq ! ( coins. amount_of( "uusd" ) . u128 ( ) , 123 ) ;
443+ assert_eq ! ( coins. amount_of( "uusd" ) , Uint256 :: new ( 123 ) ) ;
444444
445445 // zero amount, new denom
446446 coins. add ( coin ( 0 , "utest" ) ) . unwrap ( ) ;
@@ -462,7 +462,7 @@ mod tests {
462462 // partial sub
463463 coins. sub ( coin ( 1 , "uatom" ) ) . unwrap ( ) ;
464464 assert_eq ! ( coins. len( ) , 1 ) ;
465- assert_eq ! ( coins. amount_of( "uatom" ) . u128 ( ) , 12344 ) ;
465+ assert_eq ! ( coins. amount_of( "uatom" ) , Uint256 :: new ( 12344 ) ) ;
466466
467467 // full sub
468468 coins. sub ( coin ( 12344 , "uatom" ) ) . unwrap ( ) ;
@@ -476,7 +476,7 @@ mod tests {
476476 // sub zero, non-existent denom
477477 coins. sub ( coin ( 0 , "uatom" ) ) . unwrap ( ) ;
478478 assert_eq ! ( coins. len( ) , 1 ) ;
479- assert_eq ! ( coins. amount_of( "uatom" ) . u128 ( ) , 12345 ) ;
479+ assert_eq ! ( coins. amount_of( "uatom" ) , Uint256 :: new ( 12345 ) ) ;
480480 }
481481
482482 #[ test]
@@ -488,7 +488,7 @@ mod tests {
488488 // happy path
489489 let coins = Coins :: from ( coin ( 12345 , "uatom" ) ) ;
490490 assert_eq ! ( coins. len( ) , 1 ) ;
491- assert_eq ! ( coins. amount_of( "uatom" ) . u128 ( ) , 12345 ) ;
491+ assert_eq ! ( coins. amount_of( "uatom" ) , Uint256 :: new ( 12345 ) ) ;
492492 }
493493
494494 #[ test]
@@ -524,6 +524,6 @@ mod tests {
524524 . eq( coins. to_vec( ) . iter( ) . map( |c| & c. denom) ) ) ;
525525
526526 // can still use the coins afterwards
527- assert_eq ! ( coins. amount_of( "uatom" ) . u128 ( ) , 12345 ) ;
527+ assert_eq ! ( coins. amount_of( "uatom" ) , Uint256 :: new ( 12345 ) ) ;
528528 }
529529}
0 commit comments