From a221e220e199dedad79bfdfa45c6f7d68edfcc60 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 18:01:58 +0100 Subject: [PATCH 01/42] Move types to `cosmwasm-core` --- Cargo.lock | 82 +++- README.md | 4 + packages/core/Cargo.toml | 21 + packages/core/src/__internal.rs | 13 + packages/{std => core}/src/binary.rs | 28 +- .../{std => core}/src/errors/backtrace.rs | 10 +- packages/core/src/errors/core_error.rs | 359 ++++++++++++++++++ packages/core/src/errors/mod.rs | 11 + packages/{std => core}/src/forward_ref.rs | 3 + packages/core/src/lib.rs | 35 ++ packages/{std => core}/src/math/conversion.rs | 0 packages/{std => core}/src/math/decimal.rs | 64 ++-- packages/{std => core}/src/math/decimal256.rs | 81 ++-- packages/{std => core}/src/math/fraction.rs | 0 packages/{std => core}/src/math/int128.rs | 19 +- packages/{std => core}/src/math/int256.rs | 19 +- packages/{std => core}/src/math/int512.rs | 17 +- packages/{std => core}/src/math/int64.rs | 19 +- packages/{std => core}/src/math/isqrt.rs | 0 packages/{std => core}/src/math/mod.rs | 0 packages/{std => core}/src/math/num_consts.rs | 0 .../{std => core}/src/math/signed_decimal.rs | 54 +-- .../src/math/signed_decimal_256.rs | 58 +-- packages/{std => core}/src/math/uint128.rs | 19 +- packages/{std => core}/src/math/uint256.rs | 23 +- packages/{std => core}/src/math/uint512.rs | 17 +- packages/{std => core}/src/math/uint64.rs | 17 +- packages/{std => core}/src/serde.rs | 26 +- .../{std => core}/src/testing/assertions.rs | 8 +- packages/core/src/testing/mod.rs | 5 + packages/std/Cargo.toml | 5 +- packages/std/src/addresses.rs | 6 +- packages/std/src/coin.rs | 3 +- packages/std/src/errors/mod.rs | 12 +- packages/std/src/errors/std_error.rs | 172 +++------ packages/std/src/ibc.rs | 5 +- packages/std/src/lib.rs | 16 +- packages/std/src/results/contract_result.rs | 16 +- packages/std/src/results/cosmos_msg.rs | 3 +- packages/std/src/results/empty.rs | 2 +- packages/std/src/results/query.rs | 4 +- packages/std/src/results/submessages.rs | 12 +- packages/std/src/stdack.rs | 2 +- packages/std/src/testing/mock.rs | 4 +- packages/std/src/testing/mod.rs | 5 +- packages/std/src/timestamp.rs | 2 +- packages/std/src/traits.rs | 5 +- 47 files changed, 854 insertions(+), 432 deletions(-) create mode 100644 packages/core/src/__internal.rs rename packages/{std => core}/src/binary.rs (94%) rename packages/{std => core}/src/errors/backtrace.rs (91%) create mode 100644 packages/core/src/errors/core_error.rs create mode 100644 packages/core/src/errors/mod.rs rename packages/{std => core}/src/forward_ref.rs (88%) rename packages/{std => core}/src/math/conversion.rs (100%) rename packages/{std => core}/src/math/decimal.rs (97%) rename packages/{std => core}/src/math/decimal256.rs (96%) rename packages/{std => core}/src/math/fraction.rs (100%) rename packages/{std => core}/src/math/int128.rs (98%) rename packages/{std => core}/src/math/int256.rs (98%) rename packages/{std => core}/src/math/int512.rs (99%) rename packages/{std => core}/src/math/int64.rs (98%) rename packages/{std => core}/src/math/isqrt.rs (100%) rename packages/{std => core}/src/math/mod.rs (100%) rename packages/{std => core}/src/math/num_consts.rs (100%) rename packages/{std => core}/src/math/signed_decimal.rs (98%) rename packages/{std => core}/src/math/signed_decimal_256.rs (98%) rename packages/{std => core}/src/math/uint128.rs (98%) rename packages/{std => core}/src/math/uint256.rs (99%) rename packages/{std => core}/src/math/uint512.rs (98%) rename packages/{std => core}/src/math/uint64.rs (98%) rename packages/{std => core}/src/serde.rs (86%) rename packages/{std => core}/src/testing/assertions.rs (97%) create mode 100644 packages/core/src/testing/mod.rs diff --git a/Cargo.lock b/Cargo.lock index cdb687df18..75649ffdd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,6 +174,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.0" @@ -227,9 +233,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.11.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" [[package]] name = "bstr" @@ -423,6 +429,17 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" +dependencies = [ + "base64 0.21.7", + "bnum", + "crc32fast", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] [[package]] name = "cosmwasm-crypto" @@ -483,16 +500,15 @@ dependencies = [ name = "cosmwasm-std" version = "2.0.1" dependencies = [ - "base64", + "base64 0.22.0", "bech32", - "bnum", "chrono", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "cosmwasm-schema", "crc32fast", "derivative", - "forward_ref", "hex", "hex-literal", "schemars", @@ -500,7 +516,6 @@ dependencies = [ "serde-json-wasm", "serde_json", "sha2", - "static_assertions", "thiserror", ] @@ -632,9 +647,9 @@ checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -846,6 +861,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.55", + "unicode-xid", +] + [[package]] name = "dhat" version = "0.3.3" @@ -1963,9 +1999,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1975,9 +2011,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -2025,9 +2061,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -2054,9 +2090,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", @@ -2265,18 +2301,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", @@ -2392,6 +2428,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "utf8parse" version = "0.2.1" diff --git a/README.md b/README.md index 9338f6653f..a4b7db8973 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ The following packages are maintained here: | cosmwasm-crypto | Internal only | [![cosmwasm-crypto on crates.io](https://img.shields.io/crates/v/cosmwasm-crypto.svg)](https://crates.io/crates/cosmwasm-crypto) | [![Docs](https://docs.rs/cosmwasm-crypto/badge.svg)](https://docs.rs/cosmwasm-crypto) | [![Coverage][cov-badge-crypto]][cov-link-crypto] | | cosmwasm-derive | Internal only | [![cosmwasm-derive on crates.io](https://img.shields.io/crates/v/cosmwasm-derive.svg)](https://crates.io/crates/cosmwasm-derive) | [![Docs](https://docs.rs/cosmwasm-derive/badge.svg)](https://docs.rs/cosmwasm-derive) | [![Coverage][cov-badge-derive]][cov-link-derive] | | cosmwasm-schema | Contract development | [![cosmwasm-schema on crates.io](https://img.shields.io/crates/v/cosmwasm-schema.svg)](https://crates.io/crates/cosmwasm-schema) | [![Docs](https://docs.rs/cosmwasm-schema/badge.svg)](https://docs.rs/cosmwasm-schema) | [![Coverage][cov-badge-schema]][cov-link-schema] | +| cosmwasm-core | Contract development | [![cosmwasm-core on crates.io](https://img.shields.io/crates/v/cosmwasm-core.svg)](https://crates.io/crates/cosmwasm-core) | [![Docs](https://docs.rs/cosmwasm-core/badge.svg)](https://docs.rs/cosmwasm-core) | [![Coverage][cov-badge-core]][cov-link-core] | | cosmwasm-std | Contract development | [![cosmwasm-std on crates.io](https://img.shields.io/crates/v/cosmwasm-std.svg)](https://crates.io/crates/cosmwasm-std) | [![Docs](https://docs.rs/cosmwasm-std/badge.svg)](https://docs.rs/cosmwasm-std) | [![Coverage][cov-badge-std]][cov-link-std] | | cosmwasm-vm | Host environments | [![cosmwasm-vm on crates.io](https://img.shields.io/crates/v/cosmwasm-vm.svg)](https://crates.io/crates/cosmwasm-vm) | [![Docs](https://docs.rs/cosmwasm-vm/badge.svg)](https://docs.rs/cosmwasm-vm) | [![Coverage][cov-badge-vm]][cov-link-vm] | | cosmwasm-check | Contract development | [![cosmwasm-check on crates.io](https://img.shields.io/crates/v/cosmwasm-check.svg)](https://crates.io/crates/cosmwasm-check) | `cosmwasm-check -h` | N/A | @@ -27,6 +28,8 @@ maintained and has been dropped in favor of https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-derive [cov-badge-schema]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-schema +[cov-badge-core]: + https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-core [cov-badge-std]: https://codecov.io/gh/CosmWasm/cosmwasm/branch/main/graph/badge.svg?flag=cosmwasm-std [cov-badge-vm]: @@ -37,6 +40,7 @@ maintained and has been dropped in favor of https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/derive [cov-link-schema]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/schema +[cov-link-core]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/core [cov-link-std]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/std [cov-link-vm]: https://codecov.io/gh/CosmWasm/cosmwasm/tree/main/packages/vm diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 2de1ec3e3f..d7ccaa8007 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -11,3 +11,24 @@ readme = "README.md" release = false [dependencies] +base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } +bnum = "0.10.0" +crc32fast = { version = "1.4.0", optional = true, default-features = false } +derive_more = { version = "1.0.0-beta.6", features = ["display", "from"] } +forward_ref = "1.0.0" +schemars = { version = "0.8.16", optional = true } +serde = { version = "1.0.197", default-features = false, features = ["derive"] } +serde-json-wasm = { version = "1.0.1", default-features = false } +static_assertions = "1.1.0" + +[features] +#default = ["std"] +std = ["dep:schemars"] +# Expose things that are usually gated behind `#[cfg(test)]` inside the `testing` module +# (do NOT use in production please. Or I will cry.) +# +# Also this is semver exempt. Beware here be dragons. +testing = ["dep:crc32fast"] + +[dev-dependencies] +crc32fast = { version = "1.4.0", default-features = false } diff --git a/packages/core/src/__internal.rs b/packages/core/src/__internal.rs new file mode 100644 index 0000000000..e42d2f7e79 --- /dev/null +++ b/packages/core/src/__internal.rs @@ -0,0 +1,13 @@ +//! +//! # ⚠ DO NOT DEPEND ON THIS AS AN OUTSIDE CONSUMER +//! +//! Module for re-exporting implementation details from `core` to `std` +//! + +pub mod errors { + pub use crate::errors::*; +} + +pub mod backtrace { + pub use crate::errors::backtrace::*; +} diff --git a/packages/std/src/binary.rs b/packages/core/src/binary.rs similarity index 94% rename from packages/std/src/binary.rs rename to packages/core/src/binary.rs index 48498b78be..42d16883a4 100644 --- a/packages/std/src/binary.rs +++ b/packages/core/src/binary.rs @@ -2,19 +2,18 @@ use core::fmt; use core::ops::Deref; use base64::engine::{Engine, GeneralPurpose}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{StdError, StdResult}; -use crate::prelude::*; +use crate::errors::{CoreError, CoreResult}; /// Binary is a wrapper around Vec to add base64 de/serialization /// with serde. It also adds some helper methods to help encode inline. /// /// This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. /// See also . -#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, JsonSchema)] -pub struct Binary(#[schemars(with = "String")] Vec); +#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Binary(#[cfg_attr(feature = "std", schemars(with = "String"))] Vec); impl Binary { /// Base64 encoding engine used in conversion to/from base64. @@ -34,11 +33,11 @@ impl Binary { /// take an (untrusted) string and decode it into bytes. /// fails if it is not valid base64 - pub fn from_base64(encoded: &str) -> StdResult { + pub fn from_base64(encoded: &str) -> CoreResult { Self::B64_ENGINE .decode(encoded.as_bytes()) .map(Binary::from) - .map_err(StdError::invalid_base64) + .map_err(CoreError::invalid_base64) } /// encode to base64 string (guaranteed to be success as we control the data inside). @@ -72,9 +71,9 @@ impl Binary { /// let num = u64::from_be_bytes(binary.to_array().unwrap()); /// assert_eq!(num, 10045108015024774967); /// ``` - pub fn to_array(&self) -> StdResult<[u8; LENGTH]> { + pub fn to_array(&self) -> CoreResult<[u8; LENGTH]> { if self.len() != LENGTH { - return Err(StdError::invalid_data_size(LENGTH, self.len())); + return Err(CoreError::invalid_data_size(LENGTH, self.len())); } let mut out: [u8; LENGTH] = [0; LENGTH]; @@ -249,7 +248,7 @@ impl<'de> de::Visitor<'de> for Base64Visitor { { match Binary::from_base64(v) { Ok(binary) => Ok(binary), - Err(_) => Err(E::custom(format!("invalid base64: {v}"))), + Err(_) => Err(E::custom(format_args!("invalid base64: {v}"))), } } } @@ -258,6 +257,7 @@ impl<'de> de::Visitor<'de> for Base64Visitor { mod tests { use super::*; use crate::assert_hash_works; + use crate::errors::CoreError; use crate::serde::{from_json, to_json_vec}; #[test] @@ -276,7 +276,7 @@ mod tests { let binary = Binary::from(&[1, 2, 3]); let error = binary.to_array::<8>().unwrap_err(); match error { - StdError::InvalidDataSize { + CoreError::InvalidDataSize { expected, actual, .. } => { assert_eq!(expected, 8); @@ -331,11 +331,11 @@ mod tests { #[test] fn test_base64_encoding_error() { for (invalid_base64, want) in [ - ("cm%uZG9taVo", "Invalid symbol 37, offset 2."), - ("cmFuZ", "Invalid input length: 5"), + ("cm%uZG9taVo", "Invalid byte 37, offset 2."), + ("cmFuZ", "Encoded text cannot have a 6-bit remainder."), ] { match Binary::from_base64(invalid_base64) { - Err(StdError::InvalidBase64 { msg, .. }) => assert_eq!(want, msg), + Err(CoreError::InvalidBase64 { msg, .. }) => assert_eq!(want, msg), result => panic!("Unexpected result: {result:?}"), } } diff --git a/packages/std/src/errors/backtrace.rs b/packages/core/src/errors/backtrace.rs similarity index 91% rename from packages/std/src/errors/backtrace.rs rename to packages/core/src/errors/backtrace.rs index 7575a1f406..31df716946 100644 --- a/packages/std/src/errors/backtrace.rs +++ b/packages/core/src/errors/backtrace.rs @@ -1,7 +1,5 @@ use core::fmt::{Debug, Display, Formatter, Result}; -use crate::prelude::*; - /// This wraps an actual backtrace to achieve two things: /// - being able to fill this with a stub implementation in `no_std` environments /// - being able to use this in conjunction with [`thiserror::Error`] @@ -59,19 +57,21 @@ impl Display for Stub { /// the target error has a `backtrace` field. /// This is meant as a replacement for `thiserror`'s `#[from]` attribute, which does not /// work with our custom backtrace wrapper. -macro_rules! impl_from_err { +#[macro_export] +#[doc(hidden)] +macro_rules! __internal__impl_from_err { ($from:ty, $to:ty, $map:path) => { impl From<$from> for $to { fn from(err: $from) -> Self { $map { source: err, - backtrace: $crate::errors::backtrace::BT::capture(), + backtrace: $crate::__internal::backtrace::BT::capture(), } } } }; } -pub(crate) use impl_from_err; +pub use __internal__impl_from_err as impl_from_err; #[cfg(test)] mod tests { diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs new file mode 100644 index 0000000000..82adb1adfc --- /dev/null +++ b/packages/core/src/errors/core_error.rs @@ -0,0 +1,359 @@ +use derive_more::{Display, From}; + +use super::backtrace::{impl_from_err, BT}; + +#[derive(Display, Debug)] +#[non_exhaustive] +pub enum CoreError { + /// Whenever there is no specific error type available + #[display("Generic error: {msg}")] + GenericErr { msg: String, backtrace: BT }, + #[display("Invalid Base64 string: {msg}")] + InvalidBase64 { msg: String, backtrace: BT }, + #[display("Invalid data size: expected={expected} actual={actual}")] + InvalidDataSize { + expected: u64, + actual: u64, + backtrace: BT, + }, + #[display("Error parsing into type {target_type}: {msg}")] + ParseErr { + /// the target type that was attempted + target_type: String, + msg: String, + backtrace: BT, + }, + #[display("Error serializing type {source_type}: {msg}")] + SerializeErr { + /// the source type that was attempted + source_type: String, + msg: String, + backtrace: BT, + }, + #[display("Overflow: {source}")] + Overflow { + source: OverflowError, + backtrace: BT, + }, + #[display("Divide by zero: {source}")] + DivideByZero { + source: DivideByZeroError, + backtrace: BT, + }, + #[display("Conversion error: ")] + ConversionOverflow { + source: ConversionOverflowError, + backtrace: BT, + }, +} + +#[cfg(feature = "std")] +impl std::error::Error for CoreError {} + +impl_from_err!( + ConversionOverflowError, + CoreError, + CoreError::ConversionOverflow +); + +impl CoreError { + pub fn generic_err(msg: impl Into) -> Self { + CoreError::GenericErr { + msg: msg.into(), + backtrace: BT::capture(), + } + } + + pub fn invalid_base64(msg: impl ToString) -> Self { + CoreError::InvalidBase64 { + msg: msg.to_string(), + backtrace: BT::capture(), + } + } + + pub fn invalid_data_size(expected: usize, actual: usize) -> Self { + CoreError::InvalidDataSize { + // Cast is safe because usize is 32 or 64 bit large in all environments we support + expected: expected as u64, + actual: actual as u64, + backtrace: BT::capture(), + } + } + + pub fn parse_err(target: impl Into, msg: impl ToString) -> Self { + CoreError::ParseErr { + target_type: target.into(), + msg: msg.to_string(), + backtrace: BT::capture(), + } + } + + pub fn serialize_err(source: impl Into, msg: impl ToString) -> Self { + CoreError::SerializeErr { + source_type: source.into(), + msg: msg.to_string(), + backtrace: BT::capture(), + } + } + + pub fn overflow(source: OverflowError) -> Self { + CoreError::Overflow { + source, + backtrace: BT::capture(), + } + } + + pub fn divide_by_zero(source: DivideByZeroError) -> Self { + CoreError::DivideByZero { + source, + backtrace: BT::capture(), + } + } +} + +impl PartialEq for CoreError { + fn eq(&self, rhs: &CoreError) -> bool { + match self { + CoreError::GenericErr { msg, backtrace: _ } => { + if let CoreError::GenericErr { + msg: rhs_msg, + backtrace: _, + } = rhs + { + msg == rhs_msg + } else { + false + } + } + CoreError::InvalidBase64 { msg, backtrace: _ } => { + if let CoreError::InvalidBase64 { + msg: rhs_msg, + backtrace: _, + } = rhs + { + msg == rhs_msg + } else { + false + } + } + CoreError::InvalidDataSize { + expected, + actual, + backtrace: _, + } => { + if let CoreError::InvalidDataSize { + expected: rhs_expected, + actual: rhs_actual, + backtrace: _, + } = rhs + { + expected == rhs_expected && actual == rhs_actual + } else { + false + } + } + CoreError::ParseErr { + target_type, + msg, + backtrace: _, + } => { + if let CoreError::ParseErr { + target_type: rhs_target_type, + msg: rhs_msg, + backtrace: _, + } = rhs + { + target_type == rhs_target_type && msg == rhs_msg + } else { + false + } + } + CoreError::SerializeErr { + source_type, + msg, + backtrace: _, + } => { + if let CoreError::SerializeErr { + source_type: rhs_source_type, + msg: rhs_msg, + backtrace: _, + } = rhs + { + source_type == rhs_source_type && msg == rhs_msg + } else { + false + } + } + CoreError::Overflow { + source, + backtrace: _, + } => { + if let CoreError::Overflow { + source: rhs_source, + backtrace: _, + } = rhs + { + source == rhs_source + } else { + false + } + } + CoreError::DivideByZero { + source, + backtrace: _, + } => { + if let CoreError::DivideByZero { + source: rhs_source, + backtrace: _, + } = rhs + { + source == rhs_source + } else { + false + } + } + CoreError::ConversionOverflow { + source, + backtrace: _, + } => { + if let CoreError::ConversionOverflow { + source: rhs_source, + backtrace: _, + } = rhs + { + source == rhs_source + } else { + false + } + } + } + } +} + +#[derive(Display, Debug, PartialEq, Eq)] +pub enum OverflowOperation { + Add, + Sub, + Mul, + Pow, + Shr, + Shl, +} + +#[derive(Display, Debug, PartialEq, Eq)] +#[display("Cannot {operation} with given operands")] +pub struct OverflowError { + pub operation: OverflowOperation, +} + +impl OverflowError { + pub fn new(operation: OverflowOperation) -> Self { + Self { operation } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for OverflowError {} + +/// The error returned by [`TryFrom`] conversions that overflow, for example +/// when converting from [`Uint256`] to [`Uint128`]. +/// +/// [`TryFrom`]: core::convert::TryFrom +/// [`Uint256`]: crate::Uint256 +/// [`Uint128`]: crate::Uint128 +#[derive(Display, Debug, PartialEq, Eq)] +#[display("Error converting {source_type} to {target_type}")] +pub struct ConversionOverflowError { + pub source_type: &'static str, + pub target_type: &'static str, +} + +impl ConversionOverflowError { + pub fn new(source_type: &'static str, target_type: &'static str) -> Self { + Self { + source_type, + target_type, + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ConversionOverflowError {} + +#[derive(Display, Debug, Default, PartialEq, Eq)] +#[display("Cannot divide by zero")] +pub struct DivideByZeroError; + +impl DivideByZeroError { + pub fn new() -> Self { + Self + } +} + +#[cfg(feature = "std")] +impl std::error::Error for DivideByZeroError {} + +#[derive(Display, Debug, PartialEq, Eq)] +pub enum DivisionError { + #[display("Divide by zero")] + DivideByZero, + + #[display("Overflow in division")] + Overflow, +} + +#[cfg(feature = "std")] +impl std::error::Error for DivisionError {} + +#[derive(Display, Debug, From, PartialEq, Eq)] +pub enum CheckedMultiplyFractionError { + #[display("{_0}")] + DivideByZero(#[from] DivideByZeroError), + + #[display("{_0}")] + ConversionOverflow(#[from] ConversionOverflowError), + + #[display("{_0}")] + Overflow(#[from] OverflowError), +} + +#[cfg(feature = "std")] +impl std::error::Error for CheckedMultiplyFractionError {} + +#[derive(Display, Debug, PartialEq, Eq)] +pub enum CheckedMultiplyRatioError { + #[display("Denominator must not be zero")] + DivideByZero, + + #[display("Multiplication overflow")] + Overflow, +} + +#[cfg(feature = "std")] +impl std::error::Error for CheckedMultiplyRatioError {} + +#[derive(Display, Debug, PartialEq, Eq)] +pub enum CheckedFromRatioError { + #[display("Denominator must not be zero")] + DivideByZero, + + #[display("Overflow")] + Overflow, +} + +#[cfg(feature = "std")] +impl std::error::Error for CheckedFromRatioError {} + +#[derive(Display, Debug, PartialEq, Eq)] +#[display("Round up operation failed because of overflow")] +pub struct RoundUpOverflowError; + +#[cfg(feature = "std")] +impl std::error::Error for RoundUpOverflowError {} + +#[derive(Display, Debug, PartialEq, Eq)] +#[display("Round down operation failed because of overflow")] +pub struct RoundDownOverflowError; + +#[cfg(feature = "std")] +impl std::error::Error for RoundDownOverflowError {} diff --git a/packages/core/src/errors/mod.rs b/packages/core/src/errors/mod.rs new file mode 100644 index 0000000000..589f5ee70d --- /dev/null +++ b/packages/core/src/errors/mod.rs @@ -0,0 +1,11 @@ +mod core_error; + +pub(crate) mod backtrace; + +pub type CoreResult = core::result::Result; + +pub use core_error::{ + CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, + ConversionOverflowError, CoreError, DivideByZeroError, DivisionError, OverflowError, + OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, +}; diff --git a/packages/std/src/forward_ref.rs b/packages/core/src/forward_ref.rs similarity index 88% rename from packages/std/src/forward_ref.rs rename to packages/core/src/forward_ref.rs index 16385fbc97..1a71ecc3eb 100644 --- a/packages/std/src/forward_ref.rs +++ b/packages/core/src/forward_ref.rs @@ -1,8 +1,11 @@ +/// # ⚠ THIS IS AN INTERNAL IMPLEMENTATION DETAIL. DO NOT USE. +/// /// Given an implementation of `T == U`, implements: /// - `&T == U` /// - `T == &U` /// /// We don't need to add `&T == &U` here because this is implemented automatically. +#[doc(hidden)] #[macro_export] macro_rules! forward_ref_partial_eq { ($t:ty, $u:ty) => { diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 5af8387c67..b9d90b59ad 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -1,3 +1,38 @@ //! cosmwasm-core contains components of cosmwasm-std that can be used in a no_std environment. //! All symbols are re-exported by cosmwasm-std, such that contract developers don't need to //! add this dependency directly. It is recommended to only use cosmwasm-std whenever possible. + +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; + +mod binary; +mod errors; +mod forward_ref; +mod math; +mod serde; + +#[doc(hidden)] +pub mod __internal; + +pub use crate::binary::Binary; +pub use crate::errors::{ + CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, + ConversionOverflowError, CoreError, CoreResult, DivideByZeroError, DivisionError, + OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, +}; +pub use crate::math::{ + Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, Fraction, Int128, Int256, + Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, + SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, +}; +#[allow(deprecated)] +pub use crate::serde::{ + from_binary, from_json, from_slice, to_binary, to_json_binary, to_json_string, to_json_vec, + to_vec, +}; + +/// Exposed for testing only +/// Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm. +#[cfg(not(target_arch = "wasm32"))] +pub mod testing; diff --git a/packages/std/src/math/conversion.rs b/packages/core/src/math/conversion.rs similarity index 100% rename from packages/std/src/math/conversion.rs rename to packages/core/src/math/conversion.rs diff --git a/packages/std/src/math/decimal.rs b/packages/core/src/math/decimal.rs similarity index 97% rename from packages/std/src/math/decimal.rs rename to packages/core/src/math/decimal.rs index 9f1de8607a..39a5fae1e5 100644 --- a/packages/std/src/math/decimal.rs +++ b/packages/core/src/math/decimal.rs @@ -2,16 +2,14 @@ use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; use core::str::FromStr; +use derive_more::Display; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use thiserror::Error; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, - OverflowOperation, RoundUpOverflowError, StdError, + CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, + OverflowOperation, RoundUpOverflowError, }; -use crate::prelude::*; use crate::{forward_ref_partial_eq, Decimal256, SignedDecimal, SignedDecimal256}; use super::Fraction; @@ -21,15 +19,19 @@ use super::{Uint128, Uint256}; /// A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 /// /// The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Decimal(#[schemars(with = "String")] Uint128); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Decimal(#[cfg_attr(feature = "std", schemars(with = "String"))] Uint128); forward_ref_partial_eq!(Decimal, Decimal); -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Decimal range exceeded")] +#[derive(Display, Debug, PartialEq, Eq)] +#[display("Decimal range exceeded")] pub struct DecimalRangeExceeded; +#[cfg(feature = "std")] +impl std::error::Error for DecimalRangeExceeded {} + impl Decimal { const DECIMAL_FRACTIONAL: Uint128 = Uint128::new(1_000_000_000_000_000_000u128); // 1*10**18 const DECIMAL_FRACTIONAL_SQUARED: Uint128 = @@ -537,7 +539,7 @@ impl TryFrom for Decimal { } impl FromStr for Decimal { - type Err = StdError; + type Err = CoreError; /// Converts the decimal string to a Decimal /// Possible inputs: "1.23", "1", "000012", "1.123000000" @@ -551,18 +553,18 @@ impl FromStr for Decimal { let whole_part = parts_iter.next().unwrap(); // split always returns at least one element let whole = whole_part .parse::() - .map_err(|_| StdError::generic_err("Error parsing whole"))?; + .map_err(|_| CoreError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() - .map_err(|_| StdError::generic_err("Error parsing fractional"))?; + .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - StdError::generic_err(format!( + CoreError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -576,11 +578,11 @@ impl FromStr for Decimal { // fractional < 10^DECIMAL_PLACES && fractional_factor <= 10^DECIMAL_PLACES fractional.checked_mul(fractional_factor).unwrap(), ) - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(StdError::generic_err("Unexpected number of dots")); + return Err(CoreError::generic_err("Unexpected number of dots")); } Ok(Decimal(atomics)) @@ -775,7 +777,7 @@ impl<'de> de::Visitor<'de> for DecimalVisitor { { match Decimal::from_str(v) { Ok(d) => Ok(d), - Err(e) => Err(E::custom(format!("Error parsing decimal '{v}': {e}"))), + Err(e) => Err(E::custom(format_args!("Error parsing decimal '{v}': {e}"))), } } } @@ -1090,17 +1092,17 @@ mod tests { #[test] fn decimal_from_str_errors_for_broken_whole_part() { match Decimal::from_str("").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str(" ").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("-1").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } } @@ -1108,22 +1110,22 @@ mod tests { #[test] fn decimal_from_str_errors_for_broken_fractional_part() { match Decimal::from_str("1.").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1. ").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1.e").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1.2e3").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } } @@ -1131,7 +1133,7 @@ mod tests { #[test] fn decimal_from_str_errors_for_more_than_18_fractional_digits() { match Decimal::from_str("7.1234567890123456789").unwrap_err() { - StdError::GenericErr { msg, .. } => { + CoreError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits",) } e => panic!("Unexpected error: {e:?}"), @@ -1139,7 +1141,7 @@ mod tests { // No special rules for trailing zeros. This could be changed but adds gas cost for the happy path. match Decimal::from_str("7.1230000000000000000").unwrap_err() { - StdError::GenericErr { msg, .. } => { + CoreError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {e:?}"), @@ -1149,12 +1151,12 @@ mod tests { #[test] fn decimal_from_str_errors_for_invalid_number_of_dots() { match Decimal::from_str("1.2.3").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1.2.3.4").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } } @@ -1163,17 +1165,17 @@ mod tests { fn decimal_from_str_errors_for_more_than_max_value() { // Integer match Decimal::from_str("340282366920938463464").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } // Decimal match Decimal::from_str("340282366920938463464.0").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("340282366920938463463.374607431768211456").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } } diff --git a/packages/std/src/math/decimal256.rs b/packages/core/src/math/decimal256.rs similarity index 96% rename from packages/std/src/math/decimal256.rs rename to packages/core/src/math/decimal256.rs index 1fb73b31b7..0a17f0917e 100644 --- a/packages/std/src/math/decimal256.rs +++ b/packages/core/src/math/decimal256.rs @@ -2,16 +2,14 @@ use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; use core::str::FromStr; +use derive_more::Display; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use thiserror::Error; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, - OverflowOperation, RoundUpOverflowError, StdError, + CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, + OverflowOperation, RoundUpOverflowError, }; -use crate::prelude::*; use crate::{forward_ref_partial_eq, Decimal, SignedDecimal, SignedDecimal256, Uint512}; use super::Fraction; @@ -23,15 +21,19 @@ use super::Uint256; /// The greatest possible value that can be represented is /// 115792089237316195423570985008687907853269984665640564039457.584007913129639935 /// (which is (2^256 - 1) / 10^18) -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Decimal256(#[schemars(with = "String")] Uint256); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Decimal256(#[cfg_attr(feature = "std", schemars(with = "String"))] Uint256); forward_ref_partial_eq!(Decimal256, Decimal256); -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Decimal256 range exceeded")] +#[derive(Display, Debug, PartialEq, Eq)] +#[display("Decimal256 range exceeded")] pub struct Decimal256RangeExceeded; +#[cfg(feature = "std")] +impl std::error::Error for Decimal256RangeExceeded {} + impl Decimal256 { const DECIMAL_FRACTIONAL: Uint256 = // 1*10**18 Uint256::from_u128(1_000_000_000_000_000_000); @@ -536,17 +538,8 @@ impl TryFrom for Decimal256 { } } -impl TryFrom for Decimal256 { - type Error = Decimal256RangeExceeded; - - #[inline] - fn try_from(value: Uint256) -> Result { - Self::from_atomics(value, 0) - } -} - impl FromStr for Decimal256 { - type Err = StdError; + type Err = CoreError; /// Converts the decimal string to a Decimal256 /// Possible inputs: "1.23", "1", "000012", "1.123000000" @@ -560,18 +553,18 @@ impl FromStr for Decimal256 { let whole_part = parts_iter.next().unwrap(); // split always returns at least one element let whole = whole_part .parse::() - .map_err(|_| StdError::generic_err("Error parsing whole"))?; + .map_err(|_| CoreError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() - .map_err(|_| StdError::generic_err("Error parsing fractional"))?; + .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - StdError::generic_err(format!( + CoreError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -585,11 +578,11 @@ impl FromStr for Decimal256 { // fractional < 10^DECIMAL_PLACES && fractional_factor <= 10^DECIMAL_PLACES fractional.checked_mul(fractional_factor).unwrap(), ) - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(StdError::generic_err("Unexpected number of dots")); + return Err(CoreError::generic_err("Unexpected number of dots")); } Ok(Self(atomics)) @@ -784,7 +777,7 @@ impl<'de> de::Visitor<'de> for Decimal256Visitor { { match Self::Value::from_str(v) { Ok(d) => Ok(d), - Err(e) => Err(E::custom(format!("Error parsing decimal '{v}': {e}"))), + Err(e) => Err(E::custom(format_args!("Error parsing decimal '{v}': {e}"))), } } } @@ -792,19 +785,13 @@ impl<'de> de::Visitor<'de> for Decimal256Visitor { #[cfg(test)] mod tests { use super::*; + use crate::errors::CoreError; use crate::{from_json, to_json_vec}; fn dec(input: &str) -> Decimal256 { Decimal256::from_str(input).unwrap() } - #[test] - fn decimal256_try_from_integer() { - let int = Uint256::from_u128(0xDEADBEEF); - let decimal = Decimal256::try_from(int).unwrap(); - assert_eq!(int.to_string(), decimal.to_string()); - } - #[test] fn decimal256_new() { let expected = Uint256::from(300u128); @@ -1131,17 +1118,17 @@ mod tests { #[test] fn decimal256_from_str_errors_for_broken_whole_part() { match Decimal256::from_str("").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str(" ").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("-1").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } } @@ -1149,22 +1136,22 @@ mod tests { #[test] fn decimal256_from_str_errors_for_broken_fractional_part() { match Decimal256::from_str("1.").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1. ").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1.e").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1.2e3").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } } @@ -1172,7 +1159,7 @@ mod tests { #[test] fn decimal256_from_str_errors_for_more_than_36_fractional_digits() { match Decimal256::from_str("7.1234567890123456789").unwrap_err() { - StdError::GenericErr { msg, .. } => { + CoreError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {e:?}"), @@ -1180,7 +1167,7 @@ mod tests { // No special rules for trailing zeros. This could be changed but adds gas cost for the happy path. match Decimal256::from_str("7.1230000000000000000").unwrap_err() { - StdError::GenericErr { msg, .. } => { + CoreError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {e:?}"), @@ -1190,12 +1177,12 @@ mod tests { #[test] fn decimal256_from_str_errors_for_invalid_number_of_dots() { match Decimal256::from_str("1.2.3").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1.2.3.4").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } } @@ -1206,7 +1193,7 @@ mod tests { match Decimal256::from_str("115792089237316195423570985008687907853269984665640564039458") .unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } @@ -1214,7 +1201,7 @@ mod tests { match Decimal256::from_str("115792089237316195423570985008687907853269984665640564039458.0") .unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str( @@ -1222,7 +1209,7 @@ mod tests { ) .unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } } diff --git a/packages/std/src/math/fraction.rs b/packages/core/src/math/fraction.rs similarity index 100% rename from packages/std/src/math/fraction.rs rename to packages/core/src/math/fraction.rs diff --git a/packages/std/src/math/int128.rs b/packages/core/src/math/int128.rs similarity index 98% rename from packages/std/src/math/int128.rs rename to packages/core/src/math/int128.rs index aa86525b8e..e23e8d17da 100644 --- a/packages/std/src/math/int128.rs +++ b/packages/core/src/math/int128.rs @@ -5,11 +5,11 @@ use core::ops::{ }; use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; -use crate::prelude::*; +use crate::errors::{ + CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, +}; use crate::{ forward_ref_partial_eq, CheckedMultiplyRatioError, Int256, Int512, Int64, Uint128, Uint256, Uint512, Uint64, @@ -31,8 +31,9 @@ use super::num_consts::NumConsts; /// let a = Int128::from(258i128); /// assert_eq!(a.i128(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Int128(#[schemars(with = "String")] pub(crate) i128); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Int128(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) i128); forward_ref_partial_eq!(Int128, Int128); @@ -356,7 +357,7 @@ impl From for Int128 { } impl TryFrom<&str> for Int128 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -364,12 +365,12 @@ impl TryFrom<&str> for Int128 { } impl FromStr for Int128 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { match s.parse::() { Ok(u) => Ok(Self(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing Int128: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing Int128: {e}"))), } } } @@ -555,7 +556,7 @@ impl<'de> de::Visitor<'de> for Int128Visitor { where E: de::Error, { - Int128::try_from(v).map_err(|e| E::custom(format!("invalid Int128 '{v}' - {e}"))) + Int128::try_from(v).map_err(|e| E::custom(format_args!("invalid Int128 '{v}' - {e}"))) } } diff --git a/packages/std/src/math/int256.rs b/packages/core/src/math/int256.rs similarity index 98% rename from packages/std/src/math/int256.rs rename to packages/core/src/math/int256.rs index 64e5771f07..0b383a8cd5 100644 --- a/packages/std/src/math/int256.rs +++ b/packages/core/src/math/int256.rs @@ -5,11 +5,11 @@ use core::ops::{ }; use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; -use crate::prelude::*; +use crate::errors::{ + CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, +}; use crate::{ forward_ref_partial_eq, CheckedMultiplyRatioError, Int128, Int512, Int64, Uint128, Uint256, Uint512, Uint64, @@ -42,8 +42,9 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Int256(#[schemars(with = "String")] pub(crate) I256); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Int256(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) I256); forward_ref_partial_eq!(Int256, Int256); @@ -431,7 +432,7 @@ impl From for Int256 { } impl TryFrom<&str> for Int256 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -439,12 +440,12 @@ impl TryFrom<&str> for Int256 { } impl FromStr for Int256 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { match I256::from_str_radix(s, 10) { Ok(u) => Ok(Self(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing Int256: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing Int256: {e}"))), } } } @@ -630,7 +631,7 @@ impl<'de> de::Visitor<'de> for Int256Visitor { where E: de::Error, { - Int256::try_from(v).map_err(|e| E::custom(format!("invalid Int256 '{v}' - {e}"))) + Int256::try_from(v).map_err(|e| E::custom(format_args!("invalid Int256 '{v}' - {e}"))) } } diff --git a/packages/std/src/math/int512.rs b/packages/core/src/math/int512.rs similarity index 99% rename from packages/std/src/math/int512.rs rename to packages/core/src/math/int512.rs index 32499b657c..1d8c24ce2a 100644 --- a/packages/std/src/math/int512.rs +++ b/packages/core/src/math/int512.rs @@ -5,11 +5,11 @@ use core::ops::{ }; use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; -use crate::prelude::*; +use crate::errors::{ + CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, +}; use crate::{forward_ref_partial_eq, Int128, Int256, Int64, Uint128, Uint256, Uint512, Uint64}; /// Used internally - we don't want to leak this type since we might change @@ -43,8 +43,9 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Int512(#[schemars(with = "String")] pub(crate) I512); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Int512(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) I512); forward_ref_partial_eq!(Int512, Int512); @@ -428,7 +429,7 @@ impl From for Int512 { } impl TryFrom<&str> for Int512 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -436,12 +437,12 @@ impl TryFrom<&str> for Int512 { } impl FromStr for Int512 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { match I512::from_str_radix(s, 10) { Ok(u) => Ok(Self(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing Int512: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing Int512: {e}"))), } } } diff --git a/packages/std/src/math/int64.rs b/packages/core/src/math/int64.rs similarity index 98% rename from packages/std/src/math/int64.rs rename to packages/core/src/math/int64.rs index de88022811..36814087b2 100644 --- a/packages/std/src/math/int64.rs +++ b/packages/core/src/math/int64.rs @@ -5,11 +5,11 @@ use core::ops::{ }; use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; -use crate::prelude::*; +use crate::errors::{ + CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, +}; use crate::{ forward_ref_partial_eq, CheckedMultiplyRatioError, Int128, Int256, Int512, Uint128, Uint256, Uint512, Uint64, @@ -31,8 +31,9 @@ use super::num_consts::NumConsts; /// let a = Int64::from(258i64); /// assert_eq!(a.i64(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Int64(#[schemars(with = "String")] pub(crate) i64); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Int64(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) i64); forward_ref_partial_eq!(Int64, Int64); @@ -335,7 +336,7 @@ forward_try_from!(Uint256, Int64); forward_try_from!(Uint512, Int64); impl TryFrom<&str> for Int64 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -343,12 +344,12 @@ impl TryFrom<&str> for Int64 { } impl FromStr for Int64 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { match s.parse::() { Ok(u) => Ok(Self(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing Int64: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing Int64: {e}"))), } } } @@ -534,7 +535,7 @@ impl<'de> de::Visitor<'de> for Int64Visitor { where E: de::Error, { - Int64::try_from(v).map_err(|e| E::custom(format!("invalid Int64 '{v}' - {e}"))) + Int64::try_from(v).map_err(|e| E::custom(format_args!("invalid Int64 '{v}' - {e}"))) } } diff --git a/packages/std/src/math/isqrt.rs b/packages/core/src/math/isqrt.rs similarity index 100% rename from packages/std/src/math/isqrt.rs rename to packages/core/src/math/isqrt.rs diff --git a/packages/std/src/math/mod.rs b/packages/core/src/math/mod.rs similarity index 100% rename from packages/std/src/math/mod.rs rename to packages/core/src/math/mod.rs diff --git a/packages/std/src/math/num_consts.rs b/packages/core/src/math/num_consts.rs similarity index 100% rename from packages/std/src/math/num_consts.rs rename to packages/core/src/math/num_consts.rs diff --git a/packages/std/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs similarity index 98% rename from packages/std/src/math/signed_decimal.rs rename to packages/core/src/math/signed_decimal.rs index 6dea96717d..55f933cf85 100644 --- a/packages/std/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -4,16 +4,14 @@ use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; use core::str::FromStr; +use derive_more::Display; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use thiserror::Error; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, - OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, StdError, + CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, + OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, }; -use crate::prelude::*; use crate::{forward_ref_partial_eq, Decimal, Decimal256, Int256, SignedDecimal256}; use super::Fraction; @@ -23,15 +21,19 @@ use super::Int128; /// /// The greatest possible value that can be represented is 170141183460469231731.687303715884105727 (which is (2^127 - 1) / 10^18) /// and the smallest is -170141183460469231731.687303715884105728 (which is -2^127 / 10^18). -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct SignedDecimal(#[schemars(with = "String")] Int128); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct SignedDecimal(#[cfg_attr(feature = "std", schemars(with = "String"))] Int128); forward_ref_partial_eq!(SignedDecimal, SignedDecimal); -#[derive(Error, Debug, PartialEq, Eq)] -#[error("SignedDecimal range exceeded")] +#[derive(Display, Debug, PartialEq, Eq)] +#[display("SignedDecimal range exceeded")] pub struct SignedDecimalRangeExceeded; +#[cfg(feature = "std")] +impl std::error::Error for SignedDecimalRangeExceeded {} + impl SignedDecimal { const DECIMAL_FRACTIONAL: Int128 = Int128::new(1_000_000_000_000_000_000i128); // 1*10**18 const DECIMAL_FRACTIONAL_SQUARED: Int128 = @@ -648,7 +650,7 @@ impl TryFrom for SignedDecimal { } impl FromStr for SignedDecimal { - type Err = StdError; + type Err = CoreError; /// Converts the decimal string to a SignedDecimal /// Possible inputs: "1.23", "1", "000012", "1.123000000", "-1.12300" @@ -664,18 +666,18 @@ impl FromStr for SignedDecimal { let whole = whole_part .parse::() - .map_err(|_| StdError::generic_err("Error parsing whole"))?; + .map_err(|_| CoreError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() // u64 is enough for 18 decimal places - .map_err(|_| StdError::generic_err("Error parsing fractional"))?; + .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - StdError::generic_err(format!( + CoreError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -696,11 +698,11 @@ impl FromStr for SignedDecimal { } else { atomics.checked_add(fractional_part) } - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(StdError::generic_err("Unexpected number of dots")); + return Err(CoreError::generic_err("Unexpected number of dots")); } Ok(SignedDecimal(atomics)) @@ -900,7 +902,7 @@ impl<'de> de::Visitor<'de> for SignedDecimalVisitor { { match SignedDecimal::from_str(v) { Ok(d) => Ok(d), - Err(e) => Err(E::custom(format!("Error parsing decimal '{v}': {e}"))), + Err(e) => Err(E::custom(format_args!("Error parsing decimal '{v}': {e}"))), } } } @@ -1357,7 +1359,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_broken_whole_part() { - let expected_err = StdError::generic_err("Error parsing whole"); + let expected_err = CoreError::generic_err("Error parsing whole"); assert_eq!(SignedDecimal::from_str("").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str(" ").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str("-").unwrap_err(), expected_err); @@ -1365,7 +1367,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_broken_fractional_part() { - let expected_err = StdError::generic_err("Error parsing fractional"); + let expected_err = CoreError::generic_err("Error parsing fractional"); assert_eq!(SignedDecimal::from_str("1.").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str("1. ").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str("1.e").unwrap_err(), expected_err); @@ -1375,7 +1377,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_more_than_18_fractional_digits() { - let expected_err = StdError::generic_err("Cannot parse more than 18 fractional digits"); + let expected_err = CoreError::generic_err("Cannot parse more than 18 fractional digits"); assert_eq!( SignedDecimal::from_str("7.1234567890123456789").unwrap_err(), expected_err @@ -1389,7 +1391,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_invalid_number_of_dots() { - let expected_err = StdError::generic_err("Unexpected number of dots"); + let expected_err = CoreError::generic_err("Unexpected number of dots"); assert_eq!(SignedDecimal::from_str("1.2.3").unwrap_err(), expected_err); assert_eq!( SignedDecimal::from_str("1.2.3.4").unwrap_err(), @@ -1399,7 +1401,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_more_than_max_value() { - let expected_err = StdError::generic_err("Value too big"); + let expected_err = CoreError::generic_err("Value too big"); // Integer assert_eq!( SignedDecimal::from_str("170141183460469231732").unwrap_err(), @@ -3064,17 +3066,17 @@ mod tests { #[test] fn signed_decimal_can_be_serialized_and_deserialized() { // properly deserialized - let value: SignedDecimal = serde_json::from_str(r#""123""#).unwrap(); + let value: SignedDecimal = serde_json_wasm::from_str(r#""123""#).unwrap(); assert_eq!(SignedDecimal::from_str("123").unwrap(), value); // properly serialized let value = SignedDecimal::from_str("456").unwrap(); - assert_eq!(r#""456""#, serde_json::to_string(&value).unwrap()); + assert_eq!(r#""456""#, serde_json_wasm::to_string(&value).unwrap()); // invalid: not a string encoded decimal assert_eq!( "invalid type: integer `123`, expected string-encoded decimal at line 1 column 3", - serde_json::from_str::("123") + serde_json_wasm::from_str::("123") .err() .unwrap() .to_string() @@ -3083,7 +3085,7 @@ mod tests { // invalid: not properly defined signed decimal value assert_eq!( "Error parsing decimal '1.e': Generic error: Error parsing fractional at line 1 column 5", - serde_json::from_str::(r#""1.e""#) + serde_json_wasm::from_str::(r#""1.e""#) .err() .unwrap() .to_string() diff --git a/packages/std/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs similarity index 98% rename from packages/std/src/math/signed_decimal_256.rs rename to packages/core/src/math/signed_decimal_256.rs index 5a696c3279..ec98fa0b43 100644 --- a/packages/std/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -4,16 +4,14 @@ use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; use core::str::FromStr; +use derive_more::Display; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use thiserror::Error; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, - OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, StdError, + CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, + OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, }; -use crate::prelude::*; use crate::{forward_ref_partial_eq, Decimal, Decimal256, Int512, SignedDecimal}; use super::Fraction; @@ -28,15 +26,19 @@ use super::Int256; /// and the smallest is /// -57896044618658097711785492504343953926634992332820282019728.792003956564819968 /// (which is -2^255 / 10^18). -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct SignedDecimal256(#[schemars(with = "String")] Int256); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct SignedDecimal256(#[cfg_attr(feature = "std", schemars(with = "String"))] Int256); forward_ref_partial_eq!(SignedDecimal256, SignedDecimal256); -#[derive(Error, Debug, PartialEq, Eq)] -#[error("SignedDecimal256 range exceeded")] +#[derive(Display, Debug, PartialEq, Eq)] +#[display("SignedDecimal256 range exceeded")] pub struct SignedDecimal256RangeExceeded; +#[cfg(feature = "std")] +impl std::error::Error for SignedDecimal256RangeExceeded {} + impl SignedDecimal256 { const DECIMAL_FRACTIONAL: Int256 = // 1*10**18 Int256::from_i128(1_000_000_000_000_000_000); @@ -649,7 +651,7 @@ impl TryFrom for SignedDecimal256 { } impl FromStr for SignedDecimal256 { - type Err = StdError; + type Err = CoreError; /// Converts the decimal string to a SignedDecimal256 /// Possible inputs: "1.23", "1", "000012", "1.123000000", "-1.12300" @@ -665,18 +667,18 @@ impl FromStr for SignedDecimal256 { let whole = whole_part .parse::() - .map_err(|_| StdError::generic_err("Error parsing whole"))?; + .map_err(|_| CoreError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() // u64 is enough for 18 decimal places - .map_err(|_| StdError::generic_err("Error parsing fractional"))?; + .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - StdError::generic_err(format!( + CoreError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -697,11 +699,11 @@ impl FromStr for SignedDecimal256 { } else { atomics.checked_add(fractional_part) } - .map_err(|_| StdError::generic_err("Value too big"))?; + .map_err(|_| CoreError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(StdError::generic_err("Unexpected number of dots")); + return Err(CoreError::generic_err("Unexpected number of dots")); } Ok(SignedDecimal256(atomics)) @@ -901,7 +903,7 @@ impl<'de> de::Visitor<'de> for SignedDecimal256Visitor { { match SignedDecimal256::from_str(v) { Ok(d) => Ok(d), - Err(e) => Err(E::custom(format!("Error parsing decimal '{v}': {e}"))), + Err(e) => Err(E::custom(format_args!("Error parsing decimal '{v}': {e}"))), } } } @@ -910,7 +912,6 @@ impl<'de> de::Visitor<'de> for SignedDecimal256Visitor { mod tests { use super::*; use crate::{from_json, to_json_vec}; - use schemars::schema_for; fn dec(input: &str) -> SignedDecimal256 { SignedDecimal256::from_str(input).unwrap() @@ -1364,7 +1365,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_broken_whole_part() { - let expected_err = StdError::generic_err("Error parsing whole"); + let expected_err = CoreError::generic_err("Error parsing whole"); assert_eq!(SignedDecimal256::from_str("").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str(" ").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str("-").unwrap_err(), expected_err); @@ -1372,7 +1373,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_broken_fractional_part() { - let expected_err = StdError::generic_err("Error parsing fractional"); + let expected_err = CoreError::generic_err("Error parsing fractional"); assert_eq!(SignedDecimal256::from_str("1.").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str("1. ").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str("1.e").unwrap_err(), expected_err); @@ -1388,7 +1389,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_more_than_18_fractional_digits() { - let expected_err = StdError::generic_err("Cannot parse more than 18 fractional digits"); + let expected_err = CoreError::generic_err("Cannot parse more than 18 fractional digits"); assert_eq!( SignedDecimal256::from_str("7.1234567890123456789").unwrap_err(), expected_err @@ -1402,7 +1403,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_invalid_number_of_dots() { - let expected_err = StdError::generic_err("Unexpected number of dots"); + let expected_err = CoreError::generic_err("Unexpected number of dots"); assert_eq!( SignedDecimal256::from_str("1.2.3").unwrap_err(), expected_err @@ -1415,7 +1416,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_more_than_max_value() { - let expected_err = StdError::generic_err("Value too big"); + let expected_err = CoreError::generic_err("Value too big"); // Integer assert_eq!( SignedDecimal256::from_str( @@ -3237,17 +3238,17 @@ mod tests { #[test] fn signed_decimal_256_can_be_serialized_and_deserialized() { // properly deserialized - let value: SignedDecimal256 = serde_json::from_str(r#""123""#).unwrap(); + let value: SignedDecimal256 = serde_json_wasm::from_str(r#""123""#).unwrap(); assert_eq!(SignedDecimal256::from_str("123").unwrap(), value); // properly serialized let value = SignedDecimal256::from_str("456").unwrap(); - assert_eq!(r#""456""#, serde_json::to_string(&value).unwrap()); + assert_eq!(r#""456""#, serde_json_wasm::to_string(&value).unwrap()); // invalid: not a string encoded decimal assert_eq!( "invalid type: integer `123`, expected string-encoded decimal at line 1 column 3", - serde_json::from_str::("123") + serde_json_wasm::from_str::("123") .err() .unwrap() .to_string() @@ -3256,7 +3257,7 @@ mod tests { // invalid: not properly defined signed decimal value assert_eq!( "Error parsing decimal '1.e': Generic error: Error parsing fractional at line 1 column 5", - serde_json::from_str::(r#""1.e""#) + serde_json_wasm::from_str::(r#""1.e""#) .err() .unwrap() .to_string() @@ -3264,8 +3265,9 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn signed_decimal_256_has_defined_json_schema() { - let schema = schema_for!(SignedDecimal256); + let schema = schemars::schema_for!(SignedDecimal256); assert_eq!( "SignedDecimal256", schema.schema.metadata.unwrap().title.unwrap() diff --git a/packages/std/src/math/uint128.rs b/packages/core/src/math/uint128.rs similarity index 98% rename from packages/std/src/math/uint128.rs rename to packages/core/src/math/uint128.rs index 9ee5c9841c..9fde45beb9 100644 --- a/packages/std/src/math/uint128.rs +++ b/packages/core/src/math/uint128.rs @@ -6,14 +6,12 @@ use core::ops::{ use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedMultiplyFractionError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, - OverflowOperation, StdError, + CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, + OverflowError, OverflowOperation, }; -use crate::prelude::*; use crate::{ forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint256, Uint64, @@ -41,8 +39,9 @@ use super::num_consts::NumConsts; /// let c = Uint128::from(70u32); /// assert_eq!(c.u128(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint128(#[schemars(with = "String")] pub(crate) u128); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Uint128(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) u128); forward_ref_partial_eq!(Uint128, Uint128); @@ -332,7 +331,7 @@ forward_try_from!(Int256, Uint128); forward_try_from!(Int512, Uint128); impl TryFrom<&str> for Uint128 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -340,12 +339,12 @@ impl TryFrom<&str> for Uint128 { } impl FromStr for Uint128 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { match s.parse::() { Ok(u) => Ok(Uint128(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing u128: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing u128: {e}"))), } } } @@ -592,7 +591,7 @@ impl<'de> de::Visitor<'de> for Uint128Visitor { { match v.parse::() { Ok(u) => Ok(Uint128(u)), - Err(e) => Err(E::custom(format!("invalid Uint128 '{v}' - {e}"))), + Err(e) => Err(E::custom(format_args!("invalid Uint128 '{v}' - {e}"))), } } } diff --git a/packages/std/src/math/uint256.rs b/packages/core/src/math/uint256.rs similarity index 99% rename from packages/std/src/math/uint256.rs rename to packages/core/src/math/uint256.rs index 6b4814feea..6821df9548 100644 --- a/packages/std/src/math/uint256.rs +++ b/packages/core/src/math/uint256.rs @@ -5,14 +5,12 @@ use core::ops::{ }; use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, - DivideByZeroError, OverflowError, OverflowOperation, StdError, + CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, CoreError, + DivideByZeroError, OverflowError, OverflowOperation, }; -use crate::prelude::*; use crate::{ forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint128, Uint512, Uint64, @@ -45,8 +43,9 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint256(#[schemars(with = "String")] pub(crate) U256); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Uint256(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) U256); forward_ref_partial_eq!(Uint256, Uint256); @@ -402,7 +401,7 @@ try_from_int_to_uint!(Int256, Uint256); try_from_int_to_uint!(Int512, Uint256); impl TryFrom<&str> for Uint256 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -410,16 +409,18 @@ impl TryFrom<&str> for Uint256 { } impl FromStr for Uint256 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { if s.is_empty() { - return Err(StdError::generic_err("Parsing u256: received empty string")); + return Err(CoreError::generic_err( + "Parsing u256: received empty string", + )); } match U256::from_str_radix(s, 10) { Ok(u) => Ok(Uint256(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing u256: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing u256: {e}"))), } } } @@ -655,7 +656,7 @@ impl<'de> de::Visitor<'de> for Uint256Visitor { where E: de::Error, { - Uint256::try_from(v).map_err(|e| E::custom(format!("invalid Uint256 '{v}' - {e}"))) + Uint256::try_from(v).map_err(|e| E::custom(format_args!("invalid Uint256 '{v}' - {e}"))) } } diff --git a/packages/std/src/math/uint512.rs b/packages/core/src/math/uint512.rs similarity index 98% rename from packages/std/src/math/uint512.rs rename to packages/core/src/math/uint512.rs index 2842b726bd..4332f048d5 100644 --- a/packages/std/src/math/uint512.rs +++ b/packages/core/src/math/uint512.rs @@ -5,13 +5,11 @@ use core::ops::{ }; use core::str::FromStr; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, StdError, + ConversionOverflowError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, }; -use crate::prelude::*; use crate::{forward_ref_partial_eq, Int128, Int256, Int512, Int64, Uint128, Uint256, Uint64}; /// Used internally - we don't want to leak this type since we might change @@ -45,8 +43,9 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint512(#[schemars(with = "String")] pub(crate) U512); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Uint512(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) U512); forward_ref_partial_eq!(Uint512, Uint512); @@ -387,7 +386,7 @@ try_from_int_to_uint!(Int256, Uint512); try_from_int_to_uint!(Int512, Uint512); impl TryFrom<&str> for Uint512 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -395,12 +394,12 @@ impl TryFrom<&str> for Uint512 { } impl FromStr for Uint512 { - type Err = StdError; + type Err = CoreError; fn from_str(s: &str) -> Result { match U512::from_str_radix(s, 10) { Ok(u) => Ok(Self(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing u512: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing u512: {e}"))), } } } @@ -624,7 +623,7 @@ impl<'de> de::Visitor<'de> for Uint512Visitor { where E: de::Error, { - Uint512::try_from(v).map_err(|e| E::custom(format!("invalid Uint512 '{v}' - {e}"))) + Uint512::try_from(v).map_err(|e| E::custom(format_args!("invalid Uint512 '{v}' - {e}"))) } } diff --git a/packages/std/src/math/uint64.rs b/packages/core/src/math/uint64.rs similarity index 98% rename from packages/std/src/math/uint64.rs rename to packages/core/src/math/uint64.rs index 188115b4ac..67f57e85d3 100644 --- a/packages/std/src/math/uint64.rs +++ b/packages/core/src/math/uint64.rs @@ -4,14 +4,12 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedMultiplyFractionError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, - OverflowOperation, StdError, + CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, + OverflowError, OverflowOperation, }; -use crate::prelude::*; use crate::{ forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint128, }; @@ -35,8 +33,9 @@ use super::num_consts::NumConsts; /// let b = Uint64::from(70u32); /// assert_eq!(b.u64(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint64(#[schemars(with = "String")] pub(crate) u64); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct Uint64(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) u64); forward_ref_partial_eq!(Uint64, Uint64); @@ -313,12 +312,12 @@ forward_try_from!(Int256, Uint64); forward_try_from!(Int512, Uint64); impl TryFrom<&str> for Uint64 { - type Error = StdError; + type Error = CoreError; fn try_from(val: &str) -> Result { match val.parse::() { Ok(u) => Ok(Uint64(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing u64: {e}"))), + Err(e) => Err(CoreError::generic_err(format!("Parsing u64: {e}"))), } } } @@ -557,7 +556,7 @@ impl<'de> de::Visitor<'de> for Uint64Visitor { { match v.parse::() { Ok(u) => Ok(Uint64(u)), - Err(e) => Err(E::custom(format!("invalid Uint64 '{v}' - {e}"))), + Err(e) => Err(E::custom(format_args!("invalid Uint64 '{v}' - {e}"))), } } } diff --git a/packages/std/src/serde.rs b/packages/core/src/serde.rs similarity index 86% rename from packages/std/src/serde.rs rename to packages/core/src/serde.rs index 5adaf24567..c95c5ae5fa 100644 --- a/packages/std/src/serde.rs +++ b/packages/core/src/serde.rs @@ -2,33 +2,33 @@ // The reason is two fold: // 1. To easily ensure that all calling libraries use the same version (minimize code size) // 2. To allow us to switch out to eg. serde-json-core more easily + use core::any::type_name; use serde::{de::DeserializeOwned, Serialize}; use crate::binary::Binary; -use crate::errors::{StdError, StdResult}; -use crate::prelude::*; +use crate::errors::{CoreError, CoreResult}; #[deprecated = "use from_json instead"] -pub fn from_slice(value: &[u8]) -> StdResult { +pub fn from_slice(value: &[u8]) -> CoreResult { from_json(value) } #[deprecated = "use from_json instead"] -pub fn from_binary(value: &Binary) -> StdResult { +pub fn from_binary(value: &Binary) -> CoreResult { from_json(value) } /// Deserializes the given JSON bytes to a data structure. /// /// Errors if the input is not valid JSON or cannot be deserialized to the given type. -pub fn from_json(value: impl AsRef<[u8]>) -> StdResult { +pub fn from_json(value: impl AsRef<[u8]>) -> CoreResult { serde_json_wasm::from_slice(value.as_ref()) - .map_err(|e| StdError::parse_err(type_name::(), e)) + .map_err(|e| CoreError::parse_err(type_name::(), e)) } #[deprecated = "use to_json_vec instead"] -pub fn to_vec(data: &T) -> StdResult> +pub fn to_vec(data: &T) -> CoreResult> where T: Serialize + ?Sized, { @@ -36,7 +36,7 @@ where } #[deprecated = "use to_json_binary instead"] -pub fn to_binary(data: &T) -> StdResult +pub fn to_binary(data: &T) -> CoreResult where T: Serialize + ?Sized, { @@ -44,23 +44,23 @@ where } /// Serializes the given data structure as a JSON byte vector. -pub fn to_json_vec(data: &T) -> StdResult> +pub fn to_json_vec(data: &T) -> CoreResult> where T: Serialize + ?Sized, { - serde_json_wasm::to_vec(data).map_err(|e| StdError::serialize_err(type_name::(), e)) + serde_json_wasm::to_vec(data).map_err(|e| CoreError::serialize_err(type_name::(), e)) } /// Serializes the given data structure as a JSON string. -pub fn to_json_string(data: &T) -> StdResult +pub fn to_json_string(data: &T) -> CoreResult where T: Serialize + ?Sized, { - serde_json_wasm::to_string(data).map_err(|e| StdError::serialize_err(type_name::(), e)) + serde_json_wasm::to_string(data).map_err(|e| CoreError::serialize_err(type_name::(), e)) } /// Serializes the given data structure as JSON bytes. -pub fn to_json_binary(data: &T) -> StdResult +pub fn to_json_binary(data: &T) -> CoreResult where T: Serialize + ?Sized, { diff --git a/packages/std/src/testing/assertions.rs b/packages/core/src/testing/assertions.rs similarity index 97% rename from packages/std/src/testing/assertions.rs rename to packages/core/src/testing/assertions.rs index 01d68b29cd..e762e0e42f 100644 --- a/packages/std/src/testing/assertions.rs +++ b/packages/core/src/testing/assertions.rs @@ -1,6 +1,6 @@ -use crate::prelude::*; use crate::{Decimal, Uint128}; -#[cfg(test)] + +#[cfg(any(test, feature = "testing"))] use core::hash::{Hash, Hasher}; use core::str::FromStr as _; @@ -33,7 +33,7 @@ macro_rules! assert_approx_eq { /// so once working pair is identified, the test’s going to continue /// passing. #[macro_export] -#[cfg(test)] +#[cfg(any(test, feature = "testing"))] macro_rules! assert_hash_works { ($left:expr, $right:expr $(,)?) => {{ $crate::testing::assert_hash_works_impl($left, $right, None); @@ -74,7 +74,7 @@ pub fn assert_approx_eq_impl>( /// pair is identified, the test’s going to continue passing. #[track_caller] #[doc(hidden)] -#[cfg(test)] +#[cfg(any(test, feature = "testing"))] pub fn assert_hash_works_impl(left: T, right: T, panic_msg: Option) { fn hash(value: &impl Hash) -> u64 { let mut hasher = crc32fast::Hasher::default(); diff --git a/packages/core/src/testing/mod.rs b/packages/core/src/testing/mod.rs new file mode 100644 index 0000000000..b3bc438a93 --- /dev/null +++ b/packages/core/src/testing/mod.rs @@ -0,0 +1,5 @@ +mod assertions; + +pub use assertions::assert_approx_eq_impl; +#[cfg(any(test, feature = "testing"))] +pub use assertions::assert_hash_works_impl; diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 34f686be6a..6d4a1b5f71 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -56,22 +56,21 @@ cosmwasm_2_1 = ["cosmwasm_2_0"] [dependencies] base64 = "0.22.0" cosmwasm-derive = { version = "2.0.1", path = "../derive" } +cosmwasm-core = { path = "../core", version = "2.0.1", features = ["std"] } derivative = { version = "2", features = ["use_core"] } -forward_ref = "1" hex = "0.4" schemars = { workspace = true } sha2 = "0.10.3" serde = { workspace = true } serde-json-wasm = { version = "1.0.1", default-features = false } thiserror = "1.0.26" -bnum = "0.11.0" -static_assertions = "1.1.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] bech32 = "0.11.0" cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } [dev-dependencies] +cosmwasm-core = { path = "../core", version = "2.0.1", features = ["testing"] } cosmwasm-schema = { version = "2.0.1", path = "../schema" } # The chrono dependency is only used in an example, which Rust compiles for us. If this causes trouble, remove it. chrono = { version = "0.4", default-features = false, features = ["alloc", "std"] } diff --git a/packages/std/src/addresses.rs b/packages/std/src/addresses.rs index 66b07c4267..bed74f6548 100644 --- a/packages/std/src/addresses.rs +++ b/packages/std/src/addresses.rs @@ -1,6 +1,7 @@ use alloc::borrow::Cow; use core::fmt; use core::ops::Deref; +use cosmwasm_core::Binary; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use sha2::{ @@ -10,7 +11,7 @@ use sha2::{ use thiserror::Error; use crate::prelude::*; -use crate::{binary::Binary, forward_ref_partial_eq, HexBinary}; +use crate::{forward_ref_partial_eq, HexBinary}; /// A human readable address. /// @@ -360,7 +361,8 @@ fn hash(ty: &str, key: &[u8]) -> Vec { #[cfg(test)] mod tests { use super::*; - use crate::assert_hash_works; + use crate::HexBinary; + use cosmwasm_core::assert_hash_works; use hex_literal::hex; #[test] diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index daf1df1738..67df41a089 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -1,9 +1,10 @@ use core::{fmt, str::FromStr}; +use cosmwasm_core::Uint128; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use crate::errors::CoinFromStrError; use crate::prelude::*; -use crate::{errors::CoinFromStrError, math::Uint128}; #[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema)] pub struct Coin { diff --git a/packages/std/src/errors/mod.rs b/packages/std/src/errors/mod.rs index f85e7774d9..fdad099641 100644 --- a/packages/std/src/errors/mod.rs +++ b/packages/std/src/errors/mod.rs @@ -1,16 +1,14 @@ -mod backtrace; mod recover_pubkey_error; mod std_error; mod system_error; mod verification_error; -pub(crate) use backtrace::{impl_from_err, BT}; -pub use recover_pubkey_error::RecoverPubkeyError; -pub use std_error::{ +pub(crate) use cosmwasm_core::__internal::backtrace::{impl_from_err, BT}; +pub use cosmwasm_core::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - CoinFromStrError, CoinsError, ConversionOverflowError, DivideByZeroError, DivisionError, - OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, StdError, - StdResult, + ConversionOverflowError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, }; +pub use recover_pubkey_error::RecoverPubkeyError; +pub use std_error::{CoinFromStrError, CoinsError, StdError, StdResult}; pub use system_error::SystemError; pub use verification_error::VerificationError; diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index 8b997178b6..f26f94dcf8 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -1,6 +1,5 @@ -use core::fmt; - use super::{impl_from_err, BT}; +use cosmwasm_core::{ConversionOverflowError, CoreError, DivideByZeroError, OverflowError}; use thiserror::Error; use crate::errors::{RecoverPubkeyError, VerificationError}; @@ -23,6 +22,8 @@ use crate::prelude::*; /// - Add creator function in std_error_helpers.rs #[derive(Error, Debug)] pub enum StdError { + #[error("Core error: {source}")] + CoreErr { source: CoreError, backtrace: BT }, #[error("Verification error: {source}")] VerificationErr { source: VerificationError, @@ -82,6 +83,51 @@ pub enum StdError { }, } +// Needs complex conversion to not break user expectations.. AAAAAAAAAAAAAAAAAAAAAAAAAAAA +impl From for StdError { + fn from(value: CoreError) -> Self { + match value { + CoreError::ConversionOverflow { source, backtrace } => { + Self::ConversionOverflow { source, backtrace } + } + CoreError::GenericErr { msg, backtrace } => Self::GenericErr { msg, backtrace }, + CoreError::InvalidBase64 { msg, backtrace } => Self::InvalidBase64 { msg, backtrace }, + CoreError::InvalidDataSize { + expected, + actual, + backtrace, + } => Self::InvalidDataSize { + expected, + actual, + backtrace, + }, + CoreError::ParseErr { + target_type, + msg, + backtrace, + } => Self::ParseErr { + target_type, + msg, + backtrace, + }, + CoreError::SerializeErr { + source_type, + msg, + backtrace, + } => Self::SerializeErr { + source_type, + msg, + backtrace, + }, + CoreError::Overflow { source, backtrace } => Self::Overflow { source, backtrace }, + CoreError::DivideByZero { source, backtrace } => { + Self::DivideByZero { source, backtrace } + } + _ => todo!(), + } + } +} + impl_from_err!( ConversionOverflowError, StdError, @@ -181,6 +227,20 @@ impl StdError { impl PartialEq for StdError { fn eq(&self, rhs: &StdError) -> bool { match self { + StdError::CoreErr { + source, + backtrace: _, + } => { + if let StdError::CoreErr { + source: rhs_source, + backtrace: _, + } = rhs + { + source == rhs_source + } else { + false + } + } StdError::VerificationErr { source, backtrace: _, @@ -401,113 +461,6 @@ impl From for StdError { /// result/error type in cosmwasm-std. pub type StdResult = core::result::Result; -#[derive(Error, Debug, PartialEq, Eq)] -pub enum OverflowOperation { - Add, - Sub, - Mul, - Pow, - Shr, - Shl, -} - -impl fmt::Display for OverflowOperation { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{self:?}") - } -} - -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Cannot {operation} with given operands")] -pub struct OverflowError { - pub operation: OverflowOperation, -} - -impl OverflowError { - pub fn new(operation: OverflowOperation) -> Self { - Self { operation } - } -} - -/// The error returned by [`TryFrom`] conversions that overflow, for example -/// when converting from [`Uint256`] to [`Uint128`]. -/// -/// [`TryFrom`]: core::convert::TryFrom -/// [`Uint256`]: crate::Uint256 -/// [`Uint128`]: crate::Uint128 -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Error converting {source_type} to {target_type}")] -pub struct ConversionOverflowError { - pub source_type: &'static str, - pub target_type: &'static str, -} - -impl ConversionOverflowError { - pub fn new(source_type: &'static str, target_type: &'static str) -> Self { - Self { - source_type, - target_type, - } - } -} - -#[derive(Error, Debug, Default, PartialEq, Eq)] -#[error("Cannot divide by zero")] -pub struct DivideByZeroError; - -impl DivideByZeroError { - pub fn new() -> Self { - Self - } -} - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum DivisionError { - #[error("Divide by zero")] - DivideByZero, - - #[error("Overflow in division")] - Overflow, -} - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum CheckedMultiplyFractionError { - #[error("{0}")] - DivideByZero(#[from] DivideByZeroError), - - #[error("{0}")] - ConversionOverflow(#[from] ConversionOverflowError), - - #[error("{0}")] - Overflow(#[from] OverflowError), -} - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum CheckedMultiplyRatioError { - #[error("Denominator must not be zero")] - DivideByZero, - - #[error("Multiplication overflow")] - Overflow, -} - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum CheckedFromRatioError { - #[error("Denominator must not be zero")] - DivideByZero, - - #[error("Overflow")] - Overflow, -} - -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Round up operation failed because of overflow")] -pub struct RoundUpOverflowError; - -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Round down operation failed because of overflow")] -pub struct RoundDownOverflowError; - #[derive(Error, Debug, PartialEq, Eq)] pub enum CoinsError { #[error("Duplicate denom")] @@ -546,6 +499,7 @@ impl From for StdError { mod tests { use super::*; use core::str; + use cosmwasm_core::OverflowOperation; // constructors diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index f66ffb8aff..d96e32dfee 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -1,17 +1,16 @@ // The CosmosMsg variants are defined in results/cosmos_msg.rs // The rest of the IBC related functionality is defined here -use core::cmp::Ordering; +use core::cmp::{Ord, Ordering, PartialOrd}; +use cosmwasm_core::{to_json_binary, Binary}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::addresses::Addr; -use crate::binary::Binary; use crate::coin::Coin; use crate::errors::StdResult; use crate::prelude::*; use crate::results::{Attribute, CosmosMsg, Empty, Event, SubMsg}; -use crate::serde::to_json_binary; use crate::timestamp::Timestamp; /// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 75ab78e1e2..625f398bf4 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -11,20 +11,17 @@ Builds without the std feature are currently not expected to work. If you need n mod addresses; mod assertions; -mod binary; mod checksum; mod coin; mod coins; mod conversion; mod deps; mod errors; -mod forward_ref; mod hex_binary; mod ibc; mod import_helpers; #[cfg(feature = "iterator")] mod iterator; -mod math; mod metadata; mod never; mod pagination; @@ -32,7 +29,6 @@ mod panic; mod query; mod results; mod sections; -mod serde; mod stdack; mod storage; mod timestamp; @@ -48,7 +44,6 @@ pub(crate) mod prelude; pub mod storage_keys; pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; -pub use crate::binary::Binary; pub use crate::checksum::{Checksum, ChecksumError}; pub use crate::coin::{coin, coins, has_coins, Coin}; pub use crate::coins::Coins; @@ -69,11 +64,6 @@ pub use crate::ibc::{ }; #[cfg(feature = "iterator")] pub use crate::iterator::{Order, Record}; -pub use crate::math::{ - Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, Fraction, Int128, Int256, - Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, - SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, -}; pub use crate::metadata::{DenomMetadata, DenomUnit}; pub use crate::never::Never; pub use crate::pagination::PageRequest; @@ -97,11 +87,6 @@ pub use crate::results::{ pub use crate::results::{DistributionMsg, StakingMsg}; #[cfg(feature = "stargate")] pub use crate::results::{GovMsg, VoteOption}; -#[allow(deprecated)] -pub use crate::serde::{ - from_binary, from_json, from_slice, to_binary, to_json_binary, to_json_string, to_json_vec, - to_vec, -}; pub use crate::stdack::StdAck; pub use crate::storage::MemoryStorage; pub use crate::timestamp::Timestamp; @@ -134,4 +119,5 @@ pub mod testing; // Re-exports +pub use cosmwasm_core::*; pub use cosmwasm_derive::entry_point; diff --git a/packages/std/src/results/contract_result.rs b/packages/std/src/results/contract_result.rs index e887c74500..d84f0e102f 100644 --- a/packages/std/src/results/contract_result.rs +++ b/packages/std/src/results/contract_result.rs @@ -89,8 +89,10 @@ impl From> for Result { #[cfg(test)] mod tests { + use cosmwasm_core::{CoreError, CoreResult}; + use super::*; - use crate::{from_json, to_json_vec, Response, StdError, StdResult}; + use crate::{from_json, to_json_vec, Response, StdError}; #[test] fn contract_result_serialization_works() { @@ -131,20 +133,20 @@ mod tests { assert_eq!(result, ContractResult::Ok(5898)); // fails for additional attributes - let parse: StdResult> = from_json(br#"{"unrelated":321,"ok":4554}"#); + let parse: CoreResult> = from_json(br#"{"unrelated":321,"ok":4554}"#); match parse.unwrap_err() { - StdError::ParseErr { .. } => {} + CoreError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } - let parse: StdResult> = from_json(br#"{"ok":4554,"unrelated":321}"#); + let parse: CoreResult> = from_json(br#"{"ok":4554,"unrelated":321}"#); match parse.unwrap_err() { - StdError::ParseErr { .. } => {} + CoreError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } - let parse: StdResult> = + let parse: CoreResult> = from_json(br#"{"ok":4554,"error":"What's up now?"}"#); match parse.unwrap_err() { - StdError::ParseErr { .. } => {} + CoreError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } } diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 35ede3d123..dad619b3fa 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -1,17 +1,16 @@ #![allow(deprecated)] use core::fmt; +use cosmwasm_core::{to_json_binary, Binary}; use derivative::Derivative; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::binary::Binary; use crate::coin::Coin; use crate::errors::StdResult; #[cfg(feature = "stargate")] use crate::ibc::IbcMsg; use crate::prelude::*; -use crate::serde::to_json_binary; #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] use crate::Decimal; diff --git a/packages/std/src/results/empty.rs b/packages/std/src/results/empty.rs index 9efd96d908..180cb99a48 100644 --- a/packages/std/src/results/empty.rs +++ b/packages/std/src/results/empty.rs @@ -16,7 +16,7 @@ pub struct Empty {} mod tests { use super::*; - use crate::serde::{from_json, to_json_vec}; + use cosmwasm_core::{from_json, to_json_vec}; #[test] fn empty_can_be_instantiated() { diff --git a/packages/std/src/results/query.rs b/packages/std/src/results/query.rs index 588bc7ffe5..6db3a13d0d 100644 --- a/packages/std/src/results/query.rs +++ b/packages/std/src/results/query.rs @@ -1,3 +1 @@ -use crate::binary::Binary; - -pub type QueryResponse = Binary; +pub type QueryResponse = cosmwasm_core::Binary; diff --git a/packages/std/src/results/submessages.rs b/packages/std/src/results/submessages.rs index 18f20530d8..68762f1e80 100644 --- a/packages/std/src/results/submessages.rs +++ b/packages/std/src/results/submessages.rs @@ -289,8 +289,10 @@ pub struct MsgResponse { #[cfg(test)] #[allow(deprecated)] mod tests { + use cosmwasm_core::{CoreError, CoreResult}; + use super::*; - use crate::{coins, from_json, to_json_vec, Attribute, BankMsg, StdError, StdResult}; + use crate::{coins, from_json, to_json_vec, Attribute, BankMsg, StdError}; #[test] fn sub_msg_new_works() { @@ -430,14 +432,14 @@ mod tests { assert_eq!(result, SubMsgResult::Err("broken".to_string())); // fails for additional attributes - let parse: StdResult = from_json(br#"{"unrelated":321,"error":"broken"}"#); + let parse: CoreResult = from_json(br#"{"unrelated":321,"error":"broken"}"#); match parse.unwrap_err() { - StdError::ParseErr { .. } => {} + CoreError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } - let parse: StdResult = from_json(br#"{"error":"broken","unrelated":321}"#); + let parse: CoreResult = from_json(br#"{"error":"broken","unrelated":321}"#); match parse.unwrap_err() { - StdError::ParseErr { .. } => {} + CoreError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } } diff --git a/packages/std/src/stdack.rs b/packages/std/src/stdack.rs index 1d65a7d8f4..50b72a6ae6 100644 --- a/packages/std/src/stdack.rs +++ b/packages/std/src/stdack.rs @@ -1,7 +1,7 @@ +use cosmwasm_core::Binary; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::binary::Binary; use crate::prelude::*; use crate::to_json_binary; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index c25b42cefa..cf6505c186 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -7,13 +7,13 @@ use bech32::{encode, Bech32, Hrp}; use core::marker::PhantomData; #[cfg(feature = "cosmwasm_1_3")] use core::ops::Bound; +use cosmwasm_core::{from_json, to_json_binary, Binary, Uint128}; use serde::de::DeserializeOwned; #[cfg(feature = "stargate")] use serde::Serialize; use sha2::{Digest, Sha256}; use crate::addresses::{Addr, CanonicalAddr}; -use crate::binary::Binary; use crate::coin::Coin; use crate::deps::OwnedDeps; use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; @@ -23,7 +23,6 @@ use crate::ibc::{ IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcTimeoutBlock, }; -use crate::math::Uint128; #[cfg(feature = "cosmwasm_1_1")] use crate::query::SupplyResponse; use crate::query::{ @@ -37,7 +36,6 @@ use crate::query::{ #[cfg(feature = "cosmwasm_1_3")] use crate::query::{DelegatorWithdrawAddressResponse, DistributionQuery}; use crate::results::{ContractResult, Empty, SystemResult}; -use crate::serde::{from_json, to_json_binary}; use crate::storage::MemoryStorage; use crate::timestamp::Timestamp; use crate::traits::{Api, Querier, QuerierResult}; diff --git a/packages/std/src/testing/mod.rs b/packages/std/src/testing/mod.rs index 820580c40c..5810a7cf27 100644 --- a/packages/std/src/testing/mod.rs +++ b/packages/std/src/testing/mod.rs @@ -3,12 +3,9 @@ // Exposed for testing only // Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm. -mod assertions; mod mock; -pub use assertions::assert_approx_eq_impl; -#[cfg(test)] -pub use assertions::assert_hash_works_impl; +pub use cosmwasm_core::testing::*; #[cfg(feature = "cosmwasm_1_3")] pub use mock::DistributionQuerier; diff --git a/packages/std/src/timestamp.rs b/packages/std/src/timestamp.rs index 8421e3b1b6..a0c0fe9f91 100644 --- a/packages/std/src/timestamp.rs +++ b/packages/std/src/timestamp.rs @@ -1,8 +1,8 @@ use core::fmt; +use cosmwasm_core::Uint64; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::math::Uint64; use crate::prelude::*; /// A point in time in nanosecond precision. diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index fd974cd619..a657c7ba50 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -1,9 +1,9 @@ use core::marker::PhantomData; use core::ops::Deref; +use cosmwasm_core::{from_json, to_json_binary, to_json_vec, Binary}; use serde::{de::DeserializeOwned, Serialize}; use crate::addresses::{Addr, CanonicalAddr}; -use crate::binary::Binary; use crate::coin::Coin; use crate::errors::{RecoverPubkeyError, StdError, StdResult, VerificationError}; #[cfg(feature = "iterator")] @@ -27,7 +27,6 @@ use crate::query::{ DistributionQuery, }; use crate::results::{ContractResult, Empty, SystemResult}; -use crate::serde::{from_json, to_json_binary, to_json_vec}; use crate::ContractInfoResponse; #[cfg(feature = "cosmwasm_1_3")] use crate::{DenomMetadata, PageRequest}; @@ -279,7 +278,7 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> { SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err( format!("Querier contract error: {contract_err}"), )), - SystemResult::Ok(ContractResult::Ok(value)) => from_json(value), + SystemResult::Ok(ContractResult::Ok(value)) => from_json(value).map_err(Into::into), } } From 08f86014f2fcbf5a2ec4caf7c8c2bd4ae780c4d7 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 18:56:30 +0100 Subject: [PATCH 02/42] Fix `no_std` compile issues --- packages/core/src/binary.rs | 5 +-- packages/core/src/errors/backtrace.rs | 1 + packages/core/src/errors/core_error.rs | 1 + packages/core/src/lib.rs | 1 + packages/core/src/math/conversion.rs | 5 ++- packages/core/src/math/decimal.rs | 16 +++++---- packages/core/src/math/decimal256.rs | 16 +++++---- packages/core/src/math/fraction.rs | 8 ++--- packages/core/src/math/int128.rs | 5 +-- packages/core/src/math/int256.rs | 5 +-- packages/core/src/math/int512.rs | 3 +- packages/core/src/math/int64.rs | 5 +-- packages/core/src/math/signed_decimal.rs | 38 ++++++++++---------- packages/core/src/math/signed_decimal_256.rs | 34 +++++++++--------- packages/core/src/math/uint128.rs | 5 +-- packages/core/src/math/uint256.rs | 5 +-- packages/core/src/math/uint512.rs | 3 +- packages/core/src/math/uint64.rs | 6 ++-- packages/core/src/serde.rs | 2 ++ packages/core/src/testing/assertions.rs | 3 +- 20 files changed, 97 insertions(+), 70 deletions(-) diff --git a/packages/core/src/binary.rs b/packages/core/src/binary.rs index 42d16883a4..610d777e63 100644 --- a/packages/core/src/binary.rs +++ b/packages/core/src/binary.rs @@ -1,3 +1,4 @@ +use alloc::{string::String, vec::Vec}; use core::fmt; use core::ops::Deref; @@ -57,7 +58,7 @@ impl Binary { /// Copy to array of explicit length /// /// ``` - /// # use cosmwasm_std::Binary; + /// # use cosmwasm_core::Binary; /// let binary = Binary::from(&[0xfb, 0x1f, 0x37]); /// let array: [u8; 3] = binary.to_array().unwrap(); /// assert_eq!(array, [0xfb, 0x1f, 0x37]); @@ -66,7 +67,7 @@ impl Binary { /// Copy to integer /// /// ``` - /// # use cosmwasm_std::Binary; + /// # use cosmwasm_core::Binary; /// let binary = Binary::from(&[0x8b, 0x67, 0x64, 0x84, 0xb5, 0xfb, 0x1f, 0x37]); /// let num = u64::from_be_bytes(binary.to_array().unwrap()); /// assert_eq!(num, 10045108015024774967); diff --git a/packages/core/src/errors/backtrace.rs b/packages/core/src/errors/backtrace.rs index 31df716946..08c126ad55 100644 --- a/packages/core/src/errors/backtrace.rs +++ b/packages/core/src/errors/backtrace.rs @@ -1,3 +1,4 @@ +use alloc::boxed::Box; use core::fmt::{Debug, Display, Formatter, Result}; /// This wraps an actual backtrace to achieve two things: diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index 82adb1adfc..15d325a497 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use derive_more::{Display, From}; use super::backtrace::{impl_from_err, BT}; diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index b9d90b59ad..f077a3eab1 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -4,6 +4,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +#[macro_use] extern crate alloc; mod binary; diff --git a/packages/core/src/math/conversion.rs b/packages/core/src/math/conversion.rs index c649dca7d7..87a08155c5 100644 --- a/packages/core/src/math/conversion.rs +++ b/packages/core/src/math/conversion.rs @@ -1,3 +1,6 @@ +#[allow(unused_imports)] +use alloc::string::String; + /// Grows a big endian signed integer to a bigger size. /// See pub const fn grow_be_int( @@ -195,7 +198,7 @@ where + core::cmp::PartialEq + core::fmt::Debug, String: From, - >::Error: std::fmt::Debug, + >::Error: core::fmt::Debug, { if core::mem::size_of::() <= core::mem::size_of::() { // if the input type is smaller than the output type, then `I::MAX` should fit into `O` diff --git a/packages/core/src/math/decimal.rs b/packages/core/src/math/decimal.rs index 39a5fae1e5..74d4863ed5 100644 --- a/packages/core/src/math/decimal.rs +++ b/packages/core/src/math/decimal.rs @@ -1,3 +1,4 @@ +use alloc::string::ToString; use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; @@ -75,7 +76,7 @@ impl Decimal { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_std::Decimal; + /// # use cosmwasm_core::Decimal; /// const HALF: Decimal = Decimal::percent(50); /// /// assert_eq!(HALF, Decimal::from_str("0.5").unwrap()); @@ -92,7 +93,7 @@ impl Decimal { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_std::Decimal; + /// # use cosmwasm_core::Decimal; /// const HALF: Decimal = Decimal::permille(500); /// /// assert_eq!(HALF, Decimal::from_str("0.5").unwrap()); @@ -109,7 +110,7 @@ impl Decimal { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_std::Decimal; + /// # use cosmwasm_core::Decimal; /// const TWO_BPS: Decimal = Decimal::bps(2); /// const HALF: Decimal = Decimal::bps(5000); /// @@ -133,7 +134,7 @@ impl Decimal { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{Decimal, Uint128}; + /// # use cosmwasm_core::{Decimal, Uint128}; /// let a = Decimal::from_atomics(Uint128::new(1234), 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -215,7 +216,7 @@ impl Decimal { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{Decimal, Uint128}; + /// # use cosmwasm_core::{Decimal, Uint128}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = Decimal::from_str("1.234").unwrap(); @@ -419,7 +420,7 @@ impl Decimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{Decimal, Uint128}; + /// use cosmwasm_core::{Decimal, Uint128}; /// /// let d = Decimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_floor(), Uint128::new(12)); @@ -442,7 +443,7 @@ impl Decimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{Decimal, Uint128}; + /// use cosmwasm_core::{Decimal, Uint128}; /// /// let d = Decimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_ceil(), Uint128::new(13)); @@ -786,6 +787,7 @@ impl<'de> de::Visitor<'de> for DecimalVisitor { mod tests { use super::*; use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; fn dec(input: &str) -> Decimal { Decimal::from_str(input).unwrap() diff --git a/packages/core/src/math/decimal256.rs b/packages/core/src/math/decimal256.rs index 0a17f0917e..3b053cd72d 100644 --- a/packages/core/src/math/decimal256.rs +++ b/packages/core/src/math/decimal256.rs @@ -1,3 +1,4 @@ +use alloc::string::ToString; use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; @@ -78,7 +79,7 @@ impl Decimal256 { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_std::Decimal256; + /// # use cosmwasm_core::Decimal256; /// const HALF: Decimal256 = Decimal256::percent(50); /// /// assert_eq!(HALF, Decimal256::from_str("0.5").unwrap()); @@ -95,7 +96,7 @@ impl Decimal256 { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_std::Decimal256; + /// # use cosmwasm_core::Decimal256; /// const HALF: Decimal256 = Decimal256::permille(500); /// /// assert_eq!(HALF, Decimal256::from_str("0.5").unwrap()); @@ -112,7 +113,7 @@ impl Decimal256 { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_std::Decimal256; + /// # use cosmwasm_core::Decimal256; /// const TWO_BPS: Decimal256 = Decimal256::bps(2); /// const HALF: Decimal256 = Decimal256::bps(5000); /// @@ -136,7 +137,7 @@ impl Decimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{Decimal256, Uint256}; + /// # use cosmwasm_core::{Decimal256, Uint256}; /// let a = Decimal256::from_atomics(1234u64, 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -224,7 +225,7 @@ impl Decimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{Decimal256, Uint256}; + /// # use cosmwasm_core::{Decimal256, Uint256}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = Decimal256::from_str("1.234").unwrap(); @@ -432,7 +433,7 @@ impl Decimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{Decimal256, Uint256}; + /// use cosmwasm_core::{Decimal256, Uint256}; /// /// let d = Decimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_floor(), Uint256::from(12u64)); @@ -455,7 +456,7 @@ impl Decimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{Decimal256, Uint256}; + /// use cosmwasm_core::{Decimal256, Uint256}; /// /// let d = Decimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_ceil(), Uint256::from(13u64)); @@ -787,6 +788,7 @@ mod tests { use super::*; use crate::errors::CoreError; use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; fn dec(input: &str) -> Decimal256 { Decimal256::from_str(input).unwrap() diff --git a/packages/core/src/math/fraction.rs b/packages/core/src/math/fraction.rs index c13c746182..020adb72a9 100644 --- a/packages/core/src/math/fraction.rs +++ b/packages/core/src/math/fraction.rs @@ -42,7 +42,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_std::Uint128; + /// use cosmwasm_core::Uint128; /// let fraction = (8u128, 21u128); /// let res = Uint128::new(123456).checked_mul_floor(fraction).unwrap(); /// assert_eq!(Uint128::new(47030), res); // 47030.8571 rounds down @@ -70,7 +70,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_std::Uint128; + /// use cosmwasm_core::Uint128; /// let fraction = (8u128, 21u128); /// let res = Uint128::new(123456).checked_mul_ceil(fraction).unwrap(); /// assert_eq!(Uint128::new(47031), res); // 47030.8571 rounds up @@ -102,7 +102,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_std::Uint128; + /// use cosmwasm_core::Uint128; /// let fraction = (4u128, 5u128); /// let res = Uint128::new(789).checked_div_floor(fraction).unwrap(); /// assert_eq!(Uint128::new(986), res); // 986.25 rounds down @@ -136,7 +136,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_std::Uint128; + /// use cosmwasm_core::Uint128; /// let fraction = (4u128, 5u128); /// let res = Uint128::new(789).checked_div_ceil(fraction).unwrap(); /// assert_eq!(Uint128::new(987), res); // 986.25 rounds up diff --git a/packages/core/src/math/int128.rs b/packages/core/src/math/int128.rs index e23e8d17da..93f6cc12e7 100644 --- a/packages/core/src/math/int128.rs +++ b/packages/core/src/math/int128.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -27,7 +28,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `i128` to get the value out: /// /// ``` -/// # use cosmwasm_std::Int128; +/// # use cosmwasm_core::Int128; /// let a = Int128::from(258i128); /// assert_eq!(a.i128(), 258); /// ``` @@ -129,7 +130,7 @@ impl Int128 { /// # Examples /// /// ``` - /// use cosmwasm_std::Int128; + /// use cosmwasm_core::Int128; /// /// let a = Int128::MAX; /// let result = a.full_mul(2i32); diff --git a/packages/core/src/math/int256.rs b/packages/core/src/math/int256.rs index 0b383a8cd5..52f30c943c 100644 --- a/packages/core/src/math/int256.rs +++ b/packages/core/src/math/int256.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -32,7 +33,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_std::Int256; +/// # use cosmwasm_core::Int256; /// let a = Int256::from(258u128); /// let b = Int256::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, @@ -184,7 +185,7 @@ impl Int256 { /// # Examples /// /// ``` - /// use cosmwasm_std::Int256; + /// use cosmwasm_core::Int256; /// /// let a = Int256::MAX; /// let result = a.full_mul(2i32); diff --git a/packages/core/src/math/int512.rs b/packages/core/src/math/int512.rs index 1d8c24ce2a..597b7b1d57 100644 --- a/packages/core/src/math/int512.rs +++ b/packages/core/src/math/int512.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -29,7 +30,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_std::Int512; +/// # use cosmwasm_core::Int512; /// let a = Int512::from(258u128); /// let b = Int512::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, diff --git a/packages/core/src/math/int64.rs b/packages/core/src/math/int64.rs index 36814087b2..2c37c49a2e 100644 --- a/packages/core/src/math/int64.rs +++ b/packages/core/src/math/int64.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -27,7 +28,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `i64` to get the value out: /// /// ``` -/// # use cosmwasm_std::Int64; +/// # use cosmwasm_core::Int64; /// let a = Int64::from(258i64); /// assert_eq!(a.i64(), 258); /// ``` @@ -129,7 +130,7 @@ impl Int64 { /// # Examples /// /// ``` - /// use cosmwasm_std::Int64; + /// use cosmwasm_core::Int64; /// /// let a = Int64::MAX; /// let result = a.full_mul(2i32); diff --git a/packages/core/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs index 55f933cf85..55109a2da9 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -1,3 +1,4 @@ +use alloc::string::ToString; use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{ @@ -48,7 +49,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// assert_eq!(SignedDecimal::MAX.to_string(), "170141183460469231731.687303715884105727"); /// ``` pub const MAX: Self = Self(Int128::MAX); @@ -58,7 +59,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// assert_eq!(SignedDecimal::MIN.to_string(), "-170141183460469231731.687303715884105728"); /// ``` pub const MIN: Self = Self(Int128::MIN); @@ -69,7 +70,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal, Int128}; + /// # use cosmwasm_core::{SignedDecimal, Int128}; /// assert_eq!(SignedDecimal::new(Int128::one()).to_string(), "0.000000000000000001"); /// ``` pub const fn new(value: Int128) -> Self { @@ -82,7 +83,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// assert_eq!(SignedDecimal::raw(1234i128).to_string(), "0.000000000000001234"); /// ``` pub const fn raw(value: i128) -> Self { @@ -133,7 +134,7 @@ impl SignedDecimal { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal, Int128}; + /// # use cosmwasm_core::{SignedDecimal, Int128}; /// let a = SignedDecimal::from_atomics(Int128::new(1234), 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -182,7 +183,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// assert_eq!( /// SignedDecimal::from_ratio(1, 3).to_string(), /// "0.333333333333333333" @@ -203,7 +204,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal, CheckedFromRatioError}; + /// # use cosmwasm_core::{SignedDecimal, CheckedFromRatioError}; /// assert_eq!( /// SignedDecimal::checked_from_ratio(1, 3).unwrap().to_string(), /// "0.333333333333333333" @@ -249,7 +250,7 @@ impl SignedDecimal { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal, Int128}; + /// # use cosmwasm_core::{SignedDecimal, Int128}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = SignedDecimal::from_str("1.234").unwrap(); @@ -282,7 +283,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// # use core::str::FromStr; /// assert!(SignedDecimal::from_str("0.6").unwrap().trunc().is_zero()); /// assert_eq!(SignedDecimal::from_str("-5.8").unwrap().trunc().to_string(), "-5"); @@ -297,7 +298,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// # use core::str::FromStr; /// assert!(SignedDecimal::from_str("0.6").unwrap().floor().is_zero()); /// assert_eq!(SignedDecimal::from_str("-5.2").unwrap().floor().to_string(), "-6"); @@ -332,7 +333,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal; + /// # use cosmwasm_core::SignedDecimal; /// # use core::str::FromStr; /// assert_eq!(SignedDecimal::from_str("0.2").unwrap().ceil(), SignedDecimal::one()); /// assert_eq!(SignedDecimal::from_str("-5.8").unwrap().ceil().to_string(), "-5"); @@ -486,7 +487,7 @@ impl SignedDecimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{SignedDecimal, Int128}; + /// use cosmwasm_core::{SignedDecimal, Int128}; /// /// let d = SignedDecimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_floor(), Int128::new(12)); @@ -518,7 +519,7 @@ impl SignedDecimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{SignedDecimal, Int128}; + /// use cosmwasm_core::{SignedDecimal, Int128}; /// /// let d = SignedDecimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_trunc(), Int128::new(12)); @@ -541,7 +542,7 @@ impl SignedDecimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{SignedDecimal, Int128}; + /// use cosmwasm_core::{SignedDecimal, Int128}; /// /// let d = SignedDecimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_ceil(), Int128::new(13)); @@ -911,7 +912,7 @@ impl<'de> de::Visitor<'de> for SignedDecimalVisitor { mod tests { use super::*; use crate::{from_json, to_json_vec}; - use schemars::schema_for; + use alloc::vec::Vec; fn dec(input: &str) -> SignedDecimal { SignedDecimal::from_str(input).unwrap() @@ -3075,7 +3076,7 @@ mod tests { // invalid: not a string encoded decimal assert_eq!( - "invalid type: integer `123`, expected string-encoded decimal at line 1 column 3", + "Invalid type", serde_json_wasm::from_str::("123") .err() .unwrap() @@ -3084,7 +3085,7 @@ mod tests { // invalid: not properly defined signed decimal value assert_eq!( - "Error parsing decimal '1.e': Generic error: Error parsing fractional at line 1 column 5", + "Error parsing decimal '1.e': Generic error: Error parsing fractional", serde_json_wasm::from_str::(r#""1.e""#) .err() .unwrap() @@ -3093,8 +3094,9 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn signed_decimal_has_defined_json_schema() { - let schema = schema_for!(SignedDecimal); + let schema = schemars::schema_for!(SignedDecimal); assert_eq!( "SignedDecimal", schema.schema.metadata.unwrap().title.unwrap() diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs index ec98fa0b43..667a96a5b6 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -1,3 +1,4 @@ +use alloc::string::ToString; use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{ @@ -54,7 +55,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// assert_eq!( /// SignedDecimal256::MAX.to_string(), /// "57896044618658097711785492504343953926634992332820282019728.792003956564819967" @@ -67,7 +68,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// assert_eq!( /// SignedDecimal256::MIN.to_string(), /// "-57896044618658097711785492504343953926634992332820282019728.792003956564819968" @@ -81,7 +82,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal256, Int256}; + /// # use cosmwasm_core::{SignedDecimal256, Int256}; /// assert_eq!(SignedDecimal256::new(Int256::one()).to_string(), "0.000000000000000001"); /// ``` pub const fn new(value: Int256) -> Self { @@ -94,7 +95,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// assert_eq!(SignedDecimal256::raw(1234i128).to_string(), "0.000000000000001234"); /// ``` pub const fn raw(value: i128) -> Self { @@ -146,7 +147,7 @@ impl SignedDecimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal256, Int256}; + /// # use cosmwasm_core::{SignedDecimal256, Int256}; /// let a = SignedDecimal256::from_atomics(Int256::from(1234), 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -195,7 +196,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// assert_eq!( /// SignedDecimal256::from_ratio(1, 3).to_string(), /// "0.333333333333333333" @@ -216,7 +217,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal256, CheckedFromRatioError}; + /// # use cosmwasm_core::{SignedDecimal256, CheckedFromRatioError}; /// assert_eq!( /// SignedDecimal256::checked_from_ratio(1, 3).unwrap().to_string(), /// "0.333333333333333333" @@ -262,7 +263,7 @@ impl SignedDecimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_std::{SignedDecimal256, Int256}; + /// # use cosmwasm_core::{SignedDecimal256, Int256}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = SignedDecimal256::from_str("1.234").unwrap(); @@ -295,7 +296,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// # use core::str::FromStr; /// assert!(SignedDecimal256::from_str("0.6").unwrap().trunc().is_zero()); /// assert_eq!(SignedDecimal256::from_str("-5.8").unwrap().trunc().to_string(), "-5"); @@ -310,7 +311,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// # use core::str::FromStr; /// assert!(SignedDecimal256::from_str("0.6").unwrap().floor().is_zero()); /// assert_eq!(SignedDecimal256::from_str("-5.2").unwrap().floor().to_string(), "-6"); @@ -345,7 +346,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_std::SignedDecimal256; + /// # use cosmwasm_core::SignedDecimal256; /// # use core::str::FromStr; /// assert_eq!(SignedDecimal256::from_str("0.2").unwrap().ceil(), SignedDecimal256::one()); /// assert_eq!(SignedDecimal256::from_str("-5.8").unwrap().ceil().to_string(), "-5"); @@ -499,7 +500,7 @@ impl SignedDecimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{SignedDecimal256, Int256}; + /// use cosmwasm_core::{SignedDecimal256, Int256}; /// /// let d = SignedDecimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_floor(), Int256::from(12)); @@ -531,7 +532,7 @@ impl SignedDecimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{SignedDecimal256, Int256}; + /// use cosmwasm_core::{SignedDecimal256, Int256}; /// /// let d = SignedDecimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_trunc(), Int256::from(12)); @@ -554,7 +555,7 @@ impl SignedDecimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_std::{SignedDecimal256, Int256}; + /// use cosmwasm_core::{SignedDecimal256, Int256}; /// /// let d = SignedDecimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_ceil(), Int256::from(13)); @@ -912,6 +913,7 @@ impl<'de> de::Visitor<'de> for SignedDecimal256Visitor { mod tests { use super::*; use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; fn dec(input: &str) -> SignedDecimal256 { SignedDecimal256::from_str(input).unwrap() @@ -3247,7 +3249,7 @@ mod tests { // invalid: not a string encoded decimal assert_eq!( - "invalid type: integer `123`, expected string-encoded decimal at line 1 column 3", + "Invalid type", serde_json_wasm::from_str::("123") .err() .unwrap() @@ -3256,7 +3258,7 @@ mod tests { // invalid: not properly defined signed decimal value assert_eq!( - "Error parsing decimal '1.e': Generic error: Error parsing fractional at line 1 column 5", + "Error parsing decimal '1.e': Generic error: Error parsing fractional", serde_json_wasm::from_str::(r#""1.e""#) .err() .unwrap() diff --git a/packages/core/src/math/uint128.rs b/packages/core/src/math/uint128.rs index 9fde45beb9..9d3cb49b98 100644 --- a/packages/core/src/math/uint128.rs +++ b/packages/core/src/math/uint128.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -29,7 +30,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `u128` to get the value out: /// /// ``` -/// # use cosmwasm_std::Uint128; +/// # use cosmwasm_core::Uint128; /// let a = Uint128::from(123u128); /// assert_eq!(a.u128(), 123); /// @@ -140,7 +141,7 @@ impl Uint128 { /// # Examples /// /// ``` - /// use cosmwasm_std::Uint128; + /// use cosmwasm_core::Uint128; /// /// let a = Uint128::MAX; /// let result = a.full_mul(2u32); diff --git a/packages/core/src/math/uint256.rs b/packages/core/src/math/uint256.rs index 6821df9548..594d4f4f02 100644 --- a/packages/core/src/math/uint256.rs +++ b/packages/core/src/math/uint256.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -33,7 +34,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_std::Uint256; +/// # use cosmwasm_core::Uint256; /// let a = Uint256::from(258u128); /// let b = Uint256::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, @@ -212,7 +213,7 @@ impl Uint256 { /// # Examples /// /// ``` - /// use cosmwasm_std::Uint256; + /// use cosmwasm_core::Uint256; /// /// let a = Uint256::MAX; /// let result = a.full_mul(2u32); diff --git a/packages/core/src/math/uint512.rs b/packages/core/src/math/uint512.rs index 4332f048d5..8da1da5eaa 100644 --- a/packages/core/src/math/uint512.rs +++ b/packages/core/src/math/uint512.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -29,7 +30,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_std::Uint512; +/// # use cosmwasm_core::Uint512; /// let a = Uint512::from(258u128); /// let b = Uint512::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, diff --git a/packages/core/src/math/uint64.rs b/packages/core/src/math/uint64.rs index 67f57e85d3..325b74e533 100644 --- a/packages/core/src/math/uint64.rs +++ b/packages/core/src/math/uint64.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::fmt; use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, @@ -26,7 +27,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `u64` to get the value out: /// /// ``` -/// # use cosmwasm_std::Uint64; +/// # use cosmwasm_core::Uint64; /// let a = Uint64::from(42u64); /// assert_eq!(a.u64(), 42); /// @@ -134,7 +135,7 @@ impl Uint64 { /// # Examples /// /// ``` - /// use cosmwasm_std::Uint64; + /// use cosmwasm_core::Uint64; /// /// let a = Uint64::MAX; /// let result = a.full_mul(2u32); @@ -576,6 +577,7 @@ mod tests { use crate::errors::CheckedMultiplyFractionError::{ConversionOverflow, DivideByZero}; use crate::math::conversion::test_try_from_int_to_uint; use crate::{from_json, to_json_vec, ConversionOverflowError}; + use alloc::string::ToString; #[test] fn size_of_works() { diff --git a/packages/core/src/serde.rs b/packages/core/src/serde.rs index c95c5ae5fa..4f30512b65 100644 --- a/packages/core/src/serde.rs +++ b/packages/core/src/serde.rs @@ -3,6 +3,7 @@ // 1. To easily ensure that all calling libraries use the same version (minimize code size) // 2. To allow us to switch out to eg. serde-json-core more easily +use alloc::{string::String, vec::Vec}; use core::any::type_name; use serde::{de::DeserializeOwned, Serialize}; @@ -70,6 +71,7 @@ where #[cfg(test)] mod tests { use super::*; + use alloc::string::ToString; use serde::Deserialize; #[derive(Serialize, Deserialize, Debug, PartialEq)] diff --git a/packages/core/src/testing/assertions.rs b/packages/core/src/testing/assertions.rs index e762e0e42f..5fb4ccb37b 100644 --- a/packages/core/src/testing/assertions.rs +++ b/packages/core/src/testing/assertions.rs @@ -1,5 +1,6 @@ use crate::{Decimal, Uint128}; +use alloc::string::String; #[cfg(any(test, feature = "testing"))] use core::hash::{Hash, Hasher}; use core::str::FromStr as _; @@ -43,7 +44,7 @@ macro_rules! assert_hash_works { }}; } -/// Implementation for the [`cosmwasm_std::assert_approx_eq`] macro. This does not provide any +/// Implementation for the [`cosmwasm_core::assert_approx_eq`] macro. This does not provide any /// stability guarantees and may change any time. #[track_caller] #[doc(hidden)] From 4647230ca80359c63177026c42f68eb4da4fb2c3 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:05:55 +0100 Subject: [PATCH 03/42] Add CI jobs --- .circleci/config.yml | 66 ++++++++++++++++++++ Cargo.lock | 14 ++--- contracts/burner/Cargo.lock | 87 ++++++++++++++++++-------- contracts/crypto-verify/Cargo.lock | 87 ++++++++++++++++++-------- contracts/cyberpunk/Cargo.lock | 87 ++++++++++++++++++-------- contracts/empty/Cargo.lock | 87 ++++++++++++++++++-------- contracts/floaty/Cargo.lock | 87 ++++++++++++++++++-------- contracts/hackatom/Cargo.lock | 87 ++++++++++++++++++-------- contracts/ibc-reflect-send/Cargo.lock | 87 ++++++++++++++++++-------- contracts/ibc-reflect/Cargo.lock | 87 ++++++++++++++++++-------- contracts/queue/Cargo.lock | 87 ++++++++++++++++++-------- contracts/reflect/Cargo.lock | 87 ++++++++++++++++++-------- contracts/staking/Cargo.lock | 89 +++++++++++++++++++-------- contracts/virus/Cargo.lock | 87 ++++++++++++++++++-------- packages/core/Cargo.toml | 8 +-- packages/std/src/errors/std_error.rs | 1 - 16 files changed, 830 insertions(+), 305 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 02a835509a..1357fa3219 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,6 +65,7 @@ workflows: - arm64 - package_crypto - package_check + - package_core - package_schema - package_schema_derive - package_std @@ -171,6 +172,10 @@ jobs: name: "contracts/staking: integration-test" working_directory: ~/project/contracts/staking command: cargo wasm --locked && cargo integration-test --locked + - run: + name: "packages/core: test" + working_directory: ~/project/packages/core + command: cargo test --all-features --locked - run: name: "packages/crypto: test" working_directory: ~/project/packages/crypto @@ -285,6 +290,55 @@ jobs: - target/debug/deps key: cargocache-v2-package_check-rust:1.73-{{ checksum "Cargo.lock" }} + package_core: + docker: + - image: rust:1.73 + environment: + # Limit the number of parallel jobs to avoid OOM crashes during doc testing + RUST_TEST_THREADS: 8 + steps: + - checkout + - run: + name: Version information + command: rustc --version; cargo --version; rustup --version; rustup target list --installed + - restore_cache: + keys: + - cargocache-v2-package_core-rust:1.73-{{ checksum "Cargo.lock" }} + - run: + name: Add wasm32 target + command: rustup target add wasm32-unknown-unknown && rustup target list --installed + - run: + name: Build library for native target (no features) + working_directory: ~/project/packages/core + command: cargo build --locked --no-default-features + - run: + name: Build library for wasm target (no features) + working_directory: ~/project/packages/core + command: cargo wasm --locked --no-default-features + - run: + name: Run unit tests (no features) + working_directory: ~/project/packages/core + command: cargo test --locked --no-default-features + - run: + name: Build library for native target (all features) + working_directory: ~/project/packages/core + command: cargo build --locked --features std,testing + - run: + name: Build library for wasm target (all features) + working_directory: ~/project/packages/core + command: cargo wasm --locked --features std,testingstd,testing + - run: + name: Run unit tests (all features) + working_directory: ~/project/packages/core + command: cargo test --locked --features std,testing + - save_cache: + paths: + - /usr/local/cargo/registry + - target/debug/.fingerprint + - target/debug/build + - target/debug/deps + key: cargocache-v2-package_core-rust:1.73-{{ checksum "Cargo.lock" }} + package_schema: docker: - image: rust:1.73 @@ -925,6 +979,14 @@ jobs: name: Clippy linting on schema-derive working_directory: ~/project/packages/schema-derive command: cargo clippy --all-targets --tests -- -D warnings + - run: + name: Clippy linting on core (no feature flags) + working_directory: ~/project/packages/core + command: cargo clippy --all-targets -- -D warnings + - run: + name: Clippy linting on core (all feature flags) + working_directory: ~/project/packages/core + command: cargo clippy --all-features --all-targets -- -D warnings - run: name: Clippy linting on std (no feature flags) working_directory: ~/project/packages/std @@ -999,6 +1061,7 @@ jobs: mkdir -p reports cargo test + grcov . -s packages/core --binary-path ./target/debug -t lcov -o ./reports/core.info grcov . -s packages/crypto --binary-path ./target/debug -t lcov -o ./reports/crypto.info grcov . -s packages/derive --binary-path ./target/debug -t lcov -o ./reports/derive.info grcov . -s packages/schema --binary-path ./target/debug -t lcov -o ./reports/schema.info @@ -1007,6 +1070,9 @@ jobs: environment: RUSTFLAGS: "-Cinstrument-coverage" LLVM_PROFILE_FILE: "cosmwasm-%p-%m.profraw" + - codecov/upload: + file: reports/core.info + flags: cosmwasm-core - codecov/upload: file: reports/crypto.info flags: cosmwasm-crypto diff --git a/Cargo.lock b/Cargo.lock index 75649ffdd9..d8eb735236 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,12 +174,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.0" @@ -233,9 +227,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "bstr" @@ -430,7 +424,7 @@ dependencies = [ name = "cosmwasm-core" version = "2.0.1" dependencies = [ - "base64 0.21.7", + "base64", "bnum", "crc32fast", "derive_more", @@ -500,7 +494,7 @@ dependencies = [ name = "cosmwasm-std" version = "2.0.1" dependencies = [ - "base64 0.22.0", + "base64", "bech32", "chrono", "cosmwasm-core", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index cfbc3edc9e..0e28d93d0d 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -212,6 +212,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -231,7 +245,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -251,7 +265,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -260,17 +274,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -489,7 +501,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -523,7 +535,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -561,6 +573,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -710,7 +743,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1289,9 +1322,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1301,9 +1334,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1351,9 +1384,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1380,13 +1413,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1501,7 +1534,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1523,9 +1556,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1577,7 +1610,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1601,6 +1634,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1978,7 +2017,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1998,5 +2037,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 0a6322ff57..2095e1d25b 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -496,7 +508,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -519,7 +531,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -530,7 +542,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -568,6 +580,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -717,7 +750,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1324,9 +1357,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1336,9 +1369,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1386,9 +1419,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1415,13 +1448,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1546,7 +1579,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1568,9 +1601,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1622,7 +1655,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1646,6 +1679,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -2023,7 +2062,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -2043,5 +2082,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 808d6e1a55..78d06ba242 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -230,6 +230,20 @@ dependencies = [ "windows-sys 0.33.0", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64 0.22.0", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -249,7 +263,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -269,7 +283,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -278,17 +292,15 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -507,7 +519,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -542,7 +554,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -553,7 +565,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -591,6 +603,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -740,7 +773,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1406,9 +1439,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1418,9 +1451,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1468,9 +1501,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1497,13 +1530,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1618,7 +1651,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1640,9 +1673,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1707,7 +1740,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1731,6 +1764,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -2183,7 +2222,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -2203,5 +2242,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index c48eb2c769..f3d71de566 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -709,7 +742,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1288,9 +1321,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1300,9 +1333,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1350,9 +1383,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1379,13 +1412,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1500,7 +1533,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1522,9 +1555,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1576,7 +1609,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1600,6 +1633,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1977,7 +2016,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1997,5 +2036,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index f4dd69504b..1aa907940b 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -1306,9 +1339,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1318,9 +1351,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1368,9 +1401,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1397,13 +1430,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -1518,7 +1551,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -1540,9 +1573,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1594,7 +1627,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -1618,6 +1651,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1995,7 +2034,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] [[package]] @@ -2015,5 +2054,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.52", ] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 36df027161..9a86fede4f 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1291,9 +1324,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1303,9 +1336,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1353,9 +1386,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1382,13 +1415,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1503,7 +1536,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1525,9 +1558,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1579,7 +1612,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1603,6 +1636,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1980,7 +2019,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -2000,5 +2039,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index e0ec441894..089832fdc2 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1289,9 +1322,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1301,9 +1334,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1351,9 +1384,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1380,13 +1413,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1501,7 +1534,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1523,9 +1556,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1577,7 +1610,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1601,6 +1634,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1978,7 +2017,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1998,5 +2037,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index f03b79ab28..6b4e0a85f7 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1289,9 +1322,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1301,9 +1334,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1351,9 +1384,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1380,13 +1413,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1501,7 +1534,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1523,9 +1556,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1577,7 +1610,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1601,6 +1634,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1978,7 +2017,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1998,5 +2037,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 658f0f88e8..cbfd147bda 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1289,9 +1322,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1301,9 +1334,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1351,9 +1384,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1380,13 +1413,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1501,7 +1534,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1523,9 +1556,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1577,7 +1610,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1601,6 +1634,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1978,7 +2017,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1998,5 +2037,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 62696ce9e9..1c2f8e1030 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1290,9 +1323,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1302,9 +1335,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1352,9 +1385,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1381,13 +1414,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1502,7 +1535,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1524,9 +1557,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1578,7 +1611,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1602,6 +1635,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1979,7 +2018,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1999,5 +2038,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 4f41bd0955..26a784f6af 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1278,9 +1311,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1290,9 +1323,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1340,9 +1373,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1369,13 +1402,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1467,7 +1500,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1523,7 +1556,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1545,9 +1578,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1599,7 +1632,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1623,6 +1656,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -2000,7 +2039,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -2020,5 +2059,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index b089bd4302..5f29133446 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -201,6 +201,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cosmwasm-core" +version = "2.0.0" +dependencies = [ + "base64", + "bnum", + "derive_more", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "static_assertions", +] + [[package]] name = "cosmwasm-crypto" version = "2.0.1" @@ -220,7 +234,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -240,7 +254,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -249,17 +263,15 @@ version = "2.0.1" dependencies = [ "base64", "bech32", - "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", "derivative", - "forward_ref", "hex", "schemars", "serde", "serde-json-wasm", "sha2", - "static_assertions", "thiserror", ] @@ -478,7 +490,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -501,7 +513,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -512,7 +524,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -550,6 +562,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -699,7 +732,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1278,9 +1311,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -1290,9 +1323,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1340,9 +1373,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -1369,13 +1402,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1490,7 +1523,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1512,9 +1545,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1566,7 +1599,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1590,6 +1623,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1979,7 +2018,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] [[package]] @@ -1999,5 +2038,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.52", ] diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index d7ccaa8007..73580eb949 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -11,8 +11,8 @@ readme = "README.md" release = false [dependencies] -base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } -bnum = "0.10.0" +base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } +bnum = "0.11.0" crc32fast = { version = "1.4.0", optional = true, default-features = false } derive_more = { version = "1.0.0-beta.6", features = ["display", "from"] } forward_ref = "1.0.0" @@ -22,10 +22,8 @@ serde-json-wasm = { version = "1.0.1", default-features = false } static_assertions = "1.1.0" [features] -#default = ["std"] std = ["dep:schemars"] -# Expose things that are usually gated behind `#[cfg(test)]` inside the `testing` module -# (do NOT use in production please. Or I will cry.) +# Expose things that are usually gated behind `#[cfg(test)]` inside the `testing` module (do NOT use in production) # # Also this is semver exempt. Beware here be dragons. testing = ["dep:crc32fast"] diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index f26f94dcf8..6ec02b9899 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -83,7 +83,6 @@ pub enum StdError { }, } -// Needs complex conversion to not break user expectations.. AAAAAAAAAAAAAAAAAAAAAAAAAAAA impl From for StdError { fn from(value: CoreError) -> Self { match value { From 735cf9a46fa1a6f3927b912a65e8af75c20beecb Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:07:11 +0100 Subject: [PATCH 04/42] Format README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4b7db8973..2db467637e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The following packages are maintained here: | cosmwasm-crypto | Internal only | [![cosmwasm-crypto on crates.io](https://img.shields.io/crates/v/cosmwasm-crypto.svg)](https://crates.io/crates/cosmwasm-crypto) | [![Docs](https://docs.rs/cosmwasm-crypto/badge.svg)](https://docs.rs/cosmwasm-crypto) | [![Coverage][cov-badge-crypto]][cov-link-crypto] | | cosmwasm-derive | Internal only | [![cosmwasm-derive on crates.io](https://img.shields.io/crates/v/cosmwasm-derive.svg)](https://crates.io/crates/cosmwasm-derive) | [![Docs](https://docs.rs/cosmwasm-derive/badge.svg)](https://docs.rs/cosmwasm-derive) | [![Coverage][cov-badge-derive]][cov-link-derive] | | cosmwasm-schema | Contract development | [![cosmwasm-schema on crates.io](https://img.shields.io/crates/v/cosmwasm-schema.svg)](https://crates.io/crates/cosmwasm-schema) | [![Docs](https://docs.rs/cosmwasm-schema/badge.svg)](https://docs.rs/cosmwasm-schema) | [![Coverage][cov-badge-schema]][cov-link-schema] | -| cosmwasm-core | Contract development | [![cosmwasm-core on crates.io](https://img.shields.io/crates/v/cosmwasm-core.svg)](https://crates.io/crates/cosmwasm-core) | [![Docs](https://docs.rs/cosmwasm-core/badge.svg)](https://docs.rs/cosmwasm-core) | [![Coverage][cov-badge-core]][cov-link-core] | +| cosmwasm-core | Contract development | [![cosmwasm-core on crates.io](https://img.shields.io/crates/v/cosmwasm-core.svg)](https://crates.io/crates/cosmwasm-core) | [![Docs](https://docs.rs/cosmwasm-core/badge.svg)](https://docs.rs/cosmwasm-core) | [![Coverage][cov-badge-core]][cov-link-core] | | cosmwasm-std | Contract development | [![cosmwasm-std on crates.io](https://img.shields.io/crates/v/cosmwasm-std.svg)](https://crates.io/crates/cosmwasm-std) | [![Docs](https://docs.rs/cosmwasm-std/badge.svg)](https://docs.rs/cosmwasm-std) | [![Coverage][cov-badge-std]][cov-link-std] | | cosmwasm-vm | Host environments | [![cosmwasm-vm on crates.io](https://img.shields.io/crates/v/cosmwasm-vm.svg)](https://crates.io/crates/cosmwasm-vm) | [![Docs](https://docs.rs/cosmwasm-vm/badge.svg)](https://docs.rs/cosmwasm-vm) | [![Coverage][cov-badge-vm]][cov-link-vm] | | cosmwasm-check | Contract development | [![cosmwasm-check on crates.io](https://img.shields.io/crates/v/cosmwasm-check.svg)](https://crates.io/crates/cosmwasm-check) | `cosmwasm-check -h` | N/A | From 81dfd8f34b524b73282356badeb14256b1b6ccd6 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:17:17 +0100 Subject: [PATCH 05/42] Move `serde` module back to `cosmwasm-std` --- Cargo.lock | 1 + packages/core/Cargo.toml | 2 ++ packages/core/src/binary.rs | 3 ++- packages/core/src/lib.rs | 6 ----- packages/core/src/math/decimal.rs | 3 ++- packages/core/src/math/decimal256.rs | 3 ++- packages/core/src/math/int128.rs | 4 ++- packages/core/src/math/int256.rs | 4 ++- packages/core/src/math/int512.rs | 4 ++- packages/core/src/math/int64.rs | 4 ++- packages/core/src/math/signed_decimal.rs | 3 ++- packages/core/src/math/signed_decimal_256.rs | 3 ++- packages/core/src/math/uint128.rs | 4 ++- packages/core/src/math/uint256.rs | 4 ++- packages/core/src/math/uint512.rs | 4 ++- packages/core/src/math/uint64.rs | 4 ++- packages/std/src/ibc.rs | 2 +- packages/std/src/lib.rs | 6 +++++ packages/std/src/results/contract_result.rs | 16 ++++++------ packages/std/src/results/cosmos_msg.rs | 2 +- packages/std/src/results/empty.rs | 2 +- packages/std/src/results/submessages.rs | 12 ++++----- packages/{core => std}/src/serde.rs | 26 ++++++++++---------- packages/std/src/testing/mock.rs | 2 +- packages/std/src/traits.rs | 2 +- 25 files changed, 73 insertions(+), 53 deletions(-) rename packages/{core => std}/src/serde.rs (86%) diff --git a/Cargo.lock b/Cargo.lock index d8eb735236..fd6227518e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,6 +426,7 @@ version = "2.0.1" dependencies = [ "base64", "bnum", + "cosmwasm-std", "crc32fast", "derive_more", "forward_ref", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 73580eb949..8d2a66dda6 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -29,4 +29,6 @@ std = ["dep:schemars"] testing = ["dep:crc32fast"] [dev-dependencies] +# I love cyclic dependencies. They are good for your health. +cosmwasm-std = { path = "../std", version = "2.0.0" } crc32fast = { version = "1.4.0", default-features = false } diff --git a/packages/core/src/binary.rs b/packages/core/src/binary.rs index 610d777e63..a9ddf9122a 100644 --- a/packages/core/src/binary.rs +++ b/packages/core/src/binary.rs @@ -259,7 +259,8 @@ mod tests { use super::*; use crate::assert_hash_works; use crate::errors::CoreError; - use crate::serde::{from_json, to_json_vec}; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn to_array_works() { diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index f077a3eab1..a6c0e01853 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -11,7 +11,6 @@ mod binary; mod errors; mod forward_ref; mod math; -mod serde; #[doc(hidden)] pub mod __internal; @@ -27,11 +26,6 @@ pub use crate::math::{ Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, }; -#[allow(deprecated)] -pub use crate::serde::{ - from_binary, from_json, from_slice, to_binary, to_json_binary, to_json_string, to_json_vec, - to_vec, -}; /// Exposed for testing only /// Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm. diff --git a/packages/core/src/math/decimal.rs b/packages/core/src/math/decimal.rs index 74d4863ed5..95bf7df5e8 100644 --- a/packages/core/src/math/decimal.rs +++ b/packages/core/src/math/decimal.rs @@ -786,8 +786,9 @@ impl<'de> de::Visitor<'de> for DecimalVisitor { #[cfg(test)] mod tests { use super::*; - use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; + use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> Decimal { Decimal::from_str(input).unwrap() diff --git a/packages/core/src/math/decimal256.rs b/packages/core/src/math/decimal256.rs index 3b053cd72d..f1ccf739c6 100644 --- a/packages/core/src/math/decimal256.rs +++ b/packages/core/src/math/decimal256.rs @@ -787,8 +787,9 @@ impl<'de> de::Visitor<'de> for Decimal256Visitor { mod tests { use super::*; use crate::errors::CoreError; - use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; + use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> Decimal256 { Decimal256::from_str(input).unwrap() diff --git a/packages/core/src/math/int128.rs b/packages/core/src/math/int128.rs index 93f6cc12e7..f9980b41ef 100644 --- a/packages/core/src/math/int128.rs +++ b/packages/core/src/math/int128.rs @@ -573,7 +573,9 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{from_json, math::conversion::test_try_from_uint_to_int, to_json_vec}; + use crate::math::conversion::test_try_from_uint_to_int; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/core/src/math/int256.rs b/packages/core/src/math/int256.rs index 52f30c943c..0ed420be41 100644 --- a/packages/core/src/math/int256.rs +++ b/packages/core/src/math/int256.rs @@ -648,7 +648,9 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{from_json, math::conversion::test_try_from_uint_to_int, to_json_vec}; + use crate::math::conversion::test_try_from_uint_to_int; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/core/src/math/int512.rs b/packages/core/src/math/int512.rs index 597b7b1d57..c6283a2185 100644 --- a/packages/core/src/math/int512.rs +++ b/packages/core/src/math/int512.rs @@ -645,7 +645,9 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{from_json, math::conversion::test_try_from_uint_to_int, to_json_vec}; + use crate::math::conversion::test_try_from_uint_to_int; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/core/src/math/int64.rs b/packages/core/src/math/int64.rs index 2c37c49a2e..7cfaaa5390 100644 --- a/packages/core/src/math/int64.rs +++ b/packages/core/src/math/int64.rs @@ -552,7 +552,9 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{from_json, math::conversion::test_try_from_uint_to_int, to_json_vec}; + use crate::math::conversion::test_try_from_uint_to_int; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/core/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs index 55109a2da9..2a00d7eba4 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -911,8 +911,9 @@ impl<'de> de::Visitor<'de> for SignedDecimalVisitor { #[cfg(test)] mod tests { use super::*; - use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; + use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> SignedDecimal { SignedDecimal::from_str(input).unwrap() diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs index 667a96a5b6..886399637d 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -912,8 +912,9 @@ impl<'de> de::Visitor<'de> for SignedDecimal256Visitor { #[cfg(test)] mod tests { use super::*; - use crate::{from_json, to_json_vec}; + use alloc::vec::Vec; + use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> SignedDecimal256 { SignedDecimal256::from_str(input).unwrap() diff --git a/packages/core/src/math/uint128.rs b/packages/core/src/math/uint128.rs index 9d3cb49b98..1483fe8267 100644 --- a/packages/core/src/math/uint128.rs +++ b/packages/core/src/math/uint128.rs @@ -610,7 +610,9 @@ where mod tests { use crate::errors::CheckedMultiplyFractionError::{ConversionOverflow, DivideByZero}; use crate::math::conversion::test_try_from_int_to_uint; - use crate::{from_json, to_json_vec, ConversionOverflowError, Decimal}; + use crate::{ConversionOverflowError, Decimal}; + + use cosmwasm_std::{from_json, to_json_vec}; use super::*; diff --git a/packages/core/src/math/uint256.rs b/packages/core/src/math/uint256.rs index 594d4f4f02..8ebfeb4c9e 100644 --- a/packages/core/src/math/uint256.rs +++ b/packages/core/src/math/uint256.rs @@ -675,7 +675,9 @@ mod tests { use super::*; use crate::errors::CheckedMultiplyFractionError::{ConversionOverflow, DivideByZero}; use crate::math::conversion::test_try_from_int_to_uint; - use crate::{from_json, to_json_vec, Decimal, Decimal256}; + use crate::{Decimal, Decimal256}; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/core/src/math/uint512.rs b/packages/core/src/math/uint512.rs index 8da1da5eaa..7fa7847594 100644 --- a/packages/core/src/math/uint512.rs +++ b/packages/core/src/math/uint512.rs @@ -640,7 +640,9 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{from_json, math::conversion::test_try_from_int_to_uint, to_json_vec}; + use crate::math::conversion::test_try_from_int_to_uint; + + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/core/src/math/uint64.rs b/packages/core/src/math/uint64.rs index 325b74e533..dd2ace125b 100644 --- a/packages/core/src/math/uint64.rs +++ b/packages/core/src/math/uint64.rs @@ -576,8 +576,10 @@ mod tests { use super::*; use crate::errors::CheckedMultiplyFractionError::{ConversionOverflow, DivideByZero}; use crate::math::conversion::test_try_from_int_to_uint; - use crate::{from_json, to_json_vec, ConversionOverflowError}; + use crate::ConversionOverflowError; + use alloc::string::ToString; + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index d96e32dfee..d1fdfa047b 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -2,7 +2,6 @@ // The rest of the IBC related functionality is defined here use core::cmp::{Ord, Ordering, PartialOrd}; -use cosmwasm_core::{to_json_binary, Binary}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -12,6 +11,7 @@ use crate::errors::StdResult; use crate::prelude::*; use crate::results::{Attribute, CosmosMsg, Empty, Event, SubMsg}; use crate::timestamp::Timestamp; +use crate::{to_json_binary, Binary}; /// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts /// (contracts that directly speak the IBC protocol via 6 entry points) diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 625f398bf4..820c23a8a5 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -29,6 +29,7 @@ mod panic; mod query; mod results; mod sections; +mod serde; mod stdack; mod storage; mod timestamp; @@ -87,6 +88,11 @@ pub use crate::results::{ pub use crate::results::{DistributionMsg, StakingMsg}; #[cfg(feature = "stargate")] pub use crate::results::{GovMsg, VoteOption}; +#[allow(deprecated)] +pub use crate::serde::{ + from_binary, from_json, from_slice, to_binary, to_json_binary, to_json_string, to_json_vec, + to_vec, +}; pub use crate::stdack::StdAck; pub use crate::storage::MemoryStorage; pub use crate::timestamp::Timestamp; diff --git a/packages/std/src/results/contract_result.rs b/packages/std/src/results/contract_result.rs index d84f0e102f..e887c74500 100644 --- a/packages/std/src/results/contract_result.rs +++ b/packages/std/src/results/contract_result.rs @@ -89,10 +89,8 @@ impl From> for Result { #[cfg(test)] mod tests { - use cosmwasm_core::{CoreError, CoreResult}; - use super::*; - use crate::{from_json, to_json_vec, Response, StdError}; + use crate::{from_json, to_json_vec, Response, StdError, StdResult}; #[test] fn contract_result_serialization_works() { @@ -133,20 +131,20 @@ mod tests { assert_eq!(result, ContractResult::Ok(5898)); // fails for additional attributes - let parse: CoreResult> = from_json(br#"{"unrelated":321,"ok":4554}"#); + let parse: StdResult> = from_json(br#"{"unrelated":321,"ok":4554}"#); match parse.unwrap_err() { - CoreError::ParseErr { .. } => {} + StdError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } - let parse: CoreResult> = from_json(br#"{"ok":4554,"unrelated":321}"#); + let parse: StdResult> = from_json(br#"{"ok":4554,"unrelated":321}"#); match parse.unwrap_err() { - CoreError::ParseErr { .. } => {} + StdError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } - let parse: CoreResult> = + let parse: StdResult> = from_json(br#"{"ok":4554,"error":"What's up now?"}"#); match parse.unwrap_err() { - CoreError::ParseErr { .. } => {} + StdError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } } diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index dad619b3fa..10d7d6fbfe 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -1,7 +1,6 @@ #![allow(deprecated)] use core::fmt; -use cosmwasm_core::{to_json_binary, Binary}; use derivative::Derivative; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -13,6 +12,7 @@ use crate::ibc::IbcMsg; use crate::prelude::*; #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] use crate::Decimal; +use crate::{to_json_binary, Binary}; use super::Empty; diff --git a/packages/std/src/results/empty.rs b/packages/std/src/results/empty.rs index 180cb99a48..6e648ec63e 100644 --- a/packages/std/src/results/empty.rs +++ b/packages/std/src/results/empty.rs @@ -16,7 +16,7 @@ pub struct Empty {} mod tests { use super::*; - use cosmwasm_core::{from_json, to_json_vec}; + use crate::{from_json, to_json_vec}; #[test] fn empty_can_be_instantiated() { diff --git a/packages/std/src/results/submessages.rs b/packages/std/src/results/submessages.rs index 68762f1e80..18f20530d8 100644 --- a/packages/std/src/results/submessages.rs +++ b/packages/std/src/results/submessages.rs @@ -289,10 +289,8 @@ pub struct MsgResponse { #[cfg(test)] #[allow(deprecated)] mod tests { - use cosmwasm_core::{CoreError, CoreResult}; - use super::*; - use crate::{coins, from_json, to_json_vec, Attribute, BankMsg, StdError}; + use crate::{coins, from_json, to_json_vec, Attribute, BankMsg, StdError, StdResult}; #[test] fn sub_msg_new_works() { @@ -432,14 +430,14 @@ mod tests { assert_eq!(result, SubMsgResult::Err("broken".to_string())); // fails for additional attributes - let parse: CoreResult = from_json(br#"{"unrelated":321,"error":"broken"}"#); + let parse: StdResult = from_json(br#"{"unrelated":321,"error":"broken"}"#); match parse.unwrap_err() { - CoreError::ParseErr { .. } => {} + StdError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } - let parse: CoreResult = from_json(br#"{"error":"broken","unrelated":321}"#); + let parse: StdResult = from_json(br#"{"error":"broken","unrelated":321}"#); match parse.unwrap_err() { - CoreError::ParseErr { .. } => {} + StdError::ParseErr { .. } => {} err => panic!("Unexpected error: {err:?}"), } } diff --git a/packages/core/src/serde.rs b/packages/std/src/serde.rs similarity index 86% rename from packages/core/src/serde.rs rename to packages/std/src/serde.rs index 4f30512b65..ca80bc07e6 100644 --- a/packages/core/src/serde.rs +++ b/packages/std/src/serde.rs @@ -7,29 +7,29 @@ use alloc::{string::String, vec::Vec}; use core::any::type_name; use serde::{de::DeserializeOwned, Serialize}; -use crate::binary::Binary; -use crate::errors::{CoreError, CoreResult}; +use crate::errors::{StdError, StdResult}; +use crate::Binary; #[deprecated = "use from_json instead"] -pub fn from_slice(value: &[u8]) -> CoreResult { +pub fn from_slice(value: &[u8]) -> StdResult { from_json(value) } #[deprecated = "use from_json instead"] -pub fn from_binary(value: &Binary) -> CoreResult { +pub fn from_binary(value: &Binary) -> StdResult { from_json(value) } /// Deserializes the given JSON bytes to a data structure. /// /// Errors if the input is not valid JSON or cannot be deserialized to the given type. -pub fn from_json(value: impl AsRef<[u8]>) -> CoreResult { +pub fn from_json(value: impl AsRef<[u8]>) -> StdResult { serde_json_wasm::from_slice(value.as_ref()) - .map_err(|e| CoreError::parse_err(type_name::(), e)) + .map_err(|e| StdError::parse_err(type_name::(), e)) } #[deprecated = "use to_json_vec instead"] -pub fn to_vec(data: &T) -> CoreResult> +pub fn to_vec(data: &T) -> StdResult> where T: Serialize + ?Sized, { @@ -37,7 +37,7 @@ where } #[deprecated = "use to_json_binary instead"] -pub fn to_binary(data: &T) -> CoreResult +pub fn to_binary(data: &T) -> StdResult where T: Serialize + ?Sized, { @@ -45,23 +45,23 @@ where } /// Serializes the given data structure as a JSON byte vector. -pub fn to_json_vec(data: &T) -> CoreResult> +pub fn to_json_vec(data: &T) -> StdResult> where T: Serialize + ?Sized, { - serde_json_wasm::to_vec(data).map_err(|e| CoreError::serialize_err(type_name::(), e)) + serde_json_wasm::to_vec(data).map_err(|e| StdError::serialize_err(type_name::(), e)) } /// Serializes the given data structure as a JSON string. -pub fn to_json_string(data: &T) -> CoreResult +pub fn to_json_string(data: &T) -> StdResult where T: Serialize + ?Sized, { - serde_json_wasm::to_string(data).map_err(|e| CoreError::serialize_err(type_name::(), e)) + serde_json_wasm::to_string(data).map_err(|e| StdError::serialize_err(type_name::(), e)) } /// Serializes the given data structure as JSON bytes. -pub fn to_json_binary(data: &T) -> CoreResult +pub fn to_json_binary(data: &T) -> StdResult where T: Serialize + ?Sized, { diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index cf6505c186..ced5a6bc8b 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -7,7 +7,6 @@ use bech32::{encode, Bech32, Hrp}; use core::marker::PhantomData; #[cfg(feature = "cosmwasm_1_3")] use core::ops::Bound; -use cosmwasm_core::{from_json, to_json_binary, Binary, Uint128}; use serde::de::DeserializeOwned; #[cfg(feature = "stargate")] use serde::Serialize; @@ -40,6 +39,7 @@ use crate::storage::MemoryStorage; use crate::timestamp::Timestamp; use crate::traits::{Api, Querier, QuerierResult}; use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInfo}; +use crate::{from_json, to_json_binary, Binary, Uint128}; #[cfg(feature = "cosmwasm_1_3")] use crate::{ query::{AllDenomMetadataResponse, DecCoin, DenomMetadataResponse}, diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index a657c7ba50..8cb92b1f62 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -1,6 +1,5 @@ use core::marker::PhantomData; use core::ops::Deref; -use cosmwasm_core::{from_json, to_json_binary, to_json_vec, Binary}; use serde::{de::DeserializeOwned, Serialize}; use crate::addresses::{Addr, CanonicalAddr}; @@ -28,6 +27,7 @@ use crate::query::{ }; use crate::results::{ContractResult, Empty, SystemResult}; use crate::ContractInfoResponse; +use crate::{from_json, to_json_binary, to_json_vec, Binary}; #[cfg(feature = "cosmwasm_1_3")] use crate::{DenomMetadata, PageRequest}; From e491fafb313ee1b1c5690f1bfde22a6579ccaacd Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:17:58 +0100 Subject: [PATCH 06/42] Remove `alloc` imports --- packages/std/src/serde.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/std/src/serde.rs b/packages/std/src/serde.rs index ca80bc07e6..3cf2e044dd 100644 --- a/packages/std/src/serde.rs +++ b/packages/std/src/serde.rs @@ -3,7 +3,6 @@ // 1. To easily ensure that all calling libraries use the same version (minimize code size) // 2. To allow us to switch out to eg. serde-json-core more easily -use alloc::{string::String, vec::Vec}; use core::any::type_name; use serde::{de::DeserializeOwned, Serialize}; @@ -71,7 +70,6 @@ where #[cfg(test)] mod tests { use super::*; - use alloc::string::ToString; use serde::Deserialize; #[derive(Serialize, Deserialize, Debug, PartialEq)] From 257ab45f7d5fcfd0a71788fdcf2a1a59f9973f0f Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:19:34 +0100 Subject: [PATCH 07/42] Add cargo config to `cosmwasm-core` --- packages/core/.cargo/config | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 packages/core/.cargo/config diff --git a/packages/core/.cargo/config b/packages/core/.cargo/config new file mode 100644 index 0000000000..b93207d67e --- /dev/null +++ b/packages/core/.cargo/config @@ -0,0 +1,4 @@ +[alias] +wasm = "build --release --lib --target wasm32-unknown-unknown" +wasm-debug = "build --lib --target wasm32-unknown-unknown" +unit-test = "test --lib" From 1aa7db82e9df3a543ef140ec7ba5d32440da8be5 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:28:10 +0100 Subject: [PATCH 08/42] Update contract schemas --- contracts/crypto-verify/schema/crypto-verify.json | 2 +- contracts/crypto-verify/schema/raw/query.json | 2 +- contracts/cyberpunk/schema/cyberpunk.json | 2 +- .../cyberpunk/schema/raw/response_to_mirror_env.json | 2 +- contracts/hackatom/schema/hackatom.json | 4 ++-- .../schema/raw/response_to_other_balance.json | 2 +- contracts/hackatom/schema/raw/sudo.json | 2 +- .../ibc-reflect-send/schema/ibc-reflect-send.json | 12 ++++++------ .../schema/ibc/acknowledgement_msg_balances.json | 2 +- .../ibc-reflect-send/schema/ibc/packet_msg.json | 4 ++-- contracts/ibc-reflect-send/schema/raw/execute.json | 4 ++-- .../schema/raw/response_to_account.json | 4 ++-- .../schema/raw/response_to_list_accounts.json | 4 ++-- .../schema/ibc/acknowledgement_msg_balances.json | 2 +- contracts/ibc-reflect/schema/ibc/packet_msg.json | 4 ++-- contracts/reflect/schema/raw/execute.json | 4 ++-- contracts/reflect/schema/reflect.json | 4 ++-- contracts/staking/schema/raw/execute.json | 2 +- contracts/staking/schema/raw/instantiate.json | 2 +- .../staking/schema/raw/response_to_balance.json | 2 +- contracts/staking/schema/raw/response_to_claims.json | 2 +- .../staking/schema/raw/response_to_investment.json | 2 +- contracts/staking/schema/staking.json | 10 +++++----- 23 files changed, 40 insertions(+), 40 deletions(-) diff --git a/contracts/crypto-verify/schema/crypto-verify.json b/contracts/crypto-verify/schema/crypto-verify.json index 56eba68e5d..e3e7a632bd 100644 --- a/contracts/crypto-verify/schema/crypto-verify.json +++ b/contracts/crypto-verify/schema/crypto-verify.json @@ -394,7 +394,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/crypto-verify/schema/raw/query.json b/contracts/crypto-verify/schema/raw/query.json index 76aa8b0ef7..9c3938e9c3 100644 --- a/contracts/crypto-verify/schema/raw/query.json +++ b/contracts/crypto-verify/schema/raw/query.json @@ -383,7 +383,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/cyberpunk/schema/cyberpunk.json b/contracts/cyberpunk/schema/cyberpunk.json index dbabc26fb4..be602973e9 100644 --- a/contracts/cyberpunk/schema/cyberpunk.json +++ b/contracts/cyberpunk/schema/cyberpunk.json @@ -507,7 +507,7 @@ "additionalProperties": false }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/cyberpunk/schema/raw/response_to_mirror_env.json b/contracts/cyberpunk/schema/raw/response_to_mirror_env.json index 6d4e75e50b..0cc25ba369 100644 --- a/contracts/cyberpunk/schema/raw/response_to_mirror_env.json +++ b/contracts/cyberpunk/schema/raw/response_to_mirror_env.json @@ -95,7 +95,7 @@ "additionalProperties": false }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/hackatom/schema/hackatom.json b/contracts/hackatom/schema/hackatom.json index 307c89871f..6fdf055f6e 100644 --- a/contracts/hackatom/schema/hackatom.json +++ b/contracts/hackatom/schema/hackatom.json @@ -301,7 +301,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -358,7 +358,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/hackatom/schema/raw/response_to_other_balance.json b/contracts/hackatom/schema/raw/response_to_other_balance.json index 46aa76ef1b..4c53acf22e 100644 --- a/contracts/hackatom/schema/raw/response_to_other_balance.json +++ b/contracts/hackatom/schema/raw/response_to_other_balance.json @@ -33,7 +33,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/hackatom/schema/raw/sudo.json b/contracts/hackatom/schema/raw/sudo.json index 5391911bd6..a0abebb41e 100644 --- a/contracts/hackatom/schema/raw/sudo.json +++ b/contracts/hackatom/schema/raw/sudo.json @@ -50,7 +50,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json index c8d872b5d2..79192fadea 100644 --- a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json +++ b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json @@ -663,11 +663,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { @@ -979,11 +979,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } @@ -1079,11 +1079,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json b/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json index 4f6447522d..52f7cc0884 100644 --- a/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json +++ b/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json @@ -66,7 +66,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json index cea5745b7e..5c32f93c9a 100644 --- a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json @@ -604,11 +604,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/ibc-reflect-send/schema/raw/execute.json b/contracts/ibc-reflect-send/schema/raw/execute.json index f1b1d6dcef..a4cc21d05e 100644 --- a/contracts/ibc-reflect-send/schema/raw/execute.json +++ b/contracts/ibc-reflect-send/schema/raw/execute.json @@ -652,11 +652,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/ibc-reflect-send/schema/raw/response_to_account.json b/contracts/ibc-reflect-send/schema/raw/response_to_account.json index 30c737f48d..bbfd2a8d85 100644 --- a/contracts/ibc-reflect-send/schema/raw/response_to_account.json +++ b/contracts/ibc-reflect-send/schema/raw/response_to_account.json @@ -60,11 +60,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json b/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json index 4c0a3c91c8..ffc774fd3e 100644 --- a/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json +++ b/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json @@ -75,11 +75,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json b/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json index 4f6447522d..52f7cc0884 100644 --- a/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json +++ b/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json @@ -66,7 +66,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect/schema/ibc/packet_msg.json b/contracts/ibc-reflect/schema/ibc/packet_msg.json index 31374ccadf..bfe12e7826 100644 --- a/contracts/ibc-reflect/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect/schema/ibc/packet_msg.json @@ -564,11 +564,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/reflect/schema/raw/execute.json b/contracts/reflect/schema/raw/execute.json index 947eb3997c..8833281895 100644 --- a/contracts/reflect/schema/raw/execute.json +++ b/contracts/reflect/schema/raw/execute.json @@ -812,11 +812,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 56d41ee0af..1774623932 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -822,11 +822,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/staking/schema/raw/execute.json b/contracts/staking/schema/raw/execute.json index 159d67cd90..5fa38f2d3e 100644 --- a/contracts/staking/schema/raw/execute.json +++ b/contracts/staking/schema/raw/execute.json @@ -109,7 +109,7 @@ ], "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/instantiate.json b/contracts/staking/schema/raw/instantiate.json index dd25457114..b1f71de8ff 100644 --- a/contracts/staking/schema/raw/instantiate.json +++ b/contracts/staking/schema/raw/instantiate.json @@ -53,7 +53,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/response_to_balance.json b/contracts/staking/schema/raw/response_to_balance.json index 7dcf4d4a51..2392cc8821 100644 --- a/contracts/staking/schema/raw/response_to_balance.json +++ b/contracts/staking/schema/raw/response_to_balance.json @@ -13,7 +13,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/response_to_claims.json b/contracts/staking/schema/raw/response_to_claims.json index b393e85853..83c5b0b58a 100644 --- a/contracts/staking/schema/raw/response_to_claims.json +++ b/contracts/staking/schema/raw/response_to_claims.json @@ -13,7 +13,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/response_to_investment.json b/contracts/staking/schema/raw/response_to_investment.json index 23fd138114..edcba22762 100644 --- a/contracts/staking/schema/raw/response_to_investment.json +++ b/contracts/staking/schema/raw/response_to_investment.json @@ -69,7 +69,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/staking.json b/contracts/staking/schema/staking.json index e5e3f98843..b13500b379 100644 --- a/contracts/staking/schema/staking.json +++ b/contracts/staking/schema/staking.json @@ -57,7 +57,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -173,7 +173,7 @@ ], "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -274,7 +274,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -294,7 +294,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -370,7 +370,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } From 2e7b45cc8504d095ceb661807fc2ba31fe682aad Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 13 Mar 2024 19:33:14 +0100 Subject: [PATCH 09/42] Add `no_std` checks --- .circleci/config.yml | 7 +++++++ packages/core/.cargo/config | 1 + packages/core/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1357fa3219..6b73bad5e2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -304,6 +304,9 @@ jobs: - restore_cache: keys: - cargocache-v2-package_core-rust:1.73-{{ checksum "Cargo.lock" }} + - run: + name: Add thumbv7em-none-eabi target + command: rustup target add thumbv7em-none-eabi && rustup target list --installed - run: name: Add wasm32 target command: rustup target add wasm32-unknown-unknown && rustup target list --installed @@ -315,6 +318,10 @@ jobs: name: Build library for wasm target (no features) working_directory: ~/project/packages/core command: cargo wasm --locked --no-default-features + - run: + name: Build library for no_std target (no features) + working_directory: ~/project/packages/core + command: cargo no-std --locked --no-default-features - run: name: Run unit tests (no features) working_directory: ~/project/packages/core diff --git a/packages/core/.cargo/config b/packages/core/.cargo/config index b93207d67e..54e2d5481e 100644 --- a/packages/core/.cargo/config +++ b/packages/core/.cargo/config @@ -1,4 +1,5 @@ [alias] +no-std = "build --release --lib --target thumbv7em-none-eabi" wasm = "build --release --lib --target wasm32-unknown-unknown" wasm-debug = "build --lib --target wasm32-unknown-unknown" unit-test = "test --lib" diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 8d2a66dda6..72fde7c0db 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -14,7 +14,7 @@ release = false base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } bnum = "0.11.0" crc32fast = { version = "1.4.0", optional = true, default-features = false } -derive_more = { version = "1.0.0-beta.6", features = ["display", "from"] } +derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } forward_ref = "1.0.0" schemars = { version = "0.8.16", optional = true } serde = { version = "1.0.197", default-features = false, features = ["derive"] } From ed8800c3a5b6abfb6af162ca368656b0477eea7d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 09:42:59 +0100 Subject: [PATCH 10/42] Remove `forward_ref` dependency --- Cargo.lock | 7 --- contracts/burner/Cargo.lock | 7 --- contracts/crypto-verify/Cargo.lock | 7 --- contracts/cyberpunk/Cargo.lock | 7 --- contracts/empty/Cargo.lock | 7 --- contracts/floaty/Cargo.lock | 7 --- contracts/hackatom/Cargo.lock | 7 --- contracts/ibc-reflect-send/Cargo.lock | 7 --- contracts/ibc-reflect/Cargo.lock | 7 --- contracts/queue/Cargo.lock | 7 --- contracts/reflect/Cargo.lock | 7 --- contracts/staking/Cargo.lock | 7 --- contracts/virus/Cargo.lock | 7 --- packages/core/Cargo.toml | 1 - packages/core/src/forward_ref.rs | 56 ++++++++++++++++++++ packages/core/src/math/decimal.rs | 2 +- packages/core/src/math/decimal256.rs | 2 +- packages/core/src/math/int128.rs | 2 +- packages/core/src/math/int256.rs | 2 +- packages/core/src/math/int512.rs | 2 +- packages/core/src/math/int64.rs | 2 +- packages/core/src/math/signed_decimal.rs | 2 +- packages/core/src/math/signed_decimal_256.rs | 2 +- packages/core/src/math/uint128.rs | 2 +- packages/core/src/math/uint256.rs | 2 +- packages/core/src/math/uint512.rs | 2 +- packages/core/src/math/uint64.rs | 2 +- 27 files changed, 68 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd6227518e..3dca282484 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,7 +429,6 @@ dependencies = [ "cosmwasm-std", "crc32fast", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -1136,12 +1135,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "funty" version = "2.0.0" diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 0e28d93d0d..2b58952b54 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -219,7 +219,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -780,12 +779,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 2095e1d25b..8bd46a281d 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -787,12 +786,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 78d06ba242..086f84f2c5 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -237,7 +237,6 @@ dependencies = [ "base64 0.22.0", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -840,12 +839,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index f3d71de566..e5fa06f244 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -779,12 +778,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 1aa907940b..d4e0c4c28c 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -781,12 +780,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 9a86fede4f..a6e4492492 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 089832fdc2..c854ddeb65 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 6b4e0a85f7..243df3e8e9 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index cbfd147bda..783fb79844 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 1c2f8e1030..3f9f5dfc1d 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 26a784f6af..1227ea9933 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 5f29133446..087c41b013 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -208,7 +208,6 @@ dependencies = [ "base64", "bnum", "derive_more", - "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -769,12 +768,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "fxhash" version = "0.2.1" diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 72fde7c0db..685d98a0a3 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -15,7 +15,6 @@ base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } bnum = "0.11.0" crc32fast = { version = "1.4.0", optional = true, default-features = false } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } -forward_ref = "1.0.0" schemars = { version = "0.8.16", optional = true } serde = { version = "1.0.197", default-features = false, features = ["derive"] } serde-json-wasm = { version = "1.0.1", default-features = false } diff --git a/packages/core/src/forward_ref.rs b/packages/core/src/forward_ref.rs index 1a71ecc3eb..9c41b1aec0 100644 --- a/packages/core/src/forward_ref.rs +++ b/packages/core/src/forward_ref.rs @@ -26,3 +26,59 @@ macro_rules! forward_ref_partial_eq { } }; } + +/// implements binary operators "&T op U", "T op &U", "&T op &U" +/// based on "T op U" where T and U are expected to be `Copy`able +/// +/// Copied from `libcore` +macro_rules! forward_ref_binop { + (impl $imp:ident, $method:ident for $t:ty, $u:ty) => { + impl<'a> $imp<$u> for &'a $t { + type Output = <$t as $imp<$u>>::Output; + + #[inline] + #[track_caller] + fn $method(self, other: $u) -> <$t as $imp<$u>>::Output { + $imp::$method(*self, other) + } + } + + impl $imp<&$u> for $t { + type Output = <$t as $imp<$u>>::Output; + + #[inline] + #[track_caller] + fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { + $imp::$method(self, *other) + } + } + + impl $imp<&$u> for &$t { + type Output = <$t as $imp<$u>>::Output; + + #[inline] + #[track_caller] + fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { + $imp::$method(*self, *other) + } + } + }; +} + +/// implements "T op= &U", based on "T op= U" +/// where U is expected to be `Copy`able +/// +/// Copied from `libcore` +macro_rules! forward_ref_op_assign { + (impl $imp:ident, $method:ident for $t:ty, $u:ty) => { + impl $imp<&$u> for $t { + #[inline] + #[track_caller] + fn $method(&mut self, other: &$u) { + $imp::$method(self, *other); + } + } + }; +} + +pub(crate) use {forward_ref_binop, forward_ref_op_assign}; diff --git a/packages/core/src/math/decimal.rs b/packages/core/src/math/decimal.rs index 95bf7df5e8..a4b53ed3d2 100644 --- a/packages/core/src/math/decimal.rs +++ b/packages/core/src/math/decimal.rs @@ -4,13 +4,13 @@ use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; use core::str::FromStr; use derive_more::Display; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, RoundUpOverflowError, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{forward_ref_partial_eq, Decimal256, SignedDecimal, SignedDecimal256}; use super::Fraction; diff --git a/packages/core/src/math/decimal256.rs b/packages/core/src/math/decimal256.rs index f1ccf739c6..f6e82fdf11 100644 --- a/packages/core/src/math/decimal256.rs +++ b/packages/core/src/math/decimal256.rs @@ -4,13 +4,13 @@ use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; use core::str::FromStr; use derive_more::Display; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, RoundUpOverflowError, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{forward_ref_partial_eq, Decimal, SignedDecimal, SignedDecimal256, Uint512}; use super::Fraction; diff --git a/packages/core/src/math/int128.rs b/packages/core/src/math/int128.rs index f9980b41ef..2f20e4e9bc 100644 --- a/packages/core/src/math/int128.rs +++ b/packages/core/src/math/int128.rs @@ -5,12 +5,12 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ forward_ref_partial_eq, CheckedMultiplyRatioError, Int256, Int512, Int64, Uint128, Uint256, Uint512, Uint64, diff --git a/packages/core/src/math/int256.rs b/packages/core/src/math/int256.rs index 0ed420be41..109634efe4 100644 --- a/packages/core/src/math/int256.rs +++ b/packages/core/src/math/int256.rs @@ -5,12 +5,12 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ forward_ref_partial_eq, CheckedMultiplyRatioError, Int128, Int512, Int64, Uint128, Uint256, Uint512, Uint64, diff --git a/packages/core/src/math/int512.rs b/packages/core/src/math/int512.rs index c6283a2185..c74343771f 100644 --- a/packages/core/src/math/int512.rs +++ b/packages/core/src/math/int512.rs @@ -5,12 +5,12 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{forward_ref_partial_eq, Int128, Int256, Int64, Uint128, Uint256, Uint512, Uint64}; /// Used internally - we don't want to leak this type since we might change diff --git a/packages/core/src/math/int64.rs b/packages/core/src/math/int64.rs index 7cfaaa5390..7c4520abb1 100644 --- a/packages/core/src/math/int64.rs +++ b/packages/core/src/math/int64.rs @@ -5,12 +5,12 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ forward_ref_partial_eq, CheckedMultiplyRatioError, Int128, Int256, Int512, Uint128, Uint256, Uint512, Uint64, diff --git a/packages/core/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs index 2a00d7eba4..d4d1dc92f7 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -6,13 +6,13 @@ use core::ops::{ }; use core::str::FromStr; use derive_more::Display; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{forward_ref_partial_eq, Decimal, Decimal256, Int256, SignedDecimal256}; use super::Fraction; diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs index 886399637d..d6ae212fb6 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -6,13 +6,13 @@ use core::ops::{ }; use core::str::FromStr; use derive_more::Display; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{forward_ref_partial_eq, Decimal, Decimal256, Int512, SignedDecimal}; use super::Fraction; diff --git a/packages/core/src/math/uint128.rs b/packages/core/src/math/uint128.rs index 1483fe8267..cc3030d678 100644 --- a/packages/core/src/math/uint128.rs +++ b/packages/core/src/math/uint128.rs @@ -6,13 +6,13 @@ use core::ops::{ }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint256, Uint64, diff --git a/packages/core/src/math/uint256.rs b/packages/core/src/math/uint256.rs index 8ebfeb4c9e..35352e7d7e 100644 --- a/packages/core/src/math/uint256.rs +++ b/packages/core/src/math/uint256.rs @@ -5,13 +5,13 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint128, Uint512, Uint64, diff --git a/packages/core/src/math/uint512.rs b/packages/core/src/math/uint512.rs index 7fa7847594..452fced34c 100644 --- a/packages/core/src/math/uint512.rs +++ b/packages/core/src/math/uint512.rs @@ -5,12 +5,12 @@ use core::ops::{ ShrAssign, Sub, SubAssign, }; use core::str::FromStr; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ ConversionOverflowError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{forward_ref_partial_eq, Int128, Int256, Int512, Int64, Uint128, Uint256, Uint64}; /// Used internally - we don't want to leak this type since we might change diff --git a/packages/core/src/math/uint64.rs b/packages/core/src/math/uint64.rs index dd2ace125b..5c6d7e59b5 100644 --- a/packages/core/src/math/uint64.rs +++ b/packages/core/src/math/uint64.rs @@ -4,13 +4,13 @@ use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign, }; -use forward_ref::{forward_ref_binop, forward_ref_op_assign}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, }; +use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint128, }; From aa73eb0a0f0965e7f5581061402a0ab343ddf0cf Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 09:44:56 +0100 Subject: [PATCH 11/42] Fix CI config for WASM target --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b73bad5e2..aa9529c560 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -333,7 +333,7 @@ jobs: - run: name: Build library for wasm target (all features) working_directory: ~/project/packages/core - command: cargo wasm --locked --features std,testingstd,testing + command: cargo wasm --locked --features std,testing - run: name: Run unit tests (all features) working_directory: ~/project/packages/core From 557fefce12dd454bde4dca503f770a2379069461 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 10:09:09 +0100 Subject: [PATCH 12/42] Move `HexBinary` --- Cargo.lock | 3 +- contracts/burner/Cargo.lock | 3 +- contracts/crypto-verify/Cargo.lock | 3 +- contracts/cyberpunk/Cargo.lock | 3 +- contracts/empty/Cargo.lock | 3 +- contracts/floaty/Cargo.lock | 3 +- contracts/hackatom/Cargo.lock | 3 +- contracts/ibc-reflect-send/Cargo.lock | 3 +- contracts/ibc-reflect/Cargo.lock | 3 +- contracts/queue/Cargo.lock | 3 +- contracts/reflect/Cargo.lock | 3 +- contracts/staking/Cargo.lock | 3 +- contracts/virus/Cargo.lock | 3 +- packages/core/Cargo.toml | 1 + packages/core/src/errors/core_error.rs | 56 +++--------------------- packages/{std => core}/src/hex_binary.rs | 37 ++++++++-------- packages/core/src/lib.rs | 2 + packages/std/Cargo.toml | 2 +- packages/std/src/errors/std_error.rs | 24 +++------- packages/std/src/lib.rs | 3 +- packages/std/src/results/cosmos_msg.rs | 25 ++++++----- 21 files changed, 76 insertions(+), 113 deletions(-) rename packages/{std => core}/src/hex_binary.rs (94%) diff --git a/Cargo.lock b/Cargo.lock index 3dca282484..37263406fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,6 +429,7 @@ dependencies = [ "cosmwasm-std", "crc32fast", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -502,7 +503,7 @@ dependencies = [ "cosmwasm-derive", "cosmwasm-schema", "crc32fast", - "derivative", + "derive_more", "hex", "hex-literal", "schemars", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 2b58952b54..bed77c6ec0 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -219,6 +219,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -276,7 +277,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 8bd46a281d..2cb541aa28 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 086f84f2c5..16ff68f31c 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -237,6 +237,7 @@ dependencies = [ "base64 0.22.0", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -294,7 +295,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index e5fa06f244..770f6c85fd 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index d4e0c4c28c..83efe55081 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index a6e4492492..a236fc09c9 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index c854ddeb65..babfed2bf5 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 243df3e8e9..e1b8543618 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 783fb79844..8fd94e7d0b 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 3f9f5dfc1d..fe0091e58c 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 1227ea9933..630e263d70 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 087c41b013..94aca643d7 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "base64", "bnum", "derive_more", + "hex", "schemars", "serde", "serde-json-wasm", @@ -265,7 +266,7 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", + "derive_more", "hex", "schemars", "serde", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 685d98a0a3..a4a48fedfc 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -15,6 +15,7 @@ base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } bnum = "0.11.0" crc32fast = { version = "1.4.0", optional = true, default-features = false } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } +hex = { version = "0.4.3", default-features = false, features = ["alloc"] } schemars = { version = "0.8.16", optional = true } serde = { version = "1.0.197", default-features = false, features = ["derive"] } serde-json-wasm = { version = "1.0.1", default-features = false } diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index 15d325a497..22db25d5a1 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -17,20 +17,8 @@ pub enum CoreError { actual: u64, backtrace: BT, }, - #[display("Error parsing into type {target_type}: {msg}")] - ParseErr { - /// the target type that was attempted - target_type: String, - msg: String, - backtrace: BT, - }, - #[display("Error serializing type {source_type}: {msg}")] - SerializeErr { - /// the source type that was attempted - source_type: String, - msg: String, - backtrace: BT, - }, + #[display("Invalid hex string: {msg}")] + InvalidHex { msg: String, backtrace: BT }, #[display("Overflow: {source}")] Overflow { source: OverflowError, @@ -81,17 +69,8 @@ impl CoreError { } } - pub fn parse_err(target: impl Into, msg: impl ToString) -> Self { - CoreError::ParseErr { - target_type: target.into(), - msg: msg.to_string(), - backtrace: BT::capture(), - } - } - - pub fn serialize_err(source: impl Into, msg: impl ToString) -> Self { - CoreError::SerializeErr { - source_type: source.into(), + pub fn invalid_hex(msg: impl ToString) -> Self { + CoreError::InvalidHex { msg: msg.to_string(), backtrace: BT::capture(), } @@ -153,34 +132,13 @@ impl PartialEq for CoreError { false } } - CoreError::ParseErr { - target_type, - msg, - backtrace: _, - } => { - if let CoreError::ParseErr { - target_type: rhs_target_type, - msg: rhs_msg, - backtrace: _, - } = rhs - { - target_type == rhs_target_type && msg == rhs_msg - } else { - false - } - } - CoreError::SerializeErr { - source_type, - msg, - backtrace: _, - } => { - if let CoreError::SerializeErr { - source_type: rhs_source_type, + CoreError::InvalidHex { msg, backtrace: _ } => { + if let CoreError::InvalidHex { msg: rhs_msg, backtrace: _, } = rhs { - source_type == rhs_source_type && msg == rhs_msg + msg == rhs_msg } else { false } diff --git a/packages/std/src/hex_binary.rs b/packages/core/src/hex_binary.rs similarity index 94% rename from packages/std/src/hex_binary.rs rename to packages/core/src/hex_binary.rs index 91ceca1a3a..9f6be10c8d 100644 --- a/packages/std/src/hex_binary.rs +++ b/packages/core/src/hex_binary.rs @@ -1,23 +1,23 @@ +use alloc::{string::String, vec::Vec}; use core::fmt; use core::ops::Deref; -use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::prelude::*; -use crate::{Binary, StdError, StdResult}; +use crate::{Binary, CoreError, CoreResult}; /// This is a wrapper around Vec to add hex de/serialization /// with serde. It also adds some helper methods to help encode inline. /// /// This is similar to `cosmwasm_std::Binary` but uses hex. /// See also . -#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, JsonSchema)] -pub struct HexBinary(#[schemars(with = "String")] Vec); +#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +pub struct HexBinary(#[cfg_attr(feature = "std", schemars(with = "String"))] Vec); impl HexBinary { - pub fn from_hex(input: &str) -> StdResult { - let vec = hex::decode(input).map_err(StdError::invalid_hex)?; + pub fn from_hex(input: &str) -> CoreResult { + let vec = hex::decode(input).map_err(CoreError::invalid_hex)?; Ok(Self(vec)) } @@ -50,9 +50,9 @@ impl HexBinary { /// let num = u64::from_be_bytes(data.to_array().unwrap()); /// assert_eq!(num, 10045108015024774967); /// ``` - pub fn to_array(&self) -> StdResult<[u8; LENGTH]> { + pub fn to_array(&self) -> CoreResult<[u8; LENGTH]> { if self.len() != LENGTH { - return Err(StdError::invalid_data_size(LENGTH, self.len())); + return Err(CoreError::invalid_data_size(LENGTH, self.len())); } let mut out: [u8; LENGTH] = [0; LENGTH]; @@ -248,7 +248,8 @@ impl<'de> de::Visitor<'de> for HexVisitor { mod tests { use super::*; - use crate::{assert_hash_works, from_json, to_json_vec}; + use crate::{assert_hash_works, CoreError}; + use cosmwasm_std::{from_json, to_json_vec}; #[test] fn from_hex_works() { @@ -268,21 +269,21 @@ mod tests { // odd match HexBinary::from_hex("123").unwrap_err() { - StdError::InvalidHex { msg, .. } => { + CoreError::InvalidHex { msg, .. } => { assert_eq!(msg, "Odd number of digits") } _ => panic!("Unexpected error type"), } // non-hex match HexBinary::from_hex("efgh").unwrap_err() { - StdError::InvalidHex { msg, .. } => { + CoreError::InvalidHex { msg, .. } => { assert_eq!(msg, "Invalid character 'g' at position 2") } _ => panic!("Unexpected error type"), } // 0x prefixed match HexBinary::from_hex("0xaa").unwrap_err() { - StdError::InvalidHex { msg, .. } => { + CoreError::InvalidHex { msg, .. } => { assert_eq!(msg, "Invalid character 'x' at position 1") } _ => panic!("Unexpected error type"), @@ -290,19 +291,19 @@ mod tests { // spaces assert!(matches!( HexBinary::from_hex("aa ").unwrap_err(), - StdError::InvalidHex { .. } + CoreError::InvalidHex { .. } )); assert!(matches!( HexBinary::from_hex(" aa").unwrap_err(), - StdError::InvalidHex { .. } + CoreError::InvalidHex { .. } )); assert!(matches!( HexBinary::from_hex("a a").unwrap_err(), - StdError::InvalidHex { .. } + CoreError::InvalidHex { .. } )); assert!(matches!( HexBinary::from_hex(" aa ").unwrap_err(), - StdError::InvalidHex { .. } + CoreError::InvalidHex { .. } )); } @@ -337,7 +338,7 @@ mod tests { let binary = HexBinary::from(&[1, 2, 3]); let error = binary.to_array::<8>().unwrap_err(); match error { - StdError::InvalidDataSize { + CoreError::InvalidDataSize { expected, actual, .. } => { assert_eq!(expected, 8); diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index a6c0e01853..63a704772f 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -10,6 +10,7 @@ extern crate alloc; mod binary; mod errors; mod forward_ref; +mod hex_binary; mod math; #[doc(hidden)] @@ -21,6 +22,7 @@ pub use crate::errors::{ ConversionOverflowError, CoreError, CoreResult, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, }; +pub use crate::hex_binary::HexBinary; pub use crate::math::{ Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, Fraction, Int128, Int256, Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 6d4a1b5f71..44bceec9ba 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -57,7 +57,7 @@ cosmwasm_2_1 = ["cosmwasm_2_0"] base64 = "0.22.0" cosmwasm-derive = { version = "2.0.1", path = "../derive" } cosmwasm-core = { path = "../core", version = "2.0.1", features = ["std"] } -derivative = { version = "2", features = ["use_core"] } +derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["debug"] } hex = "0.4" schemars = { workspace = true } sha2 = "0.10.3" diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index 6ec02b9899..821b471432 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -100,29 +100,15 @@ impl From for StdError { actual, backtrace, }, - CoreError::ParseErr { - target_type, - msg, - backtrace, - } => Self::ParseErr { - target_type, - msg, - backtrace, - }, - CoreError::SerializeErr { - source_type, - msg, - backtrace, - } => Self::SerializeErr { - source_type, - msg, - backtrace, - }, + CoreError::InvalidHex { msg, backtrace } => Self::InvalidHex { msg, backtrace }, CoreError::Overflow { source, backtrace } => Self::Overflow { source, backtrace }, CoreError::DivideByZero { source, backtrace } => { Self::DivideByZero { source, backtrace } } - _ => todo!(), + source => Self::CoreErr { + source, + backtrace: BT::capture(), + }, } } } diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 820c23a8a5..e9d9aa1d22 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -17,7 +17,6 @@ mod coins; mod conversion; mod deps; mod errors; -mod hex_binary; mod ibc; mod import_helpers; #[cfg(feature = "iterator")] @@ -55,7 +54,6 @@ pub use crate::errors::{ OverflowError, OverflowOperation, RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError, }; -pub use crate::hex_binary::HexBinary; pub use crate::ibc::IbcChannelOpenResponse; pub use crate::ibc::{ Ibc3ChannelOpenResponse, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, @@ -125,5 +123,6 @@ pub mod testing; // Re-exports +pub use cosmwasm_core as core; pub use cosmwasm_core::*; pub use cosmwasm_derive::entry_point; diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 10d7d6fbfe..04741e960a 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -1,7 +1,7 @@ #![allow(deprecated)] use core::fmt; -use derivative::Derivative; +use derive_more::Debug; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -139,10 +139,14 @@ pub struct AnyMsg { pub value: Binary, } -fn binary_to_string(data: &Binary, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { - match core::str::from_utf8(data.as_slice()) { - Ok(s) => fmt.write_str(s), - Err(_) => fmt::Debug::fmt(data, fmt), +struct BinaryToStringEncoder<'a>(&'a Binary); + +impl fmt::Display for BinaryToStringEncoder<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match core::str::from_utf8(self.0.as_slice()) { + Ok(s) => f.write_str(s), + Err(_) => fmt::Debug::fmt(self.0, f), + } } } @@ -150,8 +154,7 @@ fn binary_to_string(data: &Binary, fmt: &mut core::fmt::Formatter) -> core::fmt: /// /// See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Derivative, PartialEq, Eq, JsonSchema)] -#[derivative(Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum WasmMsg { /// Dispatches a call to another contract at a known address (with known ABI). @@ -161,7 +164,7 @@ pub enum WasmMsg { Execute { contract_addr: String, /// msg is the json-encoded ExecuteMsg struct (as raw Binary) - #[derivative(Debug(format_with = "binary_to_string"))] + #[debug("{}", BinaryToStringEncoder(msg))] msg: Binary, funds: Vec, }, @@ -178,7 +181,7 @@ pub enum WasmMsg { admin: Option, code_id: u64, /// msg is the JSON-encoded InstantiateMsg struct (as raw Binary) - #[derivative(Debug(format_with = "binary_to_string"))] + #[debug("{}", BinaryToStringEncoder(msg))] msg: Binary, funds: Vec, /// A human-readable label for the contract. @@ -208,7 +211,7 @@ pub enum WasmMsg { /// - not start / end with whitespace label: String, /// msg is the JSON-encoded InstantiateMsg struct (as raw Binary) - #[derivative(Debug(format_with = "binary_to_string"))] + #[debug("{}", BinaryToStringEncoder(msg))] msg: Binary, funds: Vec, salt: Binary, @@ -225,7 +228,7 @@ pub enum WasmMsg { /// the code_id of the new logic to place in the given contract new_code_id: u64, /// msg is the json-encoded MigrateMsg struct that will be passed to the new code - #[derivative(Debug(format_with = "binary_to_string"))] + #[debug("{}", BinaryToStringEncoder(msg))] msg: Binary, }, /// Sets a new admin (for migrate) on the given contract. From b3629e405407d1a4c575ecc415937bbf6d8c2927 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 10:19:55 +0100 Subject: [PATCH 13/42] Move addresses --- Cargo.lock | 12 ++++++---- packages/core/Cargo.toml | 6 +++-- packages/{std => core}/src/addresses.rs | 23 ++++++++++--------- packages/core/src/lib.rs | 2 ++ packages/core/src/math/signed_decimal.rs | 12 +++++----- packages/core/src/math/signed_decimal_256.rs | 12 +++++----- .../testdata/instantiate2_addresses.json | 0 packages/std/src/ibc.rs | 2 +- packages/std/src/lib.rs | 2 -- packages/std/src/testing/mock.rs | 2 +- packages/std/src/traits.rs | 2 +- packages/std/src/types.rs | 2 +- 12 files changed, 41 insertions(+), 36 deletions(-) rename packages/{std => core}/src/addresses.rs (98%) rename packages/{std => core}/testdata/instantiate2_addresses.json (100%) diff --git a/Cargo.lock b/Cargo.lock index 37263406fe..3d86a6ac18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -430,9 +430,11 @@ dependencies = [ "crc32fast", "derive_more", "hex", + "hex-literal", "schemars", "serde", - "serde-json-wasm", + "serde_json", + "sha2", "static_assertions", ] @@ -2101,9 +2103,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -2112,9 +2114,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index a4a48fedfc..d8aec21d28 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -17,8 +17,8 @@ crc32fast = { version = "1.4.0", optional = true, default-features = false } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } schemars = { version = "0.8.16", optional = true } -serde = { version = "1.0.197", default-features = false, features = ["derive"] } -serde-json-wasm = { version = "1.0.1", default-features = false } +serde = { version = "1.0.197", default-features = false, features = ["alloc", "derive"] } +sha2 = { version = "0.10.8", default-features = false } static_assertions = "1.1.0" [features] @@ -32,3 +32,5 @@ testing = ["dep:crc32fast"] # I love cyclic dependencies. They are good for your health. cosmwasm-std = { path = "../std", version = "2.0.0" } crc32fast = { version = "1.4.0", default-features = false } +hex-literal = "0.4.1" +serde_json = { version = "1.0.114", default-features = false } diff --git a/packages/std/src/addresses.rs b/packages/core/src/addresses.rs similarity index 98% rename from packages/std/src/addresses.rs rename to packages/core/src/addresses.rs index bed74f6548..c9d89d82e9 100644 --- a/packages/std/src/addresses.rs +++ b/packages/core/src/addresses.rs @@ -1,16 +1,13 @@ -use alloc::borrow::Cow; +use alloc::{borrow::Cow, string::String, vec::Vec}; use core::fmt; use core::ops::Deref; -use cosmwasm_core::Binary; -use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use sha2::{ digest::{Digest, Update}, Sha256, }; -use thiserror::Error; -use crate::prelude::*; +use crate::Binary; use crate::{forward_ref_partial_eq, HexBinary}; /// A human readable address. @@ -29,9 +26,8 @@ use crate::{forward_ref_partial_eq, HexBinary}; /// This type is immutable. If you really need to mutate it (Really? Are you sure?), create /// a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` /// instance. -#[derive( - Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, JsonSchema, -)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] pub struct Addr(String); forward_ref_partial_eq!(Addr, Addr); @@ -131,7 +127,8 @@ impl<'a> From<&'a Addr> for Cow<'a, Addr> { /// addition to that there are many unsafe ways to convert any binary data into an instance. /// So the type should be treated as a marker to express the intended data type, not as /// a validity guarantee of any sort. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] pub struct CanonicalAddr(Binary); /// Implement `CanonicalAddr == Binary` @@ -252,7 +249,7 @@ impl fmt::Display for CanonicalAddr { } } -#[derive(Error, Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq)] pub enum Instantiate2AddressError { /// Checksum must be 32 bytes InvalidChecksumLength, @@ -269,6 +266,9 @@ impl fmt::Display for Instantiate2AddressError { } } +#[cfg(feature = "std")] +impl std::error::Error for Instantiate2AddressError {} + /// Creates a contract address using the predictable address format introduced with /// wasmd 0.29. When using instantiate2, this is a way to precompute the address. /// When using instantiate, the contract address will use a different algorithm and @@ -361,8 +361,9 @@ fn hash(ty: &str, key: &[u8]) -> Vec { #[cfg(test)] mod tests { use super::*; + use crate::assert_hash_works; use crate::HexBinary; - use cosmwasm_core::assert_hash_works; + use hex_literal::hex; #[test] diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 63a704772f..b868cc2afa 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -7,6 +7,7 @@ #[macro_use] extern crate alloc; +mod addresses; mod binary; mod errors; mod forward_ref; @@ -16,6 +17,7 @@ mod math; #[doc(hidden)] pub mod __internal; +pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; pub use crate::binary::Binary; pub use crate::errors::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, diff --git a/packages/core/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs index d4d1dc92f7..b6dc1bf46c 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -3068,17 +3068,17 @@ mod tests { #[test] fn signed_decimal_can_be_serialized_and_deserialized() { // properly deserialized - let value: SignedDecimal = serde_json_wasm::from_str(r#""123""#).unwrap(); + let value: SignedDecimal = serde_json::from_str(r#""123""#).unwrap(); assert_eq!(SignedDecimal::from_str("123").unwrap(), value); // properly serialized let value = SignedDecimal::from_str("456").unwrap(); - assert_eq!(r#""456""#, serde_json_wasm::to_string(&value).unwrap()); + assert_eq!(r#""456""#, serde_json::to_string(&value).unwrap()); // invalid: not a string encoded decimal assert_eq!( - "Invalid type", - serde_json_wasm::from_str::("123") + "invalid type: integer `123`, expected string-encoded decimal at line 1 column 3", + serde_json::from_str::("123") .err() .unwrap() .to_string() @@ -3086,8 +3086,8 @@ mod tests { // invalid: not properly defined signed decimal value assert_eq!( - "Error parsing decimal '1.e': Generic error: Error parsing fractional", - serde_json_wasm::from_str::(r#""1.e""#) + "Error parsing decimal '1.e': Generic error: Error parsing fractional at line 1 column 5", + serde_json::from_str::(r#""1.e""#) .err() .unwrap() .to_string() diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs index d6ae212fb6..11336386dd 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -3241,17 +3241,17 @@ mod tests { #[test] fn signed_decimal_256_can_be_serialized_and_deserialized() { // properly deserialized - let value: SignedDecimal256 = serde_json_wasm::from_str(r#""123""#).unwrap(); + let value: SignedDecimal256 = serde_json::from_str(r#""123""#).unwrap(); assert_eq!(SignedDecimal256::from_str("123").unwrap(), value); // properly serialized let value = SignedDecimal256::from_str("456").unwrap(); - assert_eq!(r#""456""#, serde_json_wasm::to_string(&value).unwrap()); + assert_eq!(r#""456""#, serde_json::to_string(&value).unwrap()); // invalid: not a string encoded decimal assert_eq!( - "Invalid type", - serde_json_wasm::from_str::("123") + "invalid type: integer `123`, expected string-encoded decimal at line 1 column 3", + serde_json::from_str::("123") .err() .unwrap() .to_string() @@ -3259,8 +3259,8 @@ mod tests { // invalid: not properly defined signed decimal value assert_eq!( - "Error parsing decimal '1.e': Generic error: Error parsing fractional", - serde_json_wasm::from_str::(r#""1.e""#) + "Error parsing decimal '1.e': Generic error: Error parsing fractional at line 1 column 5", + serde_json::from_str::(r#""1.e""#) .err() .unwrap() .to_string() diff --git a/packages/std/testdata/instantiate2_addresses.json b/packages/core/testdata/instantiate2_addresses.json similarity index 100% rename from packages/std/testdata/instantiate2_addresses.json rename to packages/core/testdata/instantiate2_addresses.json diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index d1fdfa047b..e8c5364d16 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -2,10 +2,10 @@ // The rest of the IBC related functionality is defined here use core::cmp::{Ord, Ordering, PartialOrd}; +use cosmwasm_core::Addr; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::addresses::Addr; use crate::coin::Coin; use crate::errors::StdResult; use crate::prelude::*; diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index e9d9aa1d22..3a9be7cec9 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -9,7 +9,6 @@ Builds without the std feature are currently not expected to work. If you need n // Exposed on all platforms -mod addresses; mod assertions; mod checksum; mod coin; @@ -43,7 +42,6 @@ pub(crate) mod prelude; /// contract devs to use it directly. pub mod storage_keys; -pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; pub use crate::checksum::{Checksum, ChecksumError}; pub use crate::coin::{coin, coins, has_coins, Coin}; pub use crate::coins::Coins; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index ced5a6bc8b..f0cb1a5429 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -7,12 +7,12 @@ use bech32::{encode, Bech32, Hrp}; use core::marker::PhantomData; #[cfg(feature = "cosmwasm_1_3")] use core::ops::Bound; +use cosmwasm_core::{Addr, CanonicalAddr}; use serde::de::DeserializeOwned; #[cfg(feature = "stargate")] use serde::Serialize; use sha2::{Digest, Sha256}; -use crate::addresses::{Addr, CanonicalAddr}; use crate::coin::Coin; use crate::deps::OwnedDeps; use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 8cb92b1f62..27978afa07 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -1,8 +1,8 @@ use core::marker::PhantomData; use core::ops::Deref; +use cosmwasm_core::{Addr, CanonicalAddr}; use serde::{de::DeserializeOwned, Serialize}; -use crate::addresses::{Addr, CanonicalAddr}; use crate::coin::Coin; use crate::errors::{RecoverPubkeyError, StdError, StdResult, VerificationError}; #[cfg(feature = "iterator")] diff --git a/packages/std/src/types.rs b/packages/std/src/types.rs index 6a77eccd80..654da76dab 100644 --- a/packages/std/src/types.rs +++ b/packages/std/src/types.rs @@ -1,7 +1,7 @@ +use cosmwasm_core::Addr; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::addresses::Addr; use crate::coin::Coin; use crate::prelude::*; use crate::timestamp::Timestamp; From 44aba654c371deca940708dd0f55570bd54b862a Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 10:23:05 +0100 Subject: [PATCH 14/42] Update lockfiles --- contracts/burner/Cargo.lock | 6 +++--- contracts/crypto-verify/Cargo.lock | 6 +++--- contracts/cyberpunk/Cargo.lock | 6 +++--- contracts/empty/Cargo.lock | 6 +++--- contracts/floaty/Cargo.lock | 6 +++--- contracts/hackatom/Cargo.lock | 6 +++--- contracts/ibc-reflect-send/Cargo.lock | 6 +++--- contracts/ibc-reflect/Cargo.lock | 6 +++--- contracts/queue/Cargo.lock | 6 +++--- contracts/reflect/Cargo.lock | 6 +++--- contracts/staking/Cargo.lock | 6 +++--- contracts/virus/Cargo.lock | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index bed77c6ec0..551acfac8f 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -222,7 +222,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1440,9 +1440,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 2cb541aa28..d847e252bb 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1475,9 +1475,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 16ff68f31c..f6233bc9c0 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -240,7 +240,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1557,9 +1557,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 770f6c85fd..75b133f426 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1439,9 +1439,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 83efe55081..010ab6e373 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1457,9 +1457,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index a236fc09c9..7ac773c9b1 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1442,9 +1442,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index babfed2bf5..a55f337b8a 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1440,9 +1440,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index e1b8543618..1e2b5a9df5 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1440,9 +1440,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 8fd94e7d0b..896a4eba64 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1440,9 +1440,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index fe0091e58c..9d3610a39c 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1441,9 +1441,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 630e263d70..f76846db16 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1429,9 +1429,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 94aca643d7..c6408c8c67 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "sha2", "static_assertions", ] @@ -1429,9 +1429,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", From de6e0cec571e3abd47607208adbb714dfe39e0b3 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 10:28:46 +0100 Subject: [PATCH 15/42] Fix imports --- packages/std/src/imports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/std/src/imports.rs b/packages/std/src/imports.rs index 306a6d2f9b..1838e4245f 100644 --- a/packages/std/src/imports.rs +++ b/packages/std/src/imports.rs @@ -1,6 +1,6 @@ use alloc::vec::Vec; +use cosmwasm_core::{Addr, CanonicalAddr}; -use crate::addresses::{Addr, CanonicalAddr}; use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; use crate::import_helpers::{from_high_half, from_low_half}; use crate::memory::{alloc, build_region, consume_region, Region}; From c50ce9606d95271bb76909cde6084a9a9ef62841 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 10:40:19 +0100 Subject: [PATCH 16/42] Move encoding logic into public functions --- packages/core/src/binary.rs | 23 +++++------------- packages/core/src/encoding.rs | 42 +++++++++++++++++++++++++++++++++ packages/core/src/hex_binary.rs | 10 ++++---- packages/core/src/lib.rs | 2 ++ 4 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 packages/core/src/encoding.rs diff --git a/packages/core/src/binary.rs b/packages/core/src/binary.rs index a9ddf9122a..efe31080b9 100644 --- a/packages/core/src/binary.rs +++ b/packages/core/src/binary.rs @@ -2,10 +2,12 @@ use alloc::{string::String, vec::Vec}; use core::fmt; use core::ops::Deref; -use base64::engine::{Engine, GeneralPurpose}; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{CoreError, CoreResult}; +use crate::{ + encoding::{from_base64, to_base64}, + errors::{CoreError, CoreResult}, +}; /// Binary is a wrapper around Vec to add base64 de/serialization /// with serde. It also adds some helper methods to help encode inline. @@ -17,16 +19,6 @@ use crate::errors::{CoreError, CoreResult}; pub struct Binary(#[cfg_attr(feature = "std", schemars(with = "String"))] Vec); impl Binary { - /// Base64 encoding engine used in conversion to/from base64. - /// - /// The engine adds padding when encoding and accepts strings with or - /// without padding when decoding. - const B64_ENGINE: GeneralPurpose = GeneralPurpose::new( - &base64::alphabet::STANDARD, - base64::engine::GeneralPurposeConfig::new() - .with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent), - ); - /// Creates a new `Binary` containing the given data. pub const fn new(data: Vec) -> Self { Self(data) @@ -35,16 +27,13 @@ impl Binary { /// take an (untrusted) string and decode it into bytes. /// fails if it is not valid base64 pub fn from_base64(encoded: &str) -> CoreResult { - Self::B64_ENGINE - .decode(encoded.as_bytes()) - .map(Binary::from) - .map_err(CoreError::invalid_base64) + from_base64(encoded).map(Self::new) } /// encode to base64 string (guaranteed to be success as we control the data inside). /// this returns normalized form (with trailing = if needed) pub fn to_base64(&self) -> String { - Self::B64_ENGINE.encode(self.0.as_slice()) + to_base64(&self.0) } pub fn as_slice(&self) -> &[u8] { diff --git a/packages/core/src/encoding.rs b/packages/core/src/encoding.rs new file mode 100644 index 0000000000..dd05728cb5 --- /dev/null +++ b/packages/core/src/encoding.rs @@ -0,0 +1,42 @@ +use alloc::vec::Vec; +use base64::{engine::GeneralPurpose, Engine}; + +use crate::{CoreError, CoreResult}; + +/// Base64 encoding engine used in conversion to/from base64. +/// +/// The engine adds padding when encoding and accepts strings with or +/// without padding when decoding. +const B64_ENGINE: GeneralPurpose = GeneralPurpose::new( + &base64::alphabet::STANDARD, + base64::engine::GeneralPurposeConfig::new() + .with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent), +); + +pub fn from_base64(input: I) -> CoreResult> +where + I: AsRef<[u8]>, +{ + B64_ENGINE.decode(input).map_err(CoreError::invalid_base64) +} + +pub fn to_base64(input: I) -> String +where + I: AsRef<[u8]>, +{ + B64_ENGINE.encode(input) +} + +pub fn from_hex(input: I) -> CoreResult> +where + I: AsRef<[u8]>, +{ + hex::decode(input).map_err(CoreError::invalid_hex) +} + +pub fn to_hex(input: I) -> String +where + I: AsRef<[u8]>, +{ + hex::encode(input) +} diff --git a/packages/core/src/hex_binary.rs b/packages/core/src/hex_binary.rs index 9f6be10c8d..0a24c5b12b 100644 --- a/packages/core/src/hex_binary.rs +++ b/packages/core/src/hex_binary.rs @@ -4,7 +4,10 @@ use core::ops::Deref; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::{Binary, CoreError, CoreResult}; +use crate::{ + encoding::{from_hex, to_hex}, + Binary, CoreError, CoreResult, +}; /// This is a wrapper around Vec to add hex de/serialization /// with serde. It also adds some helper methods to help encode inline. @@ -17,12 +20,11 @@ pub struct HexBinary(#[cfg_attr(feature = "std", schemars(with = "String"))] Vec impl HexBinary { pub fn from_hex(input: &str) -> CoreResult { - let vec = hex::decode(input).map_err(CoreError::invalid_hex)?; - Ok(Self(vec)) + from_hex(input).map(Self) } pub fn to_hex(&self) -> String { - hex::encode(&self.0) + to_hex(&self.0) } pub fn as_slice(&self) -> &[u8] { diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index b868cc2afa..fd22c28d78 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -9,6 +9,7 @@ extern crate alloc; mod addresses; mod binary; +mod encoding; mod errors; mod forward_ref; mod hex_binary; @@ -19,6 +20,7 @@ pub mod __internal; pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; pub use crate::binary::Binary; +pub use crate::encoding::{from_base64, from_hex, to_base64, to_hex}; pub use crate::errors::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, CoreError, CoreResult, DivideByZeroError, DivisionError, From d66a3d4c3d3fe72f4c89a6df45303c7a8f1cc257 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 10:42:25 +0100 Subject: [PATCH 17/42] Add some documentation --- packages/core/src/encoding.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/encoding.rs b/packages/core/src/encoding.rs index dd05728cb5..7872186273 100644 --- a/packages/core/src/encoding.rs +++ b/packages/core/src/encoding.rs @@ -1,4 +1,4 @@ -use alloc::vec::Vec; +use alloc::{string::String, vec::Vec}; use base64::{engine::GeneralPurpose, Engine}; use crate::{CoreError, CoreResult}; @@ -13,6 +13,7 @@ const B64_ENGINE: GeneralPurpose = GeneralPurpose::new( .with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent), ); +/// Deserialize a bag of bytes from Base64 into a vector of bytes pub fn from_base64(input: I) -> CoreResult> where I: AsRef<[u8]>, @@ -20,6 +21,7 @@ where B64_ENGINE.decode(input).map_err(CoreError::invalid_base64) } +/// Encode a bag of bytes into the Base64 format pub fn to_base64(input: I) -> String where I: AsRef<[u8]>, @@ -27,6 +29,7 @@ where B64_ENGINE.encode(input) } +/// Decode a bag of bytes from hex into a vector of bytes pub fn from_hex(input: I) -> CoreResult> where I: AsRef<[u8]>, @@ -34,6 +37,7 @@ where hex::decode(input).map_err(CoreError::invalid_hex) } +/// Encode a bag of bytes into the hex format pub fn to_hex(input: I) -> String where I: AsRef<[u8]>, From c214ef3d26b29bc0e789ce98edebe80ce71843f3 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 11:20:16 +0100 Subject: [PATCH 18/42] Add tests to the encoding module --- packages/core/src/encoding.rs | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/core/src/encoding.rs b/packages/core/src/encoding.rs index 7872186273..9a8e2a44a2 100644 --- a/packages/core/src/encoding.rs +++ b/packages/core/src/encoding.rs @@ -44,3 +44,51 @@ where { hex::encode(input) } + +#[cfg(test)] +mod test { + use crate::{from_base64, from_hex, to_base64, to_hex}; + + const BASE64_FOOBAR: &str = "Zm9vYmFy"; // utf-8 encoded "foobar" + const HEX_FOOBAR: &str = "666f6f626172"; // utf-8 encoded "foobar" + + #[test] + fn from_base64_works() { + let decoded = from_base64(BASE64_FOOBAR).unwrap(); + assert_eq!(decoded, b"foobar"); + } + + #[test] + fn to_base64_works() { + let encoded = to_base64("foobar"); + assert_eq!(encoded, BASE64_FOOBAR); + } + + #[test] + fn base64_roundtrip_works() { + let decoded = from_base64(BASE64_FOOBAR).unwrap(); + assert_eq!(decoded, b"foobar"); + let encoded = to_base64(decoded); + assert_eq!(encoded, BASE64_FOOBAR); + } + + #[test] + fn from_hex_works() { + let decoded = from_hex(HEX_FOOBAR).unwrap(); + assert_eq!(decoded, b"foobar"); + } + + #[test] + fn to_hex_works() { + let encoded = to_hex("foobar"); + assert_eq!(encoded, HEX_FOOBAR); + } + + #[test] + fn hex_roundtrip_works() { + let decoded = from_hex(HEX_FOOBAR).unwrap(); + assert_eq!(decoded, b"foobar"); + let encoded = to_hex(decoded); + assert_eq!(encoded, HEX_FOOBAR); + } +} From eaf21f628c092b2c0d659b3dba139b370f3a746e Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 13:54:59 +0100 Subject: [PATCH 19/42] Test coverage of core error --- packages/core/src/errors/core_error.rs | 173 +++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index 22db25d5a1..bc1a10ed35 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -316,3 +316,176 @@ pub struct RoundDownOverflowError; #[cfg(feature = "std")] impl std::error::Error for RoundDownOverflowError {} + +impl From for CoreError { + fn from(source: OverflowError) -> Self { + Self::overflow(source) + } +} + +impl From for CoreError { + fn from(source: DivideByZeroError) -> Self { + Self::divide_by_zero(source) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + // constructors + + // example of reporting contract errors with format! + #[test] + fn generic_err_owned() { + let guess = 7; + let error = CoreError::generic_err(format!("{guess} is too low")); + match error { + CoreError::GenericErr { msg, .. } => { + assert_eq!(msg, String::from("7 is too low")); + } + e => panic!("unexpected error, {e:?}"), + } + } + + // example of reporting static contract errors + #[test] + fn generic_err_ref() { + let error = CoreError::generic_err("not implemented"); + match error { + CoreError::GenericErr { msg, .. } => assert_eq!(msg, "not implemented"), + e => panic!("unexpected error, {e:?}"), + } + } + + #[test] + fn invalid_base64_works_for_strings() { + let error = CoreError::invalid_base64("my text"); + match error { + CoreError::InvalidBase64 { msg, .. } => { + assert_eq!(msg, "my text"); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn invalid_base64_works_for_errors() { + let original = base64::DecodeError::InvalidLength; + let error = CoreError::invalid_base64(original); + match error { + CoreError::InvalidBase64 { msg, .. } => { + assert_eq!(msg, "Encoded text cannot have a 6-bit remainder."); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn invalid_data_size_works() { + let error = CoreError::invalid_data_size(31, 14); + match error { + CoreError::InvalidDataSize { + expected, actual, .. + } => { + assert_eq!(expected, 31); + assert_eq!(actual, 14); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn invalid_hex_works_for_strings() { + let error = CoreError::invalid_hex("my text"); + match error { + CoreError::InvalidHex { msg, .. } => { + assert_eq!(msg, "my text"); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn invalid_hex_works_for_errors() { + let original = hex::FromHexError::OddLength; + let error = CoreError::invalid_hex(original); + match error { + CoreError::InvalidHex { msg, .. } => { + assert_eq!(msg, "Odd number of digits"); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn underflow_works_for_u128() { + let error = CoreError::overflow(OverflowError::new(OverflowOperation::Sub)); + assert!(matches!( + error, + CoreError::Overflow { + source: OverflowError { + operation: OverflowOperation::Sub + }, + .. + } + )); + } + + #[test] + fn overflow_works_for_i64() { + let error = CoreError::overflow(OverflowError::new(OverflowOperation::Sub)); + assert!(matches!( + error, + CoreError::Overflow { + source: OverflowError { + operation: OverflowOperation::Sub + }, + .. + } + )); + } + + #[test] + fn divide_by_zero_works() { + let error = CoreError::divide_by_zero(DivideByZeroError); + assert!(matches!( + error, + CoreError::DivideByZero { + source: DivideByZeroError, + .. + } + )); + } + + #[test] + fn implements_debug() { + let error: CoreError = CoreError::from(OverflowError::new(OverflowOperation::Sub)); + let embedded = format!("Debug: {error:?}"); + let expected = r#"Debug: Overflow { source: OverflowError { operation: Sub }, backtrace: }"#; + assert_eq!(embedded, expected); + } + + #[test] + fn implements_display() { + let error: CoreError = CoreError::from(OverflowError::new(OverflowOperation::Sub)); + let embedded = format!("Display: {error}"); + assert_eq!( + embedded, + "Display: Overflow: Cannot Sub with given operands" + ); + } + + #[test] + fn implements_partial_eq() { + let u1 = CoreError::from(OverflowError::new(OverflowOperation::Sub)); + let u2 = CoreError::from(OverflowError::new(OverflowOperation::Sub)); + let s1 = CoreError::generic_err("Content too long"); + let s2 = CoreError::generic_err("Content too long"); + let s3 = CoreError::generic_err("Title too long"); + assert_eq!(u1, u2); + assert_ne!(u1, s1); + assert_eq!(s1, s2); + assert_ne!(s1, s3); + } +} From e92179cee45f5493a7d1c38aa5e698b7b375728f Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 14:00:35 +0100 Subject: [PATCH 20/42] Only export needed types via __internal module --- packages/core/src/__internal.rs | 11 ++++------- packages/core/src/errors/backtrace.rs | 4 ++-- packages/std/src/errors/mod.rs | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/core/src/__internal.rs b/packages/core/src/__internal.rs index e42d2f7e79..c5d74f7f0a 100644 --- a/packages/core/src/__internal.rs +++ b/packages/core/src/__internal.rs @@ -1,13 +1,10 @@ //! //! # ⚠ DO NOT DEPEND ON THIS AS AN OUTSIDE CONSUMER //! +//! **THIS MODULE IS SEMVER EXCEMPT AND ONLY MEANT TO SHARE TYPES BETWEEN CORE AND STD** +//! //! Module for re-exporting implementation details from `core` to `std` //! -pub mod errors { - pub use crate::errors::*; -} - -pub mod backtrace { - pub use crate::errors::backtrace::*; -} +pub use crate::errors::backtrace::impl_from_err; +pub use crate::errors::backtrace::BT; diff --git a/packages/core/src/errors/backtrace.rs b/packages/core/src/errors/backtrace.rs index 08c126ad55..d957d2f45a 100644 --- a/packages/core/src/errors/backtrace.rs +++ b/packages/core/src/errors/backtrace.rs @@ -58,15 +58,15 @@ impl Display for Stub { /// the target error has a `backtrace` field. /// This is meant as a replacement for `thiserror`'s `#[from]` attribute, which does not /// work with our custom backtrace wrapper. -#[macro_export] #[doc(hidden)] +#[macro_export] macro_rules! __internal__impl_from_err { ($from:ty, $to:ty, $map:path) => { impl From<$from> for $to { fn from(err: $from) -> Self { $map { source: err, - backtrace: $crate::__internal::backtrace::BT::capture(), + backtrace: $crate::__internal::BT::capture(), } } } diff --git a/packages/std/src/errors/mod.rs b/packages/std/src/errors/mod.rs index fdad099641..e864fe132f 100644 --- a/packages/std/src/errors/mod.rs +++ b/packages/std/src/errors/mod.rs @@ -3,7 +3,7 @@ mod std_error; mod system_error; mod verification_error; -pub(crate) use cosmwasm_core::__internal::backtrace::{impl_from_err, BT}; +pub(crate) use cosmwasm_core::__internal::{impl_from_err, BT}; pub use cosmwasm_core::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, From 3d36e18b3d8d12937bfa0df7345c6fa290d46136 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 14:04:43 +0100 Subject: [PATCH 21/42] Make it obvious macro is internal only and reexport via `__internal` --- packages/core/src/__internal.rs | 1 + packages/core/src/forward_ref.rs | 2 +- packages/core/src/lib.rs | 2 ++ packages/std/src/results/events.rs | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/__internal.rs b/packages/core/src/__internal.rs index c5d74f7f0a..e31c3ddd1b 100644 --- a/packages/core/src/__internal.rs +++ b/packages/core/src/__internal.rs @@ -6,5 +6,6 @@ //! Module for re-exporting implementation details from `core` to `std` //! +pub use crate::__internal__forward_ref_partial_eq as forward_ref_partial_eq; pub use crate::errors::backtrace::impl_from_err; pub use crate::errors::backtrace::BT; diff --git a/packages/core/src/forward_ref.rs b/packages/core/src/forward_ref.rs index 9c41b1aec0..7be5b91686 100644 --- a/packages/core/src/forward_ref.rs +++ b/packages/core/src/forward_ref.rs @@ -7,7 +7,7 @@ /// We don't need to add `&T == &U` here because this is implemented automatically. #[doc(hidden)] #[macro_export] -macro_rules! forward_ref_partial_eq { +macro_rules! __internal__forward_ref_partial_eq { ($t:ty, $u:ty) => { // `&T == U` impl<'a> PartialEq<$u> for &'a $t { diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index fd22c28d78..121ef63f3c 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -18,6 +18,8 @@ mod math; #[doc(hidden)] pub mod __internal; +use crate::__internal__forward_ref_partial_eq as forward_ref_partial_eq; + pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; pub use crate::binary::Binary; pub use crate::encoding::{from_base64, from_hex, to_base64, to_hex}; diff --git a/packages/std/src/results/events.rs b/packages/std/src/results/events.rs index 2ed593ae68..6ab3957202 100644 --- a/packages/std/src/results/events.rs +++ b/packages/std/src/results/events.rs @@ -1,7 +1,7 @@ +use cosmwasm_core::__internal::forward_ref_partial_eq; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::forward_ref_partial_eq; use crate::prelude::*; /// A full [*Cosmos SDK* event]. From 67836e6c2278eab21577cb714bd038d0ec7551a7 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 14:29:49 +0100 Subject: [PATCH 22/42] Tests for core error conversion --- packages/std/src/errors/std_error.rs | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index 821b471432..ffb74e62c7 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -511,6 +511,56 @@ mod tests { } } + #[test] + fn core_error_conversion() { + let generic = StdError::from(CoreError::generic_err("test error")); + let base64 = StdError::from(CoreError::invalid_base64("invalid data")); + let data_size = StdError::from(CoreError::invalid_data_size(10, 12)); + let hex = StdError::from(CoreError::invalid_hex("invalid hex")); + let overflow = StdError::from(CoreError::overflow(OverflowError::new( + OverflowOperation::Pow, + ))); + let divide = StdError::from(CoreError::divide_by_zero(DivideByZeroError::new())); + + match generic { + StdError::GenericErr { msg, .. } => assert_eq!(msg, "test error"), + _ => panic!("expected different error"), + } + + match base64 { + StdError::InvalidBase64 { msg, .. } => assert_eq!(msg, "invalid data"), + _ => panic!("expected different error"), + } + + match data_size { + StdError::InvalidDataSize { + expected, actual, .. + } => { + assert_eq!(expected, 10); + assert_eq!(actual, 12); + } + _ => panic!("expected different error"), + } + + match hex { + StdError::InvalidHex { msg, .. } => assert_eq!(msg, "invalid hex"), + _ => panic!("expected different error"), + } + + match overflow { + StdError::Overflow { + source: OverflowError { operation }, + .. + } => assert_eq!(operation, OverflowOperation::Pow), + _ => panic!("expected different error"), + } + + match divide { + StdError::DivideByZero { .. } => (), + _ => panic!("expected different error"), + } + } + #[test] fn invalid_base64_works_for_strings() { let error = StdError::invalid_base64("my text"); From 314cf017be9a51b1755f2a87650eea381bb91691 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 17:32:12 +0100 Subject: [PATCH 23/42] Run coverage reports with all features --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aa9529c560..86fa3147a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1066,7 +1066,7 @@ jobs: name: Run tests with coverage command: | mkdir -p reports - cargo test + cargo test --all-features grcov . -s packages/core --binary-path ./target/debug -t lcov -o ./reports/core.info grcov . -s packages/crypto --binary-path ./target/debug -t lcov -o ./reports/crypto.info From ec621727280819c25b66acd90601e0265aba61f4 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 18:02:06 +0100 Subject: [PATCH 24/42] Address review --- .../crypto-verify/schema/crypto-verify.json | 2 +- contracts/crypto-verify/schema/raw/query.json | 2 +- contracts/cyberpunk/schema/cyberpunk.json | 2 +- .../schema/raw/response_to_mirror_env.json | 2 +- contracts/hackatom/schema/hackatom.json | 4 +- .../schema/raw/response_to_other_balance.json | 2 +- contracts/hackatom/schema/raw/sudo.json | 2 +- .../schema/ibc-reflect-send.json | 12 +-- .../ibc/acknowledgement_msg_balances.json | 2 +- .../schema/ibc/packet_msg.json | 4 +- .../ibc-reflect-send/schema/raw/execute.json | 4 +- .../schema/raw/response_to_account.json | 4 +- .../schema/raw/response_to_list_accounts.json | 4 +- .../ibc/acknowledgement_msg_balances.json | 2 +- .../ibc-reflect/schema/ibc/packet_msg.json | 4 +- contracts/reflect/schema/raw/execute.json | 4 +- contracts/reflect/schema/reflect.json | 4 +- contracts/staking/schema/raw/execute.json | 2 +- contracts/staking/schema/raw/instantiate.json | 2 +- .../schema/raw/response_to_balance.json | 2 +- .../schema/raw/response_to_claims.json | 2 +- .../schema/raw/response_to_investment.json | 2 +- contracts/staking/schema/staking.json | 10 +-- packages/core/Cargo.toml | 4 +- packages/core/src/binary.rs | 18 ++--- packages/core/src/hex_binary.rs | 13 ++-- packages/core/src/math/decimal.rs | 67 ++++++++++------ packages/core/src/math/decimal256.rs | 49 ++++++------ packages/core/src/math/fraction.rs | 8 +- packages/core/src/math/int128.rs | 10 +-- packages/core/src/math/int256.rs | 10 +-- packages/core/src/math/int512.rs | 8 +- packages/core/src/math/int64.rs | 10 +-- packages/core/src/math/signed_decimal.rs | 77 ++++++++++--------- packages/core/src/math/signed_decimal_256.rs | 77 ++++++++++--------- packages/core/src/math/uint128.rs | 10 +-- packages/core/src/math/uint256.rs | 10 +-- packages/core/src/math/uint512.rs | 8 +- packages/core/src/math/uint64.rs | 9 +-- packages/core/src/testing/assertions.rs | 2 +- 40 files changed, 245 insertions(+), 225 deletions(-) diff --git a/contracts/crypto-verify/schema/crypto-verify.json b/contracts/crypto-verify/schema/crypto-verify.json index e3e7a632bd..56eba68e5d 100644 --- a/contracts/crypto-verify/schema/crypto-verify.json +++ b/contracts/crypto-verify/schema/crypto-verify.json @@ -394,7 +394,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/crypto-verify/schema/raw/query.json b/contracts/crypto-verify/schema/raw/query.json index 9c3938e9c3..76aa8b0ef7 100644 --- a/contracts/crypto-verify/schema/raw/query.json +++ b/contracts/crypto-verify/schema/raw/query.json @@ -383,7 +383,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/cyberpunk/schema/cyberpunk.json b/contracts/cyberpunk/schema/cyberpunk.json index be602973e9..dbabc26fb4 100644 --- a/contracts/cyberpunk/schema/cyberpunk.json +++ b/contracts/cyberpunk/schema/cyberpunk.json @@ -507,7 +507,7 @@ "additionalProperties": false }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/cyberpunk/schema/raw/response_to_mirror_env.json b/contracts/cyberpunk/schema/raw/response_to_mirror_env.json index 0cc25ba369..6d4e75e50b 100644 --- a/contracts/cyberpunk/schema/raw/response_to_mirror_env.json +++ b/contracts/cyberpunk/schema/raw/response_to_mirror_env.json @@ -95,7 +95,7 @@ "additionalProperties": false }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/hackatom/schema/hackatom.json b/contracts/hackatom/schema/hackatom.json index 6fdf055f6e..307c89871f 100644 --- a/contracts/hackatom/schema/hackatom.json +++ b/contracts/hackatom/schema/hackatom.json @@ -301,7 +301,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -358,7 +358,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/hackatom/schema/raw/response_to_other_balance.json b/contracts/hackatom/schema/raw/response_to_other_balance.json index 4c53acf22e..46aa76ef1b 100644 --- a/contracts/hackatom/schema/raw/response_to_other_balance.json +++ b/contracts/hackatom/schema/raw/response_to_other_balance.json @@ -33,7 +33,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/hackatom/schema/raw/sudo.json b/contracts/hackatom/schema/raw/sudo.json index a0abebb41e..5391911bd6 100644 --- a/contracts/hackatom/schema/raw/sudo.json +++ b/contracts/hackatom/schema/raw/sudo.json @@ -50,7 +50,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json index 79192fadea..c8d872b5d2 100644 --- a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json +++ b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json @@ -663,11 +663,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { @@ -979,11 +979,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } @@ -1079,11 +1079,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json b/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json index 52f7cc0884..4f6447522d 100644 --- a/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json +++ b/contracts/ibc-reflect-send/schema/ibc/acknowledgement_msg_balances.json @@ -66,7 +66,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json index 5c32f93c9a..cea5745b7e 100644 --- a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json @@ -604,11 +604,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/ibc-reflect-send/schema/raw/execute.json b/contracts/ibc-reflect-send/schema/raw/execute.json index a4cc21d05e..f1b1d6dcef 100644 --- a/contracts/ibc-reflect-send/schema/raw/execute.json +++ b/contracts/ibc-reflect-send/schema/raw/execute.json @@ -652,11 +652,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/ibc-reflect-send/schema/raw/response_to_account.json b/contracts/ibc-reflect-send/schema/raw/response_to_account.json index bbfd2a8d85..30c737f48d 100644 --- a/contracts/ibc-reflect-send/schema/raw/response_to_account.json +++ b/contracts/ibc-reflect-send/schema/raw/response_to_account.json @@ -60,11 +60,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json b/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json index ffc774fd3e..4c0a3c91c8 100644 --- a/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json +++ b/contracts/ibc-reflect-send/schema/raw/response_to_list_accounts.json @@ -75,11 +75,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json b/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json index 52f7cc0884..4f6447522d 100644 --- a/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json +++ b/contracts/ibc-reflect/schema/ibc/acknowledgement_msg_balances.json @@ -66,7 +66,7 @@ "additionalProperties": false }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/ibc-reflect/schema/ibc/packet_msg.json b/contracts/ibc-reflect/schema/ibc/packet_msg.json index bfe12e7826..31374ccadf 100644 --- a/contracts/ibc-reflect/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect/schema/ibc/packet_msg.json @@ -564,11 +564,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/reflect/schema/raw/execute.json b/contracts/reflect/schema/raw/execute.json index 8833281895..947eb3997c 100644 --- a/contracts/reflect/schema/raw/execute.json +++ b/contracts/reflect/schema/raw/execute.json @@ -812,11 +812,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 1774623932..56d41ee0af 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -822,11 +822,11 @@ ] }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" }, "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_core::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, "VoteOption": { diff --git a/contracts/staking/schema/raw/execute.json b/contracts/staking/schema/raw/execute.json index 5fa38f2d3e..159d67cd90 100644 --- a/contracts/staking/schema/raw/execute.json +++ b/contracts/staking/schema/raw/execute.json @@ -109,7 +109,7 @@ ], "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/instantiate.json b/contracts/staking/schema/raw/instantiate.json index b1f71de8ff..dd25457114 100644 --- a/contracts/staking/schema/raw/instantiate.json +++ b/contracts/staking/schema/raw/instantiate.json @@ -53,7 +53,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/response_to_balance.json b/contracts/staking/schema/raw/response_to_balance.json index 2392cc8821..7dcf4d4a51 100644 --- a/contracts/staking/schema/raw/response_to_balance.json +++ b/contracts/staking/schema/raw/response_to_balance.json @@ -13,7 +13,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/response_to_claims.json b/contracts/staking/schema/raw/response_to_claims.json index 83c5b0b58a..b393e85853 100644 --- a/contracts/staking/schema/raw/response_to_claims.json +++ b/contracts/staking/schema/raw/response_to_claims.json @@ -13,7 +13,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/raw/response_to_investment.json b/contracts/staking/schema/raw/response_to_investment.json index edcba22762..23fd138114 100644 --- a/contracts/staking/schema/raw/response_to_investment.json +++ b/contracts/staking/schema/raw/response_to_investment.json @@ -69,7 +69,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/contracts/staking/schema/staking.json b/contracts/staking/schema/staking.json index b13500b379..e5e3f98843 100644 --- a/contracts/staking/schema/staking.json +++ b/contracts/staking/schema/staking.json @@ -57,7 +57,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -173,7 +173,7 @@ ], "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -274,7 +274,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -294,7 +294,7 @@ "additionalProperties": false, "definitions": { "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } @@ -370,7 +370,7 @@ "type": "string" }, "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_core::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" } } diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index d8aec21d28..0ec4a8dd1e 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -29,8 +29,8 @@ std = ["dep:schemars"] testing = ["dep:crc32fast"] [dev-dependencies] -# I love cyclic dependencies. They are good for your health. +# Cyclic dependencies for doc tests.. cosmwasm-std = { path = "../std", version = "2.0.0" } crc32fast = { version = "1.4.0", default-features = false } hex-literal = "0.4.1" -serde_json = { version = "1.0.114", default-features = false } +serde_json = "1.0.114" diff --git a/packages/core/src/binary.rs b/packages/core/src/binary.rs index efe31080b9..e6ae76e052 100644 --- a/packages/core/src/binary.rs +++ b/packages/core/src/binary.rs @@ -47,7 +47,7 @@ impl Binary { /// Copy to array of explicit length /// /// ``` - /// # use cosmwasm_core::Binary; + /// # use cosmwasm_std::Binary; /// let binary = Binary::from(&[0xfb, 0x1f, 0x37]); /// let array: [u8; 3] = binary.to_array().unwrap(); /// assert_eq!(array, [0xfb, 0x1f, 0x37]); @@ -56,7 +56,7 @@ impl Binary { /// Copy to integer /// /// ``` - /// # use cosmwasm_core::Binary; + /// # use cosmwasm_std::Binary; /// let binary = Binary::from(&[0x8b, 0x67, 0x64, 0x84, 0xb5, 0xfb, 0x1f, 0x37]); /// let num = u64::from_be_bytes(binary.to_array().unwrap()); /// assert_eq!(num, 10045108015024774967); @@ -249,8 +249,6 @@ mod tests { use crate::assert_hash_works; use crate::errors::CoreError; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn to_array_works() { // simple @@ -446,8 +444,8 @@ mod tests { fn serialization_works() { let binary = Binary(vec![0u8, 187, 61, 11, 250, 0]); - let json = to_json_vec(&binary).unwrap(); - let deserialized: Binary = from_json(json).unwrap(); + let json = serde_json::to_vec(&binary).unwrap(); + let deserialized: Binary = serde_json::from_slice(&json).unwrap(); assert_eq!(binary, deserialized); } @@ -458,16 +456,16 @@ mod tests { // this is the binary behind above string let expected = vec![0u8, 187, 61, 11, 250, 0]; - let serialized = to_json_vec(&b64_str).unwrap(); - let deserialized: Binary = from_json(serialized).unwrap(); + let serialized = serde_json::to_vec(&b64_str).unwrap(); + let deserialized: Binary = serde_json::from_slice(&serialized).unwrap(); assert_eq!(expected, deserialized.as_slice()); } #[test] fn deserialize_from_invalid_string() { let invalid_str = "**BAD!**"; - let serialized = to_json_vec(&invalid_str).unwrap(); - let res = from_json::(&serialized); + let serialized = serde_json::to_vec(&invalid_str).unwrap(); + let res = serde_json::from_slice::(&serialized); assert!(res.is_err()); } diff --git a/packages/core/src/hex_binary.rs b/packages/core/src/hex_binary.rs index 0a24c5b12b..f55a8daeae 100644 --- a/packages/core/src/hex_binary.rs +++ b/packages/core/src/hex_binary.rs @@ -251,7 +251,6 @@ mod tests { use super::*; use crate::{assert_hash_works, CoreError}; - use cosmwasm_std::{from_json, to_json_vec}; #[test] fn from_hex_works() { @@ -519,8 +518,8 @@ mod tests { fn serialization_works() { let binary = HexBinary(vec![0u8, 187, 61, 11, 250, 0]); - let json = to_json_vec(&binary).unwrap(); - let deserialized: HexBinary = from_json(json).unwrap(); + let json = serde_json::to_vec(&binary).unwrap(); + let deserialized: HexBinary = serde_json::from_slice(&json).unwrap(); assert_eq!(binary, deserialized); } @@ -531,16 +530,16 @@ mod tests { // this is the binary behind above string let expected = vec![0u8, 187, 61, 11, 250, 0]; - let serialized = to_json_vec(&hex).unwrap(); - let deserialized: HexBinary = from_json(serialized).unwrap(); + let serialized = serde_json::to_vec(&hex).unwrap(); + let deserialized: HexBinary = serde_json::from_slice(&serialized).unwrap(); assert_eq!(expected, deserialized.as_slice()); } #[test] fn deserialize_from_invalid_string() { let invalid_str = "**BAD!**"; - let serialized = to_json_vec(&invalid_str).unwrap(); - let res = from_json::(&serialized); + let serialized = serde_json::to_vec(&invalid_str).unwrap(); + let res = serde_json::from_slice::(&serialized); assert!(res.is_err()); } diff --git a/packages/core/src/math/decimal.rs b/packages/core/src/math/decimal.rs index a4b53ed3d2..2fa16547d7 100644 --- a/packages/core/src/math/decimal.rs +++ b/packages/core/src/math/decimal.rs @@ -76,7 +76,7 @@ impl Decimal { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_core::Decimal; + /// # use cosmwasm_std::Decimal; /// const HALF: Decimal = Decimal::percent(50); /// /// assert_eq!(HALF, Decimal::from_str("0.5").unwrap()); @@ -93,7 +93,7 @@ impl Decimal { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_core::Decimal; + /// # use cosmwasm_std::Decimal; /// const HALF: Decimal = Decimal::permille(500); /// /// assert_eq!(HALF, Decimal::from_str("0.5").unwrap()); @@ -110,7 +110,7 @@ impl Decimal { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_core::Decimal; + /// # use cosmwasm_std::Decimal; /// const TWO_BPS: Decimal = Decimal::bps(2); /// const HALF: Decimal = Decimal::bps(5000); /// @@ -134,7 +134,7 @@ impl Decimal { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{Decimal, Uint128}; + /// # use cosmwasm_std::{Decimal, Uint128}; /// let a = Decimal::from_atomics(Uint128::new(1234), 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -216,7 +216,7 @@ impl Decimal { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{Decimal, Uint128}; + /// # use cosmwasm_std::{Decimal, Uint128}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = Decimal::from_str("1.234").unwrap(); @@ -420,7 +420,7 @@ impl Decimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{Decimal, Uint128}; + /// use cosmwasm_std::{Decimal, Uint128}; /// /// let d = Decimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_floor(), Uint128::new(12)); @@ -443,7 +443,7 @@ impl Decimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{Decimal, Uint128}; + /// use cosmwasm_std::{Decimal, Uint128}; /// /// let d = Decimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_ceil(), Uint128::new(13)); @@ -788,7 +788,6 @@ mod tests { use super::*; use alloc::vec::Vec; - use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> Decimal { Decimal::from_str(input).unwrap() @@ -1904,35 +1903,59 @@ mod tests { #[test] fn decimal_serialize() { - assert_eq!(to_json_vec(&Decimal::zero()).unwrap(), br#""0""#); - assert_eq!(to_json_vec(&Decimal::one()).unwrap(), br#""1""#); - assert_eq!(to_json_vec(&Decimal::percent(8)).unwrap(), br#""0.08""#); - assert_eq!(to_json_vec(&Decimal::percent(87)).unwrap(), br#""0.87""#); - assert_eq!(to_json_vec(&Decimal::percent(876)).unwrap(), br#""8.76""#); - assert_eq!(to_json_vec(&Decimal::percent(8765)).unwrap(), br#""87.65""#); + assert_eq!(serde_json::to_vec(&Decimal::zero()).unwrap(), br#""0""#); + assert_eq!(serde_json::to_vec(&Decimal::one()).unwrap(), br#""1""#); + assert_eq!( + serde_json::to_vec(&Decimal::percent(8)).unwrap(), + br#""0.08""# + ); + assert_eq!( + serde_json::to_vec(&Decimal::percent(87)).unwrap(), + br#""0.87""# + ); + assert_eq!( + serde_json::to_vec(&Decimal::percent(876)).unwrap(), + br#""8.76""# + ); + assert_eq!( + serde_json::to_vec(&Decimal::percent(8765)).unwrap(), + br#""87.65""# + ); } #[test] fn decimal_deserialize() { - assert_eq!(from_json::(br#""0""#).unwrap(), Decimal::zero()); - assert_eq!(from_json::(br#""1""#).unwrap(), Decimal::one()); - assert_eq!(from_json::(br#""000""#).unwrap(), Decimal::zero()); - assert_eq!(from_json::(br#""001""#).unwrap(), Decimal::one()); + assert_eq!( + serde_json::from_slice::(br#""0""#).unwrap(), + Decimal::zero() + ); + assert_eq!( + serde_json::from_slice::(br#""1""#).unwrap(), + Decimal::one() + ); + assert_eq!( + serde_json::from_slice::(br#""000""#).unwrap(), + Decimal::zero() + ); + assert_eq!( + serde_json::from_slice::(br#""001""#).unwrap(), + Decimal::one() + ); assert_eq!( - from_json::(br#""0.08""#).unwrap(), + serde_json::from_slice::(br#""0.08""#).unwrap(), Decimal::percent(8) ); assert_eq!( - from_json::(br#""0.87""#).unwrap(), + serde_json::from_slice::(br#""0.87""#).unwrap(), Decimal::percent(87) ); assert_eq!( - from_json::(br#""8.76""#).unwrap(), + serde_json::from_slice::(br#""8.76""#).unwrap(), Decimal::percent(876) ); assert_eq!( - from_json::(br#""87.65""#).unwrap(), + serde_json::from_slice::(br#""87.65""#).unwrap(), Decimal::percent(8765) ); } diff --git a/packages/core/src/math/decimal256.rs b/packages/core/src/math/decimal256.rs index f6e82fdf11..164254f96a 100644 --- a/packages/core/src/math/decimal256.rs +++ b/packages/core/src/math/decimal256.rs @@ -79,7 +79,7 @@ impl Decimal256 { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_core::Decimal256; + /// # use cosmwasm_std::Decimal256; /// const HALF: Decimal256 = Decimal256::percent(50); /// /// assert_eq!(HALF, Decimal256::from_str("0.5").unwrap()); @@ -96,7 +96,7 @@ impl Decimal256 { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_core::Decimal256; + /// # use cosmwasm_std::Decimal256; /// const HALF: Decimal256 = Decimal256::permille(500); /// /// assert_eq!(HALF, Decimal256::from_str("0.5").unwrap()); @@ -113,7 +113,7 @@ impl Decimal256 { /// /// ``` /// # use std::str::FromStr; - /// # use cosmwasm_core::Decimal256; + /// # use cosmwasm_std::Decimal256; /// const TWO_BPS: Decimal256 = Decimal256::bps(2); /// const HALF: Decimal256 = Decimal256::bps(5000); /// @@ -137,7 +137,7 @@ impl Decimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{Decimal256, Uint256}; + /// # use cosmwasm_std::{Decimal256, Uint256}; /// let a = Decimal256::from_atomics(1234u64, 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -225,7 +225,7 @@ impl Decimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{Decimal256, Uint256}; + /// # use cosmwasm_std::{Decimal256, Uint256}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = Decimal256::from_str("1.234").unwrap(); @@ -433,7 +433,7 @@ impl Decimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{Decimal256, Uint256}; + /// use cosmwasm_std::{Decimal256, Uint256}; /// /// let d = Decimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_floor(), Uint256::from(12u64)); @@ -456,7 +456,7 @@ impl Decimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{Decimal256, Uint256}; + /// use cosmwasm_std::{Decimal256, Uint256}; /// /// let d = Decimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_uint_ceil(), Uint256::from(13u64)); @@ -789,7 +789,6 @@ mod tests { use crate::errors::CoreError; use alloc::vec::Vec; - use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> Decimal256 { Decimal256::from_str(input).unwrap() @@ -1966,16 +1965,22 @@ mod tests { #[test] fn decimal256_serialize() { - assert_eq!(to_json_vec(&Decimal256::zero()).unwrap(), br#""0""#); - assert_eq!(to_json_vec(&Decimal256::one()).unwrap(), br#""1""#); - assert_eq!(to_json_vec(&Decimal256::percent(8)).unwrap(), br#""0.08""#); - assert_eq!(to_json_vec(&Decimal256::percent(87)).unwrap(), br#""0.87""#); + assert_eq!(serde_json::to_vec(&Decimal256::zero()).unwrap(), br#""0""#); + assert_eq!(serde_json::to_vec(&Decimal256::one()).unwrap(), br#""1""#); assert_eq!( - to_json_vec(&Decimal256::percent(876)).unwrap(), + serde_json::to_vec(&Decimal256::percent(8)).unwrap(), + br#""0.08""# + ); + assert_eq!( + serde_json::to_vec(&Decimal256::percent(87)).unwrap(), + br#""0.87""# + ); + assert_eq!( + serde_json::to_vec(&Decimal256::percent(876)).unwrap(), br#""8.76""# ); assert_eq!( - to_json_vec(&Decimal256::percent(8765)).unwrap(), + serde_json::to_vec(&Decimal256::percent(8765)).unwrap(), br#""87.65""# ); } @@ -1983,36 +1988,36 @@ mod tests { #[test] fn decimal256_deserialize() { assert_eq!( - from_json::(br#""0""#).unwrap(), + serde_json::from_slice::(br#""0""#).unwrap(), Decimal256::zero() ); assert_eq!( - from_json::(br#""1""#).unwrap(), + serde_json::from_slice::(br#""1""#).unwrap(), Decimal256::one() ); assert_eq!( - from_json::(br#""000""#).unwrap(), + serde_json::from_slice::(br#""000""#).unwrap(), Decimal256::zero() ); assert_eq!( - from_json::(br#""001""#).unwrap(), + serde_json::from_slice::(br#""001""#).unwrap(), Decimal256::one() ); assert_eq!( - from_json::(br#""0.08""#).unwrap(), + serde_json::from_slice::(br#""0.08""#).unwrap(), Decimal256::percent(8) ); assert_eq!( - from_json::(br#""0.87""#).unwrap(), + serde_json::from_slice::(br#""0.87""#).unwrap(), Decimal256::percent(87) ); assert_eq!( - from_json::(br#""8.76""#).unwrap(), + serde_json::from_slice::(br#""8.76""#).unwrap(), Decimal256::percent(876) ); assert_eq!( - from_json::(br#""87.65""#).unwrap(), + serde_json::from_slice::(br#""87.65""#).unwrap(), Decimal256::percent(8765) ); } diff --git a/packages/core/src/math/fraction.rs b/packages/core/src/math/fraction.rs index 020adb72a9..c13c746182 100644 --- a/packages/core/src/math/fraction.rs +++ b/packages/core/src/math/fraction.rs @@ -42,7 +42,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_core::Uint128; + /// use cosmwasm_std::Uint128; /// let fraction = (8u128, 21u128); /// let res = Uint128::new(123456).checked_mul_floor(fraction).unwrap(); /// assert_eq!(Uint128::new(47030), res); // 47030.8571 rounds down @@ -70,7 +70,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_core::Uint128; + /// use cosmwasm_std::Uint128; /// let fraction = (8u128, 21u128); /// let res = Uint128::new(123456).checked_mul_ceil(fraction).unwrap(); /// assert_eq!(Uint128::new(47031), res); // 47030.8571 rounds up @@ -102,7 +102,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_core::Uint128; + /// use cosmwasm_std::Uint128; /// let fraction = (4u128, 5u128); /// let res = Uint128::new(789).checked_div_floor(fraction).unwrap(); /// assert_eq!(Uint128::new(986), res); // 986.25 rounds down @@ -136,7 +136,7 @@ macro_rules! impl_mul_fraction { /// ## Examples /// /// ``` - /// use cosmwasm_core::Uint128; + /// use cosmwasm_std::Uint128; /// let fraction = (4u128, 5u128); /// let res = Uint128::new(789).checked_div_ceil(fraction).unwrap(); /// assert_eq!(Uint128::new(987), res); // 986.25 rounds up diff --git a/packages/core/src/math/int128.rs b/packages/core/src/math/int128.rs index 2f20e4e9bc..6eae7422e0 100644 --- a/packages/core/src/math/int128.rs +++ b/packages/core/src/math/int128.rs @@ -28,7 +28,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `i128` to get the value out: /// /// ``` -/// # use cosmwasm_core::Int128; +/// # use cosmwasm_std::Int128; /// let a = Int128::from(258i128); /// assert_eq!(a.i128(), 258); /// ``` @@ -130,7 +130,7 @@ impl Int128 { /// # Examples /// /// ``` - /// use cosmwasm_core::Int128; + /// use cosmwasm_std::Int128; /// /// let a = Int128::MAX; /// let result = a.full_mul(2i32); @@ -575,8 +575,6 @@ mod tests { use super::*; use crate::math::conversion::test_try_from_uint_to_int; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn size_of_works() { assert_eq!(core::mem::size_of::(), 16); @@ -827,9 +825,9 @@ mod tests { #[test] fn int128_json() { let orig = Int128::from(1234567890987654321i128); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Int128 = from_json(serialized).unwrap(); + let parsed: Int128 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/int256.rs b/packages/core/src/math/int256.rs index 109634efe4..7c2f0e5a9b 100644 --- a/packages/core/src/math/int256.rs +++ b/packages/core/src/math/int256.rs @@ -33,7 +33,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_core::Int256; +/// # use cosmwasm_std::Int256; /// let a = Int256::from(258u128); /// let b = Int256::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, @@ -185,7 +185,7 @@ impl Int256 { /// # Examples /// /// ``` - /// use cosmwasm_core::Int256; + /// use cosmwasm_std::Int256; /// /// let a = Int256::MAX; /// let result = a.full_mul(2i32); @@ -650,8 +650,6 @@ mod tests { use super::*; use crate::math::conversion::test_try_from_uint_to_int; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn size_of_works() { assert_eq!(core::mem::size_of::(), 32); @@ -934,9 +932,9 @@ mod tests { #[test] fn int256_json() { let orig = Int256::from(1234567890987654321u128); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Int256 = from_json(serialized).unwrap(); + let parsed: Int256 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/int512.rs b/packages/core/src/math/int512.rs index c74343771f..ebf72bdf6a 100644 --- a/packages/core/src/math/int512.rs +++ b/packages/core/src/math/int512.rs @@ -30,7 +30,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_core::Int512; +/// # use cosmwasm_std::Int512; /// let a = Int512::from(258u128); /// let b = Int512::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, @@ -647,8 +647,6 @@ mod tests { use super::*; use crate::math::conversion::test_try_from_uint_to_int; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn size_of_works() { assert_eq!(core::mem::size_of::(), 64); @@ -962,9 +960,9 @@ mod tests { #[test] fn int512_json() { let orig = Int512::from(1234567890987654321u128); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Int512 = from_json(serialized).unwrap(); + let parsed: Int512 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/int64.rs b/packages/core/src/math/int64.rs index 7c4520abb1..20d956e4ef 100644 --- a/packages/core/src/math/int64.rs +++ b/packages/core/src/math/int64.rs @@ -28,7 +28,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `i64` to get the value out: /// /// ``` -/// # use cosmwasm_core::Int64; +/// # use cosmwasm_std::Int64; /// let a = Int64::from(258i64); /// assert_eq!(a.i64(), 258); /// ``` @@ -130,7 +130,7 @@ impl Int64 { /// # Examples /// /// ``` - /// use cosmwasm_core::Int64; + /// use cosmwasm_std::Int64; /// /// let a = Int64::MAX; /// let result = a.full_mul(2i32); @@ -554,8 +554,6 @@ mod tests { use super::*; use crate::math::conversion::test_try_from_uint_to_int; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn size_of_works() { assert_eq!(core::mem::size_of::(), 8); @@ -799,9 +797,9 @@ mod tests { #[test] fn int64_json() { let orig = Int64::from(1234567890987654321i64); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Int64 = from_json(serialized).unwrap(); + let parsed: Int64 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs index b6dc1bf46c..5e6dba24a4 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -49,7 +49,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// assert_eq!(SignedDecimal::MAX.to_string(), "170141183460469231731.687303715884105727"); /// ``` pub const MAX: Self = Self(Int128::MAX); @@ -59,7 +59,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// assert_eq!(SignedDecimal::MIN.to_string(), "-170141183460469231731.687303715884105728"); /// ``` pub const MIN: Self = Self(Int128::MIN); @@ -70,7 +70,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal, Int128}; + /// # use cosmwasm_std::{SignedDecimal, Int128}; /// assert_eq!(SignedDecimal::new(Int128::one()).to_string(), "0.000000000000000001"); /// ``` pub const fn new(value: Int128) -> Self { @@ -83,7 +83,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// assert_eq!(SignedDecimal::raw(1234i128).to_string(), "0.000000000000001234"); /// ``` pub const fn raw(value: i128) -> Self { @@ -134,7 +134,7 @@ impl SignedDecimal { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal, Int128}; + /// # use cosmwasm_std::{SignedDecimal, Int128}; /// let a = SignedDecimal::from_atomics(Int128::new(1234), 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -183,7 +183,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// assert_eq!( /// SignedDecimal::from_ratio(1, 3).to_string(), /// "0.333333333333333333" @@ -204,7 +204,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal, CheckedFromRatioError}; + /// # use cosmwasm_std::{SignedDecimal, CheckedFromRatioError}; /// assert_eq!( /// SignedDecimal::checked_from_ratio(1, 3).unwrap().to_string(), /// "0.333333333333333333" @@ -250,7 +250,7 @@ impl SignedDecimal { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal, Int128}; + /// # use cosmwasm_std::{SignedDecimal, Int128}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = SignedDecimal::from_str("1.234").unwrap(); @@ -283,7 +283,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// # use core::str::FromStr; /// assert!(SignedDecimal::from_str("0.6").unwrap().trunc().is_zero()); /// assert_eq!(SignedDecimal::from_str("-5.8").unwrap().trunc().to_string(), "-5"); @@ -298,7 +298,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// # use core::str::FromStr; /// assert!(SignedDecimal::from_str("0.6").unwrap().floor().is_zero()); /// assert_eq!(SignedDecimal::from_str("-5.2").unwrap().floor().to_string(), "-6"); @@ -333,7 +333,7 @@ impl SignedDecimal { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal; + /// # use cosmwasm_std::SignedDecimal; /// # use core::str::FromStr; /// assert_eq!(SignedDecimal::from_str("0.2").unwrap().ceil(), SignedDecimal::one()); /// assert_eq!(SignedDecimal::from_str("-5.8").unwrap().ceil().to_string(), "-5"); @@ -487,7 +487,7 @@ impl SignedDecimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{SignedDecimal, Int128}; + /// use cosmwasm_std::{SignedDecimal, Int128}; /// /// let d = SignedDecimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_floor(), Int128::new(12)); @@ -519,7 +519,7 @@ impl SignedDecimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{SignedDecimal, Int128}; + /// use cosmwasm_std::{SignedDecimal, Int128}; /// /// let d = SignedDecimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_trunc(), Int128::new(12)); @@ -542,7 +542,7 @@ impl SignedDecimal { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{SignedDecimal, Int128}; + /// use cosmwasm_std::{SignedDecimal, Int128}; /// /// let d = SignedDecimal::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_ceil(), Int128::new(13)); @@ -913,7 +913,6 @@ mod tests { use super::*; use alloc::vec::Vec; - use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> SignedDecimal { SignedDecimal::from_str(input).unwrap() @@ -2443,34 +2442,40 @@ mod tests { #[test] fn signed_decimal_serialize() { - assert_eq!(to_json_vec(&SignedDecimal::zero()).unwrap(), br#""0""#); - assert_eq!(to_json_vec(&SignedDecimal::one()).unwrap(), br#""1""#); assert_eq!( - to_json_vec(&SignedDecimal::percent(8)).unwrap(), + serde_json::to_vec(&SignedDecimal::zero()).unwrap(), + br#""0""# + ); + assert_eq!( + serde_json::to_vec(&SignedDecimal::one()).unwrap(), + br#""1""# + ); + assert_eq!( + serde_json::to_vec(&SignedDecimal::percent(8)).unwrap(), br#""0.08""# ); assert_eq!( - to_json_vec(&SignedDecimal::percent(87)).unwrap(), + serde_json::to_vec(&SignedDecimal::percent(87)).unwrap(), br#""0.87""# ); assert_eq!( - to_json_vec(&SignedDecimal::percent(876)).unwrap(), + serde_json::to_vec(&SignedDecimal::percent(876)).unwrap(), br#""8.76""# ); assert_eq!( - to_json_vec(&SignedDecimal::percent(8765)).unwrap(), + serde_json::to_vec(&SignedDecimal::percent(8765)).unwrap(), br#""87.65""# ); assert_eq!( - to_json_vec(&SignedDecimal::percent(-87654)).unwrap(), + serde_json::to_vec(&SignedDecimal::percent(-87654)).unwrap(), br#""-876.54""# ); assert_eq!( - to_json_vec(&SignedDecimal::negative_one()).unwrap(), + serde_json::to_vec(&SignedDecimal::negative_one()).unwrap(), br#""-1""# ); assert_eq!( - to_json_vec(&-SignedDecimal::percent(8)).unwrap(), + serde_json::to_vec(&-SignedDecimal::percent(8)).unwrap(), br#""-0.08""# ); } @@ -2478,54 +2483,54 @@ mod tests { #[test] fn signed_decimal_deserialize() { assert_eq!( - from_json::(br#""0""#).unwrap(), + serde_json::from_slice::(br#""0""#).unwrap(), SignedDecimal::zero() ); assert_eq!( - from_json::(br#""1""#).unwrap(), + serde_json::from_slice::(br#""1""#).unwrap(), SignedDecimal::one() ); assert_eq!( - from_json::(br#""000""#).unwrap(), + serde_json::from_slice::(br#""000""#).unwrap(), SignedDecimal::zero() ); assert_eq!( - from_json::(br#""001""#).unwrap(), + serde_json::from_slice::(br#""001""#).unwrap(), SignedDecimal::one() ); assert_eq!( - from_json::(br#""0.08""#).unwrap(), + serde_json::from_slice::(br#""0.08""#).unwrap(), SignedDecimal::percent(8) ); assert_eq!( - from_json::(br#""0.87""#).unwrap(), + serde_json::from_slice::(br#""0.87""#).unwrap(), SignedDecimal::percent(87) ); assert_eq!( - from_json::(br#""8.76""#).unwrap(), + serde_json::from_slice::(br#""8.76""#).unwrap(), SignedDecimal::percent(876) ); assert_eq!( - from_json::(br#""87.65""#).unwrap(), + serde_json::from_slice::(br#""87.65""#).unwrap(), SignedDecimal::percent(8765) ); // negative numbers assert_eq!( - from_json::(br#""-0""#).unwrap(), + serde_json::from_slice::(br#""-0""#).unwrap(), SignedDecimal::zero() ); assert_eq!( - from_json::(br#""-1""#).unwrap(), + serde_json::from_slice::(br#""-1""#).unwrap(), SignedDecimal::negative_one() ); assert_eq!( - from_json::(br#""-001""#).unwrap(), + serde_json::from_slice::(br#""-001""#).unwrap(), SignedDecimal::negative_one() ); assert_eq!( - from_json::(br#""-0.08""#).unwrap(), + serde_json::from_slice::(br#""-0.08""#).unwrap(), SignedDecimal::percent(-8) ); } diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs index 11336386dd..9819d44807 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -55,7 +55,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// assert_eq!( /// SignedDecimal256::MAX.to_string(), /// "57896044618658097711785492504343953926634992332820282019728.792003956564819967" @@ -68,7 +68,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// assert_eq!( /// SignedDecimal256::MIN.to_string(), /// "-57896044618658097711785492504343953926634992332820282019728.792003956564819968" @@ -82,7 +82,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal256, Int256}; + /// # use cosmwasm_std::{SignedDecimal256, Int256}; /// assert_eq!(SignedDecimal256::new(Int256::one()).to_string(), "0.000000000000000001"); /// ``` pub const fn new(value: Int256) -> Self { @@ -95,7 +95,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// assert_eq!(SignedDecimal256::raw(1234i128).to_string(), "0.000000000000001234"); /// ``` pub const fn raw(value: i128) -> Self { @@ -147,7 +147,7 @@ impl SignedDecimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal256, Int256}; + /// # use cosmwasm_std::{SignedDecimal256, Int256}; /// let a = SignedDecimal256::from_atomics(Int256::from(1234), 3).unwrap(); /// assert_eq!(a.to_string(), "1.234"); /// @@ -196,7 +196,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// assert_eq!( /// SignedDecimal256::from_ratio(1, 3).to_string(), /// "0.333333333333333333" @@ -217,7 +217,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal256, CheckedFromRatioError}; + /// # use cosmwasm_std::{SignedDecimal256, CheckedFromRatioError}; /// assert_eq!( /// SignedDecimal256::checked_from_ratio(1, 3).unwrap().to_string(), /// "0.333333333333333333" @@ -263,7 +263,7 @@ impl SignedDecimal256 { /// ## Examples /// /// ``` - /// # use cosmwasm_core::{SignedDecimal256, Int256}; + /// # use cosmwasm_std::{SignedDecimal256, Int256}; /// # use core::str::FromStr; /// // Value with whole and fractional part /// let a = SignedDecimal256::from_str("1.234").unwrap(); @@ -296,7 +296,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// # use core::str::FromStr; /// assert!(SignedDecimal256::from_str("0.6").unwrap().trunc().is_zero()); /// assert_eq!(SignedDecimal256::from_str("-5.8").unwrap().trunc().to_string(), "-5"); @@ -311,7 +311,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// # use core::str::FromStr; /// assert!(SignedDecimal256::from_str("0.6").unwrap().floor().is_zero()); /// assert_eq!(SignedDecimal256::from_str("-5.2").unwrap().floor().to_string(), "-6"); @@ -346,7 +346,7 @@ impl SignedDecimal256 { /// # Examples /// /// ``` - /// # use cosmwasm_core::SignedDecimal256; + /// # use cosmwasm_std::SignedDecimal256; /// # use core::str::FromStr; /// assert_eq!(SignedDecimal256::from_str("0.2").unwrap().ceil(), SignedDecimal256::one()); /// assert_eq!(SignedDecimal256::from_str("-5.8").unwrap().ceil().to_string(), "-5"); @@ -500,7 +500,7 @@ impl SignedDecimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{SignedDecimal256, Int256}; + /// use cosmwasm_std::{SignedDecimal256, Int256}; /// /// let d = SignedDecimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_floor(), Int256::from(12)); @@ -532,7 +532,7 @@ impl SignedDecimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{SignedDecimal256, Int256}; + /// use cosmwasm_std::{SignedDecimal256, Int256}; /// /// let d = SignedDecimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_trunc(), Int256::from(12)); @@ -555,7 +555,7 @@ impl SignedDecimal256 { /// /// ``` /// use core::str::FromStr; - /// use cosmwasm_core::{SignedDecimal256, Int256}; + /// use cosmwasm_std::{SignedDecimal256, Int256}; /// /// let d = SignedDecimal256::from_str("12.345").unwrap(); /// assert_eq!(d.to_int_ceil(), Int256::from(13)); @@ -914,7 +914,6 @@ mod tests { use super::*; use alloc::vec::Vec; - use cosmwasm_std::{from_json, to_json_vec}; fn dec(input: &str) -> SignedDecimal256 { SignedDecimal256::from_str(input).unwrap() @@ -2546,34 +2545,40 @@ mod tests { #[test] fn signed_decimal_256_serialize() { - assert_eq!(to_json_vec(&SignedDecimal256::zero()).unwrap(), br#""0""#); - assert_eq!(to_json_vec(&SignedDecimal256::one()).unwrap(), br#""1""#); assert_eq!( - to_json_vec(&SignedDecimal256::percent(8)).unwrap(), + serde_json::to_vec(&SignedDecimal256::zero()).unwrap(), + br#""0""# + ); + assert_eq!( + serde_json::to_vec(&SignedDecimal256::one()).unwrap(), + br#""1""# + ); + assert_eq!( + serde_json::to_vec(&SignedDecimal256::percent(8)).unwrap(), br#""0.08""# ); assert_eq!( - to_json_vec(&SignedDecimal256::percent(87)).unwrap(), + serde_json::to_vec(&SignedDecimal256::percent(87)).unwrap(), br#""0.87""# ); assert_eq!( - to_json_vec(&SignedDecimal256::percent(876)).unwrap(), + serde_json::to_vec(&SignedDecimal256::percent(876)).unwrap(), br#""8.76""# ); assert_eq!( - to_json_vec(&SignedDecimal256::percent(8765)).unwrap(), + serde_json::to_vec(&SignedDecimal256::percent(8765)).unwrap(), br#""87.65""# ); assert_eq!( - to_json_vec(&SignedDecimal256::percent(-87654)).unwrap(), + serde_json::to_vec(&SignedDecimal256::percent(-87654)).unwrap(), br#""-876.54""# ); assert_eq!( - to_json_vec(&SignedDecimal256::negative_one()).unwrap(), + serde_json::to_vec(&SignedDecimal256::negative_one()).unwrap(), br#""-1""# ); assert_eq!( - to_json_vec(&-SignedDecimal256::percent(8)).unwrap(), + serde_json::to_vec(&-SignedDecimal256::percent(8)).unwrap(), br#""-0.08""# ); } @@ -2581,54 +2586,54 @@ mod tests { #[test] fn signed_decimal_256_deserialize() { assert_eq!( - from_json::(br#""0""#).unwrap(), + serde_json::from_slice::(br#""0""#).unwrap(), SignedDecimal256::zero() ); assert_eq!( - from_json::(br#""1""#).unwrap(), + serde_json::from_slice::(br#""1""#).unwrap(), SignedDecimal256::one() ); assert_eq!( - from_json::(br#""000""#).unwrap(), + serde_json::from_slice::(br#""000""#).unwrap(), SignedDecimal256::zero() ); assert_eq!( - from_json::(br#""001""#).unwrap(), + serde_json::from_slice::(br#""001""#).unwrap(), SignedDecimal256::one() ); assert_eq!( - from_json::(br#""0.08""#).unwrap(), + serde_json::from_slice::(br#""0.08""#).unwrap(), SignedDecimal256::percent(8) ); assert_eq!( - from_json::(br#""0.87""#).unwrap(), + serde_json::from_slice::(br#""0.87""#).unwrap(), SignedDecimal256::percent(87) ); assert_eq!( - from_json::(br#""8.76""#).unwrap(), + serde_json::from_slice::(br#""8.76""#).unwrap(), SignedDecimal256::percent(876) ); assert_eq!( - from_json::(br#""87.65""#).unwrap(), + serde_json::from_slice::(br#""87.65""#).unwrap(), SignedDecimal256::percent(8765) ); // negative numbers assert_eq!( - from_json::(br#""-0""#).unwrap(), + serde_json::from_slice::(br#""-0""#).unwrap(), SignedDecimal256::zero() ); assert_eq!( - from_json::(br#""-1""#).unwrap(), + serde_json::from_slice::(br#""-1""#).unwrap(), SignedDecimal256::negative_one() ); assert_eq!( - from_json::(br#""-001""#).unwrap(), + serde_json::from_slice::(br#""-001""#).unwrap(), SignedDecimal256::negative_one() ); assert_eq!( - from_json::(br#""-0.08""#).unwrap(), + serde_json::from_slice::(br#""-0.08""#).unwrap(), SignedDecimal256::percent(-8) ); } diff --git a/packages/core/src/math/uint128.rs b/packages/core/src/math/uint128.rs index cc3030d678..9c04c54fc2 100644 --- a/packages/core/src/math/uint128.rs +++ b/packages/core/src/math/uint128.rs @@ -30,7 +30,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `u128` to get the value out: /// /// ``` -/// # use cosmwasm_core::Uint128; +/// # use cosmwasm_std::Uint128; /// let a = Uint128::from(123u128); /// assert_eq!(a.u128(), 123); /// @@ -141,7 +141,7 @@ impl Uint128 { /// # Examples /// /// ``` - /// use cosmwasm_core::Uint128; + /// use cosmwasm_std::Uint128; /// /// let a = Uint128::MAX; /// let result = a.full_mul(2u32); @@ -612,8 +612,6 @@ mod tests { use crate::math::conversion::test_try_from_int_to_uint; use crate::{ConversionOverflowError, Decimal}; - use cosmwasm_std::{from_json, to_json_vec}; - use super::*; #[test] @@ -784,9 +782,9 @@ mod tests { #[test] fn uint128_json() { let orig = Uint128(1234567890987654321); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Uint128 = from_json(serialized).unwrap(); + let parsed: Uint128 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/uint256.rs b/packages/core/src/math/uint256.rs index 35352e7d7e..a81942cf19 100644 --- a/packages/core/src/math/uint256.rs +++ b/packages/core/src/math/uint256.rs @@ -34,7 +34,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_core::Uint256; +/// # use cosmwasm_std::Uint256; /// let a = Uint256::from(258u128); /// let b = Uint256::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, @@ -213,7 +213,7 @@ impl Uint256 { /// # Examples /// /// ``` - /// use cosmwasm_core::Uint256; + /// use cosmwasm_std::Uint256; /// /// let a = Uint256::MAX; /// let result = a.full_mul(2u32); @@ -677,8 +677,6 @@ mod tests { use crate::math::conversion::test_try_from_int_to_uint; use crate::{Decimal, Decimal256}; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn size_of_works() { assert_eq!(core::mem::size_of::(), 32); @@ -1299,9 +1297,9 @@ mod tests { #[test] fn uint256_json() { let orig = Uint256::from(1234567890987654321u128); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Uint256 = from_json(serialized).unwrap(); + let parsed: Uint256 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/uint512.rs b/packages/core/src/math/uint512.rs index 452fced34c..bd26d255a2 100644 --- a/packages/core/src/math/uint512.rs +++ b/packages/core/src/math/uint512.rs @@ -30,7 +30,7 @@ use super::num_consts::NumConsts; /// endian bytes: /// /// ``` -/// # use cosmwasm_core::Uint512; +/// # use cosmwasm_std::Uint512; /// let a = Uint512::from(258u128); /// let b = Uint512::new([ /// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, @@ -642,8 +642,6 @@ mod tests { use super::*; use crate::math::conversion::test_try_from_int_to_uint; - use cosmwasm_std::{from_json, to_json_vec}; - #[test] fn size_of_works() { assert_eq!(core::mem::size_of::(), 64); @@ -1004,9 +1002,9 @@ mod tests { #[test] fn uint512_json() { let orig = Uint512::from(1234567890987654321u128); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Uint512 = from_json(serialized).unwrap(); + let parsed: Uint512 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/math/uint64.rs b/packages/core/src/math/uint64.rs index 5c6d7e59b5..804cc6d751 100644 --- a/packages/core/src/math/uint64.rs +++ b/packages/core/src/math/uint64.rs @@ -27,7 +27,7 @@ use super::num_consts::NumConsts; /// Use `from` to create instances of this and `u64` to get the value out: /// /// ``` -/// # use cosmwasm_core::Uint64; +/// # use cosmwasm_std::Uint64; /// let a = Uint64::from(42u64); /// assert_eq!(a.u64(), 42); /// @@ -135,7 +135,7 @@ impl Uint64 { /// # Examples /// /// ``` - /// use cosmwasm_core::Uint64; + /// use cosmwasm_std::Uint64; /// /// let a = Uint64::MAX; /// let result = a.full_mul(2u32); @@ -579,7 +579,6 @@ mod tests { use crate::ConversionOverflowError; use alloc::string::ToString; - use cosmwasm_std::{from_json, to_json_vec}; #[test] fn size_of_works() { @@ -710,9 +709,9 @@ mod tests { #[test] fn uint64_json() { let orig = Uint64(1234567890987654321); - let serialized = to_json_vec(&orig).unwrap(); + let serialized = serde_json::to_vec(&orig).unwrap(); assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Uint64 = from_json(serialized).unwrap(); + let parsed: Uint64 = serde_json::from_slice(&serialized).unwrap(); assert_eq!(parsed, orig); } diff --git a/packages/core/src/testing/assertions.rs b/packages/core/src/testing/assertions.rs index 5fb4ccb37b..683455cb99 100644 --- a/packages/core/src/testing/assertions.rs +++ b/packages/core/src/testing/assertions.rs @@ -44,7 +44,7 @@ macro_rules! assert_hash_works { }}; } -/// Implementation for the [`cosmwasm_core::assert_approx_eq`] macro. This does not provide any +/// Implementation for the [`cosmwasm_std::assert_approx_eq`] macro. This does not provide any /// stability guarantees and may change any time. #[track_caller] #[doc(hidden)] From 115e178da3969978751e5675ef303c635f95edd1 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 18:36:19 +0100 Subject: [PATCH 25/42] Make `cosmwasm-crypto` compatible with `no_std` --- Cargo.lock | 48 ++---------------------------- packages/crypto/Cargo.toml | 11 +++---- packages/crypto/benches/main.rs | 3 ++ packages/crypto/src/backtrace.rs | 35 ++++++++++++++++++++-- packages/crypto/src/ed25519.rs | 51 ++++++++++++++++++-------------- packages/crypto/src/errors.rs | 23 ++++++++------ packages/crypto/src/lib.rs | 5 ++++ packages/crypto/src/secp256k1.rs | 1 + packages/crypto/src/secp256r1.rs | 2 ++ packages/std/Cargo.toml | 1 + packages/std/src/testing/mock.rs | 2 ++ packages/vm/Cargo.toml | 4 +-- packages/vm/src/imports.rs | 3 +- 13 files changed, 100 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d86a6ac18..daf48f7767 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,12 +180,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bech32" version = "0.11.0" @@ -443,6 +437,7 @@ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ "criterion", + "derive_more", "digest", "ecdsa", "ed25519-zebra", @@ -456,7 +451,6 @@ dependencies = [ "serde_json", "sha2", "sha3", - "thiserror", ] [[package]] @@ -508,6 +502,7 @@ dependencies = [ "derive_more", "hex", "hex-literal", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -834,7 +829,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -962,7 +956,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -971,8 +964,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -987,7 +978,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -1010,8 +1000,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -1376,9 +1364,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1590,31 +1576,12 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" @@ -2033,7 +2000,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -2171,16 +2137,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/packages/crypto/Cargo.toml b/packages/crypto/Cargo.toml index 77eddd57bc..b8a93da52d 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -9,20 +9,21 @@ license = "Apache-2.0" [features] default = [] +std = [] [lib] # See https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options bench = false [dependencies] -k256 = { version = "0.13.3", features = ["ecdsa"] } -ed25519-zebra = "4.0.3" +derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } +k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] } +ed25519-zebra = { version = "4.0.3", default-features = false } digest = "0.10" -rand_core = { version = "0.6", features = ["getrandom"] } -thiserror = "1.0.38" +rand_core = "0.6" # Not used directly, but needed to bump transitive dependency, see: https://github.com/CosmWasm/cosmwasm/pull/1899 for details. ecdsa = "0.16.2" -p256 = { version = "0.13.2", features = ["ecdsa"] } +p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] } [dev-dependencies] criterion = "0.5.1" diff --git a/packages/crypto/benches/main.rs b/packages/crypto/benches/main.rs index 74422cdc1a..ca1ba3077e 100644 --- a/packages/crypto/benches/main.rs +++ b/packages/crypto/benches/main.rs @@ -1,4 +1,5 @@ use criterion::{criterion_group, criterion_main, Criterion, PlottingBackend}; +use rand_core::OsRng; use std::time::Duration; use english_numbers::convert_no_fmt; @@ -158,6 +159,7 @@ fn bench_crypto(c: &mut Criterion) { |b| { b.iter(|| { assert!(ed25519_batch_verify( + &mut OsRng, &messages[..n], &signatures[..n], &public_keys[..n] @@ -189,6 +191,7 @@ fn bench_crypto(c: &mut Criterion) { |b| { b.iter(|| { assert!(ed25519_batch_verify( + &mut OsRng, &messages.repeat(n), &signatures.repeat(n), &public_keys diff --git a/packages/crypto/src/backtrace.rs b/packages/crypto/src/backtrace.rs index 549279132b..56415bd9a1 100644 --- a/packages/crypto/src/backtrace.rs +++ b/packages/crypto/src/backtrace.rs @@ -1,18 +1,32 @@ +use alloc::boxed::Box; use core::fmt::{Debug, Display, Formatter, Result}; -use std::backtrace::Backtrace; /// This wraps an actual backtrace to achieve two things: /// - being able to fill this with a stub implementation in `no_std` environments /// - being able to use this in conjunction with [`thiserror::Error`] -pub struct BT(Backtrace); +pub struct BT(Box); impl BT { #[track_caller] pub fn capture() -> Self { - BT(Backtrace::capture()) + // in case of no_std, we can fill with a stub here + #[cfg(feature = "std")] + { + #[cfg(target_arch = "wasm32")] + return BT(Box::new(std::backtrace::Backtrace::disabled())); + #[cfg(not(target_arch = "wasm32"))] + return BT(Box::new(std::backtrace::Backtrace::capture())); + } + #[cfg(not(feature = "std"))] + { + BT(Box::new(Stub)) + } } } +trait Printable: Debug + Display {} +impl Printable for T where T: Debug + Display {} + impl Debug for BT { fn fmt(&self, f: &mut Formatter<'_>) -> Result { Debug::fmt(&self.0, f) @@ -24,3 +38,18 @@ impl Display for BT { Display::fmt(&self.0, f) } } + +#[allow(unused)] +struct Stub; + +impl Debug for Stub { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + write!(f, "") + } +} + +impl Display for Stub { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + write!(f, "") + } +} diff --git a/packages/crypto/src/ed25519.rs b/packages/crypto/src/ed25519.rs index 7b87affcd8..895708ca2b 100644 --- a/packages/crypto/src/ed25519.rs +++ b/packages/crypto/src/ed25519.rs @@ -1,5 +1,5 @@ use ed25519_zebra::{batch, Signature, VerificationKey}; -use rand_core::OsRng; +use rand_core::CryptoRngCore; use crate::errors::{CryptoError, CryptoResult}; @@ -60,11 +60,15 @@ pub fn ed25519_verify(message: &[u8], signature: &[u8], public_key: &[u8]) -> Cr /// - The "one-public key, with zero messages and zero signatures" case, is considered the empty /// case. /// - The empty case (no messages, no signatures and no public keys) returns true. -pub fn ed25519_batch_verify( +pub fn ed25519_batch_verify( + rng: &mut R, messages: &[&[u8]], signatures: &[&[u8]], public_keys: &[&[u8]], -) -> CryptoResult { +) -> CryptoResult +where + R: CryptoRngCore, +{ // Structural checks let messages_len = messages.len(); let signatures_len = signatures.len(); @@ -103,7 +107,7 @@ pub fn ed25519_batch_verify( } // Batch verification - match batch.verify(OsRng) { + match batch.verify(rng) { Ok(()) => Ok(true), Err(_) => Ok(false), } @@ -139,6 +143,7 @@ fn read_pubkey(data: &[u8]) -> Result<[u8; 32], InvalidEd25519PubkeyFormat> { mod tests { use super::*; use ed25519_zebra::SigningKey; + use rand_core::OsRng; use serde::Deserialize; // For generic signature verification @@ -282,7 +287,7 @@ mod tests { let public_keys: Vec<&[u8]> = public_keys.iter().map(|m| m.as_slice()).collect(); // ed25519_batch_verify() works - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); } // structural tests @@ -293,7 +298,7 @@ mod tests { let public_keys: Vec<&[u8]> = vec![]; // ed25519_batch_verify() works for empty msgs / sigs / pubkeys - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); } #[test] @@ -320,12 +325,12 @@ mod tests { let mut public_keys: Vec<&[u8]> = public_keys.iter().map(|m| m.as_slice()).collect(); // Check the whole set passes - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); // Remove one message let msg = messages.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -340,7 +345,7 @@ mod tests { // Remove one signature let sig = signatures.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -355,7 +360,7 @@ mod tests { // Remove one public key let pubkey = public_keys.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -370,7 +375,7 @@ mod tests { // Add one message messages.push(messages[0]); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -384,7 +389,7 @@ mod tests { // Add one signature signatures.push(signatures[0]); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -398,7 +403,7 @@ mod tests { // Add one public keys public_keys.push(public_keys[0]); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -432,18 +437,18 @@ mod tests { let mut public_keys: Vec<&[u8]> = public_keys.iter().map(|m| m.as_slice()).collect(); // Check the whole set passes - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); // Just one message messages.truncate(1); // Check (in passing) this fails verification - assert!(!ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(!ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); // Remove one sig let sig = signatures.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -458,7 +463,7 @@ mod tests { // Remove one public key let pubkey = public_keys.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -495,18 +500,18 @@ mod tests { let mut public_keys: Vec<&[u8]> = public_keys.iter().map(|m| m.as_slice()).collect(); // Check the whole set passes - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); // Just one public key public_keys.truncate(1); // Check (in passing) this fails verification - assert!(!ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(!ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); // Remove one sig let sig = signatures.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -521,7 +526,7 @@ mod tests { // Remove one msg let msg = messages.pop().unwrap(); - let res = ed25519_batch_verify(&messages, &signatures, &public_keys); + let res = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); match res.unwrap_err() { CryptoError::BatchErr { msg, .. } => assert_eq!( msg, @@ -551,7 +556,7 @@ mod tests { let messages: Vec<&[u8]> = messages.iter().map(|m| m.as_slice()).collect(); // ed25519_batch_verify() works for empty sigs / pubkeys - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); } #[test] @@ -571,6 +576,6 @@ mod tests { let public_keys: Vec<&[u8]> = public_keys.iter().map(|m| m.as_slice()).collect(); // ed25519_batch_verify() works for empty msgs / sigs - assert!(ed25519_batch_verify(&messages, &signatures, &public_keys).unwrap()); + assert!(ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys).unwrap()); } } diff --git a/packages/crypto/src/errors.rs b/packages/crypto/src/errors.rs index db4ba3fe11..0016b85eb0 100644 --- a/packages/crypto/src/errors.rs +++ b/packages/crypto/src/errors.rs @@ -1,25 +1,30 @@ +use alloc::string::String; +use derive_more::Display; +use core::fmt::Debug; + use crate::BT; -use std::fmt::Debug; -use thiserror::Error; pub type CryptoResult = core::result::Result; -#[derive(Error, Debug)] +#[derive(Display, Debug)] pub enum CryptoError { - #[error("Batch verify error: {msg}")] + #[display("Batch verify error: {msg}")] BatchErr { msg: String, backtrace: BT }, - #[error("Crypto error: {msg}")] + #[display("Crypto error: {msg}")] GenericErr { msg: String, backtrace: BT }, - #[error("Invalid hash format")] + #[display("Invalid hash format")] InvalidHashFormat { backtrace: BT }, - #[error("Invalid public key format")] + #[display("Invalid public key format")] InvalidPubkeyFormat { backtrace: BT }, - #[error("Invalid signature format")] + #[display("Invalid signature format")] InvalidSignatureFormat { backtrace: BT }, - #[error("Invalid recovery parameter. Supported values: 0 and 1.")] + #[display("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam { backtrace: BT }, } +#[cfg(feature = "std")] +impl std::error::Error for CryptoError {} + impl CryptoError { pub fn batch_err(msg: impl Into) -> Self { CryptoError::BatchErr { diff --git a/packages/crypto/src/lib.rs b/packages/crypto/src/lib.rs index f8a3967655..81f8b6131c 100644 --- a/packages/crypto/src/lib.rs +++ b/packages/crypto/src/lib.rs @@ -2,6 +2,11 @@ //! Please don't use any of these types directly, as //! they might change frequently, or be removed in the future. //! This crate does not adhere to semantic versioning. + +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; + mod backtrace; mod ecdsa; mod ed25519; diff --git a/packages/crypto/src/secp256k1.rs b/packages/crypto/src/secp256k1.rs index bbbe2a103d..3fdac7680e 100644 --- a/packages/crypto/src/secp256k1.rs +++ b/packages/crypto/src/secp256k1.rs @@ -3,6 +3,7 @@ use k256::{ ecdsa::signature::DigestVerifier, // traits ecdsa::{RecoveryId, Signature, VerifyingKey}, // type aliases }; +use alloc::{string::ToString, vec::Vec}; use crate::ecdsa::{ECDSA_COMPRESSED_PUBKEY_LEN, ECDSA_UNCOMPRESSED_PUBKEY_LEN}; use crate::errors::{CryptoError, CryptoResult}; diff --git a/packages/crypto/src/secp256r1.rs b/packages/crypto/src/secp256r1.rs index eacb74fa33..95256ad205 100644 --- a/packages/crypto/src/secp256r1.rs +++ b/packages/crypto/src/secp256r1.rs @@ -4,6 +4,8 @@ use p256::{ ecdsa::signature::DigestVerifier, // traits ecdsa::{Signature, VerifyingKey}, // type aliases }; +use core::convert::TryInto; +use alloc::{string::ToString, vec::Vec}; use crate::ecdsa::{ECDSA_COMPRESSED_PUBKEY_LEN, ECDSA_UNCOMPRESSED_PUBKEY_LEN}; use crate::errors::{CryptoError, CryptoResult}; diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 44bceec9ba..461626bc49 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -64,6 +64,7 @@ sha2 = "0.10.3" serde = { workspace = true } serde-json-wasm = { version = "1.0.1", default-features = false } thiserror = "1.0.26" +rand_core = { version = "0.6.4", features = ["getrandom"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] bech32 = "0.11.0" diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index f0cb1a5429..210fa3fb56 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use rand_core::OsRng; use alloc::collections::BTreeMap; #[cfg(feature = "cosmwasm_1_3")] use alloc::collections::BTreeSet; @@ -217,6 +218,7 @@ impl Api for MockApi { public_keys: &[&[u8]], ) -> Result { Ok(cosmwasm_crypto::ed25519_batch_verify( + &mut OsRng, messages, signatures, public_keys, diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 647b8ae2f3..b801c813b7 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -46,9 +46,10 @@ crc32fast = "1.3.2" bech32 = "0.11.0" # Uses the path when built locally; uses the given version from crates.io when published cosmwasm-std = { version = "2.0.1", path = "../std", default-features = false, features = ["std"] } -cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } +cosmwasm-crypto = { version = "2.0.1", path = "../crypto", features = ["std"] } derivative = "2" hex = "0.4" +rand = "0.8" schemars = { workspace = true } serde = { workspace = true } serde_json = "1.0.40" @@ -78,7 +79,6 @@ hex-literal = "0.4.1" tempfile = "3.1.0" wat = "1.0" clap = "4" -rand = "0.8" leb128 = "0.2" target-lexicon = "0.12" time = { version = "0.3.28", features = ["formatting"] } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 4be82c6744..fa11c2cab1 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -7,6 +7,7 @@ use cosmwasm_crypto::{ ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, secp256r1_recover_pubkey, secp256r1_verify, CryptoError, }; +use rand::rngs::OsRng; use cosmwasm_crypto::{ ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, MESSAGE_HASH_MAX_LEN, }; @@ -484,7 +485,7 @@ pub fn do_ed25519_batch_verify< } * signatures.len() as u64; let gas_info = GasInfo::with_cost(max(gas_cost, data.gas_config.ed25519_verify_cost)); process_gas_info(data, &mut store, gas_info)?; - let result = ed25519_batch_verify(&messages, &signatures, &public_keys); + let result = ed25519_batch_verify(&mut OsRng, &messages, &signatures, &public_keys); let code = match result { Ok(valid) => { if valid { From a6b07e988beb5f0e1e4a1ffb86c9f117c8170a3c Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 18:38:22 +0100 Subject: [PATCH 26/42] Fix CI fails --- contracts/burner/Cargo.lock | 76 ++++++++++---------------- contracts/crypto-verify/Cargo.lock | 55 ++++++++++++------- contracts/cyberpunk/Cargo.lock | 76 ++++++++++---------------- contracts/empty/Cargo.lock | 76 ++++++++++---------------- contracts/floaty/Cargo.lock | 60 +++++--------------- contracts/hackatom/Cargo.lock | 76 ++++++++++---------------- contracts/ibc-reflect-send/Cargo.lock | 76 ++++++++++---------------- contracts/ibc-reflect/Cargo.lock | 76 ++++++++++---------------- contracts/queue/Cargo.lock | 76 ++++++++++---------------- contracts/reflect/Cargo.lock | 76 ++++++++++---------------- contracts/staking/Cargo.lock | 76 ++++++++++---------------- contracts/virus/Cargo.lock | 76 ++++++++++---------------- packages/core/src/errors/core_error.rs | 2 +- packages/crypto/src/errors.rs | 2 +- packages/crypto/src/secp256k1.rs | 2 +- packages/crypto/src/secp256r1.rs | 4 +- packages/std/src/testing/mock.rs | 2 +- packages/vm/src/imports.rs | 2 +- 18 files changed, 355 insertions(+), 534 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 551acfac8f..b86508a2aa 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -230,13 +224,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -279,6 +273,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -298,6 +293,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -558,7 +554,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -649,7 +644,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -658,8 +652,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -674,7 +666,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -697,8 +688,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -929,9 +918,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1078,37 +1065,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1180,6 +1154,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1359,7 +1354,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1487,16 +1481,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index d847e252bb..da848bfab7 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -87,9 +87,9 @@ checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" [[package]] name = "base64ct" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bech32" @@ -219,13 +219,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +268,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +288,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -565,7 +567,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -665,8 +666,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -681,7 +680,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -704,7 +702,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", "pkcs8", "rand_core", "sec1", @@ -942,9 +939,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1097,15 +1092,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1128,6 +1114,12 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1199,6 +1191,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1534,9 +1547,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index f6233bc9c0..6f85ca599f 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -97,12 +97,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -248,13 +242,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -297,6 +291,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -316,6 +311,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -588,7 +584,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -679,7 +674,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -688,8 +682,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -704,7 +696,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -727,8 +718,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -1015,9 +1004,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1170,37 +1157,24 @@ dependencies = [ "windows-targets 0.48.0", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1272,6 +1246,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1476,7 +1471,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1604,16 +1598,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 75b133f426..2b52700a1a 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -928,9 +917,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1077,37 +1064,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1179,6 +1153,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1358,7 +1353,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1486,16 +1480,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 010ab6e373..320a45f6e3 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -930,9 +919,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1079,31 +1066,12 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" @@ -1187,6 +1155,17 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + [[package]] name = "rand_chacha" version = "0.3.1" @@ -1376,7 +1355,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1504,16 +1482,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 7ac773c9b1..7e72a868fa 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -931,9 +920,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1080,37 +1067,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1182,6 +1156,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1361,7 +1356,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1489,16 +1483,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index a55f337b8a..3db0256c67 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -929,9 +918,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1078,37 +1065,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1180,6 +1154,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1359,7 +1354,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1487,16 +1481,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 1e2b5a9df5..4e6a16245a 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -929,9 +918,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1078,37 +1065,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1180,6 +1154,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1359,7 +1354,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1487,16 +1481,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 896a4eba64..160b5a3af6 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -918,9 +907,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1067,37 +1054,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1180,6 +1154,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1359,7 +1354,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1487,16 +1481,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 9d3610a39c..5f6fbcff7c 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -918,9 +907,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1067,37 +1054,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1169,6 +1143,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1360,7 +1355,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1488,16 +1482,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index f76846db16..51b54d8626 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -918,9 +907,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1067,37 +1054,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1169,6 +1143,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1348,7 +1343,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1497,16 +1491,6 @@ dependencies = [ "syn 2.0.52", ] -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index c6408c8c67..4694ba3f0e 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" -[[package]] -name = "base64ct" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" - [[package]] name = "bech32" version = "0.11.0" @@ -219,13 +213,13 @@ dependencies = [ name = "cosmwasm-crypto" version = "2.0.1" dependencies = [ + "derive_more", "digest", "ecdsa", "ed25519-zebra", "k256", "p256", "rand_core", - "thiserror", ] [[package]] @@ -268,6 +262,7 @@ dependencies = [ "cosmwasm-derive", "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", @@ -287,6 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", + "rand", "schemars", "serde", "serde_json", @@ -547,7 +543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -638,7 +633,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -647,8 +641,6 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8", - "serde", "signature", ] @@ -663,7 +655,6 @@ dependencies = [ "hashbrown 0.14.3", "hex", "rand_core", - "serde", "sha2", "zeroize", ] @@ -686,8 +677,6 @@ dependencies = [ "ff", "generic-array", "group", - "pem-rfc7468", - "pkcs8", "rand_core", "sec1", "subtle", @@ -918,9 +907,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -1067,37 +1054,24 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "platforms" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -1169,6 +1143,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1348,7 +1343,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1476,16 +1470,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index bc1a10ed35..b344a7c74f 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -371,7 +371,7 @@ mod tests { #[test] fn invalid_base64_works_for_errors() { - let original = base64::DecodeError::InvalidLength; + let original = base64::DecodeError::InvalidLength(10); let error = CoreError::invalid_base64(original); match error { CoreError::InvalidBase64 { msg, .. } => { diff --git a/packages/crypto/src/errors.rs b/packages/crypto/src/errors.rs index 0016b85eb0..0f2f5df9f1 100644 --- a/packages/crypto/src/errors.rs +++ b/packages/crypto/src/errors.rs @@ -1,6 +1,6 @@ use alloc::string::String; -use derive_more::Display; use core::fmt::Debug; +use derive_more::Display; use crate::BT; diff --git a/packages/crypto/src/secp256k1.rs b/packages/crypto/src/secp256k1.rs index 3fdac7680e..3c1dbc0641 100644 --- a/packages/crypto/src/secp256k1.rs +++ b/packages/crypto/src/secp256k1.rs @@ -1,9 +1,9 @@ +use alloc::{string::ToString, vec::Vec}; use digest::{Digest, Update}; // trait use k256::{ ecdsa::signature::DigestVerifier, // traits ecdsa::{RecoveryId, Signature, VerifyingKey}, // type aliases }; -use alloc::{string::ToString, vec::Vec}; use crate::ecdsa::{ECDSA_COMPRESSED_PUBKEY_LEN, ECDSA_UNCOMPRESSED_PUBKEY_LEN}; use crate::errors::{CryptoError, CryptoResult}; diff --git a/packages/crypto/src/secp256r1.rs b/packages/crypto/src/secp256r1.rs index 95256ad205..9e7aa3b9ca 100644 --- a/packages/crypto/src/secp256r1.rs +++ b/packages/crypto/src/secp256r1.rs @@ -1,11 +1,11 @@ +use alloc::{string::ToString, vec::Vec}; +use core::convert::TryInto; use digest::{Digest, Update}; // trait use ecdsa::RecoveryId; use p256::{ ecdsa::signature::DigestVerifier, // traits ecdsa::{Signature, VerifyingKey}, // type aliases }; -use core::convert::TryInto; -use alloc::{string::ToString, vec::Vec}; use crate::ecdsa::{ECDSA_COMPRESSED_PUBKEY_LEN, ECDSA_UNCOMPRESSED_PUBKEY_LEN}; use crate::errors::{CryptoError, CryptoResult}; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index 210fa3fb56..b7a5f870f4 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -1,5 +1,4 @@ use crate::prelude::*; -use rand_core::OsRng; use alloc::collections::BTreeMap; #[cfg(feature = "cosmwasm_1_3")] use alloc::collections::BTreeSet; @@ -9,6 +8,7 @@ use core::marker::PhantomData; #[cfg(feature = "cosmwasm_1_3")] use core::ops::Bound; use cosmwasm_core::{Addr, CanonicalAddr}; +use rand_core::OsRng; use serde::de::DeserializeOwned; #[cfg(feature = "stargate")] use serde::Serialize; diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index fa11c2cab1..5e2074de97 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -7,10 +7,10 @@ use cosmwasm_crypto::{ ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, secp256r1_recover_pubkey, secp256r1_verify, CryptoError, }; -use rand::rngs::OsRng; use cosmwasm_crypto::{ ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, MESSAGE_HASH_MAX_LEN, }; +use rand::rngs::OsRng; #[cfg(feature = "iterator")] use cosmwasm_std::Order; From 0f8503d20c5dcfd0723ce0cb5e10c9bfdff77cd1 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 14 Mar 2024 18:48:17 +0100 Subject: [PATCH 27/42] Actually fix CI failures --- Cargo.lock | 1 + contracts/burner/Cargo.lock | 29 +-------------------------- contracts/crypto-verify/Cargo.lock | 29 +-------------------------- contracts/cyberpunk/Cargo.lock | 29 +-------------------------- contracts/empty/Cargo.lock | 29 +-------------------------- contracts/floaty/Cargo.lock | 13 +----------- contracts/hackatom/Cargo.lock | 29 +-------------------------- contracts/ibc-reflect-send/Cargo.lock | 29 +-------------------------- contracts/ibc-reflect/Cargo.lock | 29 +-------------------------- contracts/queue/Cargo.lock | 29 +-------------------------- contracts/reflect/Cargo.lock | 29 +-------------------------- contracts/staking/Cargo.lock | 29 +-------------------------- contracts/virus/Cargo.lock | 29 +-------------------------- packages/crypto/Cargo.toml | 1 + packages/crypto/src/ed25519.rs | 3 +++ packages/crypto/src/secp256k1.rs | 3 +++ packages/crypto/src/secp256r1.rs | 5 +++++ packages/std/Cargo.toml | 2 +- packages/vm/Cargo.toml | 3 ++- packages/vm/src/imports.rs | 2 +- 20 files changed, 29 insertions(+), 323 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index daf48f7767..2f5c0b4020 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,6 +530,7 @@ dependencies = [ "hex-literal", "leb128", "rand", + "rand_core", "schemars", "serde", "serde_json", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index b86508a2aa..487607452f 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -293,7 +293,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1077,12 +1077,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1154,27 +1148,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index da848bfab7..7182514cc2 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -288,7 +288,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1114,12 +1114,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1191,27 +1185,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 6f85ca599f..6dad118432 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -311,7 +311,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1169,12 +1169,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1246,27 +1240,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 2b52700a1a..7598dc90c8 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1076,12 +1076,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1153,27 +1147,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 320a45f6e3..26f09a0b01 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1155,17 +1155,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - [[package]] name = "rand_chacha" version = "0.3.1" diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 7e72a868fa..41940ded9c 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1079,12 +1079,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1156,27 +1150,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 3db0256c67..8db0f9fc35 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1077,12 +1077,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1154,27 +1148,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 4e6a16245a..db33be00f2 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1077,12 +1077,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1154,27 +1148,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 160b5a3af6..f6d140a78e 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1066,12 +1066,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1154,27 +1148,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 5f6fbcff7c..2b07f14cd5 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1066,12 +1066,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1143,27 +1137,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 51b54d8626..93596253d7 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1066,12 +1066,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1143,27 +1137,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 4694ba3f0e..e5f375e7a2 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ "crc32fast", "derivative", "hex", - "rand", + "rand_core", "schemars", "serde", "serde_json", @@ -1066,12 +1066,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "primeorder" version = "0.13.6" @@ -1143,27 +1137,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - [[package]] name = "rand_core" version = "0.6.4" diff --git a/packages/crypto/Cargo.toml b/packages/crypto/Cargo.toml index b8a93da52d..e6cacc36ec 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -27,6 +27,7 @@ p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] } [dev-dependencies] criterion = "0.5.1" +rand_core = { version = "0.6", features = ["getrandom"] } serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } serde_json = "1.0.40" sha2 = "0.10" diff --git a/packages/crypto/src/ed25519.rs b/packages/crypto/src/ed25519.rs index 895708ca2b..20e26c023c 100644 --- a/packages/crypto/src/ed25519.rs +++ b/packages/crypto/src/ed25519.rs @@ -141,7 +141,10 @@ fn read_pubkey(data: &[u8]) -> Result<[u8; 32], InvalidEd25519PubkeyFormat> { #[cfg(test)] mod tests { + extern crate std; // allow for file I/O during tests + use super::*; + use alloc::{string::String, vec, vec::Vec}; use ed25519_zebra::SigningKey; use rand_core::OsRng; use serde::Deserialize; diff --git a/packages/crypto/src/secp256k1.rs b/packages/crypto/src/secp256k1.rs index 3c1dbc0641..9ffc16a48b 100644 --- a/packages/crypto/src/secp256k1.rs +++ b/packages/crypto/src/secp256k1.rs @@ -167,8 +167,11 @@ fn check_pubkey(data: &[u8]) -> Result<(), InvalidSecp256k1PubkeyFormat> { #[cfg(test)] mod tests { + extern crate std; // allow for file I/O during tests + use super::*; + use alloc::{format, string::String}; use hex_literal::hex; use k256::{ ecdsa::signature::DigestSigner, // trait diff --git a/packages/crypto/src/secp256r1.rs b/packages/crypto/src/secp256r1.rs index 9e7aa3b9ca..c79847238c 100644 --- a/packages/crypto/src/secp256r1.rs +++ b/packages/crypto/src/secp256r1.rs @@ -142,10 +142,15 @@ fn check_pubkey(data: &[u8]) -> Result<(), InvalidSecp256r1PubkeyFormat> { #[cfg(test)] mod tests { + extern crate std; // allow for file I/O during tests + use super::*; use std::fs::File; use std::io::BufReader; + use crate::secp256r1_recover_pubkey; + use alloc::string::String; + use ecdsa::RecoveryId; use p256::{ ecdsa::signature::DigestSigner, ecdsa::SigningKey, elliptic_curve::rand_core::OsRng, }; diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 461626bc49..e117187a60 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -64,11 +64,11 @@ sha2 = "0.10.3" serde = { workspace = true } serde-json-wasm = { version = "1.0.1", default-features = false } thiserror = "1.0.26" -rand_core = { version = "0.6.4", features = ["getrandom"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] bech32 = "0.11.0" cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } +rand_core = { version = "0.6.4", features = ["getrandom"] } [dev-dependencies] cosmwasm-core = { path = "../core", version = "2.0.1", features = ["testing"] } diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index b801c813b7..f140107243 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -49,7 +49,7 @@ cosmwasm-std = { version = "2.0.1", path = "../std", default-features = false, f cosmwasm-crypto = { version = "2.0.1", path = "../crypto", features = ["std"] } derivative = "2" hex = "0.4" -rand = "0.8" +rand_core = { version = "0.6", features = ["getrandom"] } schemars = { workspace = true } serde = { workspace = true } serde_json = "1.0.40" @@ -76,6 +76,7 @@ tracing = "0.1.32" criterion = { version = "0.5.1", features = ["html_reports"] } glob = "0.3.1" hex-literal = "0.4.1" +rand = "0.8" tempfile = "3.1.0" wat = "1.0" clap = "4" diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 5e2074de97..b0324f16f5 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -10,7 +10,7 @@ use cosmwasm_crypto::{ use cosmwasm_crypto::{ ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, MESSAGE_HASH_MAX_LEN, }; -use rand::rngs::OsRng; +use rand_core::OsRng; #[cfg(feature = "iterator")] use cosmwasm_std::Order; From fbdebe6ed4fb9a26574b40be6efbf86e80869563 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 15 Mar 2024 10:47:23 +0100 Subject: [PATCH 28/42] Add `extern crate` declaration to the top of the crates --- packages/core/src/lib.rs | 3 +++ packages/crypto/src/ed25519.rs | 2 -- packages/crypto/src/lib.rs | 3 +++ packages/crypto/src/secp256k1.rs | 2 -- packages/crypto/src/secp256r1.rs | 2 -- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 121ef63f3c..455d16c89c 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -7,6 +7,9 @@ #[macro_use] extern crate alloc; +#[cfg(test)] +extern crate std; // allow for file I/O during tests + mod addresses; mod binary; mod encoding; diff --git a/packages/crypto/src/ed25519.rs b/packages/crypto/src/ed25519.rs index 20e26c023c..31e2bc1aa2 100644 --- a/packages/crypto/src/ed25519.rs +++ b/packages/crypto/src/ed25519.rs @@ -141,8 +141,6 @@ fn read_pubkey(data: &[u8]) -> Result<[u8; 32], InvalidEd25519PubkeyFormat> { #[cfg(test)] mod tests { - extern crate std; // allow for file I/O during tests - use super::*; use alloc::{string::String, vec, vec::Vec}; use ed25519_zebra::SigningKey; diff --git a/packages/crypto/src/lib.rs b/packages/crypto/src/lib.rs index 81f8b6131c..04667b7320 100644 --- a/packages/crypto/src/lib.rs +++ b/packages/crypto/src/lib.rs @@ -7,6 +7,9 @@ extern crate alloc; +#[cfg(test)] +extern crate std; // allow for file I/O during tests + mod backtrace; mod ecdsa; mod ed25519; diff --git a/packages/crypto/src/secp256k1.rs b/packages/crypto/src/secp256k1.rs index 9ffc16a48b..c5ab3bb559 100644 --- a/packages/crypto/src/secp256k1.rs +++ b/packages/crypto/src/secp256k1.rs @@ -167,8 +167,6 @@ fn check_pubkey(data: &[u8]) -> Result<(), InvalidSecp256k1PubkeyFormat> { #[cfg(test)] mod tests { - extern crate std; // allow for file I/O during tests - use super::*; use alloc::{format, string::String}; diff --git a/packages/crypto/src/secp256r1.rs b/packages/crypto/src/secp256r1.rs index c79847238c..574f625500 100644 --- a/packages/crypto/src/secp256r1.rs +++ b/packages/crypto/src/secp256r1.rs @@ -142,8 +142,6 @@ fn check_pubkey(data: &[u8]) -> Result<(), InvalidSecp256r1PubkeyFormat> { #[cfg(test)] mod tests { - extern crate std; // allow for file I/O during tests - use super::*; use std::fs::File; use std::io::BufReader; From f2bbfff51e0285f0674d84d806d7ed3586b0ef98 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 15 Mar 2024 11:11:10 +0100 Subject: [PATCH 29/42] Move full `StdError` to `cosmwasm-core` --- Cargo.lock | 1 + contracts/burner/Cargo.lock | 1 + contracts/crypto-verify/Cargo.lock | 1 + contracts/cyberpunk/Cargo.lock | 1 + contracts/empty/Cargo.lock | 1 + contracts/floaty/Cargo.lock | 1 + contracts/hackatom/Cargo.lock | 1 + contracts/ibc-reflect-send/Cargo.lock | 1 + contracts/ibc-reflect/Cargo.lock | 1 + contracts/queue/Cargo.lock | 1 + contracts/reflect/Cargo.lock | 1 + contracts/staking/Cargo.lock | 1 + contracts/virus/Cargo.lock | 1 + packages/core/Cargo.toml | 1 + packages/core/src/__internal.rs | 2 - packages/core/src/errors/backtrace.rs | 8 +- packages/core/src/errors/core_error.rs | 365 +++++++- packages/core/src/errors/mod.rs | 17 +- .../src/errors/recover_pubkey_error.rs | 15 +- .../{std => core}/src/errors/system_error.rs | 17 +- .../src/errors/verification_error.rs | 21 +- packages/core/src/lib.rs | 5 +- packages/std/src/coin.rs | 2 +- packages/std/src/coins.rs | 4 +- packages/std/src/errors/mod.rs | 14 - packages/std/src/errors/std_error.rs | 779 ------------------ packages/std/src/ibc.rs | 2 +- packages/std/src/imports.rs | 2 +- packages/std/src/iterator.rs | 2 +- packages/std/src/lib.rs | 10 +- packages/std/src/results/cosmos_msg.rs | 2 +- packages/std/src/results/system_result.rs | 3 +- packages/std/src/serde.rs | 2 +- packages/std/src/testing/mock.rs | 2 +- packages/std/src/traits.rs | 2 +- 35 files changed, 424 insertions(+), 866 deletions(-) rename packages/{std => core}/src/errors/recover_pubkey_error.rs (87%) rename packages/{std => core}/src/errors/system_error.rs (86%) rename packages/{std => core}/src/errors/verification_error.rs (86%) delete mode 100644 packages/std/src/errors/mod.rs delete mode 100644 packages/std/src/errors/std_error.rs diff --git a/Cargo.lock b/Cargo.lock index 2f5c0b4020..8f9f06b1a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,6 +420,7 @@ version = "2.0.1" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "cosmwasm-std", "crc32fast", "derive_more", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 487607452f..68e143e4e6 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -212,6 +212,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 7182514cc2..425e1b2b6f 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -207,6 +207,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 6dad118432..4bc9b154fb 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -230,6 +230,7 @@ version = "2.0.0" dependencies = [ "base64 0.22.0", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 7598dc90c8..05eb2302af 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 26f09a0b01..e713a56632 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 41940ded9c..ad298f7671 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 8db0f9fc35..893a53e2a3 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index db33be00f2..fc3f78b509 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index f6d140a78e..702fe9792f 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 2b07f14cd5..a0f5490a17 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 93596253d7..403c6aa329 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index e5f375e7a2..84d781576d 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -201,6 +201,7 @@ version = "2.0.0" dependencies = [ "base64", "bnum", + "cosmwasm-crypto", "derive_more", "hex", "schemars", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 0ec4a8dd1e..af020fd72e 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -13,6 +13,7 @@ release = false [dependencies] base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } bnum = "0.11.0" +cosmwasm-crypto = { version = "2.0.0", path = "../crypto" } crc32fast = { version = "1.4.0", optional = true, default-features = false } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } diff --git a/packages/core/src/__internal.rs b/packages/core/src/__internal.rs index e31c3ddd1b..d30bd75455 100644 --- a/packages/core/src/__internal.rs +++ b/packages/core/src/__internal.rs @@ -7,5 +7,3 @@ //! pub use crate::__internal__forward_ref_partial_eq as forward_ref_partial_eq; -pub use crate::errors::backtrace::impl_from_err; -pub use crate::errors::backtrace::BT; diff --git a/packages/core/src/errors/backtrace.rs b/packages/core/src/errors/backtrace.rs index d957d2f45a..14b92d851e 100644 --- a/packages/core/src/errors/backtrace.rs +++ b/packages/core/src/errors/backtrace.rs @@ -58,21 +58,19 @@ impl Display for Stub { /// the target error has a `backtrace` field. /// This is meant as a replacement for `thiserror`'s `#[from]` attribute, which does not /// work with our custom backtrace wrapper. -#[doc(hidden)] -#[macro_export] -macro_rules! __internal__impl_from_err { +macro_rules! impl_from_err { ($from:ty, $to:ty, $map:path) => { impl From<$from> for $to { fn from(err: $from) -> Self { $map { source: err, - backtrace: $crate::__internal::BT::capture(), + backtrace: $crate::errors::backtrace::BT::capture(), } } } }; } -pub use __internal__impl_from_err as impl_from_err; +pub(crate) use impl_from_err; #[cfg(test)] mod tests { diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index b344a7c74f..36de7cf67e 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -1,11 +1,38 @@ use alloc::string::{String, ToString}; +use core::fmt; use derive_more::{Display, From}; -use super::backtrace::{impl_from_err, BT}; +use super::{impl_from_err, BT}; +use crate::errors::{RecoverPubkeyError, VerificationError}; + +/// Structured error type for init, execute and query. +/// +/// This can be serialized and passed over the Wasm/VM boundary, which allows us to use structured +/// error types in e.g. integration tests. In that process backtraces are stripped off. +/// +/// The prefix "Std" means "the standard error within the standard library". This is not the only +/// result/error type in cosmwasm-std. +/// +/// When new cases are added, they should describe the problem rather than what was attempted (e.g. +/// InvalidBase64 is preferred over Base64DecodingErr). In the long run this allows us to get rid of +/// the duplication in "StdError::FooErr". +/// +/// Checklist for adding a new error: +/// - Add enum case +/// - Add creator function in std_error_helpers.rs #[derive(Display, Debug)] -#[non_exhaustive] pub enum CoreError { + #[display("Verification error: {source}")] + VerificationErr { + source: VerificationError, + backtrace: BT, + }, + #[display("Recover pubkey error: {source}")] + RecoverPubkeyErr { + source: RecoverPubkeyError, + backtrace: BT, + }, /// Whenever there is no specific error type available #[display("Generic error: {msg}")] GenericErr { msg: String, backtrace: BT }, @@ -19,6 +46,25 @@ pub enum CoreError { }, #[display("Invalid hex string: {msg}")] InvalidHex { msg: String, backtrace: BT }, + /// Whenever UTF-8 bytes cannot be decoded into a unicode string, e.g. in String::from_utf8 or str::from_utf8. + #[display("Cannot decode UTF8 bytes into string: {msg}")] + InvalidUtf8 { msg: String, backtrace: BT }, + #[display("{kind} not found")] + NotFound { kind: String, backtrace: BT }, + #[display("Error parsing into type {target_type}: {msg}")] + ParseErr { + /// the target type that was attempted + target_type: String, + msg: String, + backtrace: BT, + }, + #[display("Error serializing type {source_type}: {msg}")] + SerializeErr { + /// the source type that was attempted + source_type: String, + msg: String, + backtrace: BT, + }, #[display("Overflow: {source}")] Overflow { source: OverflowError, @@ -36,9 +82,6 @@ pub enum CoreError { }, } -#[cfg(feature = "std")] -impl std::error::Error for CoreError {} - impl_from_err!( ConversionOverflowError, CoreError, @@ -46,6 +89,20 @@ impl_from_err!( ); impl CoreError { + pub fn verification_err(source: VerificationError) -> Self { + CoreError::VerificationErr { + source, + backtrace: BT::capture(), + } + } + + pub fn recover_pubkey_err(source: RecoverPubkeyError) -> Self { + CoreError::RecoverPubkeyErr { + source, + backtrace: BT::capture(), + } + } + pub fn generic_err(msg: impl Into) -> Self { CoreError::GenericErr { msg: msg.into(), @@ -76,6 +133,36 @@ impl CoreError { } } + pub fn invalid_utf8(msg: impl ToString) -> Self { + CoreError::InvalidUtf8 { + msg: msg.to_string(), + backtrace: BT::capture(), + } + } + + pub fn not_found(kind: impl Into) -> Self { + CoreError::NotFound { + kind: kind.into(), + backtrace: BT::capture(), + } + } + + pub fn parse_err(target: impl Into, msg: impl ToString) -> Self { + CoreError::ParseErr { + target_type: target.into(), + msg: msg.to_string(), + backtrace: BT::capture(), + } + } + + pub fn serialize_err(source: impl Into, msg: impl ToString) -> Self { + CoreError::SerializeErr { + source_type: source.into(), + msg: msg.to_string(), + backtrace: BT::capture(), + } + } + pub fn overflow(source: OverflowError) -> Self { CoreError::Overflow { source, @@ -91,9 +178,40 @@ impl CoreError { } } +#[cfg(feature = "std")] +impl std::error::Error for CoreError {} + impl PartialEq for CoreError { fn eq(&self, rhs: &CoreError) -> bool { match self { + CoreError::VerificationErr { + source, + backtrace: _, + } => { + if let CoreError::VerificationErr { + source: rhs_source, + backtrace: _, + } = rhs + { + source == rhs_source + } else { + false + } + } + CoreError::RecoverPubkeyErr { + source, + backtrace: _, + } => { + if let CoreError::RecoverPubkeyErr { + source: rhs_source, + backtrace: _, + } = rhs + { + source == rhs_source + } else { + false + } + } CoreError::GenericErr { msg, backtrace: _ } => { if let CoreError::GenericErr { msg: rhs_msg, @@ -143,6 +261,60 @@ impl PartialEq for CoreError { false } } + CoreError::InvalidUtf8 { msg, backtrace: _ } => { + if let CoreError::InvalidUtf8 { + msg: rhs_msg, + backtrace: _, + } = rhs + { + msg == rhs_msg + } else { + false + } + } + CoreError::NotFound { kind, backtrace: _ } => { + if let CoreError::NotFound { + kind: rhs_kind, + backtrace: _, + } = rhs + { + kind == rhs_kind + } else { + false + } + } + CoreError::ParseErr { + target_type, + msg, + backtrace: _, + } => { + if let CoreError::ParseErr { + target_type: rhs_target_type, + msg: rhs_msg, + backtrace: _, + } = rhs + { + target_type == rhs_target_type && msg == rhs_msg + } else { + false + } + } + CoreError::SerializeErr { + source_type, + msg, + backtrace: _, + } => { + if let CoreError::SerializeErr { + source_type: rhs_source_type, + msg: rhs_msg, + backtrace: _, + } = rhs + { + source_type == rhs_source_type && msg == rhs_msg + } else { + false + } + } CoreError::Overflow { source, backtrace: _, @@ -189,7 +361,50 @@ impl PartialEq for CoreError { } } -#[derive(Display, Debug, PartialEq, Eq)] +impl From for CoreError { + fn from(source: core::str::Utf8Error) -> Self { + Self::invalid_utf8(source) + } +} + +impl From for CoreError { + fn from(source: alloc::string::FromUtf8Error) -> Self { + Self::invalid_utf8(source) + } +} + +impl From for CoreError { + fn from(source: VerificationError) -> Self { + Self::verification_err(source) + } +} + +impl From for CoreError { + fn from(source: RecoverPubkeyError) -> Self { + Self::recover_pubkey_err(source) + } +} + +impl From for CoreError { + fn from(source: OverflowError) -> Self { + Self::overflow(source) + } +} + +impl From for CoreError { + fn from(source: DivideByZeroError) -> Self { + Self::divide_by_zero(source) + } +} + +/// The return type for init, execute and query. Since the error type cannot be serialized to JSON, +/// this is only available within the contract and its unit tests. +/// +/// The prefix "Std" means "the standard result within the standard library". This is not the only +/// result/error type in cosmwasm-std. +pub type CoreResult = core::result::Result; + +#[derive(Debug, PartialEq, Eq)] pub enum OverflowOperation { Add, Sub, @@ -199,6 +414,12 @@ pub enum OverflowOperation { Shl, } +impl fmt::Display for OverflowOperation { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{self:?}") + } +} + #[derive(Display, Debug, PartialEq, Eq)] #[display("Cannot {operation} with given operands")] pub struct OverflowError { @@ -317,21 +538,50 @@ pub struct RoundDownOverflowError; #[cfg(feature = "std")] impl std::error::Error for RoundDownOverflowError {} -impl From for CoreError { - fn from(source: OverflowError) -> Self { - Self::overflow(source) +#[derive(Display, Debug, PartialEq, Eq)] +pub enum CoinsError { + #[display("Duplicate denom")] + DuplicateDenom, +} + +#[cfg(feature = "std")] +impl std::error::Error for CoinsError {} + +impl From for CoreError { + fn from(value: CoinsError) -> Self { + Self::generic_err(format!("Creating Coins: {value}")) } } -impl From for CoreError { - fn from(source: DivideByZeroError) -> Self { - Self::divide_by_zero(source) +#[derive(Display, Debug, PartialEq, Eq)] +pub enum CoinFromStrError { + #[display("Missing denominator")] + MissingDenom, + #[display("Missing amount or non-digit characters in amount")] + MissingAmount, + #[display("Invalid amount: {_0}")] + InvalidAmount(core::num::ParseIntError), +} + +#[cfg(feature = "std")] +impl std::error::Error for CoinFromStrError {} + +impl From for CoinFromStrError { + fn from(value: core::num::ParseIntError) -> Self { + Self::InvalidAmount(value) + } +} + +impl From for CoreError { + fn from(value: CoinFromStrError) -> Self { + Self::generic_err(format!("Parsing Coin: {value}")) } } #[cfg(test)] mod tests { use super::*; + use core::str; // constructors @@ -418,6 +668,66 @@ mod tests { } } + #[test] + fn invalid_utf8_works_for_strings() { + let error = CoreError::invalid_utf8("my text"); + match error { + CoreError::InvalidUtf8 { msg, .. } => { + assert_eq!(msg, "my text"); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn invalid_utf8_works_for_errors() { + let original = String::from_utf8(vec![0x80]).unwrap_err(); + let error = CoreError::invalid_utf8(original); + match error { + CoreError::InvalidUtf8 { msg, .. } => { + assert_eq!(msg, "invalid utf-8 sequence of 1 bytes from index 0"); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn not_found_works() { + let error = CoreError::not_found("gold"); + match error { + CoreError::NotFound { kind, .. } => assert_eq!(kind, "gold"), + _ => panic!("expect different error"), + } + } + + #[test] + fn parse_err_works() { + let error = CoreError::parse_err("Book", "Missing field: title"); + match error { + CoreError::ParseErr { + target_type, msg, .. + } => { + assert_eq!(target_type, "Book"); + assert_eq!(msg, "Missing field: title"); + } + _ => panic!("expect different error"), + } + } + + #[test] + fn serialize_err_works() { + let error = CoreError::serialize_err("Book", "Content too long"); + match error { + CoreError::SerializeErr { + source_type, msg, .. + } => { + assert_eq!(source_type, "Book"); + assert_eq!(msg, "Content too long"); + } + _ => panic!("expect different error"), + } + } + #[test] fn underflow_works_for_u128() { let error = CoreError::overflow(OverflowError::new(OverflowOperation::Sub)); @@ -480,12 +790,37 @@ mod tests { fn implements_partial_eq() { let u1 = CoreError::from(OverflowError::new(OverflowOperation::Sub)); let u2 = CoreError::from(OverflowError::new(OverflowOperation::Sub)); - let s1 = CoreError::generic_err("Content too long"); - let s2 = CoreError::generic_err("Content too long"); - let s3 = CoreError::generic_err("Title too long"); + let s1 = CoreError::serialize_err("Book", "Content too long"); + let s2 = CoreError::serialize_err("Book", "Content too long"); + let s3 = CoreError::serialize_err("Book", "Title too long"); assert_eq!(u1, u2); assert_ne!(u1, s1); assert_eq!(s1, s2); assert_ne!(s1, s3); } + + #[test] + fn from_std_str_utf8error_works() { + let broken = Vec::from(b"Hello \xF0\x90\x80World" as &[u8]); + let error: CoreError = str::from_utf8(&broken).unwrap_err().into(); + match error { + CoreError::InvalidUtf8 { msg, .. } => { + assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") + } + err => panic!("Unexpected error: {err:?}"), + } + } + + #[test] + fn from_std_string_from_utf8error_works() { + let error: CoreError = String::from_utf8(b"Hello \xF0\x90\x80World".to_vec()) + .unwrap_err() + .into(); + match error { + CoreError::InvalidUtf8 { msg, .. } => { + assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") + } + err => panic!("Unexpected error: {err:?}"), + } + } } diff --git a/packages/core/src/errors/mod.rs b/packages/core/src/errors/mod.rs index 589f5ee70d..60533e027d 100644 --- a/packages/core/src/errors/mod.rs +++ b/packages/core/src/errors/mod.rs @@ -1,11 +1,16 @@ +mod backtrace; mod core_error; +mod recover_pubkey_error; +mod system_error; +mod verification_error; -pub(crate) mod backtrace; - -pub type CoreResult = core::result::Result; - +pub(crate) use backtrace::{impl_from_err, BT}; pub use core_error::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - ConversionOverflowError, CoreError, DivideByZeroError, DivisionError, OverflowError, - OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, + CoinFromStrError, CoinsError, ConversionOverflowError, CoreError, CoreResult, + DivideByZeroError, DivisionError, OverflowError, OverflowOperation, RoundDownOverflowError, + RoundUpOverflowError, }; +pub use recover_pubkey_error::RecoverPubkeyError; +pub use system_error::SystemError; +pub use verification_error::VerificationError; diff --git a/packages/std/src/errors/recover_pubkey_error.rs b/packages/core/src/errors/recover_pubkey_error.rs similarity index 87% rename from packages/std/src/errors/recover_pubkey_error.rs rename to packages/core/src/errors/recover_pubkey_error.rs index ac2b174a26..5e15230d95 100644 --- a/packages/std/src/errors/recover_pubkey_error.rs +++ b/packages/core/src/errors/recover_pubkey_error.rs @@ -1,19 +1,19 @@ use core::fmt::Debug; #[cfg(not(target_arch = "wasm32"))] use cosmwasm_crypto::CryptoError; +use derive_more::Display; use super::BT; -use thiserror::Error; -#[derive(Error, Debug)] +#[derive(Display, Debug)] pub enum RecoverPubkeyError { - #[error("Invalid hash format")] + #[display("Invalid hash format")] InvalidHashFormat, - #[error("Invalid signature format")] + #[display("Invalid signature format")] InvalidSignatureFormat, - #[error("Invalid recovery parameter. Supported values: 0 and 1.")] + #[display("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam, - #[error("Unknown error: {error_code}")] + #[display("Unknown error: {error_code}")] UnknownErr { error_code: u32, backtrace: BT }, } @@ -27,6 +27,9 @@ impl RecoverPubkeyError { } } +#[cfg(feature = "std")] +impl std::error::Error for RecoverPubkeyError {} + impl PartialEq for RecoverPubkeyError { fn eq(&self, rhs: &RecoverPubkeyError) -> bool { match self { diff --git a/packages/std/src/errors/system_error.rs b/packages/core/src/errors/system_error.rs similarity index 86% rename from packages/std/src/errors/system_error.rs rename to packages/core/src/errors/system_error.rs index e7a0b5a865..f43c41a05f 100644 --- a/packages/std/src/errors/system_error.rs +++ b/packages/core/src/errors/system_error.rs @@ -1,7 +1,6 @@ -use schemars::JsonSchema; +use alloc::string::String; use serde::{Deserialize, Serialize}; -use crate::prelude::*; use crate::Binary; /// SystemError is used for errors inside the VM and is API friendly (i.e. serializable). @@ -13,7 +12,8 @@ use crate::Binary; /// /// Such errors are only created by the VM. The error type is defined in the standard library, to ensure /// the contract understands the error format without creating a dependency on cosmwasm-vm. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub enum SystemError { @@ -71,7 +71,6 @@ impl core::fmt::Display for SystemError { #[cfg(test)] mod tests { use super::*; - use crate::{from_json, to_json_vec}; #[test] fn system_error_no_such_contract_serialization() { @@ -80,14 +79,15 @@ mod tests { }; // ser - let json = to_json_vec(&err).unwrap(); + let json = serde_json::to_vec(&err).unwrap(); assert_eq!( String::from_utf8_lossy(&json), r#"{"no_such_contract":{"addr":"gibtsnicht"}}"#, ); // de - let err: SystemError = from_json(br#"{"no_such_contract":{"addr":"nada"}}"#).unwrap(); + let err: SystemError = + serde_json::from_slice(br#"{"no_such_contract":{"addr":"nada"}}"#).unwrap(); assert_eq!( err, SystemError::NoSuchContract { @@ -101,14 +101,15 @@ mod tests { let err = SystemError::NoSuchCode { code_id: 13 }; // ser - let json = to_json_vec(&err).unwrap(); + let json = serde_json::to_vec(&err).unwrap(); assert_eq!( String::from_utf8_lossy(&json), r#"{"no_such_code":{"code_id":13}}"#, ); // de - let err: SystemError = from_json(br#"{"no_such_code":{"code_id":987}}"#).unwrap(); + let err: SystemError = + serde_json::from_slice(br#"{"no_such_code":{"code_id":987}}"#).unwrap(); assert_eq!(err, SystemError::NoSuchCode { code_id: 987 },); } } diff --git a/packages/std/src/errors/verification_error.rs b/packages/core/src/errors/verification_error.rs similarity index 86% rename from packages/std/src/errors/verification_error.rs rename to packages/core/src/errors/verification_error.rs index d4366c5206..7a130a07b5 100644 --- a/packages/std/src/errors/verification_error.rs +++ b/packages/core/src/errors/verification_error.rs @@ -1,26 +1,26 @@ use core::fmt::Debug; +use derive_more::Display; use super::BT; -use thiserror::Error; #[cfg(not(target_arch = "wasm32"))] use cosmwasm_crypto::CryptoError; -#[derive(Error, Debug)] +#[derive(Display, Debug)] pub enum VerificationError { - #[error("Batch error")] + #[display("Batch error")] BatchErr, - #[error("Generic error")] + #[display("Generic error")] GenericErr, - #[error("Invalid hash format")] + #[display("Invalid hash format")] InvalidHashFormat, - #[error("Invalid signature format")] + #[display("Invalid signature format")] InvalidSignatureFormat, - #[error("Invalid public key format")] + #[display("Invalid public key format")] InvalidPubkeyFormat, - #[error("Invalid recovery parameter. Supported values: 0 and 1.")] + #[display("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam, - #[error("Unknown error: {error_code}")] + #[display("Unknown error: {error_code}")] UnknownErr { error_code: u32, backtrace: BT }, } @@ -34,6 +34,9 @@ impl VerificationError { } } +#[cfg(feature = "std")] +impl std::error::Error for VerificationError {} + impl PartialEq for VerificationError { fn eq(&self, rhs: &VerificationError) -> bool { match self { diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 455d16c89c..faed6f21c0 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -28,8 +28,9 @@ pub use crate::binary::Binary; pub use crate::encoding::{from_base64, from_hex, to_base64, to_hex}; pub use crate::errors::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - ConversionOverflowError, CoreError, CoreResult, DivideByZeroError, DivisionError, - OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, + CoinFromStrError, CoinsError, ConversionOverflowError, CoreError, CoreResult, + DivideByZeroError, DivisionError, OverflowError, OverflowOperation, RecoverPubkeyError, + RoundDownOverflowError, RoundUpOverflowError, SystemError, VerificationError, }; pub use crate::hex_binary::HexBinary; pub use crate::math::{ diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index 67df41a089..9807eaa007 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -3,8 +3,8 @@ use cosmwasm_core::Uint128; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::errors::CoinFromStrError; use crate::prelude::*; +use crate::CoinFromStrError; #[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema)] pub struct Coin { diff --git a/packages/std/src/coins.rs b/packages/std/src/coins.rs index 967ab7067f..dc916dc5ca 100644 --- a/packages/std/src/coins.rs +++ b/packages/std/src/coins.rs @@ -3,9 +3,7 @@ use core::fmt; use core::str::FromStr; use crate::prelude::*; -use crate::{ - errors::CoinsError, Coin, OverflowError, OverflowOperation, StdError, StdResult, Uint128, -}; +use crate::{Coin, CoinsError, OverflowError, OverflowOperation, StdError, StdResult, Uint128}; /// A collection of coins, similar to Cosmos SDK's `sdk.Coins` struct. /// diff --git a/packages/std/src/errors/mod.rs b/packages/std/src/errors/mod.rs deleted file mode 100644 index e864fe132f..0000000000 --- a/packages/std/src/errors/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -mod recover_pubkey_error; -mod std_error; -mod system_error; -mod verification_error; - -pub(crate) use cosmwasm_core::__internal::{impl_from_err, BT}; -pub use cosmwasm_core::{ - CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - ConversionOverflowError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, -}; -pub use recover_pubkey_error::RecoverPubkeyError; -pub use std_error::{CoinFromStrError, CoinsError, StdError, StdResult}; -pub use system_error::SystemError; -pub use verification_error::VerificationError; diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs deleted file mode 100644 index ffb74e62c7..0000000000 --- a/packages/std/src/errors/std_error.rs +++ /dev/null @@ -1,779 +0,0 @@ -use super::{impl_from_err, BT}; -use cosmwasm_core::{ConversionOverflowError, CoreError, DivideByZeroError, OverflowError}; -use thiserror::Error; - -use crate::errors::{RecoverPubkeyError, VerificationError}; -use crate::prelude::*; - -/// Structured error type for init, execute and query. -/// -/// This can be serialized and passed over the Wasm/VM boundary, which allows us to use structured -/// error types in e.g. integration tests. In that process backtraces are stripped off. -/// -/// The prefix "Std" means "the standard error within the standard library". This is not the only -/// result/error type in cosmwasm-std. -/// -/// When new cases are added, they should describe the problem rather than what was attempted (e.g. -/// InvalidBase64 is preferred over Base64DecodingErr). In the long run this allows us to get rid of -/// the duplication in "StdError::FooErr". -/// -/// Checklist for adding a new error: -/// - Add enum case -/// - Add creator function in std_error_helpers.rs -#[derive(Error, Debug)] -pub enum StdError { - #[error("Core error: {source}")] - CoreErr { source: CoreError, backtrace: BT }, - #[error("Verification error: {source}")] - VerificationErr { - source: VerificationError, - backtrace: BT, - }, - #[error("Recover pubkey error: {source}")] - RecoverPubkeyErr { - source: RecoverPubkeyError, - backtrace: BT, - }, - /// Whenever there is no specific error type available - #[error("Generic error: {msg}")] - GenericErr { msg: String, backtrace: BT }, - #[error("Invalid Base64 string: {msg}")] - InvalidBase64 { msg: String, backtrace: BT }, - #[error("Invalid data size: expected={expected} actual={actual}")] - InvalidDataSize { - expected: u64, - actual: u64, - backtrace: BT, - }, - #[error("Invalid hex string: {msg}")] - InvalidHex { msg: String, backtrace: BT }, - /// Whenever UTF-8 bytes cannot be decoded into a unicode string, e.g. in String::from_utf8 or str::from_utf8. - #[error("Cannot decode UTF8 bytes into string: {msg}")] - InvalidUtf8 { msg: String, backtrace: BT }, - #[error("{kind} not found")] - NotFound { kind: String, backtrace: BT }, - #[error("Error parsing into type {target_type}: {msg}")] - ParseErr { - /// the target type that was attempted - target_type: String, - msg: String, - backtrace: BT, - }, - #[error("Error serializing type {source_type}: {msg}")] - SerializeErr { - /// the source type that was attempted - source_type: String, - msg: String, - backtrace: BT, - }, - #[error("Overflow: {source}")] - Overflow { - source: OverflowError, - backtrace: BT, - }, - #[error("Divide by zero: {source}")] - DivideByZero { - source: DivideByZeroError, - backtrace: BT, - }, - #[error("Conversion error: ")] - ConversionOverflow { - source: ConversionOverflowError, - backtrace: BT, - }, -} - -impl From for StdError { - fn from(value: CoreError) -> Self { - match value { - CoreError::ConversionOverflow { source, backtrace } => { - Self::ConversionOverflow { source, backtrace } - } - CoreError::GenericErr { msg, backtrace } => Self::GenericErr { msg, backtrace }, - CoreError::InvalidBase64 { msg, backtrace } => Self::InvalidBase64 { msg, backtrace }, - CoreError::InvalidDataSize { - expected, - actual, - backtrace, - } => Self::InvalidDataSize { - expected, - actual, - backtrace, - }, - CoreError::InvalidHex { msg, backtrace } => Self::InvalidHex { msg, backtrace }, - CoreError::Overflow { source, backtrace } => Self::Overflow { source, backtrace }, - CoreError::DivideByZero { source, backtrace } => { - Self::DivideByZero { source, backtrace } - } - source => Self::CoreErr { - source, - backtrace: BT::capture(), - }, - } - } -} - -impl_from_err!( - ConversionOverflowError, - StdError, - StdError::ConversionOverflow -); - -impl StdError { - pub fn verification_err(source: VerificationError) -> Self { - StdError::VerificationErr { - source, - backtrace: BT::capture(), - } - } - - pub fn recover_pubkey_err(source: RecoverPubkeyError) -> Self { - StdError::RecoverPubkeyErr { - source, - backtrace: BT::capture(), - } - } - - pub fn generic_err(msg: impl Into) -> Self { - StdError::GenericErr { - msg: msg.into(), - backtrace: BT::capture(), - } - } - - pub fn invalid_base64(msg: impl ToString) -> Self { - StdError::InvalidBase64 { - msg: msg.to_string(), - backtrace: BT::capture(), - } - } - - pub fn invalid_data_size(expected: usize, actual: usize) -> Self { - StdError::InvalidDataSize { - // Cast is safe because usize is 32 or 64 bit large in all environments we support - expected: expected as u64, - actual: actual as u64, - backtrace: BT::capture(), - } - } - - pub fn invalid_hex(msg: impl ToString) -> Self { - StdError::InvalidHex { - msg: msg.to_string(), - backtrace: BT::capture(), - } - } - - pub fn invalid_utf8(msg: impl ToString) -> Self { - StdError::InvalidUtf8 { - msg: msg.to_string(), - backtrace: BT::capture(), - } - } - - pub fn not_found(kind: impl Into) -> Self { - StdError::NotFound { - kind: kind.into(), - backtrace: BT::capture(), - } - } - - pub fn parse_err(target: impl Into, msg: impl ToString) -> Self { - StdError::ParseErr { - target_type: target.into(), - msg: msg.to_string(), - backtrace: BT::capture(), - } - } - - pub fn serialize_err(source: impl Into, msg: impl ToString) -> Self { - StdError::SerializeErr { - source_type: source.into(), - msg: msg.to_string(), - backtrace: BT::capture(), - } - } - - pub fn overflow(source: OverflowError) -> Self { - StdError::Overflow { - source, - backtrace: BT::capture(), - } - } - - pub fn divide_by_zero(source: DivideByZeroError) -> Self { - StdError::DivideByZero { - source, - backtrace: BT::capture(), - } - } -} - -impl PartialEq for StdError { - fn eq(&self, rhs: &StdError) -> bool { - match self { - StdError::CoreErr { - source, - backtrace: _, - } => { - if let StdError::CoreErr { - source: rhs_source, - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } - StdError::VerificationErr { - source, - backtrace: _, - } => { - if let StdError::VerificationErr { - source: rhs_source, - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } - StdError::RecoverPubkeyErr { - source, - backtrace: _, - } => { - if let StdError::RecoverPubkeyErr { - source: rhs_source, - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } - StdError::GenericErr { msg, backtrace: _ } => { - if let StdError::GenericErr { - msg: rhs_msg, - backtrace: _, - } = rhs - { - msg == rhs_msg - } else { - false - } - } - StdError::InvalidBase64 { msg, backtrace: _ } => { - if let StdError::InvalidBase64 { - msg: rhs_msg, - backtrace: _, - } = rhs - { - msg == rhs_msg - } else { - false - } - } - StdError::InvalidDataSize { - expected, - actual, - backtrace: _, - } => { - if let StdError::InvalidDataSize { - expected: rhs_expected, - actual: rhs_actual, - backtrace: _, - } = rhs - { - expected == rhs_expected && actual == rhs_actual - } else { - false - } - } - StdError::InvalidHex { msg, backtrace: _ } => { - if let StdError::InvalidHex { - msg: rhs_msg, - backtrace: _, - } = rhs - { - msg == rhs_msg - } else { - false - } - } - StdError::InvalidUtf8 { msg, backtrace: _ } => { - if let StdError::InvalidUtf8 { - msg: rhs_msg, - backtrace: _, - } = rhs - { - msg == rhs_msg - } else { - false - } - } - StdError::NotFound { kind, backtrace: _ } => { - if let StdError::NotFound { - kind: rhs_kind, - backtrace: _, - } = rhs - { - kind == rhs_kind - } else { - false - } - } - StdError::ParseErr { - target_type, - msg, - backtrace: _, - } => { - if let StdError::ParseErr { - target_type: rhs_target_type, - msg: rhs_msg, - backtrace: _, - } = rhs - { - target_type == rhs_target_type && msg == rhs_msg - } else { - false - } - } - StdError::SerializeErr { - source_type, - msg, - backtrace: _, - } => { - if let StdError::SerializeErr { - source_type: rhs_source_type, - msg: rhs_msg, - backtrace: _, - } = rhs - { - source_type == rhs_source_type && msg == rhs_msg - } else { - false - } - } - StdError::Overflow { - source, - backtrace: _, - } => { - if let StdError::Overflow { - source: rhs_source, - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } - StdError::DivideByZero { - source, - backtrace: _, - } => { - if let StdError::DivideByZero { - source: rhs_source, - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } - StdError::ConversionOverflow { - source, - backtrace: _, - } => { - if let StdError::ConversionOverflow { - source: rhs_source, - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } - } - } -} - -impl From for StdError { - fn from(source: core::str::Utf8Error) -> Self { - Self::invalid_utf8(source) - } -} - -impl From for StdError { - fn from(source: alloc::string::FromUtf8Error) -> Self { - Self::invalid_utf8(source) - } -} - -impl From for StdError { - fn from(source: VerificationError) -> Self { - Self::verification_err(source) - } -} - -impl From for StdError { - fn from(source: RecoverPubkeyError) -> Self { - Self::recover_pubkey_err(source) - } -} - -impl From for StdError { - fn from(source: OverflowError) -> Self { - Self::overflow(source) - } -} - -impl From for StdError { - fn from(source: DivideByZeroError) -> Self { - Self::divide_by_zero(source) - } -} - -/// The return type for init, execute and query. Since the error type cannot be serialized to JSON, -/// this is only available within the contract and its unit tests. -/// -/// The prefix "Std" means "the standard result within the standard library". This is not the only -/// result/error type in cosmwasm-std. -pub type StdResult = core::result::Result; - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum CoinsError { - #[error("Duplicate denom")] - DuplicateDenom, -} - -impl From for StdError { - fn from(value: CoinsError) -> Self { - Self::generic_err(format!("Creating Coins: {value}")) - } -} - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum CoinFromStrError { - #[error("Missing denominator")] - MissingDenom, - #[error("Missing amount or non-digit characters in amount")] - MissingAmount, - #[error("Invalid amount: {0}")] - InvalidAmount(core::num::ParseIntError), -} - -impl From for CoinFromStrError { - fn from(value: core::num::ParseIntError) -> Self { - Self::InvalidAmount(value) - } -} - -impl From for StdError { - fn from(value: CoinFromStrError) -> Self { - Self::generic_err(format!("Parsing Coin: {value}")) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use core::str; - use cosmwasm_core::OverflowOperation; - - // constructors - - // example of reporting contract errors with format! - #[test] - fn generic_err_owned() { - let guess = 7; - let error = StdError::generic_err(format!("{guess} is too low")); - match error { - StdError::GenericErr { msg, .. } => { - assert_eq!(msg, String::from("7 is too low")); - } - e => panic!("unexpected error, {e:?}"), - } - } - - // example of reporting static contract errors - #[test] - fn generic_err_ref() { - let error = StdError::generic_err("not implemented"); - match error { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "not implemented"), - e => panic!("unexpected error, {e:?}"), - } - } - - #[test] - fn core_error_conversion() { - let generic = StdError::from(CoreError::generic_err("test error")); - let base64 = StdError::from(CoreError::invalid_base64("invalid data")); - let data_size = StdError::from(CoreError::invalid_data_size(10, 12)); - let hex = StdError::from(CoreError::invalid_hex("invalid hex")); - let overflow = StdError::from(CoreError::overflow(OverflowError::new( - OverflowOperation::Pow, - ))); - let divide = StdError::from(CoreError::divide_by_zero(DivideByZeroError::new())); - - match generic { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "test error"), - _ => panic!("expected different error"), - } - - match base64 { - StdError::InvalidBase64 { msg, .. } => assert_eq!(msg, "invalid data"), - _ => panic!("expected different error"), - } - - match data_size { - StdError::InvalidDataSize { - expected, actual, .. - } => { - assert_eq!(expected, 10); - assert_eq!(actual, 12); - } - _ => panic!("expected different error"), - } - - match hex { - StdError::InvalidHex { msg, .. } => assert_eq!(msg, "invalid hex"), - _ => panic!("expected different error"), - } - - match overflow { - StdError::Overflow { - source: OverflowError { operation }, - .. - } => assert_eq!(operation, OverflowOperation::Pow), - _ => panic!("expected different error"), - } - - match divide { - StdError::DivideByZero { .. } => (), - _ => panic!("expected different error"), - } - } - - #[test] - fn invalid_base64_works_for_strings() { - let error = StdError::invalid_base64("my text"); - match error { - StdError::InvalidBase64 { msg, .. } => { - assert_eq!(msg, "my text"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn invalid_base64_works_for_errors() { - let original = base64::DecodeError::InvalidLength(10); - let error = StdError::invalid_base64(original); - match error { - StdError::InvalidBase64 { msg, .. } => { - assert_eq!(msg, "Invalid input length: 10"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn invalid_data_size_works() { - let error = StdError::invalid_data_size(31, 14); - match error { - StdError::InvalidDataSize { - expected, actual, .. - } => { - assert_eq!(expected, 31); - assert_eq!(actual, 14); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn invalid_hex_works_for_strings() { - let error = StdError::invalid_hex("my text"); - match error { - StdError::InvalidHex { msg, .. } => { - assert_eq!(msg, "my text"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn invalid_hex_works_for_errors() { - let original = hex::FromHexError::OddLength; - let error = StdError::invalid_hex(original); - match error { - StdError::InvalidHex { msg, .. } => { - assert_eq!(msg, "Odd number of digits"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn invalid_utf8_works_for_strings() { - let error = StdError::invalid_utf8("my text"); - match error { - StdError::InvalidUtf8 { msg, .. } => { - assert_eq!(msg, "my text"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn invalid_utf8_works_for_errors() { - let original = String::from_utf8(vec![0x80]).unwrap_err(); - let error = StdError::invalid_utf8(original); - match error { - StdError::InvalidUtf8 { msg, .. } => { - assert_eq!(msg, "invalid utf-8 sequence of 1 bytes from index 0"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn not_found_works() { - let error = StdError::not_found("gold"); - match error { - StdError::NotFound { kind, .. } => assert_eq!(kind, "gold"), - _ => panic!("expect different error"), - } - } - - #[test] - fn parse_err_works() { - let error = StdError::parse_err("Book", "Missing field: title"); - match error { - StdError::ParseErr { - target_type, msg, .. - } => { - assert_eq!(target_type, "Book"); - assert_eq!(msg, "Missing field: title"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn serialize_err_works() { - let error = StdError::serialize_err("Book", "Content too long"); - match error { - StdError::SerializeErr { - source_type, msg, .. - } => { - assert_eq!(source_type, "Book"); - assert_eq!(msg, "Content too long"); - } - _ => panic!("expect different error"), - } - } - - #[test] - fn underflow_works_for_u128() { - let error = StdError::overflow(OverflowError::new(OverflowOperation::Sub)); - assert!(matches!( - error, - StdError::Overflow { - source: OverflowError { - operation: OverflowOperation::Sub - }, - .. - } - )); - } - - #[test] - fn overflow_works_for_i64() { - let error = StdError::overflow(OverflowError::new(OverflowOperation::Sub)); - assert!(matches!( - error, - StdError::Overflow { - source: OverflowError { - operation: OverflowOperation::Sub - }, - .. - } - )); - } - - #[test] - fn divide_by_zero_works() { - let error = StdError::divide_by_zero(DivideByZeroError); - assert!(matches!( - error, - StdError::DivideByZero { - source: DivideByZeroError, - .. - } - )); - } - - #[test] - fn implements_debug() { - let error: StdError = StdError::from(OverflowError::new(OverflowOperation::Sub)); - let embedded = format!("Debug: {error:?}"); - let expected = r#"Debug: Overflow { source: OverflowError { operation: Sub }, backtrace: }"#; - assert_eq!(embedded, expected); - } - - #[test] - fn implements_display() { - let error: StdError = StdError::from(OverflowError::new(OverflowOperation::Sub)); - let embedded = format!("Display: {error}"); - assert_eq!( - embedded, - "Display: Overflow: Cannot Sub with given operands" - ); - } - - #[test] - fn implements_partial_eq() { - let u1 = StdError::from(OverflowError::new(OverflowOperation::Sub)); - let u2 = StdError::from(OverflowError::new(OverflowOperation::Sub)); - let s1 = StdError::serialize_err("Book", "Content too long"); - let s2 = StdError::serialize_err("Book", "Content too long"); - let s3 = StdError::serialize_err("Book", "Title too long"); - assert_eq!(u1, u2); - assert_ne!(u1, s1); - assert_eq!(s1, s2); - assert_ne!(s1, s3); - } - - #[test] - fn from_std_str_utf8error_works() { - let broken = Vec::from(b"Hello \xF0\x90\x80World" as &[u8]); - let error: StdError = str::from_utf8(&broken).unwrap_err().into(); - match error { - StdError::InvalidUtf8 { msg, .. } => { - assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") - } - err => panic!("Unexpected error: {err:?}"), - } - } - - #[test] - fn from_std_string_from_utf8error_works() { - let error: StdError = String::from_utf8(b"Hello \xF0\x90\x80World".to_vec()) - .unwrap_err() - .into(); - match error { - StdError::InvalidUtf8 { msg, .. } => { - assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") - } - err => panic!("Unexpected error: {err:?}"), - } - } -} diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index e8c5364d16..21fa941ad5 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -7,10 +7,10 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::coin::Coin; -use crate::errors::StdResult; use crate::prelude::*; use crate::results::{Attribute, CosmosMsg, Empty, Event, SubMsg}; use crate::timestamp::Timestamp; +use crate::StdResult; use crate::{to_json_binary, Binary}; /// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts diff --git a/packages/std/src/imports.rs b/packages/std/src/imports.rs index 1838e4245f..ef970f2286 100644 --- a/packages/std/src/imports.rs +++ b/packages/std/src/imports.rs @@ -1,7 +1,6 @@ use alloc::vec::Vec; use cosmwasm_core::{Addr, CanonicalAddr}; -use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; use crate::import_helpers::{from_high_half, from_low_half}; use crate::memory::{alloc, build_region, consume_region, Region}; use crate::results::SystemResult; @@ -15,6 +14,7 @@ use crate::{ iterator::{Order, Record}, memory::get_optional_region_address, }; +use crate::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; /// An upper bound for typical canonical address lengths (e.g. 20 in Cosmos SDK/Ethereum or 32 in Nano/Substrate) const CANONICAL_ADDRESS_BUFFER_LENGTH: usize = 64; diff --git a/packages/std/src/iterator.rs b/packages/std/src/iterator.rs index 00190aa5ca..b1d0c1f004 100644 --- a/packages/std/src/iterator.rs +++ b/packages/std/src/iterator.rs @@ -1,4 +1,4 @@ -use crate::errors::StdError; +use crate::StdError; /// A record of a key-value storage that is created through an iterator API. /// The first element (key) is always raw binary data. The second element diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 3a9be7cec9..28199b4eee 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -15,7 +15,6 @@ mod coin; mod coins; mod conversion; mod deps; -mod errors; mod ibc; mod import_helpers; #[cfg(feature = "iterator")] @@ -46,12 +45,6 @@ pub use crate::checksum::{Checksum, ChecksumError}; pub use crate::coin::{coin, coins, has_coins, Coin}; pub use crate::coins::Coins; pub use crate::deps::{Deps, DepsMut, OwnedDeps}; -pub use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - CoinFromStrError, CoinsError, ConversionOverflowError, DivideByZeroError, DivisionError, - OverflowError, OverflowOperation, RecoverPubkeyError, StdError, StdResult, SystemError, - VerificationError, -}; pub use crate::ibc::IbcChannelOpenResponse; pub use crate::ibc::{ Ibc3ChannelOpenResponse, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, @@ -122,5 +115,8 @@ pub mod testing; // Re-exports pub use cosmwasm_core as core; +pub use cosmwasm_core::CoreError as StdError; +pub use cosmwasm_core::CoreResult as StdResult; pub use cosmwasm_core::*; + pub use cosmwasm_derive::entry_point; diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 04741e960a..4f76c49b98 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -6,12 +6,12 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::coin::Coin; -use crate::errors::StdResult; #[cfg(feature = "stargate")] use crate::ibc::IbcMsg; use crate::prelude::*; #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] use crate::Decimal; +use crate::StdResult; use crate::{to_json_binary, Binary}; use super::Empty; diff --git a/packages/std/src/results/system_result.rs b/packages/std/src/results/system_result.rs index 624fe0bc3b..0623d08589 100644 --- a/packages/std/src/results/system_result.rs +++ b/packages/std/src/results/system_result.rs @@ -2,9 +2,8 @@ use core::fmt; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use super::super::errors::SystemError; - use crate::prelude::*; +use crate::SystemError; /// This is the outer result type returned by a querier to the contract. /// diff --git a/packages/std/src/serde.rs b/packages/std/src/serde.rs index 3cf2e044dd..0f97b61a61 100644 --- a/packages/std/src/serde.rs +++ b/packages/std/src/serde.rs @@ -6,8 +6,8 @@ use core::any::type_name; use serde::{de::DeserializeOwned, Serialize}; -use crate::errors::{StdError, StdResult}; use crate::Binary; +use crate::{StdError, StdResult}; #[deprecated = "use from_json instead"] pub fn from_slice(value: &[u8]) -> StdResult { diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index b7a5f870f4..e8dc5d15b7 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -16,7 +16,6 @@ use sha2::{Digest, Sha256}; use crate::coin::Coin; use crate::deps::OwnedDeps; -use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; #[cfg(feature = "stargate")] use crate::ibc::{ IbcAcknowledgement, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, @@ -51,6 +50,7 @@ use crate::{Attribute, DenomMetadata}; use crate::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse}; #[cfg(feature = "cosmwasm_1_4")] use crate::{Decimal256, DelegationRewardsResponse, DelegatorValidatorsResponse}; +use crate::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; pub const MOCK_CONTRACT_ADDR: &str = "cosmos2contract"; diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 27978afa07..a15edb3c73 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -4,7 +4,6 @@ use cosmwasm_core::{Addr, CanonicalAddr}; use serde::{de::DeserializeOwned, Serialize}; use crate::coin::Coin; -use crate::errors::{RecoverPubkeyError, StdError, StdResult, VerificationError}; #[cfg(feature = "iterator")] use crate::iterator::{Order, Record}; use crate::prelude::*; @@ -30,6 +29,7 @@ use crate::ContractInfoResponse; use crate::{from_json, to_json_binary, to_json_vec, Binary}; #[cfg(feature = "cosmwasm_1_3")] use crate::{DenomMetadata, PageRequest}; +use crate::{RecoverPubkeyError, StdError, StdResult, VerificationError}; /// Storage provides read and write access to a persistent storage. /// If you only want to provide read access, provide `&Storage` From b75be76d32e83c4bbff4ee11b26e8b9ab92f2efc Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 15 Mar 2024 13:30:59 +0100 Subject: [PATCH 30/42] Mark core as 'Internal only' in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2db467637e..b5517340c5 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The following packages are maintained here: | cosmwasm-crypto | Internal only | [![cosmwasm-crypto on crates.io](https://img.shields.io/crates/v/cosmwasm-crypto.svg)](https://crates.io/crates/cosmwasm-crypto) | [![Docs](https://docs.rs/cosmwasm-crypto/badge.svg)](https://docs.rs/cosmwasm-crypto) | [![Coverage][cov-badge-crypto]][cov-link-crypto] | | cosmwasm-derive | Internal only | [![cosmwasm-derive on crates.io](https://img.shields.io/crates/v/cosmwasm-derive.svg)](https://crates.io/crates/cosmwasm-derive) | [![Docs](https://docs.rs/cosmwasm-derive/badge.svg)](https://docs.rs/cosmwasm-derive) | [![Coverage][cov-badge-derive]][cov-link-derive] | | cosmwasm-schema | Contract development | [![cosmwasm-schema on crates.io](https://img.shields.io/crates/v/cosmwasm-schema.svg)](https://crates.io/crates/cosmwasm-schema) | [![Docs](https://docs.rs/cosmwasm-schema/badge.svg)](https://docs.rs/cosmwasm-schema) | [![Coverage][cov-badge-schema]][cov-link-schema] | -| cosmwasm-core | Contract development | [![cosmwasm-core on crates.io](https://img.shields.io/crates/v/cosmwasm-core.svg)](https://crates.io/crates/cosmwasm-core) | [![Docs](https://docs.rs/cosmwasm-core/badge.svg)](https://docs.rs/cosmwasm-core) | [![Coverage][cov-badge-core]][cov-link-core] | +| cosmwasm-core | Internal only | [![cosmwasm-core on crates.io](https://img.shields.io/crates/v/cosmwasm-core.svg)](https://crates.io/crates/cosmwasm-core) | [![Docs](https://docs.rs/cosmwasm-core/badge.svg)](https://docs.rs/cosmwasm-core) | [![Coverage][cov-badge-core]][cov-link-core] | | cosmwasm-std | Contract development | [![cosmwasm-std on crates.io](https://img.shields.io/crates/v/cosmwasm-std.svg)](https://crates.io/crates/cosmwasm-std) | [![Docs](https://docs.rs/cosmwasm-std/badge.svg)](https://docs.rs/cosmwasm-std) | [![Coverage][cov-badge-std]][cov-link-std] | | cosmwasm-vm | Host environments | [![cosmwasm-vm on crates.io](https://img.shields.io/crates/v/cosmwasm-vm.svg)](https://crates.io/crates/cosmwasm-vm) | [![Docs](https://docs.rs/cosmwasm-vm/badge.svg)](https://docs.rs/cosmwasm-vm) | [![Coverage][cov-badge-vm]][cov-link-vm] | | cosmwasm-check | Contract development | [![cosmwasm-check on crates.io](https://img.shields.io/crates/v/cosmwasm-check.svg)](https://crates.io/crates/cosmwasm-check) | `cosmwasm-check -h` | N/A | From dee1f5b37de87d092b785af9260537ba77533a4e Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 15 Mar 2024 13:47:06 +0100 Subject: [PATCH 31/42] Mark `std` feature in `cosmwasm-std` as deprecated --- packages/std/Cargo.toml | 18 ++++++++++-------- packages/std/src/lib.rs | 19 +++++++++++-------- packages/std/src/prelude.rs | 3 --- packages/std/src/testing/mock.rs | 3 +-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index e117187a60..2b1aa4ae5a 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -12,13 +12,15 @@ readme = "README.md" features = ["abort", "stargate", "staking", "cosmwasm_2_0"] [features] -default = ["iterator", "abort", "std"] +default = ["iterator", "abort"] abort = [] -# This feature can be used in the future to provide support for no_std environments, -# but disabling it will not provide any benefit at the moment. Even with this feature disabled, -# we currently require an std environment. -# You probably want to keep this enabled for now to avoid possible breaking changes later. -std = ["serde/std", "serde-json-wasm/std"] +# LEGACY. REMOVE NEXT BREAKING RELEASE. +# +# This feature is unused. This library is not intended to run without the `std` library. +# Use `cosmwasm-core` instead if you *really* need a `no_std` environment. +# +# If you need any types exclusive to `cosmwasm-std` in a `no_std` environment, open an issue to discuss moving it to `cosmwasm-core`. +std = [] # iterator allows us to iterate over all DB items in a given range # optional as some merkle stores (like tries) don't support this # given Ethereum 1.0, 2.0, Substrate, and other major projects use Tries @@ -61,8 +63,8 @@ derive_more = { version = "1.0.0-beta.6", default-features = false, features = [ hex = "0.4" schemars = { workspace = true } sha2 = "0.10.3" -serde = { workspace = true } -serde-json-wasm = { version = "1.0.1", default-features = false } +serde = { workspace = true, features = ["std"] } +serde-json-wasm = { version = "1.0.1", default-features = false, features = ["std"] } thiserror = "1.0.26" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 28199b4eee..89f117c897 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -1,12 +1,6 @@ +#[macro_use] extern crate alloc; -#[cfg(not(feature = "std"))] -core::compile_error!( - r#"Please enable `cosmwasm-std`'s `std` feature, as we might move existing functionality to that feature in the future. -Builds without the std feature are currently not expected to work. If you need no_std support see #1484. -"# -); - // Exposed on all platforms mod assertions; @@ -117,6 +111,15 @@ pub mod testing; pub use cosmwasm_core as core; pub use cosmwasm_core::CoreError as StdError; pub use cosmwasm_core::CoreResult as StdResult; -pub use cosmwasm_core::*; +pub use cosmwasm_core::{ + assert_approx_eq, from_base64, from_hex, instantiate2_address, to_base64, to_hex, Addr, Binary, + CanonicalAddr, CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, + CoinFromStrError, CoinsError, ConversionOverflowError, Decimal, Decimal256, + Decimal256RangeExceeded, DecimalRangeExceeded, DivideByZeroError, DivisionError, Fraction, + HexBinary, Instantiate2AddressError, Int128, Int256, Int512, Int64, Isqrt, OverflowError, + OverflowOperation, RecoverPubkeyError, SignedDecimal, SignedDecimal256, + SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, SystemError, Uint128, Uint256, + Uint512, Uint64, VerificationError, +}; pub use cosmwasm_derive::entry_point; diff --git a/packages/std/src/prelude.rs b/packages/std/src/prelude.rs index ad2d30b855..7a3311ad1a 100644 --- a/packages/std/src/prelude.rs +++ b/packages/std/src/prelude.rs @@ -1,6 +1,3 @@ pub use alloc::boxed::Box; -pub use alloc::format; pub use alloc::string::{String, ToString}; -pub use alloc::vec; pub use alloc::vec::Vec; -pub use core::option::Option::{self, None, Some}; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index e8dc5d15b7..c03bd03b6a 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -226,7 +226,6 @@ impl Api for MockApi { } fn debug(&self, #[allow(unused)] message: &str) { - #[cfg(feature = "std")] println!("{message}"); } } @@ -2457,7 +2456,7 @@ mod tests { } #[test] - #[cfg(all(feature = "cosmwasm_1_3", feature = "std"))] + #[cfg(feature = "cosmwasm_1_3")] fn distribution_querier_new_works() { let addresses = [ ("addr0000".to_string(), "addr0001".to_string()), From 9ab33ba0ad2a58fb9afc727c2748de439e5e06df Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 15 Mar 2024 14:23:01 +0100 Subject: [PATCH 32/42] Fix reexports --- packages/std/src/lib.rs | 7 +++++-- packages/std/src/pagination.rs | 1 - packages/std/src/results/empty.rs | 2 -- packages/std/src/timestamp.rs | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 89f117c897..a5c15dab2d 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -112,8 +112,8 @@ pub use cosmwasm_core as core; pub use cosmwasm_core::CoreError as StdError; pub use cosmwasm_core::CoreResult as StdResult; pub use cosmwasm_core::{ - assert_approx_eq, from_base64, from_hex, instantiate2_address, to_base64, to_hex, Addr, Binary, - CanonicalAddr, CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, + from_base64, from_hex, instantiate2_address, to_base64, to_hex, Addr, Binary, CanonicalAddr, + CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoinFromStrError, CoinsError, ConversionOverflowError, Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, DivideByZeroError, DivisionError, Fraction, HexBinary, Instantiate2AddressError, Int128, Int256, Int512, Int64, Isqrt, OverflowError, @@ -122,4 +122,7 @@ pub use cosmwasm_core::{ Uint512, Uint64, VerificationError, }; +#[cfg(not(target_arch = "wasm32"))] +pub use cosmwasm_core::assert_approx_eq; + pub use cosmwasm_derive::entry_point; diff --git a/packages/std/src/pagination.rs b/packages/std/src/pagination.rs index d5e979f9f7..d9d1d8ef96 100644 --- a/packages/std/src/pagination.rs +++ b/packages/std/src/pagination.rs @@ -1,7 +1,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::prelude::*; use crate::Binary; /// Simplified version of the PageRequest type for pagination from the cosmos-sdk diff --git a/packages/std/src/results/empty.rs b/packages/std/src/results/empty.rs index 6e648ec63e..c3d3771d20 100644 --- a/packages/std/src/results/empty.rs +++ b/packages/std/src/results/empty.rs @@ -1,8 +1,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::prelude::*; - /// An empty struct that serves as a placeholder in different places, /// such as contracts that don't set a custom message. /// diff --git a/packages/std/src/timestamp.rs b/packages/std/src/timestamp.rs index a0c0fe9f91..dbee152e15 100644 --- a/packages/std/src/timestamp.rs +++ b/packages/std/src/timestamp.rs @@ -3,8 +3,6 @@ use cosmwasm_core::Uint64; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::prelude::*; - /// A point in time in nanosecond precision. /// /// This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. From 5b9f75568f6db44d3e0aac35a842454be24108be Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 4 Apr 2024 14:04:50 +0200 Subject: [PATCH 33/42] Fix CI failures --- packages/core/src/binary.rs | 4 ++-- packages/core/src/errors/core_error.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/binary.rs b/packages/core/src/binary.rs index e6ae76e052..1d445c7a5a 100644 --- a/packages/core/src/binary.rs +++ b/packages/core/src/binary.rs @@ -320,8 +320,8 @@ mod tests { #[test] fn test_base64_encoding_error() { for (invalid_base64, want) in [ - ("cm%uZG9taVo", "Invalid byte 37, offset 2."), - ("cmFuZ", "Encoded text cannot have a 6-bit remainder."), + ("cm%uZG9taVo", "Invalid symbol 37, offset 2."), + ("cmFuZ", "Invalid input length: 5"), ] { match Binary::from_base64(invalid_base64) { Err(CoreError::InvalidBase64 { msg, .. }) => assert_eq!(want, msg), diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index 36de7cf67e..2851a792c5 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -625,7 +625,7 @@ mod tests { let error = CoreError::invalid_base64(original); match error { CoreError::InvalidBase64 { msg, .. } => { - assert_eq!(msg, "Encoded text cannot have a 6-bit remainder."); + assert_eq!(msg, "Invalid input length: 10"); } _ => panic!("expect different error"), } From 247f1d6a1892a69dc15710f1b7682504d6b98184 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 4 Apr 2024 18:20:16 +0200 Subject: [PATCH 34/42] Update packages/core/src/__internal.rs Co-authored-by: Christoph Otter --- packages/core/src/__internal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/__internal.rs b/packages/core/src/__internal.rs index d30bd75455..6df23be4fb 100644 --- a/packages/core/src/__internal.rs +++ b/packages/core/src/__internal.rs @@ -1,7 +1,7 @@ //! //! # ⚠ DO NOT DEPEND ON THIS AS AN OUTSIDE CONSUMER //! -//! **THIS MODULE IS SEMVER EXCEMPT AND ONLY MEANT TO SHARE TYPES BETWEEN CORE AND STD** +//! **THIS MODULE IS SEMVER EXEMPT AND ONLY MEANT TO SHARE TYPES BETWEEN CORE AND STD** //! //! Module for re-exporting implementation details from `core` to `std` //! From 92d44175fc4f238620a3c21285614ae470cf548d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 4 Apr 2024 18:20:55 +0200 Subject: [PATCH 35/42] Remove core reexport --- packages/std/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index a5c15dab2d..3cfd308935 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -108,7 +108,6 @@ pub mod testing; // Re-exports -pub use cosmwasm_core as core; pub use cosmwasm_core::CoreError as StdError; pub use cosmwasm_core::CoreResult as StdResult; pub use cosmwasm_core::{ From c7dc6b2504099174aa3bbc0fdad9c098da7726f5 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 4 Apr 2024 18:22:39 +0200 Subject: [PATCH 36/42] Import only during tests --- packages/core/src/math/conversion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/math/conversion.rs b/packages/core/src/math/conversion.rs index 87a08155c5..8b31b84617 100644 --- a/packages/core/src/math/conversion.rs +++ b/packages/core/src/math/conversion.rs @@ -1,4 +1,4 @@ -#[allow(unused_imports)] +#[cfg(test)] use alloc::string::String; /// Grows a big endian signed integer to a bigger size. From 5c770c06ad639e4712f4c5c2bd5a4b4b9456ff5d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 4 Apr 2024 18:26:06 +0200 Subject: [PATCH 37/42] Remove leftover `.map_err` --- packages/std/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index a15edb3c73..1b51b2be4e 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -278,7 +278,7 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> { SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err( format!("Querier contract error: {contract_err}"), )), - SystemResult::Ok(ContractResult::Ok(value)) => from_json(value).map_err(Into::into), + SystemResult::Ok(ContractResult::Ok(value)) => from_json(value), } } From 50bb1b390e4050a86496b2865d2d90113db21401 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 5 Apr 2024 10:07:51 +0200 Subject: [PATCH 38/42] Adjust result type --- packages/core/src/errors/core_error.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index 2851a792c5..eba2d0ce0c 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -400,9 +400,9 @@ impl From for CoreError { /// The return type for init, execute and query. Since the error type cannot be serialized to JSON, /// this is only available within the contract and its unit tests. /// -/// The prefix "Std" means "the standard result within the standard library". This is not the only -/// result/error type in cosmwasm-std. -pub type CoreResult = core::result::Result; +/// The prefix "Core"/"Std" means "the standard result within the core/standard library". This is not the only +/// result/error type in cosmwasm-core/cosmwasm-std. +pub type CoreResult = core::result::Result; #[derive(Debug, PartialEq, Eq)] pub enum OverflowOperation { From e79e51b96f7f9eed6b0551d4e1712f970fbe3ef5 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 5 Apr 2024 10:12:01 +0200 Subject: [PATCH 39/42] Remove `testing` feature from core --- packages/core/Cargo.toml | 5 ----- packages/core/src/testing/assertions.rs | 6 +++--- packages/core/src/testing/mod.rs | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index af020fd72e..7550ae8f63 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -14,7 +14,6 @@ release = false base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } bnum = "0.11.0" cosmwasm-crypto = { version = "2.0.0", path = "../crypto" } -crc32fast = { version = "1.4.0", optional = true, default-features = false } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } schemars = { version = "0.8.16", optional = true } @@ -24,10 +23,6 @@ static_assertions = "1.1.0" [features] std = ["dep:schemars"] -# Expose things that are usually gated behind `#[cfg(test)]` inside the `testing` module (do NOT use in production) -# -# Also this is semver exempt. Beware here be dragons. -testing = ["dep:crc32fast"] [dev-dependencies] # Cyclic dependencies for doc tests.. diff --git a/packages/core/src/testing/assertions.rs b/packages/core/src/testing/assertions.rs index 683455cb99..757d0d69f1 100644 --- a/packages/core/src/testing/assertions.rs +++ b/packages/core/src/testing/assertions.rs @@ -1,7 +1,7 @@ use crate::{Decimal, Uint128}; use alloc::string::String; -#[cfg(any(test, feature = "testing"))] +#[cfg(test)] use core::hash::{Hash, Hasher}; use core::str::FromStr as _; @@ -34,7 +34,7 @@ macro_rules! assert_approx_eq { /// so once working pair is identified, the test’s going to continue /// passing. #[macro_export] -#[cfg(any(test, feature = "testing"))] +#[cfg(test)] macro_rules! assert_hash_works { ($left:expr, $right:expr $(,)?) => {{ $crate::testing::assert_hash_works_impl($left, $right, None); @@ -75,7 +75,7 @@ pub fn assert_approx_eq_impl>( /// pair is identified, the test’s going to continue passing. #[track_caller] #[doc(hidden)] -#[cfg(any(test, feature = "testing"))] +#[cfg(test)] pub fn assert_hash_works_impl(left: T, right: T, panic_msg: Option) { fn hash(value: &impl Hash) -> u64 { let mut hasher = crc32fast::Hasher::default(); diff --git a/packages/core/src/testing/mod.rs b/packages/core/src/testing/mod.rs index b3bc438a93..abe4990132 100644 --- a/packages/core/src/testing/mod.rs +++ b/packages/core/src/testing/mod.rs @@ -1,5 +1,5 @@ mod assertions; pub use assertions::assert_approx_eq_impl; -#[cfg(any(test, feature = "testing"))] +#[cfg(test)] pub use assertions::assert_hash_works_impl; From db219f6bbd82312866ea699c630e3efa909fad6f Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 5 Apr 2024 10:16:29 +0200 Subject: [PATCH 40/42] Fix CI --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 86fa3147a3..9ed8c89b58 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -329,15 +329,15 @@ jobs: - run: name: Build library for native target (all features) working_directory: ~/project/packages/core - command: cargo build --locked --features std,testing + command: cargo build --locked --features std - run: name: Build library for wasm target (all features) working_directory: ~/project/packages/core - command: cargo wasm --locked --features std,testing + command: cargo wasm --locked --features std - run: name: Run unit tests (all features) working_directory: ~/project/packages/core - command: cargo test --locked --features std,testing + command: cargo test --locked --features std - save_cache: paths: - /usr/local/cargo/registry From ab6b92f2db4bacad730cfb5406ead8154afc596e Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 5 Apr 2024 10:35:30 +0200 Subject: [PATCH 41/42] Use `thiserror`, regenerate lockfiles --- Cargo.lock | 2 + contracts/burner/Cargo.lock | 2 + contracts/crypto-verify/Cargo.lock | 2 + contracts/cyberpunk/Cargo.lock | 2 + contracts/empty/Cargo.lock | 2 + contracts/floaty/Cargo.lock | 2 + contracts/hackatom/Cargo.lock | 2 + contracts/ibc-reflect-send/Cargo.lock | 2 + contracts/ibc-reflect/Cargo.lock | 2 + contracts/queue/Cargo.lock | 2 + contracts/reflect/Cargo.lock | 2 + contracts/staking/Cargo.lock | 2 + contracts/virus/Cargo.lock | 2 + packages/core/Cargo.toml | 3 +- packages/core/src/addresses.rs | 4 +- packages/core/src/errors/core_error.rs | 51 +++++-------------- .../core/src/errors/recover_pubkey_error.rs | 4 +- packages/core/src/errors/system_error.rs | 5 +- .../core/src/errors/verification_error.rs | 4 +- packages/core/src/math/decimal.rs | 4 +- packages/core/src/math/decimal256.rs | 4 +- packages/core/src/math/signed_decimal.rs | 4 +- packages/core/src/math/signed_decimal_256.rs | 4 +- packages/crypto/Cargo.toml | 3 +- packages/crypto/src/errors.rs | 4 +- 25 files changed, 53 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f9f06b1a1..e1a4b08833 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,6 +431,7 @@ dependencies = [ "serde_json", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -452,6 +453,7 @@ dependencies = [ "serde_json", "sha2", "sha3", + "thiserror", ] [[package]] diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 68e143e4e6..63c787710f 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -219,6 +219,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -232,6 +233,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 425e1b2b6f..c1fa7695b5 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -214,6 +214,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -227,6 +228,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 4bc9b154fb..f77cc6f6b2 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -237,6 +237,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -250,6 +251,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 05eb2302af..17ad39865f 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index e713a56632..1b31b84e59 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index ad298f7671..ce2d7bd0d3 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 893a53e2a3..d5919cc226 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index fc3f78b509..0c72ddd440 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 702fe9792f..a3e9a1eb72 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index a0f5490a17..9f364a70b6 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 403c6aa329..e96b0dff01 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 84d781576d..89b1351431 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -208,6 +208,7 @@ dependencies = [ "serde", "sha2", "static_assertions", + "thiserror", ] [[package]] @@ -221,6 +222,7 @@ dependencies = [ "k256", "p256", "rand_core", + "thiserror", ] [[package]] diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 7550ae8f63..cc93341612 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -20,9 +20,10 @@ schemars = { version = "0.8.16", optional = true } serde = { version = "1.0.197", default-features = false, features = ["alloc", "derive"] } sha2 = { version = "0.10.8", default-features = false } static_assertions = "1.1.0" +thiserror = { version = "1.0.26", optional = true } [features] -std = ["dep:schemars"] +std = ["dep:schemars", "dep:thiserror"] [dev-dependencies] # Cyclic dependencies for doc tests.. diff --git a/packages/core/src/addresses.rs b/packages/core/src/addresses.rs index c9d89d82e9..c4e18e98aa 100644 --- a/packages/core/src/addresses.rs +++ b/packages/core/src/addresses.rs @@ -250,6 +250,7 @@ impl fmt::Display for CanonicalAddr { } #[derive(Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum Instantiate2AddressError { /// Checksum must be 32 bytes InvalidChecksumLength, @@ -266,9 +267,6 @@ impl fmt::Display for Instantiate2AddressError { } } -#[cfg(feature = "std")] -impl std::error::Error for Instantiate2AddressError {} - /// Creates a contract address using the predictable address format introduced with /// wasmd 0.29. When using instantiate2, this is a way to precompute the address. /// When using instantiate, the contract address will use a different algorithm and diff --git a/packages/core/src/errors/core_error.rs b/packages/core/src/errors/core_error.rs index eba2d0ce0c..39fefad28e 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/core/src/errors/core_error.rs @@ -22,6 +22,7 @@ use crate::errors::{RecoverPubkeyError, VerificationError}; /// - Add enum case /// - Add creator function in std_error_helpers.rs #[derive(Display, Debug)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum CoreError { #[display("Verification error: {source}")] VerificationErr { @@ -178,9 +179,6 @@ impl CoreError { } } -#[cfg(feature = "std")] -impl std::error::Error for CoreError {} - impl PartialEq for CoreError { fn eq(&self, rhs: &CoreError) -> bool { match self { @@ -421,6 +419,7 @@ impl fmt::Display for OverflowOperation { } #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Cannot {operation} with given operands")] pub struct OverflowError { pub operation: OverflowOperation, @@ -432,9 +431,6 @@ impl OverflowError { } } -#[cfg(feature = "std")] -impl std::error::Error for OverflowError {} - /// The error returned by [`TryFrom`] conversions that overflow, for example /// when converting from [`Uint256`] to [`Uint128`]. /// @@ -442,6 +438,7 @@ impl std::error::Error for OverflowError {} /// [`Uint256`]: crate::Uint256 /// [`Uint128`]: crate::Uint128 #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Error converting {source_type} to {target_type}")] pub struct ConversionOverflowError { pub source_type: &'static str, @@ -457,10 +454,8 @@ impl ConversionOverflowError { } } -#[cfg(feature = "std")] -impl std::error::Error for ConversionOverflowError {} - #[derive(Display, Debug, Default, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Cannot divide by zero")] pub struct DivideByZeroError; @@ -470,10 +465,8 @@ impl DivideByZeroError { } } -#[cfg(feature = "std")] -impl std::error::Error for DivideByZeroError {} - #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum DivisionError { #[display("Divide by zero")] DivideByZero, @@ -482,10 +475,9 @@ pub enum DivisionError { Overflow, } -#[cfg(feature = "std")] -impl std::error::Error for DivisionError {} - -#[derive(Display, Debug, From, PartialEq, Eq)] +#[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[cfg_attr(not(feature = "std"), derive(From))] pub enum CheckedMultiplyFractionError { #[display("{_0}")] DivideByZero(#[from] DivideByZeroError), @@ -497,10 +489,8 @@ pub enum CheckedMultiplyFractionError { Overflow(#[from] OverflowError), } -#[cfg(feature = "std")] -impl std::error::Error for CheckedMultiplyFractionError {} - #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum CheckedMultiplyRatioError { #[display("Denominator must not be zero")] DivideByZero, @@ -509,10 +499,8 @@ pub enum CheckedMultiplyRatioError { Overflow, } -#[cfg(feature = "std")] -impl std::error::Error for CheckedMultiplyRatioError {} - #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum CheckedFromRatioError { #[display("Denominator must not be zero")] DivideByZero, @@ -521,32 +509,23 @@ pub enum CheckedFromRatioError { Overflow, } -#[cfg(feature = "std")] -impl std::error::Error for CheckedFromRatioError {} - #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Round up operation failed because of overflow")] pub struct RoundUpOverflowError; -#[cfg(feature = "std")] -impl std::error::Error for RoundUpOverflowError {} - #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Round down operation failed because of overflow")] pub struct RoundDownOverflowError; -#[cfg(feature = "std")] -impl std::error::Error for RoundDownOverflowError {} - #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum CoinsError { #[display("Duplicate denom")] DuplicateDenom, } -#[cfg(feature = "std")] -impl std::error::Error for CoinsError {} - impl From for CoreError { fn from(value: CoinsError) -> Self { Self::generic_err(format!("Creating Coins: {value}")) @@ -554,6 +533,7 @@ impl From for CoreError { } #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum CoinFromStrError { #[display("Missing denominator")] MissingDenom, @@ -563,9 +543,6 @@ pub enum CoinFromStrError { InvalidAmount(core::num::ParseIntError), } -#[cfg(feature = "std")] -impl std::error::Error for CoinFromStrError {} - impl From for CoinFromStrError { fn from(value: core::num::ParseIntError) -> Self { Self::InvalidAmount(value) diff --git a/packages/core/src/errors/recover_pubkey_error.rs b/packages/core/src/errors/recover_pubkey_error.rs index 5e15230d95..d9b432120d 100644 --- a/packages/core/src/errors/recover_pubkey_error.rs +++ b/packages/core/src/errors/recover_pubkey_error.rs @@ -6,6 +6,7 @@ use derive_more::Display; use super::BT; #[derive(Display, Debug)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum RecoverPubkeyError { #[display("Invalid hash format")] InvalidHashFormat, @@ -27,9 +28,6 @@ impl RecoverPubkeyError { } } -#[cfg(feature = "std")] -impl std::error::Error for RecoverPubkeyError {} - impl PartialEq for RecoverPubkeyError { fn eq(&self, rhs: &RecoverPubkeyError) -> bool { match self { diff --git a/packages/core/src/errors/system_error.rs b/packages/core/src/errors/system_error.rs index f43c41a05f..b146233da2 100644 --- a/packages/core/src/errors/system_error.rs +++ b/packages/core/src/errors/system_error.rs @@ -13,7 +13,7 @@ use crate::Binary; /// Such errors are only created by the VM. The error type is defined in the standard library, to ensure /// the contract understands the error format without creating a dependency on cosmwasm-vm. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +#[cfg_attr(feature = "std", derive(schemars::JsonSchema, thiserror::Error))] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub enum SystemError { @@ -40,9 +40,6 @@ pub enum SystemError { }, } -#[cfg(feature = "std")] -impl std::error::Error for SystemError {} - impl core::fmt::Display for SystemError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { diff --git a/packages/core/src/errors/verification_error.rs b/packages/core/src/errors/verification_error.rs index 7a130a07b5..c13139a980 100644 --- a/packages/core/src/errors/verification_error.rs +++ b/packages/core/src/errors/verification_error.rs @@ -7,6 +7,7 @@ use super::BT; use cosmwasm_crypto::CryptoError; #[derive(Display, Debug)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum VerificationError { #[display("Batch error")] BatchErr, @@ -34,9 +35,6 @@ impl VerificationError { } } -#[cfg(feature = "std")] -impl std::error::Error for VerificationError {} - impl PartialEq for VerificationError { fn eq(&self, rhs: &VerificationError) -> bool { match self { diff --git a/packages/core/src/math/decimal.rs b/packages/core/src/math/decimal.rs index 2fa16547d7..831b956d80 100644 --- a/packages/core/src/math/decimal.rs +++ b/packages/core/src/math/decimal.rs @@ -27,12 +27,10 @@ pub struct Decimal(#[cfg_attr(feature = "std", schemars(with = "String"))] Uint1 forward_ref_partial_eq!(Decimal, Decimal); #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Decimal range exceeded")] pub struct DecimalRangeExceeded; -#[cfg(feature = "std")] -impl std::error::Error for DecimalRangeExceeded {} - impl Decimal { const DECIMAL_FRACTIONAL: Uint128 = Uint128::new(1_000_000_000_000_000_000u128); // 1*10**18 const DECIMAL_FRACTIONAL_SQUARED: Uint128 = diff --git a/packages/core/src/math/decimal256.rs b/packages/core/src/math/decimal256.rs index 164254f96a..5cdaf4863e 100644 --- a/packages/core/src/math/decimal256.rs +++ b/packages/core/src/math/decimal256.rs @@ -29,12 +29,10 @@ pub struct Decimal256(#[cfg_attr(feature = "std", schemars(with = "String"))] Ui forward_ref_partial_eq!(Decimal256, Decimal256); #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("Decimal256 range exceeded")] pub struct Decimal256RangeExceeded; -#[cfg(feature = "std")] -impl std::error::Error for Decimal256RangeExceeded {} - impl Decimal256 { const DECIMAL_FRACTIONAL: Uint256 = // 1*10**18 Uint256::from_u128(1_000_000_000_000_000_000); diff --git a/packages/core/src/math/signed_decimal.rs b/packages/core/src/math/signed_decimal.rs index 5e6dba24a4..bffd426bc3 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/core/src/math/signed_decimal.rs @@ -29,12 +29,10 @@ pub struct SignedDecimal(#[cfg_attr(feature = "std", schemars(with = "String"))] forward_ref_partial_eq!(SignedDecimal, SignedDecimal); #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("SignedDecimal range exceeded")] pub struct SignedDecimalRangeExceeded; -#[cfg(feature = "std")] -impl std::error::Error for SignedDecimalRangeExceeded {} - impl SignedDecimal { const DECIMAL_FRACTIONAL: Int128 = Int128::new(1_000_000_000_000_000_000i128); // 1*10**18 const DECIMAL_FRACTIONAL_SQUARED: Int128 = diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/core/src/math/signed_decimal_256.rs index 9819d44807..d47649e6f3 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/core/src/math/signed_decimal_256.rs @@ -34,12 +34,10 @@ pub struct SignedDecimal256(#[cfg_attr(feature = "std", schemars(with = "String" forward_ref_partial_eq!(SignedDecimal256, SignedDecimal256); #[derive(Display, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[display("SignedDecimal256 range exceeded")] pub struct SignedDecimal256RangeExceeded; -#[cfg(feature = "std")] -impl std::error::Error for SignedDecimal256RangeExceeded {} - impl SignedDecimal256 { const DECIMAL_FRACTIONAL: Int256 = // 1*10**18 Int256::from_i128(1_000_000_000_000_000_000); diff --git a/packages/crypto/Cargo.toml b/packages/crypto/Cargo.toml index e6cacc36ec..ae90529986 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" [features] default = [] -std = [] +std = ["dep:thiserror"] [lib] # See https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options @@ -24,6 +24,7 @@ rand_core = "0.6" # Not used directly, but needed to bump transitive dependency, see: https://github.com/CosmWasm/cosmwasm/pull/1899 for details. ecdsa = "0.16.2" p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] } +thiserror = { version = "1.0.26", optional = true } [dev-dependencies] criterion = "0.5.1" diff --git a/packages/crypto/src/errors.rs b/packages/crypto/src/errors.rs index 0f2f5df9f1..989427fba7 100644 --- a/packages/crypto/src/errors.rs +++ b/packages/crypto/src/errors.rs @@ -7,6 +7,7 @@ use crate::BT; pub type CryptoResult = core::result::Result; #[derive(Display, Debug)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum CryptoError { #[display("Batch verify error: {msg}")] BatchErr { msg: String, backtrace: BT }, @@ -22,9 +23,6 @@ pub enum CryptoError { InvalidRecoveryParam { backtrace: BT }, } -#[cfg(feature = "std")] -impl std::error::Error for CryptoError {} - impl CryptoError { pub fn batch_err(msg: impl Into) -> Self { CryptoError::BatchErr { From 026040e313841a6071e7788ff987c1d935ba1f1c Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 5 Apr 2024 10:37:35 +0200 Subject: [PATCH 42/42] Adjust version of `cosmwasm-core` --- contracts/burner/Cargo.lock | 2 +- contracts/crypto-verify/Cargo.lock | 2 +- contracts/cyberpunk/Cargo.lock | 2 +- contracts/empty/Cargo.lock | 2 +- contracts/floaty/Cargo.lock | 2 +- contracts/hackatom/Cargo.lock | 2 +- contracts/ibc-reflect-send/Cargo.lock | 2 +- contracts/ibc-reflect/Cargo.lock | 2 +- contracts/queue/Cargo.lock | 2 +- contracts/reflect/Cargo.lock | 2 +- contracts/staking/Cargo.lock | 2 +- contracts/virus/Cargo.lock | 2 +- packages/core/Cargo.toml | 4 ++-- packages/std/Cargo.toml | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 63c787710f..bf40b531fd 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -208,7 +208,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index c1fa7695b5..c949e716bc 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -203,7 +203,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index f77cc6f6b2..1508ee0e12 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64 0.22.0", "bnum", diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 17ad39865f..7f256a5b85 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 1b31b84e59..4ade5373ba 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index ce2d7bd0d3..936911c156 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index d5919cc226..1a26458f65 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 0c72ddd440..1149e062ad 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index a3e9a1eb72..2e30b080d8 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 9f364a70b6..6ae7c92024 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index e96b0dff01..b3c391445c 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 89b1351431..770cbced79 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.0.0" +version = "2.0.1" dependencies = [ "base64", "bnum", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index cc93341612..05dfbcb478 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -13,7 +13,7 @@ release = false [dependencies] base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } bnum = "0.11.0" -cosmwasm-crypto = { version = "2.0.0", path = "../crypto" } +cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } schemars = { version = "0.8.16", optional = true } @@ -27,7 +27,7 @@ std = ["dep:schemars", "dep:thiserror"] [dev-dependencies] # Cyclic dependencies for doc tests.. -cosmwasm-std = { path = "../std", version = "2.0.0" } +cosmwasm-std = { path = "../std", version = "2.0.1" } crc32fast = { version = "1.4.0", default-features = false } hex-literal = "0.4.1" serde_json = "1.0.114" diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 2b1aa4ae5a..32d3573214 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -73,7 +73,7 @@ cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } rand_core = { version = "0.6.4", features = ["getrandom"] } [dev-dependencies] -cosmwasm-core = { path = "../core", version = "2.0.1", features = ["testing"] } +cosmwasm-core = { path = "../core", version = "2.0.1" } cosmwasm-schema = { version = "2.0.1", path = "../schema" } # The chrono dependency is only used in an example, which Rust compiles for us. If this causes trouble, remove it. chrono = { version = "0.4", default-features = false, features = ["alloc", "std"] }