From 6c22540bc8c957ebe8f13cca1c2f42672f10c862 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 28 Oct 2023 23:17:38 +0100 Subject: [PATCH 1/3] new attempt --- .gitignore | 4 ++++ Cargo.lock | 12 ++++++------ packages/std/Cargo.toml | 9 ++++++--- packages/std/src/lib.rs | 3 +++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 6f20a8ecdb..3c34242e7d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ artifacts/ # Log files (e.g. memory profiling) *.log + + +rust-toolchain.toml +shell.nix \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 63a065d6ec..b0700a9688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1940,18 +1940,18 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.180" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.5.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" dependencies = [ "serde", ] @@ -1969,9 +1969,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.180" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 8099d51c99..d2dd03b9a6 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" features = ["abort", "stargate", "staking", "ibc3", "cosmwasm_1_4"] [features] -default = ["iterator", "abort"] +default = ["iterator", "abort", "std"] abort = [] # iterator allows us to iterate over all DB items in a given range # optional as some merkle stores (like tries) don't support this @@ -49,6 +49,9 @@ cosmwasm_1_3 = ["cosmwasm_1_2"] # It requires the host blockchain to run CosmWasm `1.4.0` or higher. cosmwasm_1_4 = ["cosmwasm_1_3"] +unstable = ["serde/unstable", "serde-json-wasm/unstable"] +std = ["serde/std","serde-json-wasm/std"] + [dependencies] base64 = "0.21.0" cosmwasm-derive = { path = "../derive", version = "1.5.0-rc.0" } @@ -57,11 +60,11 @@ forward_ref = "1" hex = "0.4" schemars = "0.8.3" sha2 = "0.10.3" -serde = { version = "1.0.103", default-features = false, features = [ +serde = { version = "^1.0.181", default-features = false, features = [ "derive", "alloc", ] } -serde-json-wasm = { version = "0.5.0" } +serde-json-wasm = { version = "1.0.0", default-features = false} thiserror = "1.0.26" bnum = "0.8.0" static_assertions = "1.1.0" diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index ea04f23dc1..74e7891d6b 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -1,7 +1,10 @@ #![cfg_attr(feature = "backtraces", feature(error_generic_member_access))] #![cfg_attr(feature = "backtraces", feature(provide_any))] +#![no_std] extern crate alloc; +#[cfg(test)] +extern crate std; // Exposed on all platforms From 4675dc12b34b7157de42729238ccd4c1ae7cb9d3 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 28 Oct 2023 23:26:14 +0100 Subject: [PATCH 2/3] another attempt --- packages/std/src/sections.rs | 1 + packages/std/src/testing/shuffle.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/std/src/sections.rs b/packages/std/src/sections.rs index 89433f5537..f784a7e7c0 100644 --- a/packages/std/src/sections.rs +++ b/packages/std/src/sections.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; use crate::conversion::force_to_u32; /// A sections decoder for the special case of two elements diff --git a/packages/std/src/testing/shuffle.rs b/packages/std/src/testing/shuffle.rs index aa04c17ff2..c581390935 100644 --- a/packages/std/src/testing/shuffle.rs +++ b/packages/std/src/testing/shuffle.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; /// Performs a perfect shuffle (in shuffle) /// /// https://en.wikipedia.org/wiki/Riffle_shuffle_permutation#Perfect_shuffles From b8f6577ef01a024ec4ce13b9c269c1e0f1248940 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 28 Oct 2023 23:29:34 +0100 Subject: [PATCH 3/3] vec vec --- packages/std/src/storage.rs | 1 + packages/std/src/traits.rs | 1 + packages/std/src/types.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/std/src/storage.rs b/packages/std/src/storage.rs index 26d7f710d2..f0bc388462 100644 --- a/packages/std/src/storage.rs +++ b/packages/std/src/storage.rs @@ -1,5 +1,6 @@ use alloc::collections::BTreeMap; use core::fmt; +use alloc::vec::Vec; #[cfg(feature = "iterator")] use core::iter; #[cfg(feature = "iterator")] diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 12f9824c0c..01cc1ce2e5 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -1,5 +1,6 @@ use core::marker::PhantomData; use core::ops::Deref; +use alloc::vec::Vec; use serde::{de::DeserializeOwned, Serialize}; use crate::addresses::{Addr, CanonicalAddr}; diff --git a/packages/std/src/types.rs b/packages/std/src/types.rs index 782ad1e726..4062bc9cb4 100644 --- a/packages/std/src/types.rs +++ b/packages/std/src/types.rs @@ -1,6 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use alloc::vec::Vec; use crate::addresses::Addr; use crate::coin::Coin; use crate::timestamp::Timestamp;