From 0c08a80361158419fe239be3bffe6ad9f5fc3442 Mon Sep 17 00:00:00 2001 From: Dzmitry Lahoda Date: Sun, 25 Dec 2022 14:08:58 +0000 Subject: [PATCH 1/4] no-std --- Cargo.lock | 67 ++++++++++++++++++++++----------------------- Cargo.toml | 9 +++--- src/cw_std.rs | 62 +++++++++++++++++++++++++++++++++++++++++ src/de.rs | 7 +++-- src/deque.rs | 6 ++-- src/endian.rs | 3 +- src/helpers.rs | 5 ++-- src/int_key.rs | 3 +- src/item.rs | 3 +- src/iter_helpers.rs | 1 + src/keys.rs | 2 +- src/lib.rs | 6 ++++ src/map.rs | 5 ++-- src/path.rs | 6 ++-- src/prefix.rs | 4 +-- 15 files changed, 131 insertions(+), 58 deletions(-) create mode 100644 src/cw_std.rs diff --git a/Cargo.lock b/Cargo.lock index 8991cd8..a6a87d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "atty" version = "0.2.14" @@ -116,9 +127,8 @@ checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" [[package]] name = "cosmwasm-crypto" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532d2ba11b7157e3b67114389925568af29ce3e452b582d6bdfe751cb2dadfb1" +version = "1.1.6" +source = "git+https://github.com/ComposableFi/cosmwasm.git?rev=21351cc1ced863b9af7c8a69f923036bc919b3b1#21351cc1ced863b9af7c8a69f923036bc919b3b1" dependencies = [ "digest 0.10.5", "ed25519-zebra", @@ -129,18 +139,16 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8568b289cc366981319ab39edd85d666456456f7c126433ef065ebe5257f27b2" +version = "1.1.6" +source = "git+https://github.com/ComposableFi/cosmwasm.git?rev=21351cc1ced863b9af7c8a69f923036bc919b3b1#21351cc1ced863b9af7c8a69f923036bc919b3b1" dependencies = [ "syn", ] [[package]] name = "cosmwasm-std" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1ceebd520a10167e35080e4f55f6b0284bb8ea364dec0f22197da96acd9e64" +version = "1.1.6" +source = "git+https://github.com/ComposableFi/cosmwasm.git?rev=21351cc1ced863b9af7c8a69f923036bc919b3b1#21351cc1ced863b9af7c8a69f923036bc919b3b1" dependencies = [ "base64", "cosmwasm-crypto", @@ -315,7 +323,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "1.0.1" +version = "1.0.2" dependencies = [ "cosmwasm-std", "criterion", @@ -388,16 +396,16 @@ dependencies = [ [[package]] name = "ed25519-zebra" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek", + "hashbrown", "hex", "rand_core 0.6.4", "serde", "sha2 0.9.9", - "thiserror", "zeroize", ] @@ -453,17 +461,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.7" @@ -472,7 +469,7 @@ checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -492,6 +489,15 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -701,9 +707,6 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] [[package]] name = "rand_core" @@ -711,7 +714,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom", ] [[package]] @@ -1052,12 +1055,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 0acef9c..c764b5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "cw-storage-plus" -version = "1.0.1" +version = "1.0.2" authors = ["Ethan Frey "] edition = "2021" description = "Enhanced storage engines" @@ -14,18 +14,19 @@ homepage = "https://cosmwasm.com" all-features = true # include macro feature when building docs [features] -default = ["iterator"] +default = ["iterator", "std"] iterator = ["cosmwasm-std/iterator"] macro = ["cw-storage-macro"] +std = ["cosmwasm-std/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] -cosmwasm-std = { version = "1.1.6", default-features = false } +cosmwasm-std = { git = "https://github.com/ComposableFi/cosmwasm.git", rev = "21351cc1ced863b9af7c8a69f923036bc919b3b1", default-features = false } schemars = "0.8.3" -serde = { version = "1.0", default-features = false, features = ["derive"] } +serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } cw-storage-macro = { version = "1.0.0", optional = true, path = "macros" } [dev-dependencies] diff --git a/src/cw_std.rs b/src/cw_std.rs new file mode 100644 index 0000000..efe0cca --- /dev/null +++ b/src/cw_std.rs @@ -0,0 +1,62 @@ +// no_std support + +#[cfg(feature = "std")] +pub use std::vec::Vec; + +#[cfg(not(feature = "std"))] +pub use alloc::vec; + +#[cfg(not(feature = "std"))] +pub use core::mem; +#[cfg(feature = "std")] +use std::mem; + +pub mod ops { + #[cfg(not(feature = "std"))] + pub use core::ops::Deref; + #[cfg(feature = "std")] + use std::ops::Deref; +} + +pub mod string { + #[cfg(feature = "std")] + pub use std::string::String; + + #[cfg(not(feature = "std"))] + pub use alloc::string::String; +} + +pub mod marker { + #[cfg(not(feature = "std"))] + pub use core::marker::PhantomData; + #[cfg(feature = "std")] + pub use std::marker::PhantomData; +} + +pub mod array { + #[cfg(feature = "std")] + pub use std::array::TryFromSliceError; + + #[cfg(not(feature = "std"))] + pub use core::array::TryFromSliceError; +} + +pub mod convert { + #[cfg(feature = "std")] + pub use std::convert::TryInto; + + #[cfg(not(feature = "std"))] + pub use core::convert::TryInto; +} + +pub mod any { + #[cfg(feature = "std")] + pub use std::any::type_name; + + #[cfg(not(feature = "std"))] + pub use core::any::type_name; +} + +pub mod prelude { + pub use crate::cw_std::{string::String, vec::Vec}; +} diff --git a/src/de.rs b/src/de.rs index 65b3f57..805fc02 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1,6 +1,6 @@ -use std::array::TryFromSliceError; -use std::convert::TryInto; - +use crate::cw_std::array::TryFromSliceError; +use crate::cw_std::convert::TryInto; +use crate::cw_std::prelude::*; use cosmwasm_std::{Addr, StdError, StdResult}; use crate::int_key::IntKey; @@ -200,6 +200,7 @@ impl KeyDeserialize for mod test { use super::*; use crate::PrimaryKey; + use crate::cw_std::prelude::*; const BYTES: &[u8] = b"Hello"; const STRING: &str = "Hello"; diff --git a/src/deque.rs b/src/deque.rs index 01932a5..a0dad95 100644 --- a/src/deque.rs +++ b/src/deque.rs @@ -1,5 +1,5 @@ -use std::{any::type_name, convert::TryInto, marker::PhantomData}; - +use crate::cw_std::{any::type_name, convert::TryInto, marker::PhantomData}; +use crate::cw_std::prelude::*; use cosmwasm_std::{to_vec, StdError, StdResult, Storage}; use serde::{de::DeserializeOwned, Serialize}; @@ -291,7 +291,7 @@ where #[cfg(test)] mod tests { use crate::deque::Deque; - + use crate::cw_std::{vec::Vec, string::String}; use cosmwasm_std::testing::MockStorage; use cosmwasm_std::{StdError, StdResult}; use serde::{Deserialize, Serialize}; diff --git a/src/endian.rs b/src/endian.rs index eeab878..5f40889 100644 --- a/src/endian.rs +++ b/src/endian.rs @@ -7,7 +7,8 @@ // TODO: figure out these macros and let us replace (self: Self) with self #![allow(clippy::needless_arbitrary_self_type)] -use std::mem; +use crate::cw_std::mem; +use crate::cw_std::prelude::*; pub trait Endian: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; diff --git a/src/helpers.rs b/src/helpers.rs index 701b014..0cf2786 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -5,8 +5,8 @@ //! and is in no way specific to any kind of storage. use serde::de::DeserializeOwned; -use std::any::type_name; - +use crate::cw_std::any::type_name; +use crate::cw_std::prelude::*; use crate::keys::Key; use cosmwasm_std::{ @@ -123,6 +123,7 @@ pub(crate) fn query_raw( #[cfg(test)] mod test { use super::*; + use crate::cw_std::prelude::*; use cosmwasm_std::{to_vec, StdError}; use serde::{Deserialize, Serialize}; diff --git a/src/int_key.rs b/src/int_key.rs index 0292674..2f18469 100644 --- a/src/int_key.rs +++ b/src/int_key.rs @@ -1,4 +1,5 @@ -use std::mem; +use crate::cw_std::vec::Vec; +use crate::cw_std::mem; /// Our int keys are simply the big-endian representation bytes for unsigned ints, /// but "sign-flipped" (xored msb) big-endian bytes for signed ints. diff --git a/src/item.rs b/src/item.rs index eec9c6d..2786d36 100644 --- a/src/item.rs +++ b/src/item.rs @@ -1,6 +1,7 @@ use serde::de::DeserializeOwned; use serde::Serialize; -use std::marker::PhantomData; +use crate::cw_std::marker::PhantomData; +use crate::cw_std::prelude::*; use cosmwasm_std::{ to_vec, Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage, WasmQuery, diff --git a/src/iter_helpers.rs b/src/iter_helpers.rs index fa9ad66..09002bc 100644 --- a/src/iter_helpers.rs +++ b/src/iter_helpers.rs @@ -1,4 +1,5 @@ #![cfg(feature = "iterator")] +use crate::cw_std::vec; use serde::de::DeserializeOwned; diff --git a/src/keys.rs b/src/keys.rs index 5b2be86..db70eb8 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -1,5 +1,5 @@ use cosmwasm_std::Addr; - +use crate::cw_std::{vec::Vec, string::String}; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::IntKey; diff --git a/src/lib.rs b/src/lib.rs index 20e0082..70b32a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,11 @@ the full power of generics. For more information on this package, please check out the [README](https://github.com/CosmWasm/cw-plus/blob/main/packages/storage-plus/README.md). */ +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +#[macro_use] +extern crate alloc; mod bound; mod de; @@ -29,6 +34,7 @@ mod map; mod path; mod prefix; mod snapshot; +mod cw_std; #[cfg(feature = "iterator")] pub use bound::{Bound, Bounder, PrefixBound, RawBound}; diff --git a/src/map.rs b/src/map.rs index 322cdee..ac3fcbe 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,6 +1,7 @@ use serde::de::DeserializeOwned; use serde::Serialize; -use std::marker::PhantomData; +use crate::cw_std::marker::PhantomData; +use crate::cw_std::{vec::Vec, string::String}; #[cfg(feature = "iterator")] use crate::bound::{Bound, PrefixBound}; @@ -294,7 +295,7 @@ where mod test { use super::*; use serde::{Deserialize, Serialize}; - use std::ops::Deref; + use crate::cw_std::ops::Deref; use cosmwasm_std::testing::MockStorage; use cosmwasm_std::to_binary; diff --git a/src/path.rs b/src/path.rs index e6a3cb5..c0412a0 100644 --- a/src/path.rs +++ b/src/path.rs @@ -1,11 +1,11 @@ use serde::de::DeserializeOwned; use serde::Serialize; -use std::marker::PhantomData; - +use crate::cw_std::marker::PhantomData; +use crate::cw_std::ops::Deref; +use crate::cw_std::vec::Vec; use crate::helpers::{may_deserialize, must_deserialize, nested_namespaces_with_key}; use crate::keys::Key; use cosmwasm_std::{to_vec, StdError, StdResult, Storage}; -use std::ops::Deref; #[derive(Debug, Clone)] pub struct Path diff --git a/src/prefix.rs b/src/prefix.rs index a1dbc4f..d86c516 100644 --- a/src/prefix.rs +++ b/src/prefix.rs @@ -4,9 +4,9 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::fmt::Debug; use std::marker::PhantomData; - +use crate::cw_std::vec::Vec; use cosmwasm_std::{Order, Record, StdResult, Storage}; -use std::ops::Deref; +use cw_std::ops::Deref; use crate::bound::{PrefixBound, RawBound}; use crate::de::KeyDeserialize; From 1dd917aca0436c529561819399f554d825861f8d Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Thu, 8 Jun 2023 01:41:26 +0100 Subject: [PATCH 2/4] rebased and fixed --- Cargo.lock | 344 +++------------------------------------- Cargo.toml | 6 +- rust-toolchain.toml | 11 ++ shell.nix | 23 +++ src/bound.rs | 3 +- src/cw_std.rs | 62 -------- src/de.rs | 8 +- src/deque.rs | 6 +- src/endian.rs | 4 +- src/helpers.rs | 8 +- src/indexed_map.rs | 1 + src/indexed_snapshot.rs | 1 + src/indexes/multi.rs | 3 +- src/indexes/unique.rs | 3 +- src/int_key.rs | 4 +- src/item.rs | 4 +- src/iter_helpers.rs | 2 +- src/keys.rs | 4 +- src/lib.rs | 4 +- src/map.rs | 6 +- src/no_std.rs | 130 +++++++++++++++ src/path.rs | 10 +- src/prefix.rs | 11 +- src/snapshot/map.rs | 1 + 24 files changed, 231 insertions(+), 428 deletions(-) create mode 100644 rust-toolchain.toml create mode 100644 shell.nix delete mode 100644 src/cw_std.rs create mode 100644 src/no_std.rs diff --git a/Cargo.lock b/Cargo.lock index a6a87d8..0b57977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,17 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "atty" version = "0.2.14" @@ -30,39 +19,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" -[[package]] -name = "base64ct" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" - [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.10.3" @@ -119,39 +87,20 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "const-oid" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" - -[[package]] -name = "cosmwasm-crypto" -version = "1.1.6" -source = "git+https://github.com/ComposableFi/cosmwasm.git?rev=21351cc1ced863b9af7c8a69f923036bc919b3b1#21351cc1ced863b9af7c8a69f923036bc919b3b1" -dependencies = [ - "digest 0.10.5", - "ed25519-zebra", - "k256", - "rand_core 0.6.4", - "thiserror", -] - [[package]] name = "cosmwasm-derive" -version = "1.1.6" -source = "git+https://github.com/ComposableFi/cosmwasm.git?rev=21351cc1ced863b9af7c8a69f923036bc919b3b1#21351cc1ced863b9af7c8a69f923036bc919b3b1" +version = "1.2.5" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e#7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e" dependencies = [ "syn", ] [[package]] name = "cosmwasm-std" -version = "1.1.6" -source = "git+https://github.com/ComposableFi/cosmwasm.git?rev=21351cc1ced863b9af7c8a69f923036bc919b3b1#21351cc1ced863b9af7c8a69f923036bc919b3b1" +version = "1.2.5" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e#7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e" dependencies = [ "base64", - "cosmwasm-crypto", "cosmwasm-derive", "derivative", "forward_ref", @@ -159,7 +108,8 @@ dependencies = [ "schemars", "serde", "serde-json-wasm", - "thiserror", + "sha2", + "thiserror-core", "uint", ] @@ -257,18 +207,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -301,19 +239,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - [[package]] name = "cw-storage-macro" version = "1.0.1" @@ -335,16 +260,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "der" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "derivative" version = "2.2.0" @@ -356,24 +271,14 @@ dependencies = [ "syn", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" dependencies = [ - "block-buffer 0.10.3", + "block-buffer", "crypto-common", - "subtle", ] [[package]] @@ -382,69 +287,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" -dependencies = [ - "curve25519-dalek", - "hashbrown", - "hex", - "rand_core 0.6.4", - "serde", - "sha2 0.9.9", - "zeroize", -] - [[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest 0.10.5", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "ff" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df689201f395c6b90dfe87127685f8dbfc083a5e779e613575d8bd7314300c3e" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "forward_ref" version = "1.0.0" @@ -461,43 +309,12 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "half" version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] - [[package]] name = "hermit-abi" version = "0.1.19" @@ -513,15 +330,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.5", -] - [[package]] name = "itertools" version = "0.10.5" @@ -552,18 +360,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -631,22 +427,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - [[package]] name = "plotters" version = "0.3.4" @@ -699,23 +479,14 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] [[package]] name = "rand_xoshiro" @@ -723,7 +494,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -771,17 +542,6 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" -[[package]] -name = "rfc6979" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" -dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", -] - [[package]] name = "ryu" version = "1.0.11" @@ -827,20 +587,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.145" @@ -852,9 +598,8 @@ dependencies = [ [[package]] name = "serde-json-wasm" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" +version = "0.5.1" +source = "git+https://github.com/dzmitry-lahoda-forks/serde-json-wasm?rev=8a7e522c0e4de36a6dfb535766f26a9941017d81#8a7e522c0e4de36a6dfb535766f26a9941017d81" dependencies = [ "serde", ] @@ -902,19 +647,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.6" @@ -923,27 +655,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.5", - "rand_core 0.6.4", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", + "digest", ] [[package]] @@ -952,12 +664,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "1.0.102" @@ -979,19 +685,19 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "1.0.37" +name = "thiserror-core" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497" dependencies = [ - "thiserror-impl", + "thiserror-core-impl", ] [[package]] -name = "thiserror-impl" -version = "1.0.37" +name = "thiserror-core-impl" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac" dependencies = [ "proc-macro2", "quote", @@ -1055,12 +761,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasm-bindgen" version = "0.2.83" @@ -1155,9 +855,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zeroize" -version = "1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/Cargo.toml b/Cargo.toml index c764b5b..6956dd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,15 +17,15 @@ all-features = true # include macro feature when building docs default = ["iterator", "std"] iterator = ["cosmwasm-std/iterator"] macro = ["cw-storage-macro"] -std = ["cosmwasm-std/std"] +std = ["cosmwasm-std/std", "schemars"] [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] -cosmwasm-std = { git = "https://github.com/ComposableFi/cosmwasm.git", rev = "21351cc1ced863b9af7c8a69f923036bc919b3b1", default-features = false } -schemars = "0.8.3" +cosmwasm-std = { git = "https://github.com/dzmitry-lahoda-forks/cosmwasm.git", rev = "7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e", default-features = false } +schemars = { version = "0.8.3", optional = true} serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } cw-storage-macro = { version = "1.0.0", optional = true, path = "macros" } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..1e38bbe --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,11 @@ +[toolchain] +channel = "nightly-2022-11-17" +components = [ + "rust-src", + "cargo", +] +targets = [ + "wasm32-unknown-unknown", + # that is the way to test that it checks and builds againt no_std target + "thumbv7em-none-eabi" + ] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..f31f80c --- /dev/null +++ b/shell.nix @@ -0,0 +1,23 @@ +{ pkgs ? import { overlays = [ (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/refs/heads/stable.zip")) ]; } }: +let + rust-as-on-ci = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + features = " --features iterator"; + package="cw-storage-plus"; + check-no-std = pkgs.writeShellApplication rec { + name = "check-no-std"; + runtimeInputs = [ rust-as-on-ci ]; + text = '' + cargo build --locked --no-default-features --target thumbv7em-none-eabi --package ${package} ${features} + ''; + }; + check-wasm-std = pkgs.writeShellApplication rec { + name = "check-wasm-std"; + runtimeInputs = [ rust-as-on-ci ]; + text = '' + cargo build --target wasm32-unknown-unknown --locked ${features},std --package ${package} + ''; + }; +in +pkgs.mkShell { + nativeBuildInputs = [ rust-as-on-ci check-no-std check-wasm-std]; +} diff --git a/src/bound.rs b/src/bound.rs index 597b569..380ed7c 100644 --- a/src/bound.rs +++ b/src/bound.rs @@ -1,7 +1,8 @@ #![cfg(feature = "iterator")] +use crate::no_std::marker::PhantomData; +use crate::no_std::prelude::*; use cosmwasm_std::Addr; -use std::marker::PhantomData; use crate::de::KeyDeserialize; use crate::{Prefixer, PrimaryKey}; diff --git a/src/cw_std.rs b/src/cw_std.rs deleted file mode 100644 index efe0cca..0000000 --- a/src/cw_std.rs +++ /dev/null @@ -1,62 +0,0 @@ -// no_std support - -#[cfg(feature = "std")] -pub use std::vec::Vec; - -#[cfg(not(feature = "std"))] -pub use alloc::vec; - -#[cfg(not(feature = "std"))] -pub use core::mem; -#[cfg(feature = "std")] -use std::mem; - -pub mod ops { - #[cfg(not(feature = "std"))] - pub use core::ops::Deref; - #[cfg(feature = "std")] - use std::ops::Deref; -} - -pub mod string { - #[cfg(feature = "std")] - pub use std::string::String; - - #[cfg(not(feature = "std"))] - pub use alloc::string::String; -} - -pub mod marker { - #[cfg(not(feature = "std"))] - pub use core::marker::PhantomData; - #[cfg(feature = "std")] - pub use std::marker::PhantomData; -} - -pub mod array { - #[cfg(feature = "std")] - pub use std::array::TryFromSliceError; - - #[cfg(not(feature = "std"))] - pub use core::array::TryFromSliceError; -} - -pub mod convert { - #[cfg(feature = "std")] - pub use std::convert::TryInto; - - #[cfg(not(feature = "std"))] - pub use core::convert::TryInto; -} - -pub mod any { - #[cfg(feature = "std")] - pub use std::any::type_name; - - #[cfg(not(feature = "std"))] - pub use core::any::type_name; -} - -pub mod prelude { - pub use crate::cw_std::{string::String, vec::Vec}; -} diff --git a/src/de.rs b/src/de.rs index 805fc02..42e2ebc 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1,6 +1,6 @@ -use crate::cw_std::array::TryFromSliceError; -use crate::cw_std::convert::TryInto; -use crate::cw_std::prelude::*; +use crate::no_std::array::TryFromSliceError; +use crate::no_std::convert::TryInto; +use crate::no_std::prelude::*; use cosmwasm_std::{Addr, StdError, StdResult}; use crate::int_key::IntKey; @@ -199,8 +199,8 @@ impl KeyDeserialize for #[cfg(test)] mod test { use super::*; + use crate::no_std::prelude::*; use crate::PrimaryKey; - use crate::cw_std::prelude::*; const BYTES: &[u8] = b"Hello"; const STRING: &str = "Hello"; diff --git a/src/deque.rs b/src/deque.rs index a0dad95..1b3f807 100644 --- a/src/deque.rs +++ b/src/deque.rs @@ -1,5 +1,5 @@ -use crate::cw_std::{any::type_name, convert::TryInto, marker::PhantomData}; -use crate::cw_std::prelude::*; +use crate::no_std::prelude::*; +use crate::no_std::{any::type_name, convert::TryInto, marker::PhantomData}; use cosmwasm_std::{to_vec, StdError, StdResult, Storage}; use serde::{de::DeserializeOwned, Serialize}; @@ -291,7 +291,7 @@ where #[cfg(test)] mod tests { use crate::deque::Deque; - use crate::cw_std::{vec::Vec, string::String}; + use crate::no_std::{string::String, vec::Vec}; use cosmwasm_std::testing::MockStorage; use cosmwasm_std::{StdError, StdResult}; use serde::{Deserialize, Serialize}; diff --git a/src/endian.rs b/src/endian.rs index 5f40889..1c7af0d 100644 --- a/src/endian.rs +++ b/src/endian.rs @@ -7,8 +7,8 @@ // TODO: figure out these macros and let us replace (self: Self) with self #![allow(clippy::needless_arbitrary_self_type)] -use crate::cw_std::mem; -use crate::cw_std::prelude::*; +use crate::no_std::mem; +use crate::no_std::prelude::*; pub trait Endian: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; diff --git a/src/helpers.rs b/src/helpers.rs index 0cf2786..7950c84 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -4,10 +4,10 @@ //! Everything in this file is only responsible for building such keys //! and is in no way specific to any kind of storage. -use serde::de::DeserializeOwned; -use crate::cw_std::any::type_name; -use crate::cw_std::prelude::*; use crate::keys::Key; +use crate::no_std::any::type_name; +use crate::no_std::prelude::*; +use serde::de::DeserializeOwned; use cosmwasm_std::{ from_slice, to_vec, Addr, Binary, ContractResult, CustomQuery, QuerierWrapper, QueryRequest, @@ -123,7 +123,7 @@ pub(crate) fn query_raw( #[cfg(test)] mod test { use super::*; - use crate::cw_std::prelude::*; + use crate::no_std::prelude::*; use cosmwasm_std::{to_vec, StdError}; use serde::{Deserialize, Serialize}; diff --git a/src/indexed_map.rs b/src/indexed_map.rs index 9bc791b..5dd9c79 100644 --- a/src/indexed_map.rs +++ b/src/indexed_map.rs @@ -11,6 +11,7 @@ use crate::indexes::Index; use crate::iter_helpers::{deserialize_kv, deserialize_v}; use crate::keys::{Prefixer, PrimaryKey}; use crate::map::Map; +use crate::no_std::prelude::*; use crate::prefix::{namespaced_prefix_range, Prefix}; use crate::{Bound, Path}; diff --git a/src/indexed_snapshot.rs b/src/indexed_snapshot.rs index be047a2..22e2d14 100644 --- a/src/indexed_snapshot.rs +++ b/src/indexed_snapshot.rs @@ -8,6 +8,7 @@ use serde::Serialize; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::{Prefixer, PrimaryKey}; +use crate::no_std::prelude::*; use crate::prefix::{namespaced_prefix_range, Prefix}; use crate::snapshot::{ChangeSet, SnapshotMap}; use crate::PrefixBound; diff --git a/src/indexes/multi.rs b/src/indexes/multi.rs index 1a547c5..3fde877 100644 --- a/src/indexes/multi.rs +++ b/src/indexes/multi.rs @@ -11,9 +11,10 @@ use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::iter_helpers::deserialize_kv; use crate::map::Map; +use crate::no_std::marker::PhantomData; +use crate::no_std::prelude::*; use crate::prefix::namespaced_prefix_range; use crate::{Bound, Index, Prefix, Prefixer, PrimaryKey}; -use std::marker::PhantomData; /// MultiIndex stores (namespace, index_name, idx_value, pk) -> b"pk_len". /// Allows many values per index, and references pk. diff --git a/src/indexes/unique.rs b/src/indexes/unique.rs index a1c6816..95edfbb 100644 --- a/src/indexes/unique.rs +++ b/src/indexes/unique.rs @@ -1,7 +1,7 @@ // this module requires iterator to be useful at all #![cfg(feature = "iterator")] -use std::marker::PhantomData; +use crate::no_std::marker::PhantomData; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; @@ -12,6 +12,7 @@ use crate::bound::PrefixBound; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::map::Map; +use crate::no_std::prelude::*; use crate::prefix::namespaced_prefix_range; use crate::{Bound, Index, Prefix, Prefixer, PrimaryKey}; diff --git a/src/int_key.rs b/src/int_key.rs index 2f18469..4585ad8 100644 --- a/src/int_key.rs +++ b/src/int_key.rs @@ -1,5 +1,5 @@ -use crate::cw_std::vec::Vec; -use crate::cw_std::mem; +use crate::no_std::mem; +use crate::no_std::vec::Vec; /// Our int keys are simply the big-endian representation bytes for unsigned ints, /// but "sign-flipped" (xored msb) big-endian bytes for signed ints. diff --git a/src/item.rs b/src/item.rs index 2786d36..ba69da1 100644 --- a/src/item.rs +++ b/src/item.rs @@ -1,7 +1,7 @@ +use crate::no_std::marker::PhantomData; +use crate::no_std::prelude::*; use serde::de::DeserializeOwned; use serde::Serialize; -use crate::cw_std::marker::PhantomData; -use crate::cw_std::prelude::*; use cosmwasm_std::{ to_vec, Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage, WasmQuery, diff --git a/src/iter_helpers.rs b/src/iter_helpers.rs index 09002bc..31fa448 100644 --- a/src/iter_helpers.rs +++ b/src/iter_helpers.rs @@ -1,5 +1,5 @@ #![cfg(feature = "iterator")] -use crate::cw_std::vec; +use crate::no_std::prelude::*; use serde::de::DeserializeOwned; diff --git a/src/keys.rs b/src/keys.rs index db70eb8..5ea3022 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -1,8 +1,8 @@ -use cosmwasm_std::Addr; -use crate::cw_std::{vec::Vec, string::String}; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::IntKey; +use crate::no_std::{string::String, vec::Vec}; +use cosmwasm_std::Addr; #[derive(Debug)] pub enum Key<'a> { diff --git a/src/lib.rs b/src/lib.rs index 70b32a0..056fe68 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ For more information on this package, please check out the [README](https://github.com/CosmWasm/cw-plus/blob/main/packages/storage-plus/README.md). */ #![cfg_attr(not(feature = "std"), no_std)] - +#![feature(error_in_core)] #[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; @@ -31,10 +31,10 @@ mod item; mod iter_helpers; mod keys; mod map; +mod no_std; mod path; mod prefix; mod snapshot; -mod cw_std; #[cfg(feature = "iterator")] pub use bound::{Bound, Bounder, PrefixBound, RawBound}; diff --git a/src/map.rs b/src/map.rs index ac3fcbe..6bf6e2b 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,7 +1,7 @@ +use crate::no_std::marker::PhantomData; +use crate::no_std::prelude::*; use serde::de::DeserializeOwned; use serde::Serialize; -use crate::cw_std::marker::PhantomData; -use crate::cw_std::{vec::Vec, string::String}; #[cfg(feature = "iterator")] use crate::bound::{Bound, PrefixBound}; @@ -294,8 +294,8 @@ where #[cfg(test)] mod test { use super::*; + use crate::no_std::ops::Deref; use serde::{Deserialize, Serialize}; - use crate::cw_std::ops::Deref; use cosmwasm_std::testing::MockStorage; use cosmwasm_std::to_binary; diff --git a/src/no_std.rs b/src/no_std.rs new file mode 100644 index 0000000..d3a05e5 --- /dev/null +++ b/src/no_std.rs @@ -0,0 +1,130 @@ +//! if somebody will need alternative implementation, for example for collection or fmt, one may patch for himself this one + +#[cfg(feature = "std")] +pub use std::num; + +#[cfg(not(feature = "std"))] +pub use core::num; + +#[cfg(feature = "std")] +pub use std::boxed; + +#[cfg(not(feature = "std"))] +pub use alloc::boxed; + +#[cfg(feature = "std")] +pub use std::format; + +#[cfg(not(feature = "std"))] +pub use alloc::format; + +#[cfg(feature = "std")] +pub use std::vec; + +#[cfg(not(feature = "std"))] +pub use alloc::vec; + +#[cfg(not(feature = "std"))] +pub use core::mem; +#[cfg(feature = "std")] +pub use std::mem; + +#[cfg(not(feature = "std"))] +pub use core::result; +#[cfg(feature = "std")] +pub use std::result; + +#[cfg(not(feature = "std"))] +pub use core::cmp; +#[cfg(feature = "std")] +pub use std::cmp; + +#[cfg(not(feature = "std"))] +pub use core::error; +#[cfg(feature = "std")] +pub use std::error; + +#[cfg(feature = "std")] +pub use std::iter; + +#[cfg(not(feature = "std"))] +pub use core::iter; + +#[cfg(feature = "std")] +pub use std::ops; + +#[cfg(not(feature = "std"))] +pub use core::ops; + +#[cfg(feature = "std")] +pub use std::string; + +#[cfg(not(feature = "std"))] +pub use alloc::string; + +pub mod array { + #[cfg(feature = "std")] + pub use std::array::TryFromSliceError; + + #[cfg(not(feature = "std"))] + pub use core::array::TryFromSliceError; +} + +#[cfg(feature = "std")] +pub use std::convert; + +#[cfg(not(feature = "std"))] +pub use core::convert; + +#[cfg(feature = "std")] +pub use std::collections; + +#[cfg(not(feature = "std"))] +pub use alloc::collections; + +#[cfg(feature = "std")] +pub use std::fmt; + +#[cfg(not(feature = "std"))] +pub use alloc::fmt; + +pub mod borrow { + #[cfg(feature = "std")] + pub use std::borrow::Cow; + + #[cfg(not(feature = "std"))] + pub use alloc::borrow::Cow; +} + +#[cfg(feature = "std")] +pub use std::str; + +#[cfg(not(feature = "std"))] +pub use alloc::str; + +#[cfg(feature = "std")] +pub use std::marker; + +#[cfg(not(feature = "std"))] +pub use core::marker; + +pub mod any { + #[cfg(feature = "std")] + pub use std::any::type_name; + + #[cfg(not(feature = "std"))] + pub use core::any::type_name; +} + +// just because it is default prelude +pub mod prelude { + pub use super::{ + boxed::Box, + format, + marker::{Send, Sync}, + result::Result::{Err, Ok}, + string::{String, ToString}, + vec, + vec::Vec, + }; +} diff --git a/src/path.rs b/src/path.rs index c0412a0..12ec718 100644 --- a/src/path.rs +++ b/src/path.rs @@ -1,11 +1,11 @@ -use serde::de::DeserializeOwned; -use serde::Serialize; -use crate::cw_std::marker::PhantomData; -use crate::cw_std::ops::Deref; -use crate::cw_std::vec::Vec; use crate::helpers::{may_deserialize, must_deserialize, nested_namespaces_with_key}; use crate::keys::Key; +use crate::no_std::marker::PhantomData; +use crate::no_std::ops::Deref; +use crate::no_std::vec::Vec; use cosmwasm_std::{to_vec, StdError, StdResult, Storage}; +use serde::de::DeserializeOwned; +use serde::Serialize; #[derive(Debug, Clone)] pub struct Path diff --git a/src/prefix.rs b/src/prefix.rs index d86c516..31d9f10 100644 --- a/src/prefix.rs +++ b/src/prefix.rs @@ -1,18 +1,19 @@ #![cfg(feature = "iterator")] +use crate::no_std::fmt::Debug; +use crate::no_std::marker::PhantomData; +use crate::no_std::ops::Deref; +use crate::no_std::vec::Vec; use core::fmt; +use cosmwasm_std::{Order, Record, StdResult, Storage}; use serde::de::DeserializeOwned; use serde::Serialize; -use std::fmt::Debug; -use std::marker::PhantomData; -use crate::cw_std::vec::Vec; -use cosmwasm_std::{Order, Record, StdResult, Storage}; -use cw_std::ops::Deref; use crate::bound::{PrefixBound, RawBound}; use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; +use crate::no_std::prelude::*; use crate::{Bound, Prefixer, PrimaryKey}; type DeserializeVFn = fn(&dyn Storage, &[u8], Record) -> StdResult>; diff --git a/src/snapshot/map.rs b/src/snapshot/map.rs index 3d7e6b0..2a4b054 100644 --- a/src/snapshot/map.rs +++ b/src/snapshot/map.rs @@ -8,6 +8,7 @@ use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::PrimaryKey; use crate::map::Map; +use crate::no_std::prelude::*; use crate::path::Path; use crate::prefix::{namespaced_prefix_range, Prefix}; use crate::snapshot::{ChangeSet, Snapshot}; From a5a11afe16b7d4ab5ee14ce86bf3f3e1b4502f7b Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Thu, 8 Jun 2023 19:54:57 +0100 Subject: [PATCH 3/4] fixed std --- Cargo.lock | 340 +++++++++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 2 +- shell.nix | 7 +- 3 files changed, 338 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b57977..612512a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "atty" version = "0.2.14" @@ -19,18 +30,39 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.10.3" @@ -87,10 +119,28 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "const-oid" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" + +[[package]] +name = "cosmwasm-crypto" +version = "1.2.5" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=677fa9c04b07a4934db82a6a9aa9e68fa13fcff9#677fa9c04b07a4934db82a6a9aa9e68fa13fcff9" +dependencies = [ + "digest 0.10.5", + "ed25519-zebra", + "k256", + "rand_core 0.6.4", + "thiserror", +] + [[package]] name = "cosmwasm-derive" version = "1.2.5" -source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e#7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=677fa9c04b07a4934db82a6a9aa9e68fa13fcff9#677fa9c04b07a4934db82a6a9aa9e68fa13fcff9" dependencies = [ "syn", ] @@ -98,9 +148,10 @@ dependencies = [ [[package]] name = "cosmwasm-std" version = "1.2.5" -source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e#7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=677fa9c04b07a4934db82a6a9aa9e68fa13fcff9#677fa9c04b07a4934db82a6a9aa9e68fa13fcff9" dependencies = [ "base64", + "cosmwasm-crypto", "cosmwasm-derive", "derivative", "forward_ref", @@ -108,7 +159,7 @@ dependencies = [ "schemars", "serde", "serde-json-wasm", - "sha2", + "sha2 0.10.6", "thiserror-core", "uint", ] @@ -207,6 +258,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -239,6 +302,19 @@ dependencies = [ "memchr", ] +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + [[package]] name = "cw-storage-macro" version = "1.0.1" @@ -260,6 +336,16 @@ dependencies = [ "serde_json", ] +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "derivative" version = "2.2.0" @@ -271,14 +357,24 @@ dependencies = [ "syn", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "digest" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" dependencies = [ - "block-buffer", + "block-buffer 0.10.3", "crypto-common", + "subtle", ] [[package]] @@ -287,12 +383,69 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek", + "hashbrown", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "zeroize", +] + [[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.5", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "forward_ref" version = "1.0.0" @@ -309,12 +462,43 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "half" version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -330,6 +514,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.5", +] + [[package]] name = "itertools" version = "0.10.5" @@ -360,6 +553,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -427,6 +632,22 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + [[package]] name = "plotters" version = "0.3.4" @@ -479,14 +700,23 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] [[package]] name = "rand_xoshiro" @@ -494,7 +724,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -542,6 +772,17 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + [[package]] name = "ryu" version = "1.0.11" @@ -587,6 +828,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "serde" version = "1.0.145" @@ -647,6 +902,19 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.10.6" @@ -655,7 +923,27 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.5", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.5", + "rand_core 0.6.4", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", ] [[package]] @@ -664,6 +952,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + [[package]] name = "syn" version = "1.0.102" @@ -684,6 +978,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +dependencies = [ + "thiserror-impl", +] + [[package]] name = "thiserror-core" version = "1.0.38" @@ -704,6 +1007,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -761,6 +1075,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.83" @@ -855,3 +1175,9 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/Cargo.toml b/Cargo.toml index 6956dd1..de535d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ std = ["cosmwasm-std/std", "schemars"] bench = false [dependencies] -cosmwasm-std = { git = "https://github.com/dzmitry-lahoda-forks/cosmwasm.git", rev = "7dd513691d9d9afc0871a7eda93d3ecf8d3bc07e", default-features = false } +cosmwasm-std = { git = "https://github.com/dzmitry-lahoda-forks/cosmwasm.git", rev = "677fa9c04b07a4934db82a6a9aa9e68fa13fcff9", default-features = false } schemars = { version = "0.8.3", optional = true} serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } cw-storage-macro = { version = "1.0.0", optional = true, path = "macros" } diff --git a/shell.nix b/shell.nix index f31f80c..a5a7a64 100644 --- a/shell.nix +++ b/shell.nix @@ -10,14 +10,15 @@ let cargo build --locked --no-default-features --target thumbv7em-none-eabi --package ${package} ${features} ''; }; - check-wasm-std = pkgs.writeShellApplication rec { - name = "check-wasm-std"; + check-std = pkgs.writeShellApplication rec { + name = "check-std"; runtimeInputs = [ rust-as-on-ci ]; text = '' cargo build --target wasm32-unknown-unknown --locked ${features},std --package ${package} + cargo build --locked ${features},std --package ${package} ''; }; in pkgs.mkShell { - nativeBuildInputs = [ rust-as-on-ci check-no-std check-wasm-std]; + nativeBuildInputs = [ rust-as-on-ci check-no-std check-std]; } From d0a2cf126cae3e3960c787ebcfc9baa54f59f71c Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Fri, 9 Jun 2023 16:02:49 +0100 Subject: [PATCH 4/4] up std --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- shell.nix | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 612512a..4ab05b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,7 +128,7 @@ checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "cosmwasm-crypto" version = "1.2.5" -source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=677fa9c04b07a4934db82a6a9aa9e68fa13fcff9#677fa9c04b07a4934db82a6a9aa9e68fa13fcff9" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=1277597cbf380a8d04dbe676d9cb344ca31634b6#1277597cbf380a8d04dbe676d9cb344ca31634b6" dependencies = [ "digest 0.10.5", "ed25519-zebra", @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "cosmwasm-derive" version = "1.2.5" -source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=677fa9c04b07a4934db82a6a9aa9e68fa13fcff9#677fa9c04b07a4934db82a6a9aa9e68fa13fcff9" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=1277597cbf380a8d04dbe676d9cb344ca31634b6#1277597cbf380a8d04dbe676d9cb344ca31634b6" dependencies = [ "syn", ] @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "cosmwasm-std" version = "1.2.5" -source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=677fa9c04b07a4934db82a6a9aa9e68fa13fcff9#677fa9c04b07a4934db82a6a9aa9e68fa13fcff9" +source = "git+https://github.com/dzmitry-lahoda-forks/cosmwasm.git?rev=1277597cbf380a8d04dbe676d9cb344ca31634b6#1277597cbf380a8d04dbe676d9cb344ca31634b6" dependencies = [ "base64", "cosmwasm-crypto", diff --git a/Cargo.toml b/Cargo.toml index de535d9..e6b5878 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ std = ["cosmwasm-std/std", "schemars"] bench = false [dependencies] -cosmwasm-std = { git = "https://github.com/dzmitry-lahoda-forks/cosmwasm.git", rev = "677fa9c04b07a4934db82a6a9aa9e68fa13fcff9", default-features = false } +cosmwasm-std = { git = "https://github.com/dzmitry-lahoda-forks/cosmwasm.git", rev = "1277597cbf380a8d04dbe676d9cb344ca31634b6", default-features = false } schemars = { version = "0.8.3", optional = true} serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } cw-storage-macro = { version = "1.0.0", optional = true, path = "macros" } diff --git a/shell.nix b/shell.nix index a5a7a64..0656efb 100644 --- a/shell.nix +++ b/shell.nix @@ -7,15 +7,15 @@ let name = "check-no-std"; runtimeInputs = [ rust-as-on-ci ]; text = '' - cargo build --locked --no-default-features --target thumbv7em-none-eabi --package ${package} ${features} + cargo build --no-default-features --target thumbv7em-none-eabi --package ${package} ${features} ''; }; check-std = pkgs.writeShellApplication rec { name = "check-std"; runtimeInputs = [ rust-as-on-ci ]; text = '' - cargo build --target wasm32-unknown-unknown --locked ${features},std --package ${package} - cargo build --locked ${features},std --package ${package} + cargo build --target wasm32-unknown-unknown ${features},std --package ${package} + cargo build ${features},std --package ${package} ''; }; in