File tree Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ and this project adheres to
46
46
- cosmwasm-std: ` Uint256::new ` /` Uint512::new ` now take an ` u128 ` argument
47
47
instead of bytes. Use ` ::from_be_bytes ` if you need the old behaviour.
48
48
([ #2367 ] )
49
+ - cosmwasm-std: Deprecate ` {Decimal,Decimal256}::raw ` and
50
+ ` {SignedDecimal,SignedDecimal256}::raw ` in favour of e.g.
51
+ ` Decimal::new(Uint128::new(value)) ` . ([ #2399 ] )
49
52
50
53
## Fixed
51
54
@@ -68,6 +71,7 @@ and this project adheres to
68
71
[ #2378 ] : https://github.com/CosmWasm/cosmwasm/issues/2378
69
72
[ #2383 ] : https://github.com/CosmWasm/cosmwasm/issues/2383
70
73
[ #2390 ] : https://github.com/CosmWasm/cosmwasm/issues/2390
74
+ [ #2399 ] : https://github.com/CosmWasm/cosmwasm/pull/2399
71
75
72
76
## [ 2.2.0] - 2024-12-17
73
77
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ impl Decimal {
59
59
60
60
/// Creates a Decimal(Uint128(value))
61
61
/// This is equivalent to `Decimal::from_atomics(value, 18)` but usable in a const context.
62
+ #[ deprecated(
63
+ since = "3.0.0" ,
64
+ note = "Use Decimal::new(Uint128::new(value)) instead"
65
+ ) ]
62
66
pub const fn raw ( value : u128 ) -> Self {
63
67
Self ( Uint128 :: new ( value) )
64
68
}
@@ -805,6 +809,7 @@ mod tests {
805
809
}
806
810
807
811
#[ test]
812
+ #[ allow( deprecated) ]
808
813
fn decimal_raw ( ) {
809
814
let value = 300u128 ;
810
815
assert_eq ! ( Decimal :: raw( value) . 0 . u128 ( ) , value) ;
@@ -867,7 +872,7 @@ mod tests {
867
872
fn decimal_try_from_signed_works ( ) {
868
873
assert_eq ! (
869
874
Decimal :: try_from( SignedDecimal :: MAX ) . unwrap( ) ,
870
- Decimal :: raw ( SignedDecimal :: MAX . atomics( ) . i128 ( ) as u128 )
875
+ Decimal :: new ( Uint128 :: new ( SignedDecimal :: MAX . atomics( ) . i128 ( ) as u128 ) )
871
876
) ;
872
877
assert_eq ! (
873
878
Decimal :: try_from( SignedDecimal :: zero( ) ) . unwrap( ) ,
Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ impl Decimal256 {
64
64
65
65
/// Creates a Decimal256 from u128
66
66
/// This is equivalent to `Decimal256::from_atomics(value, 18)` but usable in a const context.
67
+ #[ deprecated(
68
+ since = "3.0.0" ,
69
+ note = "Use Decimal256::new(Uint256::new(value)) instead"
70
+ ) ]
67
71
pub const fn raw ( value : u128 ) -> Self {
68
72
Self ( Uint256 :: from_u128 ( value) )
69
73
}
@@ -808,6 +812,7 @@ mod tests {
808
812
}
809
813
810
814
#[ test]
815
+ #[ allow( deprecated) ]
811
816
fn decimal256_raw ( ) {
812
817
let value = 300u128 ;
813
818
let expected = Uint256 :: from ( value) ;
Original file line number Diff line number Diff line change @@ -86,6 +86,10 @@ impl SignedDecimal {
86
86
/// # use cosmwasm_std::SignedDecimal;
87
87
/// assert_eq!(SignedDecimal::raw(1234i128).to_string(), "0.000000000000001234");
88
88
/// ```
89
+ #[ deprecated(
90
+ since = "3.0.0" ,
91
+ note = "Use SignedDecimal::new(Int128::new(value)) instead"
92
+ ) ]
89
93
pub const fn raw ( value : i128 ) -> Self {
90
94
Self ( Int128 :: new ( value) )
91
95
}
@@ -910,6 +914,8 @@ impl de::Visitor<'_> for SignedDecimalVisitor {
910
914
911
915
#[ cfg( test) ]
912
916
mod tests {
917
+ use crate :: Uint128 ;
918
+
913
919
use super :: * ;
914
920
915
921
use alloc:: vec:: Vec ;
@@ -928,6 +934,7 @@ mod tests {
928
934
}
929
935
930
936
#[ test]
937
+ #[ allow( deprecated) ]
931
938
fn signed_decimal_raw ( ) {
932
939
let value = 300i128 ;
933
940
assert_eq ! ( SignedDecimal :: raw( value) . 0 . i128 ( ) , value) ;
@@ -1461,8 +1468,8 @@ mod tests {
1461
1468
SignedDecimal :: try_from( Decimal :: MAX ) . unwrap_err( ) ,
1462
1469
SignedDecimalRangeExceeded
1463
1470
) ;
1464
- let max = Decimal :: raw ( SignedDecimal :: MAX . atomics ( ) . i128 ( ) as u128 ) ;
1465
- let too_big = max + Decimal :: raw ( 1 ) ;
1471
+ let max = Decimal :: new ( Uint128 :: new ( SignedDecimal :: MAX . atomics ( ) . i128 ( ) as u128 ) ) ;
1472
+ let too_big = max + Decimal :: new ( Uint128 :: one ( ) ) ;
1466
1473
assert_eq ! (
1467
1474
SignedDecimal :: try_from( too_big) . unwrap_err( ) ,
1468
1475
SignedDecimalRangeExceeded
Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ impl SignedDecimal256 {
98
98
/// # use cosmwasm_std::SignedDecimal256;
99
99
/// assert_eq!(SignedDecimal256::raw(1234i128).to_string(), "0.000000000000001234");
100
100
/// ```
101
+ #[ deprecated(
102
+ since = "3.0.0" ,
103
+ note = "Use SignedDecimal256::new(Int256::new(value)) instead"
104
+ ) ]
101
105
pub const fn raw ( value : i128 ) -> Self {
102
106
Self ( Int256 :: from_i128 ( value) )
103
107
}
@@ -936,6 +940,7 @@ mod tests {
936
940
}
937
941
938
942
#[ test]
943
+ #[ allow( deprecated) ]
939
944
fn signed_decimal_256_raw ( ) {
940
945
let value = 300i128 ;
941
946
assert_eq ! ( SignedDecimal256 :: raw( value) . 0 , Int256 :: from( value) ) ;
You can’t perform that action at this time.
0 commit comments