diff --git a/Cargo.lock b/Cargo.lock index 723978915..fa09b5f7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,9 +135,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b8b840947313c1a1cccf056836cd79a60b4526bdcd6582995be37dc97be4ae" +checksum = "7d7ee1963302b0ac2a9d42fe0faec826209c17452bfd36fbfd9d002a88929261" dependencies = [ "cosmwasm-std", "schemars", @@ -145,10 +145,10 @@ dependencies = [ ] [[package]] -name = "cw0" -version = "0.10.3" +name = "cw-utils" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae676b6cced78a3d38ad4b01ab4ed66fc78ac191c3c0d6bfd5372cb2efd473b" +checksum = "ef842a1792e4285beff7b3b518705f760fa4111dc1e296e53f3e92d1ef7f6220" dependencies = [ "cosmwasm-std", "schemars", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "cw2" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7002e6f9c1a1ef3915dca704a6306ba00c39495efd928551d6077c734f9a3d8" +checksum = "c1d81d7c359d6c1fba3aa83dad7ec6f999e512571380ae62f81257c3db569743" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -170,23 +170,23 @@ dependencies = [ [[package]] name = "cw721" -version = "0.10.1" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw0", + "cw-utils", "schemars", "serde", ] [[package]] name = "cw721-base" -version = "0.10.1" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", - "cw0", + "cw-utils", "cw2", "cw721", "schemars", @@ -196,7 +196,7 @@ dependencies = [ [[package]] name = "cw721-metadata-onchain" -version = "0.10.1" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -384,18 +384,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.34" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" dependencies = [ "proc-macro2", ] @@ -545,9 +545,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1dfb999630e338648c83e91c59a4e9fb7620f520c3194b6b89e276f2f1959" +checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b" dependencies = [ "proc-macro2", "quote", @@ -576,9 +576,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "uint" @@ -600,9 +600,9 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" diff --git a/contracts/cw721-base/Cargo.toml b/contracts/cw721-base/Cargo.toml index 59852e1fd..73c28e506 100644 --- a/contracts/cw721-base/Cargo.toml +++ b/contracts/cw721-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw721-base" -version = "0.10.1" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation cw721 NFTs" @@ -25,10 +25,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw0 = { version = "0.10" } -cw2 = { version = "0.10" } -cw721 = { path = "../../packages/cw721", version = "0.10" } -cw-storage-plus = { version = "0.10" } +cw-utils = { version = "0.11" } +cw2 = { version = "0.11" } +cw721 = { path = "../../packages/cw721", version = "0.11.1" } +cw-storage-plus = { version = "0.11" } cosmwasm-std = { version = "1.0.0-beta" } schemars = "0.8.6" serde = { version = "1.0.130", default-features = false, features = ["derive"] } diff --git a/contracts/cw721-base/src/query.rs b/contracts/cw721-base/src/query.rs index 54540334e..130897d08 100644 --- a/contracts/cw721-base/src/query.rs +++ b/contracts/cw721-base/src/query.rs @@ -1,15 +1,15 @@ use serde::de::DeserializeOwned; use serde::Serialize; -use cosmwasm_std::{to_binary, Binary, BlockInfo, Deps, Env, Order, Record, StdError, StdResult}; +use cosmwasm_std::{to_binary, Addr, Binary, BlockInfo, Deps, Env, Order, StdError, StdResult}; -use cw0::maybe_addr; use cw721::{ AllNftInfoResponse, ApprovalResponse, ApprovalsResponse, ContractInfoResponse, CustomMsg, Cw721Query, Expiration, NftInfoResponse, NumTokensResponse, OperatorsResponse, OwnerOfResponse, TokensResponse, }; use cw_storage_plus::Bound; +use cw_utils::maybe_addr; use crate::msg::{MinterResponse, QueryMsg}; use crate::state::{Approval, Cw721Contract, TokenInfo}; @@ -143,17 +143,16 @@ where let start = start_after.map(Bound::exclusive); let owner_addr = deps.api.addr_validate(&owner)?; - let pks: Vec<_> = self + let tokens: Vec = self .tokens .idx .owner .prefix(owner_addr) .keys(deps.storage, start, None, Order::Ascending) .take(limit) - .collect(); + .map(|x| x.map(|addr| addr.to_string())) + .collect::>>()?; - let res: Result, _> = pks.iter().map(|v| String::from_utf8(v.to_vec())).collect(); - let tokens = res.map_err(StdError::invalid_utf8)?; Ok(TokensResponse { tokens }) } @@ -170,8 +169,9 @@ where .tokens .range(deps.storage, start, None, Order::Ascending) .take(limit) - .map(|item| item.map(|(k, _)| String::from_utf8_lossy(&k).to_string())) + .map(|item| item.map(|(k, _)| k)) .collect(); + Ok(TokensResponse { tokens: tokens? }) } @@ -271,10 +271,10 @@ where } } -fn parse_approval(item: StdResult>) -> StdResult { - item.and_then(|(k, expires)| { - let spender = String::from_utf8(k)?; - Ok(cw721::Approval { spender, expires }) +fn parse_approval(item: StdResult<(Addr, Expiration)>) -> StdResult { + item.map(|(spender, expires)| cw721::Approval { + spender: spender.to_string(), + expires, }) } diff --git a/contracts/cw721-base/src/state.rs b/contracts/cw721-base/src/state.rs index 466618d85..37af50065 100644 --- a/contracts/cw721-base/src/state.rs +++ b/contracts/cw721-base/src/state.rs @@ -122,8 +122,7 @@ pub struct TokenIndexes<'a, T> where T: Serialize + DeserializeOwned + Clone, { - // pk goes to second tuple element - pub owner: MultiIndex<'a, (Addr, Vec), TokenInfo>, + pub owner: MultiIndex<'a, Addr, TokenInfo, Addr>, } impl<'a, T> IndexList> for TokenIndexes<'a, T> @@ -136,6 +135,6 @@ where } } -pub fn token_owner_idx(d: &TokenInfo, k: Vec) -> (Addr, Vec) { - (d.owner.clone(), k) +pub fn token_owner_idx(d: &TokenInfo) -> Addr { + d.owner.clone() } diff --git a/contracts/cw721-metadata-onchain/Cargo.toml b/contracts/cw721-metadata-onchain/Cargo.toml index f8a8ea2dd..2c00adf8b 100644 --- a/contracts/cw721-metadata-onchain/Cargo.toml +++ b/contracts/cw721-metadata-onchain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw721-metadata-onchain" -version = "0.10.1" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Example extending CW721 NFT to store metadata on chain" @@ -25,8 +25,8 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw721 = { path = "../../packages/cw721", version = "0.10" } -cw721-base = { path = "../cw721-base", version = "0.10", features = ["library"] } +cw721 = { path = "../../packages/cw721", version = "0.11.1" } +cw721-base = { path = "../cw721-base", version = "0.11.1", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta" } schemars = "0.8.6" serde = { version = "1.0.130", default-features = false, features = ["derive"] } diff --git a/packages/cw721/Cargo.toml b/packages/cw721/Cargo.toml index 7058527ea..b49c3b5c2 100644 --- a/packages/cw721/Cargo.toml +++ b/packages/cw721/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw721" -version = "0.10.1" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-721 NFT interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw0 = { version = "0.10" } +cw-utils = { version = "0.11" } cosmwasm-std = { version = "1.0.0-beta" } schemars = "0.8.6" serde = { version = "1.0.130", default-features = false, features = ["derive"] } diff --git a/packages/cw721/src/lib.rs b/packages/cw721/src/lib.rs index b1ac94efc..5400b4d5a 100644 --- a/packages/cw721/src/lib.rs +++ b/packages/cw721/src/lib.rs @@ -3,7 +3,7 @@ mod query; mod receiver; mod traits; -pub use cw0::Expiration; +pub use cw_utils::Expiration; pub use crate::msg::Cw721ExecuteMsg; pub use crate::query::{ diff --git a/packages/cw721/src/msg.rs b/packages/cw721/src/msg.rs index 67c0ff6c7..c7175be90 100644 --- a/packages/cw721/src/msg.rs +++ b/packages/cw721/src/msg.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::Binary; -use cw0::Expiration; +use cw_utils::Expiration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/cw721/src/query.rs b/packages/cw721/src/query.rs index aada541a8..f5453f9f1 100644 --- a/packages/cw721/src/query.rs +++ b/packages/cw721/src/query.rs @@ -1,7 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cw0::Expiration; +use cw_utils::Expiration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/cw721/src/traits.rs b/packages/cw721/src/traits.rs index eb36aa794..ee395ea75 100644 --- a/packages/cw721/src/traits.rs +++ b/packages/cw721/src/traits.rs @@ -8,7 +8,7 @@ use crate::{ NumTokensResponse, OperatorsResponse, OwnerOfResponse, TokensResponse, }; use cosmwasm_std::{Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult}; -use cw0::Expiration; +use cw_utils::Expiration; // TODO: move this somewhere else... ideally cosmwasm-std pub trait CustomMsg: Clone + std::fmt::Debug + PartialEq + JsonSchema {}