From 263ff5c2a021dc0a9e76fb871b2d521d4451af1b Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 29 Sep 2022 11:39:13 +0200 Subject: [PATCH 1/6] Remove storage-plus dependency from storage-macro --- Cargo.lock | 1 - packages/storage-macro/Cargo.toml | 1 - packages/{storage-macro => storage-plus}/tests/index_list.rs | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) rename packages/{storage-macro => storage-plus}/tests/index_list.rs (97%) diff --git a/Cargo.lock b/Cargo.lock index 93c0d63f0..0f790ab7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,7 +433,6 @@ name = "cw-storage-macro" version = "0.15.1" dependencies = [ "cosmwasm-std", - "cw-storage-plus", "serde", "syn", ] diff --git a/packages/storage-macro/Cargo.toml b/packages/storage-macro/Cargo.toml index 48cd9537d..ce5740516 100644 --- a/packages/storage-macro/Cargo.toml +++ b/packages/storage-macro/Cargo.toml @@ -16,6 +16,5 @@ proc-macro = true syn = { version = "1.0.96", features = ["full"] } [dev-dependencies] -cw-storage-plus = { version = "<=0.15.1, >=0.14.0", path = "../storage-plus" } cosmwasm-std = { version = "1.1.0", default-features = false } serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-macro/tests/index_list.rs b/packages/storage-plus/tests/index_list.rs similarity index 97% rename from packages/storage-macro/tests/index_list.rs rename to packages/storage-plus/tests/index_list.rs index 224b20551..db0d2b843 100644 --- a/packages/storage-macro/tests/index_list.rs +++ b/packages/storage-plus/tests/index_list.rs @@ -1,4 +1,4 @@ -#[cfg(test)] +#[cfg(all(test, feature = "iterator", feature = "macro"))] mod test { use cosmwasm_std::{testing::MockStorage, Addr}; use cw_storage_macro::index_list; From 7cf390fdc3cc17be1db0c67b060aafbfba3567fe Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 29 Sep 2022 11:39:35 +0200 Subject: [PATCH 2/6] Add docs to storage-macro index_list --- packages/storage-macro/src/lib.rs | 19 +++++++++++++++++++ packages/storage-plus/src/lib.rs | 1 - 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/storage-macro/src/lib.rs b/packages/storage-macro/src/lib.rs index 366723ca5..21f19d91d 100644 --- a/packages/storage-macro/src/lib.rs +++ b/packages/storage-macro/src/lib.rs @@ -5,6 +5,25 @@ use syn::{ parse_macro_input, ItemStruct, }; +/// Auto generate an `IndexList` impl for your indexes struct. +/// +/// # Example +/// +/// ```rust +/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +/// struct TestStruct { +/// id: u64, +/// id2: u32, +/// addr: Addr, +/// } +/// +/// #[index_list(TestStruct)] // <- Add this line right here. +/// struct TestIndexes<'a> { +/// id: MultiIndex<'a, u32, TestStruct, u64>, +/// addr: UniqueIndex<'a, Addr, TestStruct>, +/// } +/// ``` +/// #[proc_macro_attribute] pub fn index_list(attr: TokenStream, item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as ItemStruct); diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 014834bf8..79266d3b5 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -46,5 +46,4 @@ pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; #[macro_use] extern crate cw_storage_macro; #[cfg(all(feature = "iterator", feature = "macro"))] -#[doc(hidden)] pub use cw_storage_macro::*; From dfa8998d4eb8c7141496044a35f0df3493c252bf Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 29 Sep 2022 11:40:36 +0200 Subject: [PATCH 3/6] Run storage-plus macro tests in CI --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75ba021d7..4602c28b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -660,11 +660,11 @@ jobs: name: Run unit tests (no iterator) command: cargo test --locked --no-default-features - run: - name: Build library for native target (with iterator) - command: cargo build --locked + name: Build library for native target (with iterator and macro) + command: cargo build --locked --all-features - run: - name: Run unit tests (with iterator) - command: cargo test --locked + name: Run unit tests (with iterator and macro) + command: cargo test --locked --all-features - save_cache: paths: - /usr/local/cargo/registry From ce2300f1ccb83bcacef2cd36ddc16843353aa8cc Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 29 Sep 2022 12:44:57 +0200 Subject: [PATCH 4/6] Enable all storage-plus features on docs.rs build --- packages/storage-plus/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 7f453420a..b170ff34b 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -8,6 +8,9 @@ license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-plus" homepage = "https://cosmwasm.com" +[package.metadata.docs.rs] +all-features = true # include macro feature when building docs + [features] default = ["iterator"] iterator = ["cosmwasm-std/iterator"] @@ -24,7 +27,7 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } cw-storage-macro = { version = "0.15.1", optional = true, path = "../storage-macro" } [dev-dependencies] -criterion = { version = "0.3", features = [ "html_reports" ] } +criterion = { version = "0.3", features = ["html_reports"] } rand = "0.8" [[bench]] From 292458d53154eff68c5351a8529e8af03bfe2525 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 29 Sep 2022 13:07:09 +0200 Subject: [PATCH 5/6] Move index_list macro docs to storage-plus --- packages/storage-macro/src/lib.rs | 19 ------------------- packages/storage-plus/src/lib.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/packages/storage-macro/src/lib.rs b/packages/storage-macro/src/lib.rs index 21f19d91d..366723ca5 100644 --- a/packages/storage-macro/src/lib.rs +++ b/packages/storage-macro/src/lib.rs @@ -5,25 +5,6 @@ use syn::{ parse_macro_input, ItemStruct, }; -/// Auto generate an `IndexList` impl for your indexes struct. -/// -/// # Example -/// -/// ```rust -/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] -/// struct TestStruct { -/// id: u64, -/// id2: u32, -/// addr: Addr, -/// } -/// -/// #[index_list(TestStruct)] // <- Add this line right here. -/// struct TestIndexes<'a> { -/// id: MultiIndex<'a, u32, TestStruct, u64>, -/// addr: UniqueIndex<'a, Addr, TestStruct>, -/// } -/// ``` -/// #[proc_macro_attribute] pub fn index_list(attr: TokenStream, item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as ItemStruct); diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 79266d3b5..f5484a993 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -42,8 +42,34 @@ pub use prefix::{range_with_prefix, Prefix}; #[cfg(feature = "iterator")] pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; +// cw_storage_macro reexports #[cfg(all(feature = "iterator", feature = "macro"))] #[macro_use] extern crate cw_storage_macro; #[cfg(all(feature = "iterator", feature = "macro"))] +/// Auto generate an `IndexList` impl for your indexes struct. +/// +/// # Example +/// +/// ```rust +/// use cosmwasm_std::Addr; +/// use cw_storage_plus::{MultiIndex, UniqueIndex, index_list}; +/// use serde::{Serialize, Deserialize}; +/// +/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +/// struct TestStruct { +/// id: u64, +/// id2: u32, +/// addr: Addr, +/// } +/// +/// #[index_list(TestStruct)] // <- Add this line right here. +/// struct TestIndexes<'a> { +/// id: MultiIndex<'a, u32, TestStruct, u64>, +/// addr: UniqueIndex<'a, Addr, TestStruct>, +/// } +/// ``` +/// +pub use cw_storage_macro::index_list; +#[cfg(all(feature = "iterator", feature = "macro"))] pub use cw_storage_macro::*; From d037bf550f6718cc5c17fb3a1b25211d37d787c1 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 29 Sep 2022 13:33:24 +0200 Subject: [PATCH 6/6] Remove blanket export --- packages/storage-plus/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index f5484a993..00208b499 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -71,5 +71,3 @@ extern crate cw_storage_macro; /// ``` /// pub use cw_storage_macro::index_list; -#[cfg(all(feature = "iterator", feature = "macro"))] -pub use cw_storage_macro::*;