diff --git a/Cargo.lock b/Cargo.lock index 02def1b..8f5ed5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1313,6 +1313,8 @@ dependencies = [ [[package]] name = "sg-index-query" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7812d112f043a4ab0c0b12dd38b5f00ca38939453b405fc84c661a5ace27efd" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1321,9 +1323,7 @@ dependencies = [ [[package]] name = "sg-index-query" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7812d112f043a4ab0c0b12dd38b5f00ca38939453b405fc84c661a5ace27efd" +version = "0.1.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1618,7 +1618,7 @@ dependencies = [ "cw2 0.16.0", "schemars", "serde", - "sg-index-query 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sg-index-query 0.1.0", "sg-multi-test", "sg-std", "sg721", diff --git a/packages/sg-index-query/Cargo.toml b/packages/sg-index-query/Cargo.toml index 5b72df1..6267c13 100644 --- a/packages/sg-index-query/Cargo.toml +++ b/packages/sg-index-query/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg-index-query" -version = "0.1.0" +version = "0.1.1" authors = ["Tasio Victoria "] description = "A package that holds common functionality for dealing with cw-storage-plus indices." edition = { workspace = true } diff --git a/packages/sg-index-query/README.md b/packages/sg-index-query/README.md index c911dda..b339ba9 100644 --- a/packages/sg-index-query/README.md +++ b/packages/sg-index-query/README.md @@ -1,9 +1,45 @@ -# sg-marketplace-common +# sg-index-query -The `sg-marketplace-common` common package is used to manage functionality shared between marketplace contracts. The package is divided into the following modules: +`sg-index-query` is a Rust crate providing a `QueryOptions` struct for use in CosmWasm smart contracts. +It allows you to specify query parameters such as limit, order, and the min max of range queries. -- `mod address`: functionality related to the `cosmwasm_std::Addr` type -- `mod coin`: functionality related to the `cosmwasm_std::Coin` type -- `mod nft`: functionality related to NFT data -- `mod query`: functionality related to querying smart contracts -- `mod sale`: functionality related to NFT sales +## Features + +- `QueryOptions` struct for specifying query parameters such as limit, order, and range. +- `unpack` function for converting `QueryOptions` into `QueryOptionsInternal`, which is used for range queries in `cw_storage_plus`. + +## Usage + +First, add the following to your `Cargo.toml`: + +```toml +[dependencies] +sg-index-query = "0.1.0" +``` + +Then, you can use the `QueryOptions` struct in your code: + +```rust +use sg_index_query::QueryOptions; + +let query_options = QueryOptions::::default(); +``` + +You can specify query parameters like so: + +```rust +use sg_index_query::{QueryOptions, QueryBound}; + +let query_options = QueryOptions { + descending: Some(true), + limit: Some(20), + min: Some(QueryBound::Inclusive("test".to_string())), + max: Some(QueryBound::Exclusive("test2".to_string())), +}; +``` + +Then, you can unpack the `QueryOptions` into `QueryOptionsInternal`: + +```rust +let query_options_internal = query_options.unpack(&|offset: &String| offset.to_string(), None, None); +``` diff --git a/packages/sg-index-query/src/lib.rs b/packages/sg-index-query/src/lib.rs index 70d1b65..d537656 100644 --- a/packages/sg-index-query/src/lib.rs +++ b/packages/sg-index-query/src/lib.rs @@ -1,3 +1,49 @@ +//! # sg-index-query +//! +//! `sg-index-query` is a Rust crate providing a `QueryOptions` struct for use in CosmWasm smart contracts. +//! It allows you to specify query parameters such as limit, order, and range. +//! +//! ## Features +//! +//! - `QueryOptions` struct for specifying query parameters such as limit, order, and range. +//! - `unpack` function for converting `QueryOptions` into `QueryOptionsInternal`, which is used for range queries in `cw_storage_plus`. +//! +//! ## Usage +//! +//! First, add the following to your `Cargo.toml`: +//! +//! ```toml +//! [dependencies] +//! sg-index-query = "0.1.0" +//! ``` +//! +//! Then, you can use the `QueryOptions` struct in your code: +//! +//! ```rust +//! use sg_index_query::QueryOptions; +//! +//! let query_options = QueryOptions::::default(); +//! ``` +//! +//! You can specify query parameters like so: +//! +//! ```rust +//! use sg_index_query::{QueryOptions, QueryBound}; +//! +//! let query_options = QueryOptions { +//! descending: Some(true), +//! limit: Some(20), +//! min: Some(QueryBound::Inclusive("test".to_string())), +//! max: Some(QueryBound::Exclusive("test2".to_string())), +//! }; +//! ``` +//! +//! Then, you can unpack the `QueryOptions` into `QueryOptionsInternal`: +//! +//! ```rust +//! let query_options_internal = query_options.unpack(&|offset: &String| offset.to_string(), None, None); +//! ``` + use cosmwasm_schema::cw_serde; use cosmwasm_std::Order; use cw_storage_plus::{Bound, PrimaryKey}; diff --git a/scripts/royalty-registry/instantiate.sh b/scripts/royalty-registry/instantiate.sh new file mode 100644 index 0000000..a28ad91 --- /dev/null +++ b/scripts/royalty-registry/instantiate.sh @@ -0,0 +1,26 @@ +CODE_ID=2718 +MSG=$(cat <