Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove storage-plus dependency from storage-macro #817

Merged
merged 6 commits into from Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/storage-macro/Cargo.toml
Expand Up @@ -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" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI: the way the version requirements are specified here is a hack to make a cyclic dependency publishable to crates.io. Good thing we don't actually need it!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that this is not needed, yes. Thanks for working on simplifying this.

cosmwasm-std = { version = "1.1.0", default-features = false }
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
19 changes: 19 additions & 0 deletions packages/storage-macro/src/lib.rs
Expand Up @@ -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>,
/// }
/// ```
///
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so normally macro docs would live in the storage-plus crate, above the reexport. Here's an example.

Does this example pass when tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it does not. I'll move it to the reexport

#[proc_macro_attribute]
pub fn index_list(attr: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as ItemStruct);
Expand Down
5 changes: 4 additions & 1 deletion packages/storage-plus/Cargo.toml
Expand Up @@ -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"]
Expand All @@ -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]]
Expand Down
1 change: 0 additions & 1 deletion packages/storage-plus/src/lib.rs
Expand Up @@ -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::*;
chipshort marked this conversation as resolved.
Show resolved Hide resolved
@@ -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;
Expand Down