From ba596bcd5cf85e91c8a539d0c4ebdbb76f6c473d Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Tue, 9 Apr 2024 15:02:02 +0100 Subject: [PATCH] fixing float cw issue --- Cargo.lock | 12 ++++++------ Cargo.toml | 11 +++++++---- crates/cvm/src/asset.rs | 11 ----------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19b9eca5..7607a519 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -771,7 +771,7 @@ dependencies = [ "ibc-primitives", "ibc-proto 0.42.2", "num", - "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?branch=dz/1)", + "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522)", "parity-scale-codec", "prost", "prost-build", @@ -880,7 +880,7 @@ dependencies = [ "mantis-cw", "no-panic", "num-integer", - "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?branch=dz/1)", + "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522)", "schemars", "serde", "sha2 0.10.8", @@ -2308,7 +2308,7 @@ dependencies = [ "log", "mantis-cw", "ndarray", - "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?branch=dz/1)", + "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522)", "num-traits", "petgraph", "prost-types", @@ -2496,7 +2496,7 @@ dependencies = [ [[package]] name = "num-rational" version = "0.4.1" -source = "git+https://github.com/dzmitry-lahoda-forks/num-rational.git?branch=dz/1#53416ae7af27b7b51740701d6a9e5c54325bf994" +source = "git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522#719b4dbe0afd69b98f5875e3bdf936b9df822522" dependencies = [ "cosmwasm-std", "num-bigint", @@ -2508,9 +2508,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", diff --git a/Cargo.toml b/Cargo.toml index fd66d44a..df4fcb01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,6 @@ env_logger = { version = "0.11.3", default-features = false, features = [ "unstable-kv", ] } hex = { version = "^0.4.3", default-features = false } -num = { version = "^0.4.1", default-features = false } enumn = { version = "0.1.13" } prost-build = { version = "^0.12.2" } bech32 = { version = "^0.11.0", default-features = false } @@ -86,9 +85,13 @@ cw-storage-plus = { version = "^1.2.0", features = [ "iterator", ], default-features = false } itertools = { version = "^0.12.1", default-features = false } -num-integer = { version = "^0.1.46", default-features = false } cw-multi-test = {version = "^1.0.0", default-features = false} -num-rational = {git = "https://github.com/dzmitry-lahoda-forks/num-rational.git", branch = "dz/1", default-features = false} + +num-integer = { version = "^0.1.46", default-features = false } +num-rational = {git = "https://github.com/dzmitry-lahoda-forks/num-rational.git", rev = "719b4dbe0afd69b98f5875e3bdf936b9df822522", default-features = false} +num-traits = { version = "^0.2.18", default-features = false } +num = { version = "^0.4.1", default-features = false } + ibc-proto = { version = "^0.42.2", default-features = false } serde-json-wasm = { version = "^1.0.1", default-features = false } @@ -126,7 +129,7 @@ bip32 = { version = "^0.5.1", default-features = false, features = [ ] } prost-types = { version = "^0.12.3", default-features = false } sha2 = { version = "^0.10.8", default-features = false } -num-traits = { version = "^0.2.17", default-features = false } + thiserror = { version = "^1.0.50", default-features = false, package = "thiserror-core" } # no XCM until it has decent support for cosmwasm and wasm32 std https://github.com/paritytech/polkadot-sdk/pull/1454 # xcm = { version = "^5.0.0", default-features = false, package = "staging-xcm" } diff --git a/crates/cvm/src/asset.rs b/crates/cvm/src/asset.rs index 4fe526ff..25e2f3e8 100644 --- a/crates/cvm/src/asset.rs +++ b/crates/cvm/src/asset.rs @@ -179,17 +179,6 @@ impl Amount { // with rounding to reduce or reduce down part up to some seven bit parts pub const MAX_PARTS: u64 = 1_000_000_000_000_000_000; - #[cfg(feature = "native")] - pub fn try_floor_ratio(value: Ratio) -> Result { - if value < 0.0 || value.is_nan() { - Err(ArithmeticError::Underflow) - } else if value > u128::MAX { - Err(ArithmeticError::Underflow) - } else { - Ok((value as u128).into()) - } - } - pub const fn new(intercept: u128, slope: u64) -> Self { Self { intercept: Displayed(intercept),