From 41a513d39b8aa6a1b9207fc71e86270e18914eef Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:52:36 -0500 Subject: [PATCH 1/9] feat: upgrade to cosmwasm-std 2.0 --- Cargo.lock | 274 ++++++---------- Cargo.toml | 19 +- contracts/cw2981-royalties/Cargo.toml | 2 +- contracts/cw2981-royalties/src/lib.rs | 31 +- contracts/cw2981-royalties/src/query.rs | 4 +- contracts/cw721-base/Cargo.toml | 4 +- contracts/cw721-base/src/contract_tests.rs | 290 +++++++++-------- contracts/cw721-base/src/lib.rs | 18 +- contracts/cw721-base/src/multi_tests.rs | 107 +------ contracts/cw721-base/src/query.rs | 4 +- contracts/cw721-base/src/state.rs | 22 +- contracts/cw721-base/src/upgrades/mod.rs | 2 +- contracts/cw721-base/src/upgrades/v0_17.rs | 2 +- contracts/cw721-expiration/Cargo.toml | 2 +- .../cw721-expiration/src/contract_tests.rs | 296 ++++++++++-------- contracts/cw721-expiration/src/lib.rs | 8 +- contracts/cw721-expiration/src/state.rs | 4 +- contracts/cw721-fixed-price/Cargo.toml | 2 +- contracts/cw721-fixed-price/src/contract.rs | 76 +++-- contracts/cw721-fixed-price/src/error.rs | 3 + contracts/cw721-metadata-onchain/Cargo.toml | 2 +- contracts/cw721-metadata-onchain/src/lib.rs | 8 +- contracts/cw721-non-transferable/Cargo.toml | 2 +- contracts/cw721-receiver-tester/Cargo.toml | 2 +- 24 files changed, 554 insertions(+), 630 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8216b9c15..6badecd1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,9 +15,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.77" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d19de80eff169429ac1e9f48fffb163916b448a44e8e046186232046d9e1f9" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "base16ct" @@ -43,6 +43,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "block-buffer" version = "0.9.0" @@ -63,9 +69,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" [[package]] name = "byteorder" @@ -93,12 +99,11 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cosmwasm-crypto" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bb3c77c3b7ce472056968c745eb501c440fbc07be5004eba02782c35bfbbe3" +checksum = "d1cd7a367ebd007cb05fe17e9c449beeb3636b15160750f2c6226c7dfd46df37" dependencies = [ "digest 0.10.7", - "ecdsa", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -107,18 +112,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea73e9162e6efde00018d55ed0061e93a108b5d6ec4548b4f8ce3c706249687" +checksum = "db01ae480b00f133b78830db3211ff63afe08093e78c77ee20e73f7134849a60" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df41ea55f2946b6b43579659eec048cc2f66e8c8e2e3652fc5e5e476f673856" +checksum = "de6e530d13452b4e9d882008193ab165032307a31f197b45d7b4e2aeff7577b5" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -129,9 +134,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43609e92ce1b9368aa951b334dd354a2d0dd4d484931a5f83ae10e12a26c8ba9" +checksum = "c0ef0d7a8ae8807b8e8f5c94333d12aa9a11efc05f7b864f362582a2b167c663" dependencies = [ "proc-macro2", "quote", @@ -140,12 +145,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.5.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04d6864742e3a7662d024b51a94ea81c9af21db6faea2f9a6d2232bb97c6e53e" +checksum = "f6201969327d8fe5e9596e8c36e376ab595a885bdfcaa6a0bf57748f9ea2be2b" dependencies = [ "base64", - "bech32", + "bech32 0.9.1", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -206,26 +211,25 @@ dependencies = [ [[package]] name = "cw-address-like" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" +version = "2.0.0" +source = "git+https://github.com/PFC-Validator/cw-plus-plus?branch=v2.0.0-wip#8fc303dafffa3f6fb5c076fd645b43d7740a05d1" dependencies = [ "cosmwasm-std", ] [[package]] name = "cw-multi-test" -version = "0.20.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fff029689ae89127cf6d7655809a68d712f3edbdb9686c70b018ba438b26ca" +checksum = "b7b69c1ba533753a2c90e60f4c803f52ee80cf3ba183c3ca0645fd1796561951" dependencies = [ "anyhow", - "bech32", + "bech32 0.11.0", "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", + "cw-storage-plus", + "cw-utils", "derivative", - "itertools 0.12.0", + "itertools 0.12.1", "prost 0.12.3", "schemars", "serde", @@ -235,104 +239,61 @@ dependencies = [ [[package]] name = "cw-ownable" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093dfb4520c48b5848274dd88ea99e280a04bc08729603341c7fb0d758c74321" +version = "2.0.0" +source = "git+https://github.com/PFC-Validator/cw-plus-plus?branch=v2.0.0-wip#8fc303dafffa3f6fb5c076fd645b43d7740a05d1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-address-like", "cw-ownable-derive", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", + "cw-storage-plus", + "cw-utils", "thiserror", ] [[package]] name = "cw-ownable-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d3bf2e0f341bb6cc100d7d441d31cf713fbd3ce0c511f91e79f14b40a889af" +version = "2.0.0" +source = "git+https://github.com/PFC-Validator/cw-plus-plus?branch=v2.0.0-wip#8fc303dafffa3f6fb5c076fd645b43d7740a05d1" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", -] - -[[package]] -name = "cw-storage-plus" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" -dependencies = [ - "cosmwasm-std", - "schemars", - "serde", + "syn 2.0.59", ] [[package]] name = "cw-storage-plus" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" -dependencies = [ - "cosmwasm-std", - "schemars", - "serde", -] - -[[package]] -name = "cw-utils" -version = "0.16.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6a84c6c1c0acc3616398eba50783934bd6c964bad6974241eaee3460c8f5b26" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", - "cw2 0.16.0", "schemars", - "semver", "serde", - "thiserror", ] [[package]] name = "cw-utils" -version = "1.0.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" +checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2 1.1.2", "schemars", - "semver", "serde", "thiserror", ] [[package]] name = "cw2" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91398113b806f4d2a8d5f8d05684704a20ffd5968bf87e3473e1973710b884ad" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 0.16.0", - "schemars", - "serde", -] - -[[package]] -name = "cw2" -version = "1.1.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" +checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.2.0", + "cw-storage-plus", "schemars", "semver", "serde", @@ -341,26 +302,26 @@ dependencies = [ [[package]] name = "cw20" -version = "1.1.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" +checksum = "a42212b6bf29bbdda693743697c621894723f35d3db0d5df930be22903d0e27c" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-utils 1.0.3", + "cw-utils", "schemars", "serde", ] [[package]] name = "cw2981-royalties" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2 1.1.2", - "cw721 0.18.0", - "cw721-base 0.18.0", + "cw2", + "cw721", + "cw721-base", "schemars", "serde", "thiserror", @@ -368,58 +329,27 @@ dependencies = [ [[package]] name = "cw721" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a1ea6e6277bdd6dfc043a9b1380697fe29d6e24b072597439523658d21d791" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-utils 0.16.0", - "schemars", - "serde", -] - -[[package]] -name = "cw721" -version = "0.18.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-utils 1.0.3", - "schemars", - "serde", -] - -[[package]] -name = "cw721-base" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77518e27431d43214cff4cdfbd788a7508f68d9b1f32389e6fce513e7eaccbef" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 0.16.0", - "cw-utils 0.16.0", - "cw2 0.16.0", - "cw721 0.16.0", + "cw-utils", "schemars", "serde", - "thiserror", ] [[package]] name = "cw721-base" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", "cw-ownable", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "cw2 1.1.2", - "cw721 0.18.0", - "cw721-base 0.16.0", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw721", "schemars", "serde", "thiserror", @@ -427,16 +357,16 @@ dependencies = [ [[package]] name = "cw721-expiration" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", "cw-ownable", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw721 0.18.0", - "cw721-base 0.18.0", + "cw-storage-plus", + "cw2", + "cw721", + "cw721-base", "schemars", "serde", "thiserror", @@ -444,15 +374,15 @@ dependencies = [ [[package]] name = "cw721-fixed-price" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "cw2 1.1.2", + "cw-storage-plus", + "cw-utils", + "cw2", "cw20", - "cw721-base 0.18.0", + "cw721-base", "prost 0.10.4", "schemars", "serde", @@ -461,40 +391,40 @@ dependencies = [ [[package]] name = "cw721-metadata-onchain" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2 1.1.2", - "cw721 0.18.0", - "cw721-base 0.18.0", + "cw2", + "cw721", + "cw721-base", "schemars", "serde", ] [[package]] name = "cw721-non-transferable" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw721 0.18.0", - "cw721-base 0.18.0", + "cw-storage-plus", + "cw2", + "cw721", + "cw721-base", "schemars", "serde", ] [[package]] name = "cw721-receiver-tester" -version = "0.18.0" +version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", - "cw721 0.18.0", - "cw721-base 0.18.0", + "cw721", + "cw721-base", "schemars", "serde", "thiserror", @@ -695,9 +625,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -710,9 +640,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "k256" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -752,9 +682,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ "unicode-ident", ] @@ -802,14 +732,14 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.59", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -891,31 +821,31 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.59", ] [[package]] @@ -1009,9 +939,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ "proc-macro2", "quote", @@ -1020,22 +950,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.52" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.52" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.59", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 60963487c..0241f80c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["packages/*", "contracts/*"] [workspace.package] -version = "0.18.0" +version = "2.0.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-nfts" @@ -11,17 +11,18 @@ documentation = "https://docs.cosmwasm.com" rust-version = "1.65" [workspace.dependencies] -cosmwasm-schema = "^1.2" -cosmwasm-std = "^1.2" -cw2 = "^1.1" -cw20 = "^1.1" +cosmwasm-schema = "^2.0" +cosmwasm-std = "^2.0" +cw2 = "^2.0" +cw20 = "^2.0" cw721 = { version = "*", path = "./packages/cw721" } cw721-base = { version = "*", path = "./contracts/cw721-base" } cw721-base-016 = { version = "0.16.0", package = "cw721-base" } -cw-multi-test = "^0.20" -cw-ownable = "^0.5" -cw-storage-plus = "^1.1" -cw-utils = "^1.0" +cw-multi-test = "^2.0" +cw-ownable = { version = "2.0", git = "https://github.com/PFC-Validator/cw-plus-plus", branch = "v2.0.0-wip" } + +cw-storage-plus = "^2.0" +cw-utils = "^2.0" schemars = "^0.8" serde = { version = "1.0.152", default-features = false, features = ["derive"] } thiserror = "^1.0" diff --git a/contracts/cw2981-royalties/Cargo.toml b/contracts/cw2981-royalties/Cargo.toml index d9140bc37..99b06825e 100644 --- a/contracts/cw2981-royalties/Cargo.toml +++ b/contracts/cw2981-royalties/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"] [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw2981-royalties/src/lib.rs b/contracts/cw2981-royalties/src/lib.rs index 194412495..47cd1d0a3 100644 --- a/contracts/cw2981-royalties/src/lib.rs +++ b/contracts/cw2981-royalties/src/lib.rs @@ -131,8 +131,9 @@ mod tests { fn use_metadata_extension() { let mut deps = mock_dependencies(); let contract = Cw2981Contract::default(); + let creator = deps.api.addr_make(CREATOR).to_string(); - let info = mock_info(CREATOR, &[]); + let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { name: "SpaceShips".to_string(), symbol: "SPACE".to_string(), @@ -150,7 +151,7 @@ mod tests { }); let exec_msg = ExecuteMsg::Mint { token_id: token_id.to_string(), - owner: "john".to_string(), + owner: deps.api.addr_make("john").to_string(), token_uri: token_uri.clone(), extension: extension.clone(), }; @@ -165,8 +166,9 @@ mod tests { fn validate_royalty_information() { let mut deps = mock_dependencies(); let _contract = Cw2981Contract::default(); + let creator = deps.api.addr_make(CREATOR).to_string(); - let info = mock_info(CREATOR, &[]); + let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { name: "SpaceShips".to_string(), symbol: "SPACE".to_string(), @@ -178,7 +180,7 @@ mod tests { let token_id = "Enterprise"; let exec_msg = ExecuteMsg::Mint { token_id: token_id.to_string(), - owner: "john".to_string(), + owner: deps.api.addr_make("john").to_string(), token_uri: Some("https://starships.example.com/Starship/Enterprise.json".into()), extension: Some(Metadata { description: Some("Spaceship with Warp Drive".into()), @@ -197,7 +199,9 @@ mod tests { let mut deps = mock_dependencies(); let _contract = Cw2981Contract::default(); - let info = mock_info(CREATOR, &[]); + let creator = deps.api.addr_make(CREATOR).to_string(); + + let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { name: "SpaceShips".to_string(), symbol: "SPACE".to_string(), @@ -209,7 +213,7 @@ mod tests { let token_id = "Enterprise"; let exec_msg = ExecuteMsg::Mint { token_id: token_id.to_string(), - owner: "john".to_string(), + owner: deps.api.addr_make("john").to_string(), token_uri: Some("https://starships.example.com/Starship/Enterprise.json".into()), extension: Some(Metadata { description: Some("Spaceship with Warp Drive".into()), @@ -237,8 +241,9 @@ mod tests { #[test] fn check_token_royalties() { let mut deps = mock_dependencies(); + let creator = deps.api.addr_make(CREATOR).to_string(); - let info = mock_info(CREATOR, &[]); + let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { name: "SpaceShips".to_string(), symbol: "SPACE".to_string(), @@ -248,15 +253,15 @@ mod tests { entry::instantiate(deps.as_mut(), mock_env(), info.clone(), init_msg).unwrap(); let token_id = "Enterprise"; - let owner = "jeanluc"; + let owner = deps.api.addr_make("jeanluc").to_string(); let exec_msg = ExecuteMsg::Mint { token_id: token_id.to_string(), - owner: owner.into(), + owner: owner.clone(), token_uri: Some("https://starships.example.com/Starship/Enterprise.json".into()), extension: Some(Metadata { description: Some("Spaceship with Warp Drive".into()), name: Some("Starship USS Enterprise".to_string()), - royalty_payment_address: Some("jeanluc".to_string()), + royalty_payment_address: Some(deps.api.addr_make("jeanluc").to_string()), royalty_percentage: Some(10), ..Metadata::default() }), @@ -285,15 +290,15 @@ mod tests { // check for rounding down // which is the default behaviour let voyager_token_id = "Voyager"; - let owner = "janeway"; + let owner = deps.api.addr_make("janeway").to_string(); let voyager_exec_msg = ExecuteMsg::Mint { token_id: voyager_token_id.to_string(), - owner: owner.into(), + owner: owner.clone(), token_uri: Some("https://starships.example.com/Starship/Voyager.json".into()), extension: Some(Metadata { description: Some("Spaceship with Warp Drive".into()), name: Some("Starship USS Voyager".to_string()), - royalty_payment_address: Some("janeway".to_string()), + royalty_payment_address: Some(deps.api.addr_make("janeway").to_string()), royalty_percentage: Some(4), ..Metadata::default() }), diff --git a/contracts/cw2981-royalties/src/query.rs b/contracts/cw2981-royalties/src/query.rs index 53c20589f..1fcd385f1 100644 --- a/contracts/cw2981-royalties/src/query.rs +++ b/contracts/cw2981-royalties/src/query.rs @@ -19,7 +19,7 @@ pub fn query_royalties_info( }, None => Decimal::percent(0), }; - let royalty_from_sale_price = sale_price * royalty_percentage; + let royalty_from_sale_price = Decimal::from_ratio(sale_price,Uint128::one()) * royalty_percentage; let royalty_address = match token_info.extension { Some(ext) => match ext.royalty_payment_address { @@ -31,7 +31,7 @@ pub fn query_royalties_info( Ok(RoyaltiesInfoResponse { address: royalty_address, - royalty_amount: royalty_from_sale_price, + royalty_amount: royalty_from_sale_price.to_uint_floor(), }) } diff --git a/contracts/cw721-base/Cargo.toml b/contracts/cw721-base/Cargo.toml index be71889b1..e7e634a96 100644 --- a/contracts/cw721-base/Cargo.toml +++ b/contracts/cw721-base/Cargo.toml @@ -18,7 +18,7 @@ crate-type = ["cdylib", "rlib"] [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] @@ -30,7 +30,7 @@ cw-storage-plus = { workspace = true } cw-utils = { workspace = true } cw2 = { workspace = true } cw721 = { workspace = true } -cw721-base-016 = { workspace = true, features = ["library"] } +#cw721-base-016 = { workspace = true, features = ["library"] } schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } diff --git a/contracts/cw721-base/src/contract_tests.rs b/contracts/cw721-base/src/contract_tests.rs index a128a1939..46658380b 100644 --- a/contracts/cw721-base/src/contract_tests.rs +++ b/contracts/cw721-base/src/contract_tests.rs @@ -1,4 +1,5 @@ #![cfg(test)] + use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{ @@ -19,15 +20,16 @@ const MINTER: &str = "merlin"; const CONTRACT_NAME: &str = "Magic Power"; const SYMBOL: &str = "MGK"; -fn setup_contract(deps: DepsMut<'_>) -> Cw721Contract<'static, Extension, Empty, Empty, Empty> { +fn setup_contract(deps: DepsMut<'_>,creator:Addr,minter:Addr) -> Cw721Contract<'static, Extension, Empty, Empty, Empty> { let contract = Cw721Contract::default(); + let msg = InstantiateMsg { name: CONTRACT_NAME.to_string(), symbol: SYMBOL.to_string(), - minter: Some(String::from(MINTER)), + minter: Some(minter.to_string()), withdraw_address: None, }; - let info = mock_info("creator", &[]); + let info = mock_info(&creator.to_string(), &[]); let res = contract.instantiate(deps, mock_env(), info, msg).unwrap(); assert_eq!(0, res.messages.len()); contract @@ -37,14 +39,14 @@ fn setup_contract(deps: DepsMut<'_>) -> Cw721Contract<'static, Extension, Empty, fn proper_instantiation() { let mut deps = mock_dependencies(); let contract = Cw721Contract::::default(); - + let minter = deps.api.addr_make(MINTER).to_string(); let msg = InstantiateMsg { name: CONTRACT_NAME.to_string(), symbol: SYMBOL.to_string(), - minter: Some(String::from(MINTER)), - withdraw_address: Some(String::from(MINTER)), + minter: Some(minter.clone()), + withdraw_address: Some(minter.clone()), }; - let info = mock_info("creator", &[]); + let info = mock_info(deps.api.addr_make("creator").as_ref(), &[]); // we can just call .unwrap() to assert this was a success let res = contract @@ -54,7 +56,7 @@ fn proper_instantiation() { // it worked, let's query the state let res = contract.minter(deps.as_ref()).unwrap(); - assert_eq!(Some(MINTER.to_string()), res.minter); + assert_eq!(Some(minter.clone()), res.minter); let info = contract.contract_info(deps.as_ref()).unwrap(); assert_eq!( info, @@ -68,7 +70,7 @@ fn proper_instantiation() { .withdraw_address .may_load(deps.as_ref().storage) .unwrap(); - assert_eq!(Some(MINTER.to_string()), withdraw_address); + assert_eq!(Some(minter), withdraw_address); let count = contract.num_tokens(deps.as_ref()).unwrap(); assert_eq!(0, count.count); @@ -81,27 +83,29 @@ fn proper_instantiation() { #[test] fn minting() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").to_string(), token_uri: Some(token_uri.clone()), extension: None, }; // random cannot mint - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let err = contract .execute(deps.as_mut(), mock_env(), random, mint_msg.clone()) .unwrap_err(); assert_eq!(err, ContractError::Ownership(OwnershipError::NotOwner)); // minter can mint - let allowed = mock_info(MINTER, &[]); + let allowed = mock_info(minter.as_ref(), &[]); let _ = contract .execute(deps.as_mut(), mock_env(), allowed, mint_msg) .unwrap(); @@ -132,7 +136,7 @@ fn minting() { assert_eq!( owner, OwnerOfResponse { - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").to_string(), approvals: vec![], } ); @@ -140,12 +144,12 @@ fn minting() { // Cannot mint same token_id again let mint_msg2 = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("hercules"), + owner: deps.api.addr_make("hercules").to_string(), token_uri: None, extension: None, }; - let allowed = mock_info(MINTER, &[]); + let allowed = mock_info(minter.as_ref(), &[]); let err = contract .execute(deps.as_mut(), mock_env(), allowed, mint_msg2) .unwrap_err(); @@ -160,20 +164,23 @@ fn minting() { #[test] fn test_update_minter() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let random = deps.api.addr_make("random"); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); let mint_msg = ExecuteMsg::Mint { token_id, - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").to_string(), token_uri: Some(token_uri.clone()), extension: None, }; // Minter can mint - let minter_info = mock_info(MINTER, &[]); + let minter_info = mock_info(minter.as_ref(), &[]); let _ = contract .execute(deps.as_mut(), mock_env(), minter_info.clone(), mint_msg) .unwrap(); @@ -186,20 +193,20 @@ fn test_update_minter() { mock_env(), minter_info.clone(), ExecuteMsg::UpdateOwnership(cw_ownable::Action::TransferOwnership { - new_owner: "random".to_string(), + new_owner: random.to_string(), expiry: None, }), ) .unwrap(); // Minter does not change until ownership transfer completes. - let minter: MinterResponse = from_json( + let minter_response: MinterResponse = from_json( contract .query(deps.as_ref(), mock_env(), QueryMsg::Minter {}) .unwrap(), ) .unwrap(); - assert_eq!(minter.minter, Some(MINTER.to_string())); + assert_eq!(minter_response.minter, Some(minter.to_string())); // Pending ownership transfer should be discoverable via query. let ownership: cw_ownable::Ownership = from_json( @@ -212,14 +219,14 @@ fn test_update_minter() { assert_eq!( ownership, cw_ownable::Ownership:: { - owner: Some(Addr::unchecked(MINTER)), - pending_owner: Some(Addr::unchecked("random")), + owner: Some(minter), + pending_owner: Some(random.clone()), pending_expiry: None, } ); // Accept the ownership transfer. - let random_info = mock_info("random", &[]); + let random_info = mock_info(random.as_ref(), &[]); contract .execute( deps.as_mut(), @@ -236,11 +243,11 @@ fn test_update_minter() { .unwrap(), ) .unwrap(); - assert_eq!(minter.minter, Some("random".to_string())); + assert_eq!(minter.minter, Some(random.to_string())); let mint_msg = ExecuteMsg::Mint { token_id: "randoms_token".to_string(), - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").to_string(), token_uri: Some(token_uri), extension: None, }; @@ -260,14 +267,16 @@ fn test_update_minter() { #[test] fn burning() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: MINTER.to_string(), + owner: minter.to_string(), token_uri: Some(token_uri), extension: None, }; @@ -275,13 +284,13 @@ fn burning() { let burn_msg = ExecuteMsg::Burn { token_id }; // mint some NFT - let allowed = mock_info(MINTER, &[]); + let allowed = mock_info(minter.as_ref(), &[]); let _ = contract .execute(deps.as_mut(), mock_env(), allowed.clone(), mint_msg) .unwrap(); // random not allowed to burn - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let err = contract .execute(deps.as_mut(), mock_env(), random, burn_msg.clone()) .unwrap_err(); @@ -309,7 +318,9 @@ fn burning() { #[test] fn transferring_nft() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -317,12 +328,12 @@ fn transferring_nft() { let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("venus"), + owner: deps.api.addr_make("venus").to_string(), token_uri: Some(token_uri), extension: None, }; - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); @@ -330,7 +341,7 @@ fn transferring_nft() { // random cannot transfer let random = mock_info("random", &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("random"), + recipient: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), }; @@ -340,9 +351,9 @@ fn transferring_nft() { assert_eq!(err, ContractError::Ownership(OwnershipError::NotOwner)); // owner can - let random = mock_info("venus", &[]); + let random = mock_info(deps.api.addr_make("venus").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("random"), + recipient: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), }; @@ -354,8 +365,8 @@ fn transferring_nft() { res, Response::new() .add_attribute("action", "transfer_nft") - .add_attribute("sender", "venus") - .add_attribute("recipient", "random") + .add_attribute("sender", deps.api.addr_make("venus").as_ref()) + .add_attribute("recipient", deps.api.addr_make("random").as_ref()) .add_attribute("token_id", token_id) ); } @@ -363,7 +374,9 @@ fn transferring_nft() { #[test] fn sending_nft() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -371,38 +384,38 @@ fn sending_nft() { let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("venus"), + owner: deps.api.addr_make("venus").to_string(), token_uri: Some(token_uri), extension: None, }; - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); let msg = to_json_binary("You now have the melting power").unwrap(); - let target = String::from("another_contract"); + let target = deps.api.addr_make("another_contract").to_string(); let send_msg = ExecuteMsg::SendNft { contract: target.clone(), token_id: token_id.clone(), msg: msg.clone(), }; - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let err = contract .execute(deps.as_mut(), mock_env(), random, send_msg.clone()) .unwrap_err(); assert_eq!(err, ContractError::Ownership(OwnershipError::NotOwner)); // but owner can - let random = mock_info("venus", &[]); + let random = mock_info(deps.api.addr_make("venus").as_ref(), &[]); let res = contract .execute(deps.as_mut(), mock_env(), random, send_msg) .unwrap(); let payload = Cw721ReceiveMsg { - sender: String::from("venus"), + sender: deps.api.addr_make("venus").to_string(), token_id: token_id.clone(), msg, }; @@ -412,7 +425,7 @@ fn sending_nft() { CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, .. }) => { assert_eq!(contract_addr, &target) } - m => panic!("Unexpected message type: {m:?}"), + _m => panic!("Unexpected message type: {_m:?}"), } // and make sure this is the request sent by the contract assert_eq!( @@ -420,8 +433,8 @@ fn sending_nft() { Response::new() .add_message(expected) .add_attribute("action", "send_nft") - .add_attribute("sender", "venus") - .add_attribute("recipient", "another_contract") + .add_attribute("sender", deps.api.addr_make("venus").as_ref()) + .add_attribute("recipient", deps.api.addr_make("another_contract").as_ref()) .add_attribute("token_id", token_id) ); } @@ -429,7 +442,9 @@ fn sending_nft() { #[test] fn approving_revoking() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); // Mint a token let token_id = "grow".to_string(); @@ -437,12 +452,12 @@ fn approving_revoking() { let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("demeter"), + owner: deps.api.addr_make("demeter").to_string(), token_uri: Some(token_uri), extension: None, }; - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); @@ -453,7 +468,7 @@ fn approving_revoking() { deps.as_ref(), mock_env(), token_id.clone(), - String::from("demeter"), + deps.api.addr_make("demeter").to_string(), false, ) .unwrap(); @@ -461,7 +476,7 @@ fn approving_revoking() { res, ApprovalResponse { approval: Approval { - spender: String::from("demeter"), + spender: deps.api.addr_make("demeter").to_string(), expires: Expiration::Never {} } } @@ -469,11 +484,11 @@ fn approving_revoking() { // Give random transferring power let approve_msg = ExecuteMsg::Approve { - spender: String::from("random"), + spender:deps.api.addr_make("random").to_string(), token_id: token_id.clone(), expires: None, }; - let owner = mock_info("demeter", &[]); + let owner = mock_info(deps.api.addr_make("demeter").as_ref(), &[]); let res = contract .execute(deps.as_mut(), mock_env(), owner, approve_msg) .unwrap(); @@ -481,8 +496,8 @@ fn approving_revoking() { res, Response::new() .add_attribute("action", "approve") - .add_attribute("sender", "demeter") - .add_attribute("spender", "random") + .add_attribute("sender", deps.api.addr_make("demeter").as_ref()) + .add_attribute("spender", deps.api.addr_make("random").as_ref()) .add_attribute("token_id", token_id.clone()) ); @@ -492,7 +507,7 @@ fn approving_revoking() { deps.as_ref(), mock_env(), token_id.clone(), - String::from("random"), + deps.api.addr_make("random").to_string(), true, ) .unwrap(); @@ -500,16 +515,16 @@ fn approving_revoking() { res, ApprovalResponse { approval: Approval { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), expires: Expiration::Never {} } } ); // random can now transfer - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("person"), + recipient:deps.api.addr_make("person").to_string(), token_id: token_id.clone(), }; contract @@ -530,24 +545,24 @@ fn approving_revoking() { assert_eq!( res, OwnerOfResponse { - owner: String::from("person"), + owner:deps.api.addr_make("person").to_string(), approvals: vec![], } ); // Approve, revoke, and check for empty, to test revoke let approve_msg = ExecuteMsg::Approve { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), expires: None, }; - let owner = mock_info("person", &[]); + let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), owner.clone(), approve_msg) .unwrap(); let revoke_msg = ExecuteMsg::Revoke { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), token_id, }; contract @@ -564,7 +579,7 @@ fn approving_revoking() { assert_eq!( res, OwnerOfResponse { - owner: String::from("person"), + owner: deps.api.addr_make("person").to_string(), approvals: vec![], } ); @@ -573,7 +588,9 @@ fn approving_revoking() { #[test] fn approving_all_revoking_all() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); @@ -584,19 +601,19 @@ fn approving_all_revoking_all() { let mint_msg1 = ExecuteMsg::Mint { token_id: token_id1.clone(), - owner: String::from("demeter"), + owner: deps.api.addr_make("demeter").to_string(), token_uri: Some(token_uri1), extension: None, }; - let minter = mock_info(MINTER, &[]); + let minter = mock_info(deps.api.addr_make(MINTER).as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), minter.clone(), mint_msg1) .unwrap(); let mint_msg2 = ExecuteMsg::Mint { token_id: token_id2.clone(), - owner: String::from("demeter"), + owner: deps.api.addr_make("demeter").to_string(), token_uri: Some(token_uri2), extension: None, }; @@ -617,10 +634,10 @@ fn approving_all_revoking_all() { // demeter gives random full (operator) power over her tokens let approve_all_msg = ExecuteMsg::ApproveAll { - operator: String::from("random"), + operator: deps.api.addr_make("random").to_string(), expires: None, }; - let owner = mock_info("demeter", &[]); + let owner = mock_info(deps.api.addr_make("demeter").as_ref(), &[]); let res = contract .execute(deps.as_mut(), mock_env(), owner, approve_all_msg) .unwrap(); @@ -628,14 +645,14 @@ fn approving_all_revoking_all() { res, Response::new() .add_attribute("action", "approve_all") - .add_attribute("sender", "demeter") - .add_attribute("operator", "random") + .add_attribute("sender", deps.api.addr_make("demeter").as_ref()) + .add_attribute("operator", deps.api.addr_make("random").as_ref()) ); // random can now transfer - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("person"), + recipient: deps.api.addr_make("person").to_string(), token_id: token_id1, }; contract @@ -651,7 +668,7 @@ fn approving_all_revoking_all() { let msg: CosmosMsg = CosmosMsg::Wasm(inner_msg); let send_msg = ExecuteMsg::SendNft { - contract: String::from("another_contract"), + contract: deps.api.addr_make("another_contract").to_string(), token_id: token_id2, msg: to_json_binary(&msg).unwrap(), }; @@ -661,11 +678,11 @@ fn approving_all_revoking_all() { // Approve_all, revoke_all, and check for empty, to test revoke_all let approve_all_msg = ExecuteMsg::ApproveAll { - operator: String::from("operator"), + operator: deps.api.addr_make("operator").to_string(), expires: None, }; // person is now the owner of the tokens - let owner = mock_info("person", &[]); + let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), owner, approve_all_msg) .unwrap(); @@ -675,8 +692,8 @@ fn approving_all_revoking_all() { .operator( deps.as_ref(), mock_env(), - String::from("person"), - String::from("operator"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("operator").to_string(), true, ) .unwrap(); @@ -684,7 +701,7 @@ fn approving_all_revoking_all() { res, OperatorResponse { approval: Approval { - spender: String::from("operator"), + spender: deps.api.addr_make("operator").to_string(), expires: Expiration::Never {} } } @@ -694,12 +711,12 @@ fn approving_all_revoking_all() { let res = contract.operator( deps.as_ref(), mock_env(), - String::from("person"), - String::from("other"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("other").to_string(), true, ); match res { - Err(StdError::NotFound { kind }) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound{kind ,..}) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } @@ -707,7 +724,7 @@ fn approving_all_revoking_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), true, None, None, @@ -717,7 +734,7 @@ fn approving_all_revoking_all() { res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("operator"), + spender: deps.api.addr_make("operator").to_string(), expires: Expiration::Never {} }] } @@ -726,10 +743,10 @@ fn approving_all_revoking_all() { // second approval let buddy_expires = Expiration::AtHeight(1234567); let approve_all_msg = ExecuteMsg::ApproveAll { - operator: String::from("buddy"), + operator: deps.api.addr_make("buddy").to_string(), expires: Some(buddy_expires), }; - let owner = mock_info("person", &[]); + let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), owner.clone(), approve_all_msg) .unwrap(); @@ -739,18 +756,20 @@ fn approving_all_revoking_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), true, None, Some(1), ) .unwrap(); + // addr_make actually makes the buddy address *after* the operator one + assert_eq!( res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("buddy"), - expires: buddy_expires, + spender: deps.api.addr_make("operator").to_string(), + expires: Expiration::Never {} }] } ); @@ -758,24 +777,24 @@ fn approving_all_revoking_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), true, - Some(String::from("buddy")), + Some(deps.api.addr_make("operator").to_string()), Some(2), ) .unwrap(); + assert_eq!( res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("operator"), - expires: Expiration::Never {} + spender: deps.api.addr_make("buddy").to_string(), + expires: buddy_expires, }] } ); - let revoke_all_msg = ExecuteMsg::RevokeAll { - operator: String::from("operator"), + operator: deps.api.addr_make("operator").to_string(), }; contract .execute(deps.as_mut(), mock_env(), owner, revoke_all_msg) @@ -785,12 +804,12 @@ fn approving_all_revoking_all() { let res = contract.operator( deps.as_ref(), mock_env(), - String::from("person"), - String::from("operator"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("operator").to_string(), true, ); match res { - Err(StdError::NotFound { kind }) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound {kind, ..} ) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } @@ -799,7 +818,7 @@ fn approving_all_revoking_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), false, None, None, @@ -809,7 +828,7 @@ fn approving_all_revoking_all() { res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("buddy"), + spender: deps.api.addr_make("buddy").to_string(), expires: buddy_expires, }] } @@ -822,7 +841,7 @@ fn approving_all_revoking_all() { .operators( deps.as_ref(), late_env.clone(), - String::from("person"), + deps.api.addr_make("person").to_string(), false, None, None, @@ -834,13 +853,13 @@ fn approving_all_revoking_all() { let res = contract.operator( deps.as_ref(), late_env, - String::from("person"), - String::from("buddy"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("buddy").to_string(), false, ); match res { - Err(StdError::NotFound { kind }) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound{ kind, ..}) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } } @@ -848,94 +867,107 @@ fn approving_all_revoking_all() { #[test] fn test_set_withdraw_address() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); - + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let other = deps.api.addr_make("other"); // other cant set + let foo = deps.api.addr_make("foo"); let err = contract - .set_withdraw_address(deps.as_mut(), &Addr::unchecked("other"), "foo".to_string()) + .set_withdraw_address(deps.as_mut(), &other, foo.to_string()) .unwrap_err(); assert_eq!(err, ContractError::Ownership(OwnershipError::NotOwner)); // minter can set contract - .set_withdraw_address(deps.as_mut(), &Addr::unchecked(MINTER), "foo".to_string()) + .set_withdraw_address(deps.as_mut(), &minter, foo.to_string()) .unwrap(); let withdraw_address = contract .withdraw_address .load(deps.as_ref().storage) .unwrap(); - assert_eq!(withdraw_address, "foo".to_string()) + assert_eq!(withdraw_address, foo.to_string()) } #[test] fn test_remove_withdraw_address() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); - + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter); + let other = deps.api.addr_make("other"); + let foo = deps.api.addr_make("foo"); // other cant remove let err = contract - .remove_withdraw_address(deps.as_mut().storage, &Addr::unchecked("other")) + .remove_withdraw_address(deps.as_mut().storage, &other) .unwrap_err(); assert_eq!(err, ContractError::Ownership(OwnershipError::NotOwner)); + let minter = deps.api.addr_make(MINTER); // no owner set yet let err = contract - .remove_withdraw_address(deps.as_mut().storage, &Addr::unchecked(MINTER)) + .remove_withdraw_address(deps.as_mut().storage, &minter) .unwrap_err(); assert_eq!(err, ContractError::NoWithdrawAddress {}); // set and remove contract - .set_withdraw_address(deps.as_mut(), &Addr::unchecked(MINTER), "foo".to_string()) + .set_withdraw_address(deps.as_mut(), &minter,foo.to_string()) .unwrap(); contract - .remove_withdraw_address(deps.as_mut().storage, &Addr::unchecked(MINTER)) + .remove_withdraw_address(deps.as_mut().storage, &minter) .unwrap(); assert!(!contract.withdraw_address.exists(deps.as_ref().storage)); // test that we can set again contract - .set_withdraw_address(deps.as_mut(), &Addr::unchecked(MINTER), "foo".to_string()) + .set_withdraw_address(deps.as_mut(), &minter, foo.to_string()) .unwrap(); let withdraw_address = contract .withdraw_address .load(deps.as_ref().storage) .unwrap(); - assert_eq!(withdraw_address, "foo".to_string()) + assert_eq!(withdraw_address, foo.to_string()) } #[test] fn test_withdraw_funds() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let foo = deps.api.addr_make("foo"); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); // no withdraw address set let err = contract - .withdraw_funds(deps.as_mut().storage, &Coin::new(100, "uark")) + .withdraw_funds(deps.as_mut().storage, &Coin::new(100u32, "uark")) .unwrap_err(); assert_eq!(err, ContractError::NoWithdrawAddress {}); // set and withdraw by non-owner contract - .set_withdraw_address(deps.as_mut(), &Addr::unchecked(MINTER), "foo".to_string()) + .set_withdraw_address(deps.as_mut(), &minter,foo.to_string()) .unwrap(); contract - .withdraw_funds(deps.as_mut().storage, &Coin::new(100, "uark")) + .withdraw_funds(deps.as_mut().storage, &Coin::new(100u32, "uark")) .unwrap(); } #[test] fn query_tokens_by_owner() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut()); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + + let minter = mock_info(minter.as_ref(), &[]); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); - let demeter = String::from("demeter"); + let demeter = deps.api.addr_make("demeter").to_string(); let token_id2 = "grow2".to_string(); - let ceres = String::from("ceres"); + let ceres = deps.api.addr_make("ceres").to_string(); let token_id3 = "sing".to_string(); let mint_msg = ExecuteMsg::Mint { diff --git a/contracts/cw721-base/src/lib.rs b/contracts/cw721-base/src/lib.rs index b7b567ed8..d0d30c82c 100644 --- a/contracts/cw721-base/src/lib.rs +++ b/contracts/cw721-base/src/lib.rs @@ -86,7 +86,8 @@ pub mod entry { cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; // perform the upgrade - upgrades::v0_17::migrate::(deps) + // upgrades::v0_17::migrate::(deps) + Ok(Response::new()) } } @@ -101,15 +102,16 @@ mod tests { #[test] fn proper_cw2_initialization() { let mut deps = mock_dependencies(); - + let larry = deps.api.addr_make("larry"); + let other = deps.api.addr_make("other"); entry::instantiate( deps.as_mut(), mock_env(), - mock_info("larry", &[]), + mock_info(larry.as_ref(), &[]), InstantiateMsg { name: "".into(), symbol: "".into(), - minter: Some("other".into()), + minter: Some(other.to_string()), withdraw_address: None, }, ) @@ -119,7 +121,7 @@ mod tests { .unwrap() .owner .map(|a| a.into_string()); - assert_eq!(minter, Some("other".to_string())); + assert_eq!(minter, Some(other.to_string())); let version = cw2::get_contract_version(deps.as_ref().storage).unwrap(); assert_eq!( @@ -134,11 +136,11 @@ mod tests { #[test] fn proper_owner_initialization() { let mut deps = mock_dependencies(); - + let owner = deps.api.addr_make("owner").to_string(); entry::instantiate( deps.as_mut(), mock_env(), - mock_info("owner", &[]), + mock_info(owner.as_ref(), &[]), InstantiateMsg { name: "".into(), symbol: "".into(), @@ -152,6 +154,6 @@ mod tests { .unwrap() .owner .map(|a| a.into_string()); - assert_eq!(minter, Some("owner".to_string())); + assert_eq!(minter, Some(owner.to_string())); } } diff --git a/contracts/cw721-base/src/multi_tests.rs b/contracts/cw721-base/src/multi_tests.rs index d691d8a0a..f0a3e4f34 100644 --- a/contracts/cw721-base/src/multi_tests.rs +++ b/contracts/cw721-base/src/multi_tests.rs @@ -1,9 +1,7 @@ -use cosmwasm_std::{to_json_binary, Addr, Empty, QuerierWrapper, WasmMsg}; +use cosmwasm_std::{Addr, Empty, QuerierWrapper}; use cw721::OwnerOfResponse; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; -use crate::MinterResponse; - fn cw721_base_latest_contract() -> Box> { let contract = ContractWrapper::new( crate::entry::execute, @@ -14,15 +12,6 @@ fn cw721_base_latest_contract() -> Box> { Box::new(contract) } -fn cw721_base_016_contract() -> Box> { - use cw721_base_016 as v16; - let contract = ContractWrapper::new( - v16::entry::execute, - v16::entry::instantiate, - v16::entry::query, - ); - Box::new(contract) -} fn query_owner(querier: QuerierWrapper, cw721: &Addr, token_id: String) -> Addr { let resp: OwnerOfResponse = querier @@ -52,7 +41,7 @@ fn mint_transfer_and_burn(app: &mut App, cw721: Addr, sender: Addr, token_id: St .unwrap(); let owner = query_owner(app.wrap(), &cw721, token_id.clone()); - assert_eq!(owner, sender.to_string()); + assert_eq!(owner.to_string(), sender.to_string()); app.execute_contract( sender, @@ -66,7 +55,7 @@ fn mint_transfer_and_burn(app: &mut App, cw721: Addr, sender: Addr, token_id: St .unwrap(); let owner = query_owner(app.wrap(), &cw721, token_id.clone()); - assert_eq!(owner, "burner".to_string()); + assert_eq!(owner.to_string(), "burner".to_string()); app.execute_contract( Addr::unchecked("burner"), @@ -76,93 +65,3 @@ fn mint_transfer_and_burn(app: &mut App, cw721: Addr, sender: Addr, token_id: St ) .unwrap(); } - -/// Instantiates a 0.16 version of this contract and tests that tokens -/// can be minted, transferred, and burnred after migration. -#[test] -fn test_migration_016_to_latest() { - use cw721_base_016 as v16; - let mut app = App::default(); - let admin = || Addr::unchecked("admin"); - - let code_id_016 = app.store_code(cw721_base_016_contract()); - let code_id_latest = app.store_code(cw721_base_latest_contract()); - - let cw721 = app - .instantiate_contract( - code_id_016, - admin(), - &v16::InstantiateMsg { - name: "collection".to_string(), - symbol: "symbol".to_string(), - minter: admin().into_string(), - }, - &[], - "cw721-base", - Some(admin().into_string()), - ) - .unwrap(); - - mint_transfer_and_burn(&mut app, cw721.clone(), admin(), "1".to_string()); - - app.execute( - admin(), - WasmMsg::Migrate { - contract_addr: cw721.to_string(), - new_code_id: code_id_latest, - msg: to_json_binary(&Empty::default()).unwrap(), - } - .into(), - ) - .unwrap(); - - mint_transfer_and_burn(&mut app, cw721.clone(), admin(), "1".to_string()); - - // check new mint query response works. - let m: MinterResponse = app - .wrap() - .query_wasm_smart(&cw721, &crate::QueryMsg::::Minter {}) - .unwrap(); - assert_eq!(m.minter, Some(admin().to_string())); - - // check that the new response is backwards compatable when minter - // is not None. - let m: v16::MinterResponse = app - .wrap() - .query_wasm_smart(&cw721, &crate::QueryMsg::::Minter {}) - .unwrap(); - assert_eq!(m.minter, admin().to_string()); -} - -/// Test backward compatibility using instantiate msg from a 0.16 version on latest contract. -/// This ensures existing 3rd party contracts doesnt need to updated as well. -#[test] -fn test_instantiate_016_msg() { - use cw721_base_016 as v16; - let mut app = App::default(); - let admin = || Addr::unchecked("admin"); - - let code_id_latest = app.store_code(cw721_base_latest_contract()); - - let cw721 = app - .instantiate_contract( - code_id_latest, - admin(), - &v16::InstantiateMsg { - name: "collection".to_string(), - symbol: "symbol".to_string(), - minter: admin().into_string(), - }, - &[], - "cw721-base", - Some(admin().into_string()), - ) - .unwrap(); - - // assert withdraw address is None - let withdraw_addr: Option = app - .wrap() - .query_wasm_smart(cw721, &crate::QueryMsg::::GetWithdrawAddress {}) - .unwrap(); - assert!(withdraw_addr.is_none()); -} diff --git a/contracts/cw721-base/src/query.rs b/contracts/cw721-base/src/query.rs index 52db6a7ca..8dc820bd6 100644 --- a/contracts/cw721-base/src/query.rs +++ b/contracts/cw721-base/src/query.rs @@ -128,7 +128,7 @@ where let token = self.tokens.load(deps.storage, &token_id)?; // token owner has absolute approval - if token.owner == spender { + if token.owner.to_string() == spender { let approval = cw721::Approval { spender: token.owner.to_string(), expires: Expiration::Never {}, @@ -139,7 +139,7 @@ where let filtered: Vec<_> = token .approvals .into_iter() - .filter(|t| t.spender == spender) + .filter(|t| t.spender.to_string() == spender) .filter(|t| include_expired || !t.is_expired(&env.block)) .map(|a| cw721::Approval { spender: a.spender.into_string(), diff --git a/contracts/cw721-base/src/state.rs b/contracts/cw721-base/src/state.rs index 48bca6bf5..1fbf2540c 100644 --- a/contracts/cw721-base/src/state.rs +++ b/contracts/cw721-base/src/state.rs @@ -14,12 +14,12 @@ where Q: CustomMsg, E: CustomMsg, { - pub contract_info: Item<'a, ContractInfoResponse>, - pub token_count: Item<'a, u64>, + pub contract_info: Item, + pub token_count: Item, /// Stored as (granter, operator) giving operator full control over granter's account - pub operators: Map<'a, (&'a Addr, &'a Addr), Expiration>, - pub tokens: IndexedMap<'a, &'a str, TokenInfo, TokenIndexes<'a, T>>, - pub withdraw_address: Item<'a, String>, + pub operators: Map< (&'a Addr, &'a Addr), Expiration>, + pub tokens: IndexedMap<&'a str, TokenInfo, TokenIndexes<'a, T>>, + pub withdraw_address: Item, pub(crate) _custom_response: PhantomData, pub(crate) _custom_query: PhantomData, @@ -61,12 +61,12 @@ where Q: CustomMsg, { fn new( - contract_key: &'a str, - token_count_key: &'a str, - operator_key: &'a str, - tokens_key: &'a str, - tokens_owner_key: &'a str, - withdraw_address_key: &'a str, + contract_key: &'static str, + token_count_key: &'static str, + operator_key: &'static str, + tokens_key: &'static str, + tokens_owner_key: &'static str, + withdraw_address_key: &'static str, ) -> Self { let indexes = TokenIndexes { owner: MultiIndex::new(token_owner_idx, tokens_key, tokens_owner_key), diff --git a/contracts/cw721-base/src/upgrades/mod.rs b/contracts/cw721-base/src/upgrades/mod.rs index bdb01c30d..2fada0cf2 100644 --- a/contracts/cw721-base/src/upgrades/mod.rs +++ b/contracts/cw721-base/src/upgrades/mod.rs @@ -1 +1 @@ -pub mod v0_17; +//pub mod v0_17; diff --git a/contracts/cw721-base/src/upgrades/v0_17.rs b/contracts/cw721-base/src/upgrades/v0_17.rs index c0bd63b98..5e2856aad 100644 --- a/contracts/cw721-base/src/upgrades/v0_17.rs +++ b/contracts/cw721-base/src/upgrades/v0_17.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{CustomMsg, DepsMut, Response}; -use cw721_base_016 as v16; + use serde::{de::DeserializeOwned, Serialize}; use crate::ContractError; diff --git a/contracts/cw721-expiration/Cargo.toml b/contracts/cw721-expiration/Cargo.toml index 4854b31b6..4b272108b 100644 --- a/contracts/cw721-expiration/Cargo.toml +++ b/contracts/cw721-expiration/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"] [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-expiration/src/contract_tests.rs b/contracts/cw721-expiration/src/contract_tests.rs index 7cfe8f501..0b87fbe3a 100644 --- a/contracts/cw721-expiration/src/contract_tests.rs +++ b/contracts/cw721-expiration/src/contract_tests.rs @@ -23,16 +23,16 @@ const MINTER: &str = "merlin"; const CONTRACT_NAME: &str = "Magic Power"; const SYMBOL: &str = "MGK"; -fn setup_contract(deps: DepsMut<'_>, expiration_days: u16) -> Cw721ExpirationContract<'static> { +fn setup_contract(deps: DepsMut<'_>, expiration_days: u16,creator:Addr,minter:Addr) -> Cw721ExpirationContract<'static> { let contract = Cw721ExpirationContract::default(); let msg = InstantiateMsg { expiration_days, name: CONTRACT_NAME.to_string(), symbol: SYMBOL.to_string(), - minter: Some(String::from(MINTER)), + minter: Some(minter.to_string()), withdraw_address: None, }; - let info = mock_info("creator", &[]); + let info = mock_info(creator.as_ref(), &[]); let res = contract.instantiate(deps, mock_env(), info, msg).unwrap(); assert_eq!(0, res.messages.len()); contract @@ -42,12 +42,12 @@ fn setup_contract(deps: DepsMut<'_>, expiration_days: u16) -> Cw721ExpirationCon fn proper_instantiation() { let mut deps = mock_dependencies(); let contract = Cw721ExpirationContract::default(); - + let minter = deps.api.addr_make(MINTER); let msg = InstantiateMsg { expiration_days: 1, name: CONTRACT_NAME.to_string(), symbol: SYMBOL.to_string(), - minter: Some(String::from(MINTER)), + minter: Some(minter.to_string()), withdraw_address: None, }; let info = mock_info("creator", &[]); @@ -60,7 +60,7 @@ fn proper_instantiation() { // it worked, let's query the state let res = contract.minter(deps.as_ref()).unwrap(); - assert_eq!(Some(MINTER.to_string()), res.minter); + assert_eq!(Some(minter.to_string()), res.minter); let info = contract.contract_info(deps.as_ref()).unwrap(); assert_eq!( info, @@ -83,14 +83,16 @@ fn proper_instantiation() { #[test] fn test_mint() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make("minter"); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); let token_id = "atomize".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/atomize".to_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").into_string(), token_uri: Some(token_uri.clone()), extension: None, }; @@ -106,7 +108,7 @@ fn test_mint() { ); // minter can mint - let allowed = mock_info(MINTER, &[]); + let allowed = mock_info(minter.as_ref(), &[]); let _ = contract .execute(deps.as_mut(), mock_env(), allowed, mint_msg) .unwrap(); @@ -139,7 +141,7 @@ fn test_mint() { assert_eq!( owner, OwnerOfResponse { - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").to_string(), approvals: vec![], } ); @@ -154,12 +156,12 @@ fn test_mint() { // Cannot mint same token_id again let mint_msg2 = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("hercules"), + owner: deps.api.addr_make("hercules").to_string(), token_uri: None, extension: None, }; - let allowed = mock_info(MINTER, &[]); + let allowed = mock_info(minter.as_ref(), &[]); let err = contract .execute(deps.as_mut(), mock_env(), allowed, mint_msg2) .unwrap_err(); @@ -176,46 +178,49 @@ fn test_mint() { #[test] fn test_update_minter() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); let mint_msg = ExecuteMsg::Mint { token_id, - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").into_string(), token_uri: Some(token_uri.clone()), extension: None, }; // Minter can mint - let minter_info = mock_info(MINTER, &[]); + let minter_info = mock_info(minter.as_ref(), &[]); let _ = contract .execute(deps.as_mut(), mock_env(), minter_info.clone(), mint_msg) .unwrap(); // Update the owner to "random". The new owner should be able to // mint new tokens, the old one should not. + let random = deps.api.addr_make("random"); contract .execute( deps.as_mut(), mock_env(), minter_info.clone(), ExecuteMsg::UpdateOwnership(cw_ownable::Action::TransferOwnership { - new_owner: "random".to_string(), + new_owner: random.to_string(), expiry: None, }), ) .unwrap(); // Minter does not change until ownership transfer completes. - let minter: MinterResponse = from_json( + let minter_res: MinterResponse = from_json( contract .query(deps.as_ref(), mock_env(), QueryMsg::Minter {}) .unwrap(), ) .unwrap(); - assert_eq!(minter.minter, Some(MINTER.to_string())); + assert_eq!(minter_res.minter, Some(minter.to_string())); // Pending ownership transfer should be discoverable via query. let ownership: cw_ownable::Ownership = from_json( @@ -228,14 +233,14 @@ fn test_update_minter() { assert_eq!( ownership, cw_ownable::Ownership:: { - owner: Some(Addr::unchecked(MINTER)), - pending_owner: Some(Addr::unchecked("random")), + owner: Some(minter), + pending_owner: Some(random.clone()), pending_expiry: None, } ); // Accept the ownership transfer. - let random_info = mock_info("random", &[]); + let random_info = mock_info(random.as_ref(), &[]); contract .execute( deps.as_mut(), @@ -252,11 +257,11 @@ fn test_update_minter() { .unwrap(), ) .unwrap(); - assert_eq!(minter.minter, Some("random".to_string())); + assert_eq!(minter.minter, Some(deps.api.addr_make("random").to_string())); let mint_msg = ExecuteMsg::Mint { token_id: "randoms_token".to_string(), - owner: String::from("medusa"), + owner: deps.api.addr_make("medusa").to_string(), token_uri: Some(token_uri), extension: None, }; @@ -279,14 +284,16 @@ fn test_update_minter() { #[test] fn test_burn() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: MINTER.to_string(), + owner: minter.to_string(), token_uri: Some(token_uri), extension: None, }; @@ -297,13 +304,13 @@ fn test_burn() { // mint some NFT let mut env = mock_env(); - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); let _ = contract .execute(deps.as_mut(), env.clone(), minter.clone(), mint_msg.clone()) .unwrap(); // random not allowed to burn - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let err = contract .execute(deps.as_mut(), env.clone(), random, burn_msg.clone()) .unwrap_err(); @@ -357,30 +364,32 @@ fn test_burn() { #[test] fn test_transfer_nft() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); // Mint a token let token_id = "melt".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/melt".to_string(); - let owner = "owner"; + let owner = deps.api.addr_make("owner").into_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from(owner), + owner: owner.clone(), token_uri: Some(token_uri), extension: None, }; let mut env = mock_env(); - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), env.clone(), minter, mint_msg) .unwrap(); // random cannot transfer - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("random"), + recipient: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), }; @@ -393,8 +402,9 @@ fn test_transfer_nft() { ); // owner can - let owner_info = mock_info(owner, &[]); - let new_owner = "random"; + let owner_info = mock_info(owner.as_ref(), &[]); + let binding = deps.api.addr_make( "random"); + let new_owner =binding.as_ref(); let transfer_msg = ExecuteMsg::TransferNft { recipient: String::from(new_owner), token_id: token_id.clone(), @@ -438,7 +448,9 @@ fn test_transfer_nft() { #[test] fn test_send_nft() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -446,26 +458,26 @@ fn test_send_nft() { let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("venus"), + owner: deps.api.addr_make("venus").to_string(), token_uri: Some(token_uri), extension: None, }; let mut env = mock_env(); - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), env.clone(), minter, mint_msg) .unwrap(); let msg = to_json_binary("You now have the melting power").unwrap(); - let target = String::from("another_contract"); + let target =deps.api.addr_make("another_contract").to_string(); let send_msg = ExecuteMsg::SendNft { contract: target.clone(), token_id: token_id.clone(), msg: msg.clone(), }; - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let err = contract .execute(deps.as_mut(), env.clone(), random, send_msg.clone()) .unwrap_err(); @@ -475,13 +487,13 @@ fn test_send_nft() { ); // but owner can - let random = mock_info("venus", &[]); + let random = mock_info(deps.api.addr_make("venus").as_ref(), &[]); let res = contract .execute(deps.as_mut(), env.clone(), random.clone(), send_msg.clone()) .unwrap(); let payload = Cw721ReceiveMsg { - sender: String::from("venus"), + sender: deps.api.addr_make("venus").to_string(), token_id: token_id.clone(), msg, }; @@ -491,7 +503,7 @@ fn test_send_nft() { CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, .. }) => { assert_eq!(contract_addr, &target) } - m => panic!("Unexpected message type: {m:?}"), + _m => panic!("Unexpected message type: {_m:?}"), } // and make sure this is the request sent by the contract assert_eq!( @@ -499,8 +511,8 @@ fn test_send_nft() { Response::new() .add_message(expected) .add_attribute("action", "send_nft") - .add_attribute("sender", "venus") - .add_attribute("recipient", "another_contract") + .add_attribute("sender", deps.api.addr_make("venus").as_ref()) + .add_attribute("recipient", deps.api.addr_make("another_contract").as_ref()) .add_attribute("token_id", token_id.clone()) ); @@ -524,7 +536,9 @@ fn test_send_nft() { #[test] fn test_approve_revoke() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); // Mint a token let token_id = "grow".to_string(); @@ -532,13 +546,13 @@ fn test_approve_revoke() { let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: String::from("demeter"), + owner: deps.api.addr_make("demeter").to_string(), token_uri: Some(token_uri), extension: None, }; let mut env = mock_env(); - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), env.clone(), minter, mint_msg) .unwrap(); @@ -549,7 +563,7 @@ fn test_approve_revoke() { deps.as_ref(), env.clone(), token_id.clone(), - String::from("demeter"), + deps.api.addr_make("demeter").to_string(), false, false, ) @@ -558,7 +572,7 @@ fn test_approve_revoke() { res, ApprovalResponse { approval: Approval { - spender: String::from("demeter"), + spender: deps.api.addr_make("demeter").to_string(), expires: Expiration::Never {} } } @@ -566,11 +580,11 @@ fn test_approve_revoke() { // Give random transferring power let approve_msg = ExecuteMsg::Approve { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), expires: None, }; - let owner = mock_info("demeter", &[]); + let owner = mock_info(deps.api.addr_make("demeter").as_ref(), &[]); let res = contract .execute(deps.as_mut(), env.clone(), owner, approve_msg) .unwrap(); @@ -578,8 +592,8 @@ fn test_approve_revoke() { res, Response::new() .add_attribute("action", "approve") - .add_attribute("sender", "demeter") - .add_attribute("spender", "random") + .add_attribute("sender", deps.api.addr_make("demeter").as_ref()) + .add_attribute("spender", deps.api.addr_make("random").as_ref()) .add_attribute("token_id", token_id.clone()) ); @@ -589,7 +603,7 @@ fn test_approve_revoke() { deps.as_ref(), env.clone(), token_id.clone(), - String::from("random"), + deps.api.addr_make("random").to_string(), true, false, ) @@ -598,16 +612,16 @@ fn test_approve_revoke() { res, ApprovalResponse { approval: Approval { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), expires: Expiration::Never {} } } ); // random can now transfer - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("person"), + recipient: deps.api.addr_make("person").to_string(), token_id: token_id.clone(), }; contract @@ -629,18 +643,18 @@ fn test_approve_revoke() { assert_eq!( res, OwnerOfResponse { - owner: String::from("person"), + owner: deps.api.addr_make("person").to_string(), approvals: vec![], } ); // Approve, revoke, and check for empty, to test revoke let approve_msg = ExecuteMsg::Approve { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), expires: None, }; - let owner = mock_info("person", &[]); + let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); contract .execute( deps.as_mut(), @@ -651,7 +665,7 @@ fn test_approve_revoke() { .unwrap(); let revoke_msg = ExecuteMsg::Revoke { - spender: String::from("random"), + spender: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), }; contract @@ -673,7 +687,7 @@ fn test_approve_revoke() { assert_eq!( res, OwnerOfResponse { - owner: String::from("person"), + owner: deps.api.addr_make("person").to_string(), approvals: vec![], } ); @@ -711,7 +725,9 @@ fn test_approve_revoke() { #[test] fn test_approve_all_revoke_all() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); @@ -722,19 +738,19 @@ fn test_approve_all_revoke_all() { let mint_msg1 = ExecuteMsg::Mint { token_id: token_id1.clone(), - owner: String::from("demeter"), + owner: deps.api.addr_make("demeter").to_string(), token_uri: Some(token_uri1), extension: None, }; - let minter = mock_info(MINTER, &[]); + let minter = mock_info(minter.as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), minter.clone(), mint_msg1) .unwrap(); let mint_msg2 = ExecuteMsg::Mint { token_id: token_id2.clone(), - owner: String::from("demeter"), + owner: deps.api.addr_make("demeter").to_string(), token_uri: Some(token_uri2), extension: None, }; @@ -763,10 +779,10 @@ fn test_approve_all_revoke_all() { // demeter gives random full (operator) power over her tokens let approve_all_msg = ExecuteMsg::ApproveAll { - operator: String::from("random"), + operator: deps.api.addr_make("random").to_string(), expires: None, }; - let owner = mock_info("demeter", &[]); + let owner = mock_info(deps.api.addr_make("demeter").as_ref(), &[]); let res = contract .execute(deps.as_mut(), mock_env(), owner, approve_all_msg) .unwrap(); @@ -774,14 +790,14 @@ fn test_approve_all_revoke_all() { res, Response::new() .add_attribute("action", "approve_all") - .add_attribute("sender", "demeter") - .add_attribute("operator", "random") + .add_attribute("sender", deps.api.addr_make("demeter").as_ref()) + .add_attribute("operator", deps.api.addr_make("random").as_ref()) ); // random can now transfer - let random = mock_info("random", &[]); + let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient: String::from("person"), + recipient: deps.api.addr_make("person").to_string(), token_id: token_id1, }; contract @@ -790,14 +806,14 @@ fn test_approve_all_revoke_all() { // random can now send let inner_msg = WasmMsg::Execute { - contract_addr: "another_contract".into(), + contract_addr: deps.api.addr_make("another_contract").into(), msg: to_json_binary("You now also have the growing power").unwrap(), funds: vec![], }; let msg: CosmosMsg = CosmosMsg::Wasm(inner_msg); let send_msg = ExecuteMsg::SendNft { - contract: String::from("another_contract"), + contract: deps.api.addr_make("another_contract").to_string(), token_id: token_id2, msg: to_json_binary(&msg).unwrap(), }; @@ -807,11 +823,11 @@ fn test_approve_all_revoke_all() { // Approve_all, revoke_all, and check for empty, to test revoke_all let approve_all_msg = ExecuteMsg::ApproveAll { - operator: String::from("operator"), + operator: deps.api.addr_make("operator").to_string(), expires: None, }; // person is now the owner of the tokens - let owner = mock_info("person", &[]); + let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), owner, approve_all_msg) .unwrap(); @@ -821,8 +837,8 @@ fn test_approve_all_revoke_all() { .operator( deps.as_ref(), mock_env(), - String::from("person"), - String::from("operator"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("operator").to_string(), true, ) .unwrap(); @@ -830,7 +846,7 @@ fn test_approve_all_revoke_all() { res, OperatorResponse { approval: Approval { - spender: String::from("operator"), + spender: deps.api.addr_make("operator").to_string(), expires: Expiration::Never {} } } @@ -840,12 +856,12 @@ fn test_approve_all_revoke_all() { let res = contract.operator( deps.as_ref(), mock_env(), - String::from("person"), - String::from("other"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("other").to_string(), true, ); match res { - Err(StdError::NotFound { kind }) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } @@ -853,7 +869,7 @@ fn test_approve_all_revoke_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), true, None, None, @@ -863,7 +879,7 @@ fn test_approve_all_revoke_all() { res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("operator"), + spender: deps.api.addr_make("operator").to_string(), expires: Expiration::Never {} }] } @@ -872,10 +888,10 @@ fn test_approve_all_revoke_all() { // second approval let buddy_expires = Expiration::AtHeight(1234567); let approve_all_msg = ExecuteMsg::ApproveAll { - operator: String::from("buddy"), + operator: deps.api.addr_make("buddy").to_string(), expires: Some(buddy_expires), }; - let owner = mock_info("person", &[]); + let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); contract .execute(deps.as_mut(), mock_env(), owner.clone(), approve_all_msg) .unwrap(); @@ -885,18 +901,19 @@ fn test_approve_all_revoke_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), true, None, Some(1), ) .unwrap(); + assert_eq!( res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("buddy"), - expires: buddy_expires, + spender: deps.api.addr_make("operator").to_string(), + expires: Expiration::Never {} }] } ); @@ -904,9 +921,9 @@ fn test_approve_all_revoke_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), true, - Some(String::from("buddy")), + Some(deps.api.addr_make("operator").to_string()), Some(2), ) .unwrap(); @@ -914,14 +931,15 @@ fn test_approve_all_revoke_all() { res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("operator"), - expires: Expiration::Never {} + spender: deps.api.addr_make("buddy").to_string(), + expires: buddy_expires, }] } ); + let revoke_all_msg = ExecuteMsg::RevokeAll { - operator: String::from("operator"), + operator: deps.api.addr_make("operator").to_string(), }; contract .execute(deps.as_mut(), mock_env(), owner, revoke_all_msg) @@ -931,13 +949,13 @@ fn test_approve_all_revoke_all() { let res = contract.operator( deps.as_ref(), mock_env(), - String::from("person"), - String::from("operator"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("operator").to_string(), true, ); match res { - Err(StdError::NotFound { kind }) => assert_eq!(kind, "Approval not found"), - _ => panic!("Unexpected error"), + Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), + _ => panic!("Unexpected error {:?}",res), } // Approvals are removed / cleared without affecting others @@ -945,7 +963,7 @@ fn test_approve_all_revoke_all() { .operators( deps.as_ref(), mock_env(), - String::from("person"), + deps.api.addr_make("person").to_string(), false, None, None, @@ -955,7 +973,7 @@ fn test_approve_all_revoke_all() { res, OperatorsResponse { operators: vec![cw721::Approval { - spender: String::from("buddy"), + spender: deps.api.addr_make("buddy").to_string(), expires: buddy_expires, }] } @@ -968,7 +986,7 @@ fn test_approve_all_revoke_all() { .operators( deps.as_ref(), late_env.clone(), - String::from("person"), + deps.api.addr_make("person").to_string(), false, None, None, @@ -980,13 +998,13 @@ fn test_approve_all_revoke_all() { let res = contract.operator( deps.as_ref(), late_env, - String::from("person"), - String::from("buddy"), + deps.api.addr_make("person").to_string(), + deps.api.addr_make("buddy").to_string(), false, ); match res { - Err(StdError::NotFound { kind }) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } } @@ -994,14 +1012,17 @@ fn test_approve_all_revoke_all() { #[test] fn test_tokens_by_owner() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + + let minter = mock_info(minter.as_ref(), &[]); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); - let demeter = String::from("demeter"); + let demeter =deps.api.addr_make("demeter").to_string(); let token_id2 = "grow2".to_string(); - let ceres = String::from("ceres"); + let ceres = deps.api.addr_make("ceres").to_string(); let token_id3 = "sing".to_string(); let mint_msg = ExecuteMsg::Mint { @@ -1104,11 +1125,13 @@ fn test_tokens_by_owner() { #[test] fn test_nft_info() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { @@ -1146,11 +1169,13 @@ fn test_nft_info() { #[test] fn test_all_nft_info() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { @@ -1188,11 +1213,13 @@ fn test_all_nft_info() { #[test] fn test_owner_of() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { @@ -1230,11 +1257,13 @@ fn test_owner_of() { #[test] fn test_approval() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { @@ -1279,11 +1308,13 @@ fn test_approval() { #[test] fn test_approvals() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { @@ -1321,11 +1352,13 @@ fn test_approvals() { #[test] fn test_tokens() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { @@ -1366,11 +1399,14 @@ fn test_tokens() { #[test] fn test_all_tokens() { let mut deps = mock_dependencies(); - let contract = setup_contract(deps.as_mut(), 1); - let minter = mock_info(MINTER, &[]); + let creator = deps.api.addr_make("creator"); + let minter = deps.api.addr_make(MINTER); + let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + + let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = String::from("ark"); + let owner = deps.api.addr_make("ark").to_string(); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { diff --git a/contracts/cw721-expiration/src/lib.rs b/contracts/cw721-expiration/src/lib.rs index 29b0027f9..8ac176532 100644 --- a/contracts/cw721-expiration/src/lib.rs +++ b/contracts/cw721-expiration/src/lib.rs @@ -76,12 +76,12 @@ mod tests { #[test] fn proper_cw2_initialization() { let mut deps = mock_dependencies(); - + let mrt = deps.api.addr_make("mrt").to_string(); // assert min expiration let error = entry::instantiate( deps.as_mut(), mock_env(), - mock_info("mrt", &[]), + mock_info(mrt.as_ref(), &[]), InstantiateMsg { expiration_days: 0, name: "".into(), @@ -97,12 +97,12 @@ mod tests { entry::instantiate( deps.as_mut(), mock_env(), - mock_info("mrt", &[]), + mock_info(mrt.as_ref(), &[]), InstantiateMsg { expiration_days: 1, name: "".into(), symbol: "".into(), - minter: Some("mrt".into()), + minter: Some(mrt), withdraw_address: None, }, ) diff --git a/contracts/cw721-expiration/src/state.rs b/contracts/cw721-expiration/src/state.rs index c7ccb3d0d..caeedc937 100644 --- a/contracts/cw721-expiration/src/state.rs +++ b/contracts/cw721-expiration/src/state.rs @@ -4,8 +4,8 @@ use cw_storage_plus::{Item, Map}; use crate::Extension; pub struct Cw721ExpirationContract<'a> { - pub expiration_days: Item<'a, u16>, // max 65535 days - pub mint_timestamps: Map<'a, &'a str, Timestamp>, + pub expiration_days: Item, // max 65535 days + pub mint_timestamps: Map<&'a str, Timestamp>, pub base_contract: cw721_base::Cw721Contract<'a, Extension, Empty, Empty, Empty>, } diff --git a/contracts/cw721-fixed-price/Cargo.toml b/contracts/cw721-fixed-price/Cargo.toml index f47aeddb7..a518e8273 100644 --- a/contracts/cw721-fixed-price/Cargo.toml +++ b/contracts/cw721-fixed-price/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"] [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-fixed-price/src/contract.rs b/contracts/cw721-fixed-price/src/contract.rs index 1b9d7a4f4..a838c0acb 100644 --- a/contracts/cw721-fixed-price/src/contract.rs +++ b/contracts/cw721-fixed-price/src/contract.rs @@ -6,7 +6,7 @@ use crate::state::{Config, CONFIG}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Reply, ReplyOn, Response, + to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdResult, SubMsg, Uint128, WasmMsg, }; use cw2::set_contract_version; @@ -15,7 +15,7 @@ use cw721_base::{ helpers::Cw721Contract, msg::ExecuteMsg as Cw721ExecuteMsg, msg::InstantiateMsg as Cw721InstantiateMsg, }; -use cw_utils::parse_reply_instantiate_data; +use cw_utils::{parse_instantiate_response_data, ParseReplyError}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw721-fixed-price"; @@ -55,24 +55,18 @@ pub fn instantiate( CONFIG.save(deps.storage, &config)?; - let sub_msg: Vec = vec![SubMsg { - msg: WasmMsg::Instantiate { - code_id: msg.token_code_id, - msg: to_json_binary(&Cw721InstantiateMsg { - name: msg.name.clone(), - symbol: msg.symbol, - minter: None, - withdraw_address: msg.withdraw_address, - })?, - funds: vec![], - admin: None, - label: String::from("Instantiate fixed price NFT contract"), - } - .into(), - id: INSTANTIATE_TOKEN_REPLY_ID, - gas_limit: None, - reply_on: ReplyOn::Success, - }]; + let sub_msg: Vec = vec![SubMsg::reply_on_success(WasmMsg::Instantiate { + code_id: msg.token_code_id, + msg: to_json_binary(&Cw721InstantiateMsg { + name: msg.name.clone(), + symbol: msg.symbol, + minter: None, + withdraw_address: msg.withdraw_address, + })?, + funds: vec![], + admin: None, + label: String::from("Instantiate fixed price NFT contract"), + }, INSTANTIATE_TOKEN_REPLY_ID)]; Ok(Response::new().add_submessages(sub_msg)) } @@ -90,7 +84,12 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Date: Tue, 16 Apr 2024 21:10:36 -0500 Subject: [PATCH 2/9] chore: check in schemas --- contracts/cw2981-royalties/schema/cw2981-royalties.json | 2 +- contracts/cw721-base/schema/cw721-base.json | 2 +- contracts/cw721-expiration/schema/cw721-expiration.json | 2 +- contracts/cw721-fixed-price/schema/cw721-fixed-price.json | 2 +- .../cw721-metadata-onchain/schema/cw721-metadata-onchain.json | 2 +- .../cw721-receiver-tester/schema/cw721-receiver-tester.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/cw2981-royalties/schema/cw2981-royalties.json b/contracts/cw2981-royalties/schema/cw2981-royalties.json index 5ac8e2923..c8ad4857c 100644 --- a/contracts/cw2981-royalties/schema/cw2981-royalties.json +++ b/contracts/cw2981-royalties/schema/cw2981-royalties.json @@ -1,6 +1,6 @@ { "contract_name": "cw2981-royalties", - "contract_version": "0.18.0", + "contract_version": "2.0.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/cw721-base/schema/cw721-base.json b/contracts/cw721-base/schema/cw721-base.json index 5b2403b29..4fbd9d3e3 100644 --- a/contracts/cw721-base/schema/cw721-base.json +++ b/contracts/cw721-base/schema/cw721-base.json @@ -1,6 +1,6 @@ { "contract_name": "cw721-base", - "contract_version": "0.18.0", + "contract_version": "2.0.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/cw721-expiration/schema/cw721-expiration.json b/contracts/cw721-expiration/schema/cw721-expiration.json index 3da3c0405..927d97110 100644 --- a/contracts/cw721-expiration/schema/cw721-expiration.json +++ b/contracts/cw721-expiration/schema/cw721-expiration.json @@ -1,6 +1,6 @@ { "contract_name": "cw721-expiration", - "contract_version": "0.18.0", + "contract_version": "2.0.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/cw721-fixed-price/schema/cw721-fixed-price.json b/contracts/cw721-fixed-price/schema/cw721-fixed-price.json index 694ec7f85..d98c16969 100644 --- a/contracts/cw721-fixed-price/schema/cw721-fixed-price.json +++ b/contracts/cw721-fixed-price/schema/cw721-fixed-price.json @@ -1,6 +1,6 @@ { "contract_name": "cw721-fixed-price", - "contract_version": "0.18.0", + "contract_version": "2.0.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/cw721-metadata-onchain/schema/cw721-metadata-onchain.json b/contracts/cw721-metadata-onchain/schema/cw721-metadata-onchain.json index c6dfa6cd1..5da62c38e 100644 --- a/contracts/cw721-metadata-onchain/schema/cw721-metadata-onchain.json +++ b/contracts/cw721-metadata-onchain/schema/cw721-metadata-onchain.json @@ -1,6 +1,6 @@ { "contract_name": "cw721-metadata-onchain", - "contract_version": "0.18.0", + "contract_version": "2.0.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/cw721-receiver-tester/schema/cw721-receiver-tester.json b/contracts/cw721-receiver-tester/schema/cw721-receiver-tester.json index 639e533cb..aa91e3ae4 100644 --- a/contracts/cw721-receiver-tester/schema/cw721-receiver-tester.json +++ b/contracts/cw721-receiver-tester/schema/cw721-receiver-tester.json @@ -1,6 +1,6 @@ { "contract_name": "cw721-receiver-tester", - "contract_version": "0.18.0", + "contract_version": "2.0.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", From 040e8525f70b995442edf00c04613c647e199d21 Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:13:16 -0500 Subject: [PATCH 3/9] cargo fmt --- contracts/cw2981-royalties/src/query.rs | 3 +- contracts/cw721-base/src/contract_tests.rs | 46 ++++++++-------- contracts/cw721-base/src/lib.rs | 2 +- contracts/cw721-base/src/multi_tests.rs | 1 - contracts/cw721-base/src/state.rs | 2 +- .../cw721-expiration/src/contract_tests.rs | 53 +++++++++++-------- contracts/cw721-fixed-price/src/contract.rs | 46 +++++++++------- contracts/cw721-metadata-onchain/src/lib.rs | 2 +- 8 files changed, 88 insertions(+), 67 deletions(-) diff --git a/contracts/cw2981-royalties/src/query.rs b/contracts/cw2981-royalties/src/query.rs index 1fcd385f1..80a9e3f28 100644 --- a/contracts/cw2981-royalties/src/query.rs +++ b/contracts/cw2981-royalties/src/query.rs @@ -19,7 +19,8 @@ pub fn query_royalties_info( }, None => Decimal::percent(0), }; - let royalty_from_sale_price = Decimal::from_ratio(sale_price,Uint128::one()) * royalty_percentage; + let royalty_from_sale_price = + Decimal::from_ratio(sale_price, Uint128::one()) * royalty_percentage; let royalty_address = match token_info.extension { Some(ext) => match ext.royalty_payment_address { diff --git a/contracts/cw721-base/src/contract_tests.rs b/contracts/cw721-base/src/contract_tests.rs index 46658380b..72e6df26d 100644 --- a/contracts/cw721-base/src/contract_tests.rs +++ b/contracts/cw721-base/src/contract_tests.rs @@ -20,7 +20,11 @@ const MINTER: &str = "merlin"; const CONTRACT_NAME: &str = "Magic Power"; const SYMBOL: &str = "MGK"; -fn setup_contract(deps: DepsMut<'_>,creator:Addr,minter:Addr) -> Cw721Contract<'static, Extension, Empty, Empty, Empty> { +fn setup_contract( + deps: DepsMut<'_>, + creator: Addr, + minter: Addr, +) -> Cw721Contract<'static, Extension, Empty, Empty, Empty> { let contract = Cw721Contract::default(); let msg = InstantiateMsg { @@ -85,7 +89,7 @@ fn minting() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); @@ -167,7 +171,7 @@ fn test_update_minter() { let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); let random = deps.api.addr_make("random"); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); @@ -269,7 +273,7 @@ fn burning() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); @@ -320,7 +324,7 @@ fn transferring_nft() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -376,7 +380,7 @@ fn sending_nft() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -444,7 +448,7 @@ fn approving_revoking() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // Mint a token let token_id = "grow".to_string(); @@ -484,7 +488,7 @@ fn approving_revoking() { // Give random transferring power let approve_msg = ExecuteMsg::Approve { - spender:deps.api.addr_make("random").to_string(), + spender: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), expires: None, }; @@ -524,7 +528,7 @@ fn approving_revoking() { // random can now transfer let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); let transfer_msg = ExecuteMsg::TransferNft { - recipient:deps.api.addr_make("person").to_string(), + recipient: deps.api.addr_make("person").to_string(), token_id: token_id.clone(), }; contract @@ -545,7 +549,7 @@ fn approving_revoking() { assert_eq!( res, OwnerOfResponse { - owner:deps.api.addr_make("person").to_string(), + owner: deps.api.addr_make("person").to_string(), approvals: vec![], } ); @@ -590,7 +594,7 @@ fn approving_all_revoking_all() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter); + let contract = setup_contract(deps.as_mut(), creator, minter); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); @@ -712,11 +716,11 @@ fn approving_all_revoking_all() { deps.as_ref(), mock_env(), deps.api.addr_make("person").to_string(), - deps.api.addr_make("other").to_string(), + deps.api.addr_make("other").to_string(), true, ); match res { - Err(StdError::NotFound{kind ,..}) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } @@ -809,7 +813,7 @@ fn approving_all_revoking_all() { true, ); match res { - Err(StdError::NotFound {kind, ..} ) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } @@ -859,7 +863,7 @@ fn approving_all_revoking_all() { ); match res { - Err(StdError::NotFound{ kind, ..}) => assert_eq!(kind, "Approval not found"), + Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), _ => panic!("Unexpected error"), } } @@ -869,7 +873,7 @@ fn test_set_withdraw_address() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let other = deps.api.addr_make("other"); // other cant set let foo = deps.api.addr_make("foo"); @@ -895,7 +899,7 @@ fn test_remove_withdraw_address() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter); + let contract = setup_contract(deps.as_mut(), creator, minter); let other = deps.api.addr_make("other"); let foo = deps.api.addr_make("foo"); // other cant remove @@ -913,7 +917,7 @@ fn test_remove_withdraw_address() { // set and remove contract - .set_withdraw_address(deps.as_mut(), &minter,foo.to_string()) + .set_withdraw_address(deps.as_mut(), &minter, foo.to_string()) .unwrap(); contract .remove_withdraw_address(deps.as_mut().storage, &minter) @@ -937,7 +941,7 @@ fn test_withdraw_funds() { let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); let foo = deps.api.addr_make("foo"); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // no withdraw address set let err = contract @@ -947,7 +951,7 @@ fn test_withdraw_funds() { // set and withdraw by non-owner contract - .set_withdraw_address(deps.as_mut(), &minter,foo.to_string()) + .set_withdraw_address(deps.as_mut(), &minter, foo.to_string()) .unwrap(); contract .withdraw_funds(deps.as_mut().storage, &Coin::new(100u32, "uark")) @@ -959,7 +963,7 @@ fn query_tokens_by_owner() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(),creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); diff --git a/contracts/cw721-base/src/lib.rs b/contracts/cw721-base/src/lib.rs index d0d30c82c..7629ac45b 100644 --- a/contracts/cw721-base/src/lib.rs +++ b/contracts/cw721-base/src/lib.rs @@ -86,7 +86,7 @@ pub mod entry { cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; // perform the upgrade - // upgrades::v0_17::migrate::(deps) + // upgrades::v0_17::migrate::(deps) Ok(Response::new()) } } diff --git a/contracts/cw721-base/src/multi_tests.rs b/contracts/cw721-base/src/multi_tests.rs index f0a3e4f34..81624d18a 100644 --- a/contracts/cw721-base/src/multi_tests.rs +++ b/contracts/cw721-base/src/multi_tests.rs @@ -12,7 +12,6 @@ fn cw721_base_latest_contract() -> Box> { Box::new(contract) } - fn query_owner(querier: QuerierWrapper, cw721: &Addr, token_id: String) -> Addr { let resp: OwnerOfResponse = querier .query_wasm_smart( diff --git a/contracts/cw721-base/src/state.rs b/contracts/cw721-base/src/state.rs index 1fbf2540c..b18730417 100644 --- a/contracts/cw721-base/src/state.rs +++ b/contracts/cw721-base/src/state.rs @@ -17,7 +17,7 @@ where pub contract_info: Item, pub token_count: Item, /// Stored as (granter, operator) giving operator full control over granter's account - pub operators: Map< (&'a Addr, &'a Addr), Expiration>, + pub operators: Map<(&'a Addr, &'a Addr), Expiration>, pub tokens: IndexedMap<&'a str, TokenInfo, TokenIndexes<'a, T>>, pub withdraw_address: Item, diff --git a/contracts/cw721-expiration/src/contract_tests.rs b/contracts/cw721-expiration/src/contract_tests.rs index 0b87fbe3a..61a3c63f2 100644 --- a/contracts/cw721-expiration/src/contract_tests.rs +++ b/contracts/cw721-expiration/src/contract_tests.rs @@ -23,7 +23,12 @@ const MINTER: &str = "merlin"; const CONTRACT_NAME: &str = "Magic Power"; const SYMBOL: &str = "MGK"; -fn setup_contract(deps: DepsMut<'_>, expiration_days: u16,creator:Addr,minter:Addr) -> Cw721ExpirationContract<'static> { +fn setup_contract( + deps: DepsMut<'_>, + expiration_days: u16, + creator: Addr, + minter: Addr, +) -> Cw721ExpirationContract<'static> { let contract = Cw721ExpirationContract::default(); let msg = InstantiateMsg { expiration_days, @@ -85,7 +90,7 @@ fn test_mint() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make("minter"); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let token_id = "atomize".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/atomize".to_string(); @@ -180,7 +185,7 @@ fn test_update_minter() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); @@ -257,7 +262,10 @@ fn test_update_minter() { .unwrap(), ) .unwrap(); - assert_eq!(minter.minter, Some(deps.api.addr_make("random").to_string())); + assert_eq!( + minter.minter, + Some(deps.api.addr_make("random").to_string()) + ); let mint_msg = ExecuteMsg::Mint { token_id: "randoms_token".to_string(), @@ -286,7 +294,7 @@ fn test_burn() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let token_id = "petrify".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/petrify".to_string(); @@ -366,7 +374,7 @@ fn test_transfer_nft() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -403,8 +411,8 @@ fn test_transfer_nft() { // owner can let owner_info = mock_info(owner.as_ref(), &[]); - let binding = deps.api.addr_make( "random"); - let new_owner =binding.as_ref(); + let binding = deps.api.addr_make("random"); + let new_owner = binding.as_ref(); let transfer_msg = ExecuteMsg::TransferNft { recipient: String::from(new_owner), token_id: token_id.clone(), @@ -450,7 +458,7 @@ fn test_send_nft() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); // Mint a token let token_id = "melt".to_string(); @@ -470,7 +478,7 @@ fn test_send_nft() { .unwrap(); let msg = to_json_binary("You now have the melting power").unwrap(); - let target =deps.api.addr_make("another_contract").to_string(); + let target = deps.api.addr_make("another_contract").to_string(); let send_msg = ExecuteMsg::SendNft { contract: target.clone(), token_id: token_id.clone(), @@ -538,7 +546,7 @@ fn test_approve_revoke() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); // Mint a token let token_id = "grow".to_string(); @@ -727,7 +735,7 @@ fn test_approve_all_revoke_all() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); @@ -937,7 +945,6 @@ fn test_approve_all_revoke_all() { } ); - let revoke_all_msg = ExecuteMsg::RevokeAll { operator: deps.api.addr_make("operator").to_string(), }; @@ -955,7 +962,7 @@ fn test_approve_all_revoke_all() { ); match res { Err(StdError::NotFound { kind, .. }) => assert_eq!(kind, "Approval not found"), - _ => panic!("Unexpected error {:?}",res), + _ => panic!("Unexpected error {:?}", res), } // Approvals are removed / cleared without affecting others @@ -1014,13 +1021,13 @@ fn test_tokens_by_owner() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); - let demeter =deps.api.addr_make("demeter").to_string(); + let demeter = deps.api.addr_make("demeter").to_string(); let token_id2 = "grow2".to_string(); let ceres = deps.api.addr_make("ceres").to_string(); let token_id3 = "sing".to_string(); @@ -1127,7 +1134,7 @@ fn test_nft_info() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); @@ -1171,7 +1178,7 @@ fn test_all_nft_info() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); @@ -1215,7 +1222,7 @@ fn test_owner_of() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); @@ -1259,7 +1266,7 @@ fn test_approval() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); @@ -1310,7 +1317,7 @@ fn test_approvals() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); @@ -1354,7 +1361,7 @@ fn test_tokens() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); @@ -1401,7 +1408,7 @@ fn test_all_tokens() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), 1,creator,minter.clone()); + let contract = setup_contract(deps.as_mut(), 1, creator, minter.clone()); let minter = mock_info(minter.as_ref(), &[]); diff --git a/contracts/cw721-fixed-price/src/contract.rs b/contracts/cw721-fixed-price/src/contract.rs index a838c0acb..ee780e480 100644 --- a/contracts/cw721-fixed-price/src/contract.rs +++ b/contracts/cw721-fixed-price/src/contract.rs @@ -55,18 +55,21 @@ pub fn instantiate( CONFIG.save(deps.storage, &config)?; - let sub_msg: Vec = vec![SubMsg::reply_on_success(WasmMsg::Instantiate { - code_id: msg.token_code_id, - msg: to_json_binary(&Cw721InstantiateMsg { - name: msg.name.clone(), - symbol: msg.symbol, - minter: None, - withdraw_address: msg.withdraw_address, - })?, - funds: vec![], - admin: None, - label: String::from("Instantiate fixed price NFT contract"), - }, INSTANTIATE_TOKEN_REPLY_ID)]; + let sub_msg: Vec = vec![SubMsg::reply_on_success( + WasmMsg::Instantiate { + code_id: msg.token_code_id, + msg: to_json_binary(&Cw721InstantiateMsg { + name: msg.name.clone(), + symbol: msg.symbol, + minter: None, + withdraw_address: msg.withdraw_address, + })?, + funds: vec![], + admin: None, + label: String::from("Instantiate fixed price NFT contract"), + }, + INSTANTIATE_TOKEN_REPLY_ID, + )]; Ok(Response::new().add_submessages(sub_msg)) } @@ -84,9 +87,12 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Date: Tue, 16 Apr 2024 21:31:11 -0500 Subject: [PATCH 4/9] chore: clippy warnings --- contracts/cw2981-royalties/src/lib.rs | 4 ++-- contracts/cw721-base/src/contract_tests.rs | 2 +- contracts/cw721-fixed-price/src/contract.rs | 8 ++++++++ contracts/cw721-metadata-onchain/src/lib.rs | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/contracts/cw2981-royalties/src/lib.rs b/contracts/cw2981-royalties/src/lib.rs index 47cd1d0a3..a81a95c69 100644 --- a/contracts/cw2981-royalties/src/lib.rs +++ b/contracts/cw2981-royalties/src/lib.rs @@ -269,7 +269,7 @@ mod tests { entry::execute(deps.as_mut(), mock_env(), info.clone(), exec_msg).unwrap(); let expected = RoyaltiesInfoResponse { - address: owner.into(), + address: owner, royalty_amount: Uint128::new(10), }; let res = @@ -308,7 +308,7 @@ mod tests { // 43 x 0.04 (i.e., 4%) should be 1.72 // we expect this to be rounded down to 1 let voyager_expected = RoyaltiesInfoResponse { - address: owner.into(), + address: owner, royalty_amount: Uint128::new(1), }; diff --git a/contracts/cw721-base/src/contract_tests.rs b/contracts/cw721-base/src/contract_tests.rs index 72e6df26d..a2c5a579a 100644 --- a/contracts/cw721-base/src/contract_tests.rs +++ b/contracts/cw721-base/src/contract_tests.rs @@ -33,7 +33,7 @@ fn setup_contract( minter: Some(minter.to_string()), withdraw_address: None, }; - let info = mock_info(&creator.to_string(), &[]); + let info = mock_info(creator.as_ref(), &[]); let res = contract.instantiate(deps, mock_env(), info, msg).unwrap(); assert_eq!(0, res.messages.len()); contract diff --git a/contracts/cw721-fixed-price/src/contract.rs b/contracts/cw721-fixed-price/src/contract.rs index ee780e480..d77f715de 100644 --- a/contracts/cw721-fixed-price/src/contract.rs +++ b/contracts/cw721-fixed-price/src/contract.rs @@ -87,6 +87,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Date: Tue, 16 Apr 2024 21:37:02 -0500 Subject: [PATCH 5/9] chore: clippy warnings - remove a to_string --- contracts/cw721-base/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw721-base/src/lib.rs b/contracts/cw721-base/src/lib.rs index 7629ac45b..0a6167ab9 100644 --- a/contracts/cw721-base/src/lib.rs +++ b/contracts/cw721-base/src/lib.rs @@ -154,6 +154,6 @@ mod tests { .unwrap() .owner .map(|a| a.into_string()); - assert_eq!(minter, Some(owner.to_string())); + assert_eq!(minter, Some(owner)); } } From fb13d049e607b2df904fb219df78d5d201ff508d Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:48:27 -0500 Subject: [PATCH 6/9] chore: upgrade to 2.0.1 version of cosmwasm-check --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cee9ad8f9..79c8047dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -225,7 +225,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 1.1.0 --locked -- cosmwasm-check + command: cargo install --debug --version 2.0.1 --locked -- cosmwasm-check - save_cache: paths: - /usr/local/cargo/registry From 7e7a243bbfdd96b3b8dd833b486a1d584a6c40be Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:23:06 -0500 Subject: [PATCH 7/9] feat: fix suggestions of webmaster128. feat: upgrade rust min version to 1.73 --- .circleci/config.yml | 32 +++++------ Cargo.toml | 2 +- contracts/cw2981-royalties/Cargo.toml | 2 - contracts/cw2981-royalties/src/lib.rs | 20 +++---- contracts/cw2981-royalties/src/query.rs | 5 +- contracts/cw721-base/Cargo.toml | 2 - contracts/cw721-base/src/contract_tests.rs | 34 +++++------ contracts/cw721-base/src/lib.rs | 4 +- contracts/cw721-base/src/query.rs | 4 +- contracts/cw721-expiration/Cargo.toml | 2 - .../cw721-expiration/src/contract_tests.rs | 56 +++++++++---------- contracts/cw721-expiration/src/lib.rs | 4 +- contracts/cw721-fixed-price/Cargo.toml | 2 - contracts/cw721-metadata-onchain/Cargo.toml | 2 - contracts/cw721-non-transferable/Cargo.toml | 2 - contracts/cw721-receiver-tester/Cargo.toml | 2 - 16 files changed, 80 insertions(+), 95 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 79c8047dc..34d7a7203 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,7 +21,7 @@ workflows: jobs: contract_cw721_base: docker: - - image: rust:1.65.0 + - image: rust:1.73.0 working_directory: ~/project/contracts/cw721-base steps: - checkout: @@ -31,7 +31,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw721-base-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw721-base-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -53,11 +53,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw721-base-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw721-base-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} contract_cw721_metadata_onchain: docker: - - image: rust:1.65.0 + - image: rust:1.73.0 working_directory: ~/project/contracts/cw721-metadata-onchain steps: - checkout: @@ -67,7 +67,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw721-metadata-onchain-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw721-metadata-onchain-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -89,11 +89,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw721-metadata-onchain-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw721-metadata-onchain-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} contract_cw721_fixed_price: docker: - - image: rust:1.65.0 + - image: rust:1.73.0 working_directory: ~/project/contracts/cw721-fixed-price steps: - checkout: @@ -103,7 +103,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw721-fixed-price-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw721-fixed-price-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -125,11 +125,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw721-fixed-price-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw721-fixed-price-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} package_cw721: docker: - - image: rust:1.65.0 + - image: rust:1.73.0 working_directory: ~/project/packages/cw721 steps: - checkout: @@ -166,7 +166,7 @@ jobs: lint: docker: - - image: rust:1.65.0 + - image: rust:1.73.0 steps: - checkout - run: @@ -174,7 +174,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-lint-rust:1.65.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-lint-rust:1.73.0-{{ checksum "Cargo.lock" }} - run: name: Add rustfmt component command: rustup component add rustfmt @@ -193,7 +193,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-lint-rust:1.65.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-lint-rust:1.73.0-{{ checksum "Cargo.lock" }} # This runs one time on the top level to ensure all contracts compile properly into wasm. # We don't run the wasm build per contract build, and then reuse a lot of the same dependencies, so this speeds up CI time @@ -201,7 +201,7 @@ jobs: # We also sanity-check the resultant wasm files. wasm-build: docker: - - image: rust:1.65.0 + - image: rust:1.73.0 steps: - checkout: path: ~/project @@ -210,7 +210,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-wasm-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-wasm-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Add wasm32 target command: rustup target add wasm32-unknown-unknown @@ -230,7 +230,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-wasm-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-wasm-rust:1.73.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Check wasm contracts command: cosmwasm-check ./target/wasm32-unknown-unknown/release/*.wasm diff --git a/Cargo.toml b/Cargo.toml index 0241f80c6..334a607e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-nfts" homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" -rust-version = "1.65" +rust-version = "1.73" [workspace.dependencies] cosmwasm-schema = "^2.0" diff --git a/contracts/cw2981-royalties/Cargo.toml b/contracts/cw2981-royalties/Cargo.toml index 99b06825e..ea52d33a7 100644 --- a/contracts/cw2981-royalties/Cargo.toml +++ b/contracts/cw2981-royalties/Cargo.toml @@ -13,8 +13,6 @@ documentation = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw2981-royalties/src/lib.rs b/contracts/cw2981-royalties/src/lib.rs index a81a95c69..af3784372 100644 --- a/contracts/cw2981-royalties/src/lib.rs +++ b/contracts/cw2981-royalties/src/lib.rs @@ -131,7 +131,7 @@ mod tests { fn use_metadata_extension() { let mut deps = mock_dependencies(); let contract = Cw2981Contract::default(); - let creator = deps.api.addr_make(CREATOR).to_string(); + let creator = deps.api.addr_make(CREATOR); let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { @@ -166,7 +166,7 @@ mod tests { fn validate_royalty_information() { let mut deps = mock_dependencies(); let _contract = Cw2981Contract::default(); - let creator = deps.api.addr_make(CREATOR).to_string(); + let creator = deps.api.addr_make(CREATOR); let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { @@ -199,7 +199,7 @@ mod tests { let mut deps = mock_dependencies(); let _contract = Cw2981Contract::default(); - let creator = deps.api.addr_make(CREATOR).to_string(); + let creator = deps.api.addr_make(CREATOR); let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { @@ -241,7 +241,7 @@ mod tests { #[test] fn check_token_royalties() { let mut deps = mock_dependencies(); - let creator = deps.api.addr_make(CREATOR).to_string(); + let creator = deps.api.addr_make(CREATOR); let info = mock_info(creator.as_ref(), &[]); let init_msg = InstantiateMsg { @@ -253,10 +253,10 @@ mod tests { entry::instantiate(deps.as_mut(), mock_env(), info.clone(), init_msg).unwrap(); let token_id = "Enterprise"; - let owner = deps.api.addr_make("jeanluc").to_string(); + let owner = deps.api.addr_make("jeanluc"); let exec_msg = ExecuteMsg::Mint { token_id: token_id.to_string(), - owner: owner.clone(), + owner: owner.to_string(), token_uri: Some("https://starships.example.com/Starship/Enterprise.json".into()), extension: Some(Metadata { description: Some("Spaceship with Warp Drive".into()), @@ -269,7 +269,7 @@ mod tests { entry::execute(deps.as_mut(), mock_env(), info.clone(), exec_msg).unwrap(); let expected = RoyaltiesInfoResponse { - address: owner, + address: owner.to_string(), royalty_amount: Uint128::new(10), }; let res = @@ -290,10 +290,10 @@ mod tests { // check for rounding down // which is the default behaviour let voyager_token_id = "Voyager"; - let owner = deps.api.addr_make("janeway").to_string(); + let owner = deps.api.addr_make("janeway"); let voyager_exec_msg = ExecuteMsg::Mint { token_id: voyager_token_id.to_string(), - owner: owner.clone(), + owner: owner.to_string(), token_uri: Some("https://starships.example.com/Starship/Voyager.json".into()), extension: Some(Metadata { description: Some("Spaceship with Warp Drive".into()), @@ -308,7 +308,7 @@ mod tests { // 43 x 0.04 (i.e., 4%) should be 1.72 // we expect this to be rounded down to 1 let voyager_expected = RoyaltiesInfoResponse { - address: owner, + address: owner.to_string(), royalty_amount: Uint128::new(1), }; diff --git a/contracts/cw2981-royalties/src/query.rs b/contracts/cw2981-royalties/src/query.rs index 80a9e3f28..0d820447b 100644 --- a/contracts/cw2981-royalties/src/query.rs +++ b/contracts/cw2981-royalties/src/query.rs @@ -19,8 +19,7 @@ pub fn query_royalties_info( }, None => Decimal::percent(0), }; - let royalty_from_sale_price = - Decimal::from_ratio(sale_price, Uint128::one()) * royalty_percentage; + let royalty_from_sale_price = sale_price.mul_floor(royalty_percentage); let royalty_address = match token_info.extension { Some(ext) => match ext.royalty_payment_address { @@ -32,7 +31,7 @@ pub fn query_royalties_info( Ok(RoyaltiesInfoResponse { address: royalty_address, - royalty_amount: royalty_from_sale_price.to_uint_floor(), + royalty_amount: royalty_from_sale_price, }) } diff --git a/contracts/cw721-base/Cargo.toml b/contracts/cw721-base/Cargo.toml index e7e634a96..0d6469c4c 100644 --- a/contracts/cw721-base/Cargo.toml +++ b/contracts/cw721-base/Cargo.toml @@ -17,8 +17,6 @@ rust-version = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-base/src/contract_tests.rs b/contracts/cw721-base/src/contract_tests.rs index a2c5a579a..6a8ceb361 100644 --- a/contracts/cw721-base/src/contract_tests.rs +++ b/contracts/cw721-base/src/contract_tests.rs @@ -43,12 +43,12 @@ fn setup_contract( fn proper_instantiation() { let mut deps = mock_dependencies(); let contract = Cw721Contract::::default(); - let minter = deps.api.addr_make(MINTER).to_string(); + let minter = deps.api.addr_make(MINTER); let msg = InstantiateMsg { name: CONTRACT_NAME.to_string(), symbol: SYMBOL.to_string(), - minter: Some(minter.clone()), - withdraw_address: Some(minter.clone()), + minter: Some(minter.to_string()), + withdraw_address: Some(minter.to_string()), }; let info = mock_info(deps.api.addr_make("creator").as_ref(), &[]); @@ -60,7 +60,7 @@ fn proper_instantiation() { // it worked, let's query the state let res = contract.minter(deps.as_ref()).unwrap(); - assert_eq!(Some(minter.clone()), res.minter); + assert_eq!(Some(minter.to_string()), res.minter); let info = contract.contract_info(deps.as_ref()).unwrap(); assert_eq!( info, @@ -74,7 +74,7 @@ fn proper_instantiation() { .withdraw_address .may_load(deps.as_ref().storage) .unwrap(); - assert_eq!(Some(minter), withdraw_address); + assert_eq!(Some(minter.to_string()), withdraw_address); let count = contract.num_tokens(deps.as_ref()).unwrap(); assert_eq!(0, count.count); @@ -399,9 +399,9 @@ fn sending_nft() { .unwrap(); let msg = to_json_binary("You now have the melting power").unwrap(); - let target = deps.api.addr_make("another_contract").to_string(); + let target = deps.api.addr_make("another_contract"); let send_msg = ExecuteMsg::SendNft { - contract: target.clone(), + contract: target.to_string(), token_id: token_id.clone(), msg: msg.clone(), }; @@ -427,7 +427,7 @@ fn sending_nft() { // ensure expected serializes as we think it should match &expected { CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, .. }) => { - assert_eq!(contract_addr, &target) + assert_eq!(contract_addr, target.as_ref()) } _m => panic!("Unexpected message type: {_m:?}"), } @@ -969,14 +969,14 @@ fn query_tokens_by_owner() { // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); - let demeter = deps.api.addr_make("demeter").to_string(); + let demeter = deps.api.addr_make("demeter"); let token_id2 = "grow2".to_string(); - let ceres = deps.api.addr_make("ceres").to_string(); + let ceres = deps.api.addr_make("ceres"); let token_id3 = "sing".to_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id1.clone(), - owner: demeter.clone(), + owner: demeter.to_string(), token_uri: None, extension: None, }; @@ -986,7 +986,7 @@ fn query_tokens_by_owner() { let mint_msg = ExecuteMsg::Mint { token_id: token_id2.clone(), - owner: ceres.clone(), + owner: ceres.to_string(), token_uri: None, extension: None, }; @@ -996,7 +996,7 @@ fn query_tokens_by_owner() { let mint_msg = ExecuteMsg::Mint { token_id: token_id3.clone(), - owner: demeter.clone(), + owner: demeter.to_string(), token_uri: None, extension: None, }; @@ -1021,19 +1021,19 @@ fn query_tokens_by_owner() { let by_demeter = vec![token_id1, token_id3]; // all tokens by owner let tokens = contract - .tokens(deps.as_ref(), demeter.clone(), None, None) + .tokens(deps.as_ref(), demeter.to_string(), None, None) .unwrap(); assert_eq!(&by_demeter, &tokens.tokens); - let tokens = contract.tokens(deps.as_ref(), ceres, None, None).unwrap(); + let tokens = contract.tokens(deps.as_ref(), ceres.to_string(), None, None).unwrap(); assert_eq!(&by_ceres, &tokens.tokens); // paginate for demeter let tokens = contract - .tokens(deps.as_ref(), demeter.clone(), None, Some(1)) + .tokens(deps.as_ref(), demeter.to_string(), None, Some(1)) .unwrap(); assert_eq!(&by_demeter[..1], &tokens.tokens[..]); let tokens = contract - .tokens(deps.as_ref(), demeter, Some(by_demeter[0].clone()), Some(3)) + .tokens(deps.as_ref(), demeter.to_string(), Some(by_demeter[0].clone()), Some(3)) .unwrap(); assert_eq!(&by_demeter[1..], &tokens.tokens[..]); } diff --git a/contracts/cw721-base/src/lib.rs b/contracts/cw721-base/src/lib.rs index 0a6167ab9..5a48aa007 100644 --- a/contracts/cw721-base/src/lib.rs +++ b/contracts/cw721-base/src/lib.rs @@ -136,7 +136,7 @@ mod tests { #[test] fn proper_owner_initialization() { let mut deps = mock_dependencies(); - let owner = deps.api.addr_make("owner").to_string(); + let owner = deps.api.addr_make("owner"); entry::instantiate( deps.as_mut(), mock_env(), @@ -154,6 +154,6 @@ mod tests { .unwrap() .owner .map(|a| a.into_string()); - assert_eq!(minter, Some(owner)); + assert_eq!(minter, Some(owner.to_string())); } } diff --git a/contracts/cw721-base/src/query.rs b/contracts/cw721-base/src/query.rs index 8dc820bd6..8c7fbca7d 100644 --- a/contracts/cw721-base/src/query.rs +++ b/contracts/cw721-base/src/query.rs @@ -126,9 +126,9 @@ where include_expired: bool, ) -> StdResult { let token = self.tokens.load(deps.storage, &token_id)?; - + let spender_addr = deps.api.addr_validate(&spender)?; // token owner has absolute approval - if token.owner.to_string() == spender { + if token.owner == spender_addr { let approval = cw721::Approval { spender: token.owner.to_string(), expires: Expiration::Never {}, diff --git a/contracts/cw721-expiration/Cargo.toml b/contracts/cw721-expiration/Cargo.toml index 4b272108b..1461552f0 100644 --- a/contracts/cw721-expiration/Cargo.toml +++ b/contracts/cw721-expiration/Cargo.toml @@ -13,8 +13,6 @@ documentation = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-expiration/src/contract_tests.rs b/contracts/cw721-expiration/src/contract_tests.rs index 61a3c63f2..cebf2f03f 100644 --- a/contracts/cw721-expiration/src/contract_tests.rs +++ b/contracts/cw721-expiration/src/contract_tests.rs @@ -380,10 +380,10 @@ fn test_transfer_nft() { let token_id = "melt".to_string(); let token_uri = "https://www.merriam-webster.com/dictionary/melt".to_string(); - let owner = deps.api.addr_make("owner").into_string(); + let owner = deps.api.addr_make("owner"); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: owner.clone(), + owner: owner.to_string(), token_uri: Some(token_uri), extension: None, }; @@ -478,9 +478,9 @@ fn test_send_nft() { .unwrap(); let msg = to_json_binary("You now have the melting power").unwrap(); - let target = deps.api.addr_make("another_contract").to_string(); + let target = deps.api.addr_make("another_contract"); let send_msg = ExecuteMsg::SendNft { - contract: target.clone(), + contract: target.to_string(), token_id: token_id.clone(), msg: msg.clone(), }; @@ -509,7 +509,7 @@ fn test_send_nft() { // ensure expected serializes as we think it should match &expected { CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, .. }) => { - assert_eq!(contract_addr, &target) + assert_eq!(contract_addr, target.as_ref()) } _m => panic!("Unexpected message type: {_m:?}"), } @@ -1027,14 +1027,14 @@ fn test_tokens_by_owner() { // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); - let demeter = deps.api.addr_make("demeter").to_string(); + let demeter = deps.api.addr_make("demeter"); let token_id2 = "grow2".to_string(); - let ceres = deps.api.addr_make("ceres").to_string(); + let ceres = deps.api.addr_make("ceres"); let token_id3 = "sing".to_string(); let mint_msg = ExecuteMsg::Mint { token_id: token_id1.clone(), - owner: demeter.clone(), + owner: demeter.to_string(), token_uri: None, extension: None, }; @@ -1044,7 +1044,7 @@ fn test_tokens_by_owner() { let mint_msg = ExecuteMsg::Mint { token_id: token_id2.clone(), - owner: ceres.clone(), + owner: ceres.to_string(), token_uri: None, extension: None, }; @@ -1054,7 +1054,7 @@ fn test_tokens_by_owner() { let mint_msg = ExecuteMsg::Mint { token_id: token_id3.clone(), - owner: demeter.clone(), + owner: demeter.to_string(), token_uri: None, extension: None, }; @@ -1092,7 +1092,7 @@ fn test_tokens_by_owner() { .tokens( deps.as_ref(), mock_env(), - demeter.clone(), + demeter.to_string(), None, None, false, @@ -1100,7 +1100,7 @@ fn test_tokens_by_owner() { .unwrap(); assert_eq!(&by_demeter, &tokens.tokens); let tokens = contract - .tokens(deps.as_ref(), mock_env(), ceres, None, None, false) + .tokens(deps.as_ref(), mock_env(), ceres.to_string(), None, None, false) .unwrap(); assert_eq!(&by_ceres, &tokens.tokens); @@ -1109,7 +1109,7 @@ fn test_tokens_by_owner() { .tokens( deps.as_ref(), mock_env(), - demeter.clone(), + demeter.to_string(), None, Some(1), false, @@ -1120,7 +1120,7 @@ fn test_tokens_by_owner() { .tokens( deps.as_ref(), mock_env(), - demeter, + demeter.to_string(), Some(by_demeter[0].clone()), Some(3), false, @@ -1270,12 +1270,12 @@ fn test_approval() { let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = deps.api.addr_make("ark").to_string(); + let owner = deps.api.addr_make("ark"); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: owner.clone(), + owner: owner.to_string(), token_uri: None, extension: None, }; @@ -1289,7 +1289,7 @@ fn test_approval() { deps.as_ref(), env.clone(), token_id.clone(), - owner.clone(), + owner.to_string(), false, false, ) @@ -1300,7 +1300,7 @@ fn test_approval() { let expiration = env.block.time.plus_days(1); env.block.time = expiration; let error = contract - .approval(deps.as_ref(), env, token_id.clone(), owner, false, false) + .approval(deps.as_ref(), env, token_id.clone(), owner.to_string(), false, false) .unwrap_err(); assert_eq!( error, @@ -1321,12 +1321,12 @@ fn test_approvals() { let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = deps.api.addr_make("ark").to_string(); + let owner = deps.api.addr_make("ark"); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner, + owner: owner.to_string(), token_uri: None, extension: None, }; @@ -1365,12 +1365,12 @@ fn test_tokens() { let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = deps.api.addr_make("ark").to_string(); + let owner = deps.api.addr_make("ark"); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: owner.clone(), + owner: owner.to_string(), token_uri: None, extension: None, }; @@ -1380,20 +1380,20 @@ fn test_tokens() { // assert valid nft is returned contract - .tokens(deps.as_ref(), env.clone(), owner.clone(), None, None, false) + .tokens(deps.as_ref(), env.clone(), owner.to_string(), None, None, false) .unwrap(); // assert invalid nft is not returned let expiration = env.block.time.plus_days(1); env.block.time = expiration; let tokens = contract - .tokens(deps.as_ref(), env.clone(), owner.clone(), None, None, false) + .tokens(deps.as_ref(), env.clone(), owner.to_string(), None, None, false) .unwrap(); assert_eq!(tokens, TokensResponse { tokens: vec![] }); // assert invalid nft is returned let tokens = contract - .tokens(deps.as_ref(), env, owner, None, None, true) + .tokens(deps.as_ref(), env, owner.to_string(), None, None, true) .unwrap(); assert_eq!( tokens, @@ -1413,12 +1413,12 @@ fn test_all_tokens() { let minter = mock_info(minter.as_ref(), &[]); let token_id = "grow1".to_string(); - let owner = deps.api.addr_make("ark").to_string(); + let owner = deps.api.addr_make("ark"); let mut env = mock_env(); let mint_msg = ExecuteMsg::Mint { token_id: token_id.clone(), - owner: owner.clone(), + owner: owner.to_string(), token_uri: None, extension: None, }; @@ -1435,7 +1435,7 @@ fn test_all_tokens() { let expiration = env.block.time.plus_days(1); env.block.time = expiration; let tokens = contract - .tokens(deps.as_ref(), env.clone(), owner, None, None, false) + .tokens(deps.as_ref(), env.clone(), owner.to_string(), None, None, false) .unwrap(); assert_eq!(tokens, TokensResponse { tokens: vec![] }); diff --git a/contracts/cw721-expiration/src/lib.rs b/contracts/cw721-expiration/src/lib.rs index 8ac176532..645ea4ad9 100644 --- a/contracts/cw721-expiration/src/lib.rs +++ b/contracts/cw721-expiration/src/lib.rs @@ -76,7 +76,7 @@ mod tests { #[test] fn proper_cw2_initialization() { let mut deps = mock_dependencies(); - let mrt = deps.api.addr_make("mrt").to_string(); + let mrt = deps.api.addr_make("mrt"); // assert min expiration let error = entry::instantiate( deps.as_mut(), @@ -102,7 +102,7 @@ mod tests { expiration_days: 1, name: "".into(), symbol: "".into(), - minter: Some(mrt), + minter: Some(mrt.to_string()), withdraw_address: None, }, ) diff --git a/contracts/cw721-fixed-price/Cargo.toml b/contracts/cw721-fixed-price/Cargo.toml index a518e8273..8910c6f0e 100644 --- a/contracts/cw721-fixed-price/Cargo.toml +++ b/contracts/cw721-fixed-price/Cargo.toml @@ -12,8 +12,6 @@ documentation = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-metadata-onchain/Cargo.toml b/contracts/cw721-metadata-onchain/Cargo.toml index bfff06e29..0279b4222 100644 --- a/contracts/cw721-metadata-onchain/Cargo.toml +++ b/contracts/cw721-metadata-onchain/Cargo.toml @@ -16,8 +16,6 @@ documentation = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-non-transferable/Cargo.toml b/contracts/cw721-non-transferable/Cargo.toml index 0dbb48ef4..3050cccbc 100644 --- a/contracts/cw721-non-transferable/Cargo.toml +++ b/contracts/cw721-non-transferable/Cargo.toml @@ -13,8 +13,6 @@ documentation = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/cw721-receiver-tester/Cargo.toml b/contracts/cw721-receiver-tester/Cargo.toml index 81d4f0b01..aafff2fba 100644 --- a/contracts/cw721-receiver-tester/Cargo.toml +++ b/contracts/cw721-receiver-tester/Cargo.toml @@ -14,8 +14,6 @@ rust-version = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -# backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] From e0ac2725a997a8c9a990305c005e330bd1d84ca6 Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:27:57 -0500 Subject: [PATCH 8/9] fix up formatting --- contracts/cw721-base/src/contract_tests.rs | 11 ++++- .../cw721-expiration/src/contract_tests.rs | 45 ++++++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/contracts/cw721-base/src/contract_tests.rs b/contracts/cw721-base/src/contract_tests.rs index 6a8ceb361..b1e59fc89 100644 --- a/contracts/cw721-base/src/contract_tests.rs +++ b/contracts/cw721-base/src/contract_tests.rs @@ -1024,7 +1024,9 @@ fn query_tokens_by_owner() { .tokens(deps.as_ref(), demeter.to_string(), None, None) .unwrap(); assert_eq!(&by_demeter, &tokens.tokens); - let tokens = contract.tokens(deps.as_ref(), ceres.to_string(), None, None).unwrap(); + let tokens = contract + .tokens(deps.as_ref(), ceres.to_string(), None, None) + .unwrap(); assert_eq!(&by_ceres, &tokens.tokens); // paginate for demeter @@ -1033,7 +1035,12 @@ fn query_tokens_by_owner() { .unwrap(); assert_eq!(&by_demeter[..1], &tokens.tokens[..]); let tokens = contract - .tokens(deps.as_ref(), demeter.to_string(), Some(by_demeter[0].clone()), Some(3)) + .tokens( + deps.as_ref(), + demeter.to_string(), + Some(by_demeter[0].clone()), + Some(3), + ) .unwrap(); assert_eq!(&by_demeter[1..], &tokens.tokens[..]); } diff --git a/contracts/cw721-expiration/src/contract_tests.rs b/contracts/cw721-expiration/src/contract_tests.rs index cebf2f03f..407fd6dd3 100644 --- a/contracts/cw721-expiration/src/contract_tests.rs +++ b/contracts/cw721-expiration/src/contract_tests.rs @@ -1100,7 +1100,14 @@ fn test_tokens_by_owner() { .unwrap(); assert_eq!(&by_demeter, &tokens.tokens); let tokens = contract - .tokens(deps.as_ref(), mock_env(), ceres.to_string(), None, None, false) + .tokens( + deps.as_ref(), + mock_env(), + ceres.to_string(), + None, + None, + false, + ) .unwrap(); assert_eq!(&by_ceres, &tokens.tokens); @@ -1300,7 +1307,14 @@ fn test_approval() { let expiration = env.block.time.plus_days(1); env.block.time = expiration; let error = contract - .approval(deps.as_ref(), env, token_id.clone(), owner.to_string(), false, false) + .approval( + deps.as_ref(), + env, + token_id.clone(), + owner.to_string(), + false, + false, + ) .unwrap_err(); assert_eq!( error, @@ -1380,14 +1394,28 @@ fn test_tokens() { // assert valid nft is returned contract - .tokens(deps.as_ref(), env.clone(), owner.to_string(), None, None, false) + .tokens( + deps.as_ref(), + env.clone(), + owner.to_string(), + None, + None, + false, + ) .unwrap(); // assert invalid nft is not returned let expiration = env.block.time.plus_days(1); env.block.time = expiration; let tokens = contract - .tokens(deps.as_ref(), env.clone(), owner.to_string(), None, None, false) + .tokens( + deps.as_ref(), + env.clone(), + owner.to_string(), + None, + None, + false, + ) .unwrap(); assert_eq!(tokens, TokensResponse { tokens: vec![] }); @@ -1435,7 +1463,14 @@ fn test_all_tokens() { let expiration = env.block.time.plus_days(1); env.block.time = expiration; let tokens = contract - .tokens(deps.as_ref(), env.clone(), owner.to_string(), None, None, false) + .tokens( + deps.as_ref(), + env.clone(), + owner.to_string(), + None, + None, + false, + ) .unwrap(); assert_eq!(tokens, TokensResponse { tokens: vec![] }); From 8382de2f374dc347f264bbec5ea72b8a9de56109 Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:25:18 -0500 Subject: [PATCH 9/9] draft: merging cw2 and cw-nft-0.19 - still fails --- .cargo/{config => config.toml} | 0 Cargo.lock | 814 ++++++++++++++++--- Cargo.toml | 8 +- packages/cw721/src/execute.rs | 7 +- packages/cw721/src/query.rs | 4 +- packages/cw721/src/state.rs | 34 +- packages/cw721/src/testing/contract_tests.rs | 119 ++- packages/cw721/src/testing/multi_tests.rs | 32 +- packages/cw721/src/testing/unit_tests.rs | 23 +- 9 files changed, 813 insertions(+), 228 deletions(-) rename .cargo/{config => config.toml} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/Cargo.lock b/Cargo.lock index 3bad6b0f2..437013d11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,12 +13,157 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "anyhow" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", + "rayon", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + [[package]] name = "base16ct" version = "0.2.0" @@ -31,6 +176,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -43,6 +194,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "block-buffer" version = "0.9.0" @@ -63,9 +220,15 @@ dependencies = [ [[package]] name = "bnum" -version = "0.10.0" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" + +[[package]] +name = "bnum" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "byteorder" @@ -91,20 +254,49 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "cosmwasm-core" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" + [[package]] name = "cosmwasm-crypto" -version = "1.5.5" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd50718a2b6830ce9eb5d465de5a018a12e71729d66b70807ce97e6dd14f931d" +checksum = "8ed6aa9f904de106fa16443ad14ec2abe75e94ba003bb61c681c0e43d4c58d2a" dependencies = [ "digest 0.10.7", "ecdsa", - "ed25519-zebra", + "ed25519-zebra 3.1.0", "k256", "rand_core 0.6.4", "thiserror", ] +[[package]] +name = "cosmwasm-crypto" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ced5a6dd2801a383d3e14e5ae5caa7fdfeff1bd9f22b30e810e0aded8a5869" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", + "digest 0.10.7", + "ecdsa", + "ed25519-zebra 4.0.3", + "k256", + "num-traits", + "p256", + "rand_core 0.6.4", + "rayon", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "cosmwasm-derive" version = "1.5.5" @@ -114,13 +306,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cosmwasm-derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd1873f84d9b17edf8a90ffe10a89a649b82feacc00e36788b81d2c3cbf03c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "cosmwasm-schema" version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7879036156092ad1c22fe0d7316efc5a5eceec2bc3906462a2560215f2a2f929" dependencies = [ - "cosmwasm-schema-derive", + "cosmwasm-schema-derive 1.5.5", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27984b137eb2ac561f97f6bdb02004a98eb6f2ba263062c140b8e231ee1826b7" +dependencies = [ + "cosmwasm-schema-derive 2.1.0", "schemars", "serde", "serde_json", @@ -138,23 +354,57 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cosmwasm-schema-derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ef0d201f611bdb6c9124207032423eb956f1fc8ab3e3ee7253a9c08a5f5809" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "cosmwasm-std" -version = "1.5.5" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c1556156fdf892a55cced6115968b961eaaadd6f724a2c2cb7d1e168e32dd3" +checksum = "ad011ae7447188e26e4a7dbca2fcd0fc186aa21ae5c86df0503ea44c78f9e469" dependencies = [ - "base64", - "bech32", - "bnum", - "cosmwasm-crypto", - "cosmwasm-derive", + "base64 0.21.7", + "bech32 0.9.1", + "bnum 0.8.1", + "cosmwasm-crypto 1.5.2", + "cosmwasm-derive 1.5.5", "derivative", "forward_ref", "hex", "schemars", "serde", - "serde-json-wasm", + "serde-json-wasm 0.5.2", + "sha2 0.10.8", + "static_assertions", + "thiserror", +] + +[[package]] +name = "cosmwasm-std" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" +dependencies = [ + "base64 0.22.1", + "bech32 0.11.0", + "bnum 0.11.0", + "cosmwasm-core", + "cosmwasm-crypto 2.1.0", + "cosmwasm-derive 2.1.0", + "derive_more", + "hex", + "rand_core 0.6.4", + "schemars", + "serde", + "serde-json-wasm 1.0.1", "sha2 0.10.8", "static_assertions", "thiserror", @@ -169,6 +419,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -204,36 +479,63 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "cw-address-like" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" dependencies = [ - "cosmwasm-std", + "cosmwasm-std 1.5.2", ] [[package]] name = "cw-address-like" -version = "1.0.4" -source = "git+https://github.com/public-awesome/cw-plus-plus.git?rev=28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523#28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523" +version = "2.0.4" +source = "git+https://github.com/larry0x/cw-plus-plus.git?rev=718351d4e9d66edbf3b6dbea2d13b56ef732f51c#718351d4e9d66edbf3b6dbea2d13b56ef732f51c" dependencies = [ - "cosmwasm-std", + "cosmwasm-std 2.1.0", ] [[package]] name = "cw-multi-test" -version = "0.20.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc392a5cb7e778e3f90adbf7faa43c4db7f35b6623224b08886d796718edb875" +checksum = "e0034bfb4c06dfc8b50f0b1a06c3fc0f2312a1bae568a97db65930de071288ba" dependencies = [ "anyhow", - "bech32", - "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", + "bech32 0.11.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", "derivative", - "itertools 0.12.1", + "itertools 0.13.0", "prost 0.12.6", "schemars", "serde", @@ -247,9 +549,9 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "093dfb4520c48b5848274dd88ea99e280a04bc08729603341c7fb0d758c74321" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-address-like 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", + "cw-address-like 1.0.4", "cw-ownable-derive 0.5.1", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", @@ -259,14 +561,14 @@ dependencies = [ [[package]] name = "cw-ownable" version = "0.6.0" -source = "git+https://github.com/public-awesome/cw-plus-plus.git?rev=28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523#28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523" +source = "git+https://github.com/larry0x/cw-plus-plus.git?rev=718351d4e9d66edbf3b6dbea2d13b56ef732f51c#718351d4e9d66edbf3b6dbea2d13b56ef732f51c" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-address-like 1.0.4 (git+https://github.com/public-awesome/cw-plus-plus.git?rev=28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523)", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-address-like 2.0.4", "cw-ownable-derive 0.6.0", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", "thiserror", ] @@ -284,7 +586,7 @@ dependencies = [ [[package]] name = "cw-ownable-derive" version = "0.6.0" -source = "git+https://github.com/public-awesome/cw-plus-plus.git?rev=28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523#28c1a09bfc6b4f1942fefe3eb0b50faf9d3b1523" +source = "git+https://github.com/larry0x/cw-plus-plus.git?rev=718351d4e9d66edbf3b6dbea2d13b56ef732f51c#718351d4e9d66edbf3b6dbea2d13b56ef732f51c" dependencies = [ "proc-macro2", "quote", @@ -297,7 +599,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" dependencies = [ - "cosmwasm-std", + "cosmwasm-std 1.5.2", "schemars", "serde", ] @@ -308,7 +610,18 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ - "cosmwasm-std", + "cosmwasm-std 1.5.2", + "schemars", + "serde", +] + +[[package]] +name = "cw-storage-plus" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" +dependencies = [ + "cosmwasm-std 2.1.0", "schemars", "serde", ] @@ -319,8 +632,8 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6a84c6c1c0acc3616398eba50783934bd6c964bad6974241eaee3460c8f5b26" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw2 0.16.0", "schemars", "semver", @@ -334,8 +647,8 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw2 1.1.2", "schemars", "semver", @@ -343,14 +656,27 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" +dependencies = [ + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw2" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91398113b806f4d2a8d5f8d05684704a20ffd5968bf87e3473e1973710b884ad" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-storage-plus 0.16.0", "schemars", "serde", @@ -362,8 +688,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-storage-plus 1.2.0", "schemars", "semver", @@ -371,29 +697,44 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" +dependencies = [ + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "cw20" -version = "1.1.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" +checksum = "a42212b6bf29bbdda693743697c621894723f35d3db0d5df930be22903d0e27c" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-utils 1.0.3", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-utils 2.0.0", "schemars", "serde", ] [[package]] name = "cw2981-royalties" -version = "0.19.0" +version = "2.0.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", "cw-ownable 0.6.0", - "cw2 1.1.2", - "cw721 0.19.0", - "cw721-base 0.19.0", + "cw2 2.0.0", + "cw721 2.0.0", + "cw721-base 2.0.0", "schemars", "serde", "thiserror", @@ -405,8 +746,8 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94a1ea6e6277bdd6dfc043a9b1380697fe29d6e24b072597439523658d21d791" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-utils 0.16.0", "schemars", "serde", @@ -417,8 +758,8 @@ name = "cw721" version = "0.16.0" source = "git+https://github.com/CosmWasm/cw-nfts?tag=v0.16.0#2cad1d3e15e0a34d466a0b51e02c58b82ebe5ecd" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-utils 0.16.0", "schemars", "serde", @@ -429,8 +770,8 @@ name = "cw721" version = "0.17.0" source = "git+https://github.com/CosmWasm/cw-nfts?tag=v0.17.0#c1ece555dded6cbcebba1d417ed2a18d47ca3c8a" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-utils 1.0.3", "schemars", "serde", @@ -441,8 +782,8 @@ name = "cw721" version = "0.18.0" source = "git+https://github.com/CosmWasm/cw-nfts?tag=v0.18.0#177a993dfb5a1a3164be1baf274f43b1ca53da53" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-utils 1.0.3", "schemars", "serde", @@ -450,15 +791,15 @@ dependencies = [ [[package]] name = "cw721" -version = "0.19.0" +version = "2.0.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", "cw-multi-test", "cw-ownable 0.6.0", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "cw2 1.1.2", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", + "cw2 2.0.0", "cw721 0.16.0 (git+https://github.com/CosmWasm/cw-nfts?tag=v0.16.0)", "cw721-base 0.16.0 (git+https://github.com/CosmWasm/cw-nfts?tag=v0.16.0)", "cw721-base 0.17.0", @@ -474,8 +815,8 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77518e27431d43214cff4cdfbd788a7508f68d9b1f32389e6fce513e7eaccbef" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-storage-plus 0.16.0", "cw-utils 0.16.0", "cw2 0.16.0", @@ -490,8 +831,8 @@ name = "cw721-base" version = "0.16.0" source = "git+https://github.com/CosmWasm/cw-nfts?tag=v0.16.0#2cad1d3e15e0a34d466a0b51e02c58b82ebe5ecd" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-storage-plus 0.16.0", "cw-utils 0.16.0", "cw2 0.16.0", @@ -506,8 +847,8 @@ name = "cw721-base" version = "0.17.0" source = "git+https://github.com/CosmWasm/cw-nfts?tag=v0.17.0#c1ece555dded6cbcebba1d417ed2a18d47ca3c8a" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-ownable 0.5.1", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", @@ -524,8 +865,8 @@ name = "cw721-base" version = "0.18.0" source = "git+https://github.com/CosmWasm/cw-nfts?tag=v0.18.0#177a993dfb5a1a3164be1baf274f43b1ca53da53" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", "cw-ownable 0.5.1", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", @@ -539,30 +880,33 @@ dependencies = [ [[package]] name = "cw721-base" -version = "0.19.0" +version = "2.0.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-multi-test", "cw-ownable 0.6.0", - "cw2 1.1.2", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", + "cw2 2.0.0", "cw721 0.17.0", "cw721 0.18.0", - "cw721 0.19.0", + "cw721 2.0.0", "serde", ] [[package]] name = "cw721-expiration" -version = "0.19.0" +version = "2.0.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", "cw-multi-test", "cw-ownable 0.6.0", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw721 0.19.0", - "cw721-base 0.19.0", + "cw-storage-plus 2.0.0", + "cw2 2.0.0", + "cw721 2.0.0", + "cw721-base 2.0.0", "schemars", "serde", "thiserror", @@ -570,16 +914,16 @@ dependencies = [ [[package]] name = "cw721-fixed-price" -version = "0.19.0" +version = "2.0.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "cw2 1.1.2", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", + "cw2 2.0.0", "cw20", - "cw721 0.19.0", - "cw721-base 0.19.0", + "cw721 2.0.0", + "cw721-base 2.0.0", "prost 0.10.4", "schemars", "serde", @@ -588,27 +932,27 @@ dependencies = [ [[package]] name = "cw721-non-transferable" -version = "0.19.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw721 0.19.0", - "cw721-base 0.19.0", +version = "2.0.0" +dependencies = [ + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw2 2.0.0", + "cw721 2.0.0", + "cw721-base 2.0.0", "schemars", "serde", ] [[package]] name = "cw721-receiver-tester" -version = "0.19.0" +version = "2.0.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", "cw-multi-test", - "cw721 0.19.0", - "cw721-base 0.19.0", + "cw721 2.0.0", + "cw721-base 2.0.0", "schemars", "serde", "thiserror", @@ -635,6 +979,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "unicode-xid", +] + [[package]] name = "digest" version = "0.9.0" @@ -676,14 +1041,23 @@ dependencies = [ "spki", ] +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "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", + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", "hex", "rand_core 0.6.4", "serde", @@ -691,6 +1065,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" +dependencies = [ + "curve25519-dalek 4.1.3", + "ed25519", + "hashbrown 0.14.5", + "hex", + "rand_core 0.6.4", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "either" version = "1.12.0" @@ -726,6 +1115,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "forward_ref" version = "1.0.0" @@ -771,7 +1166,26 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.11", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", ] [[package]] @@ -807,6 +1221,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -815,9 +1238,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "k256" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -833,6 +1256,34 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -845,6 +1296,24 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pkcs8" version = "0.10.2" @@ -855,6 +1324,21 @@ dependencies = [ "spki", ] +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro2" version = "1.0.85" @@ -919,6 +1403,26 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -934,6 +1438,26 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -944,6 +1468,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.18" @@ -1012,6 +1545,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.203" @@ -1155,6 +1697,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -1167,8 +1715,42 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] diff --git a/Cargo.toml b/Cargo.toml index 52e26c657..fd5964474 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["packages/*", "contracts/*"] +resolver = "2" [workspace.package] version = "2.0.0" @@ -36,10 +37,6 @@ thiserror = "^1.0" codegen-units = 1 incremental = false -[profile.release.package.cw721-metadata-onchain] -codegen-units = 1 -incremental = false - [profile.release.package.cw721-fixed-price] codegen-units = 1 incremental = false @@ -48,10 +45,11 @@ incremental = false codegen-units = 1 incremental = false -[profile.release.package.cw721-receiver] +[profile.release.package.cw721-receiver-tester] codegen-units = 1 incremental = false + [profile.release] rpath = false lto = true diff --git a/packages/cw721/src/execute.rs b/packages/cw721/src/execute.rs index 556952e1b..96e282c59 100644 --- a/packages/cw721/src/execute.rs +++ b/packages/cw721/src/execute.rs @@ -1,8 +1,9 @@ +use std::fmt::Display; use cosmwasm_std::{ Addr, Api, BankMsg, Binary, Coin, CustomMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, Storage, }; -use cw_ownable::{none_or, Action, Ownership, OwnershipError, OwnershipStore}; +use cw_ownable::{Action, Ownership, OwnershipError}; use cw_storage_plus::Item; use cw_utils::Expiration; use serde::de::DeserializeOwned; @@ -650,7 +651,9 @@ pub fn migrate_legacy_minter_and_creator( }; Ok(response.add_attribute("creator_and_minter", none_or(creator_and_minter.as_ref()))) } - +fn none_or(or: Option<&T>) -> String { + or.map_or_else(|| "none".to_string(), |or| or.to_string()) +} /// Migrates only in case collection_info is not present pub fn migrate_legacy_collection_info( storage: &mut dyn Storage, diff --git a/packages/cw721/src/query.rs b/packages/cw721/src/query.rs index 5bdf2ed69..06222272a 100644 --- a/packages/cw721/src/query.rs +++ b/packages/cw721/src/query.rs @@ -253,7 +253,7 @@ pub trait Cw721Query< .load(deps.storage, &token_id)?; // token owner has absolute approval - if token.owner == spender { + if token.owner.to_string() == spender { let approval = Approval { spender: token.owner, expires: Expiration::Never {}, @@ -264,7 +264,7 @@ pub trait Cw721Query< let filtered: Vec<_> = token .approvals .into_iter() - .filter(|t| t.spender == spender) + .filter(|t| t.spender.to_string() == spender) .filter(|t| include_expired_approval || !t.is_expired(&env.block)) .map(|a| Approval { spender: a.spender, diff --git a/packages/cw721/src/state.rs b/packages/cw721/src/state.rs index 9dc4ac097..9a5e8c88f 100644 --- a/packages/cw721/src/state.rs +++ b/packages/cw721/src/state.rs @@ -27,14 +27,14 @@ pub struct Cw721Config< TMetadataExtensionMsg: CustomMsg, { /// Note: replaces deprecated/legacy key "nft_info"! - pub collection_info: Item<'a, CollectionInfo>, - pub token_count: Item<'a, u64>, + pub collection_info: Item, + pub token_count: Item, /// Stored as (granter, operator) giving operator full control over granter's account. /// NOTE: granter is the owner, so operator has only control for NFTs owned by granter! - pub operators: Map<'a, (&'a Addr, &'a Addr), Expiration>, + pub operators: Map<(&'a Addr, &'a Addr), Expiration>, pub nft_info: - IndexedMap<'a, &'a str, NftInfo, TokenIndexes<'a, TMetadataExtension>>, - pub withdraw_address: Item<'a, String>, + IndexedMap< &'a str, NftInfo, TokenIndexes<'a, TMetadataExtension>>, + pub withdraw_address: Item, pub(crate) _custom_response: PhantomData, pub(crate) _custom_execute: PhantomData, @@ -65,22 +65,22 @@ where TMetadataExtensionMsg: CustomMsg, { fn new( - collection_info_key: &'a str, - token_count_key: &'a str, - operator_key: &'a str, - nft_info_key: &'a str, - nft_info_owner_key: &'a str, - withdraw_address_key: &'a str, + collection_info_key: &'static str, + token_count_key: &'static str, + operator_key: &'static str, + nft_info_key: &'static str, + nft_info_owner_key: &'static str, + withdraw_address_key: &'static str, ) -> Self { let indexes = TokenIndexes { - owner: MultiIndex::new(token_owner_idx, nft_info_key, nft_info_owner_key), + owner: MultiIndex::new(token_owner_idx, nft_info_key.clone(), nft_info_owner_key.clone()), }; Self { - collection_info: Item::new(collection_info_key), - token_count: Item::new(token_count_key), - operators: Map::new(operator_key), - nft_info: IndexedMap::new(nft_info_key, indexes), - withdraw_address: Item::new(withdraw_address_key), + collection_info: Item::new(collection_info_key.clone()), + token_count: Item::new(token_count_key.clone()), + operators: Map::new(operator_key.clone()), + nft_info: IndexedMap::new(nft_info_key.clone(), indexes), + withdraw_address: Item::new(withdraw_address_key.clone()), _custom_response: PhantomData, _custom_execute: PhantomData, } diff --git a/packages/cw721/src/testing/contract_tests.rs b/packages/cw721/src/testing/contract_tests.rs index b2a03b029..a0db6d73d 100644 --- a/packages/cw721/src/testing/contract_tests.rs +++ b/packages/cw721/src/testing/contract_tests.rs @@ -1,15 +1,13 @@ #![cfg(test)] -use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; +use cosmwasm_std::testing::{message_info, mock_dependencies, mock_env}; use cosmwasm_std::{ from_json, to_json_binary, Addr, Coin, CosmosMsg, DepsMut, Empty, Response, StdError, WasmMsg, }; use crate::error::Cw721ContractError; -use crate::msg::{ - ApprovalResponse, NftInfoResponse, OperatorResponse, OperatorsResponse, OwnerOfResponse, -}; +use crate::msg::{ApprovalResponse, MinterResponse, NftInfoResponse, OperatorResponse, OperatorsResponse, OwnerOfResponse}; use crate::msg::{Cw721ExecuteMsg, Cw721InstantiateMsg, Cw721QueryMsg}; use crate::receiver::Cw721ReceiveMsg; use crate::state::{CollectionInfo, DefaultOptionMetadataExtension, MINTER}; @@ -18,7 +16,7 @@ use cw_ownable::{Action, Ownership, OwnershipError}; use super::contract::Cw721Contract; -const MINTER: &str = "minter"; +const MINTER_ADDR: &str = "minter"; const CREATOR: &str = "creator"; const CONTRACT_NAME: &str = "Magic Power"; const SYMBOL: &str = "MGK"; @@ -27,7 +25,7 @@ fn setup_contract( deps: DepsMut<'_>, creator: Addr, minter: Addr, -) -> Cw721Contract<'static, DefaultOptionMetadataExtension, Empty, Empty, Empty> { +) -> Cw721Contract<'static, DefaultOptionMetadataExtension, Empty, Empty> { let contract = Cw721Contract::default(); let msg = Cw721InstantiateMsg { name: CONTRACT_NAME.to_string(), @@ -35,7 +33,7 @@ fn setup_contract( minter: Some(minter.to_string()), withdraw_address: None, }; - let info = mock_info(creator.as_ref(), &[]); + let info = message_info(&creator, &[]); let res = contract .instantiate( deps, @@ -53,8 +51,8 @@ fn setup_contract( #[test] fn proper_instantiation() { let mut deps = mock_dependencies(); - let contract = Cw721Contract::::default(); - let minter = deps.api.addr_make(MINTER); + let contract = Cw721Contract::::default(); + let minter = deps.api.addr_make(MINTER_ADDR); let creator = deps.api.addr_make(CREATOR); let msg = Cw721InstantiateMsg { name: CONTRACT_NAME.to_string(), @@ -62,7 +60,7 @@ fn proper_instantiation() { minter: Some(minter.to_string()), withdraw_address: Some(creator.to_string()), }; - let info = mock_info(creator.as_ref(), &[]); + let info = message_info(&creator, &[]); let env = mock_env(); // we can just call .unwrap() to assert this was a success @@ -116,14 +114,14 @@ fn proper_instantiation_with_collection_info() { let mut deps = mock_dependencies(); let contract = Cw721Contract::::default(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let msg = Cw721InstantiateMsg { name: CONTRACT_NAME.to_string(), symbol: SYMBOL.to_string(), minter: Some(minter.to_string()), withdraw_address: Some(creator.to_string()), }; - let collection_info = mock_info(creator.as_ref(), &[]); + let collection_info = message_info(&creator, &[]); let env = mock_env(); // we can just call .unwrap() to assert this was a success @@ -140,7 +138,7 @@ fn proper_instantiation_with_collection_info() { assert_eq!(0, res.messages.len()); // it worked, let's query the state - let minter_ownership = minter.get_ownership(deps.as_ref().storage).unwrap(); + let minter_ownership = MINTER.get_ownership(deps.as_ref().storage).unwrap(); assert_eq!(Some(minter), minter_ownership.owner); let info = contract .query_collection_info(deps.as_ref(), env.clone()) @@ -176,7 +174,7 @@ fn proper_instantiation_with_collection_info() { fn minting() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let token_id = "petrify".to_string(); @@ -190,7 +188,7 @@ fn minting() { }; // random cannot mint - let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("random"), &[]); let env = mock_env(); let err = contract .execute(deps.as_mut(), env.clone(), random, mint_msg.clone()) @@ -198,7 +196,7 @@ fn minting() { assert_eq!(err, Cw721ContractError::Ownership(OwnershipError::NotOwner)); // minter can mint - let allowed = mock_info(minter.as_ref(), &[]); + let allowed = message_info(&minter, &[]); let _ = contract .execute(deps.as_mut(), env.clone(), allowed, mint_msg) .unwrap(); @@ -246,7 +244,7 @@ fn minting() { extension: None, }; - let allowed = mock_info(minter.as_ref(), &[]); + let allowed = message_info(&minter, &[]); let err = contract .execute(deps.as_mut(), mock_env(), allowed, mint_msg2) .unwrap_err(); @@ -264,7 +262,7 @@ fn minting() { fn test_update_minter() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let random = deps.api.addr_make("random"); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); @@ -279,7 +277,7 @@ fn test_update_minter() { }; // Minter can mint - let minter_info = mock_info(minter.as_ref(), &[]); + let minter_info = message_info(&minter, &[]); let _ = contract .execute(deps.as_mut(), mock_env(), minter_info.clone(), mint_msg) .unwrap(); @@ -301,7 +299,7 @@ fn test_update_minter() { // Minter does not change until ownership transfer completes. let minter_response: MinterResponse = from_json( contract - .query(deps.as_ref(), mock_env(), QueryMsg::Minter {}) + .query(deps.as_ref(), mock_env(), Cw721QueryMsg::Minter {}) .unwrap(), ) .unwrap(); @@ -325,7 +323,7 @@ fn test_update_minter() { ); // Accept the ownership transfer. - let random_info = mock_info(random.as_ref(), &[]); + let random_info = message_info(&random, &[]); contract .execute( deps.as_mut(), @@ -342,7 +340,7 @@ fn test_update_minter() { .unwrap(), ) .unwrap(); - assert_eq!(minter.minter, Some(random.to_string())); + assert_eq!(MINTER.minter, Some(random.to_string())); let mint_msg = Cw721ExecuteMsg::Mint { token_id: "randoms_token".to_string(), @@ -367,7 +365,7 @@ fn test_update_minter() { fn burning() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let token_id = "petrify".to_string(); @@ -383,13 +381,13 @@ fn burning() { let burn_msg = Cw721ExecuteMsg::Burn { token_id }; // mint some NFT - let allowed = mock_info(minter.as_ref(), &[]); + let allowed = message_info(&minter, &[]); let _ = contract .execute(deps.as_mut(), mock_env(), allowed.clone(), mint_msg) .unwrap(); // random not allowed to burn - let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("random"), &[]); let env = mock_env(); let err = contract @@ -424,7 +422,7 @@ fn burning() { fn transferring_nft() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // Mint a token @@ -438,13 +436,13 @@ fn transferring_nft() { extension: None, }; - let minter = mock_info(minter.as_ref(), &[]); + let minter = message_info(&minter, &[]); contract .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); // random cannot transfer - let random = mock_info("random", &[]); + let random = message_info(&deps.api.addr_make("random"), &[]); let transfer_msg = Cw721ExecuteMsg::TransferNft { recipient: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), @@ -456,7 +454,7 @@ fn transferring_nft() { assert_eq!(err, Cw721ContractError::Ownership(OwnershipError::NotOwner)); // owner can - let random = mock_info(deps.api.addr_make("venus").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("venus"), &[]); let transfer_msg = Cw721ExecuteMsg::TransferNft { recipient: deps.api.addr_make("random").to_string(), token_id: token_id.clone(), @@ -480,7 +478,7 @@ fn transferring_nft() { fn sending_nft() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // Mint a token @@ -494,7 +492,7 @@ fn sending_nft() { extension: None, }; - let minter = mock_info(minter.as_ref(), &[]); + let minter = message_info(&minter, &[]); contract .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); @@ -502,19 +500,19 @@ fn sending_nft() { let msg = to_json_binary("You now have the melting power").unwrap(); let target = deps.api.addr_make("another_contract"); let send_msg = Cw721ExecuteMsg::SendNft { - contract: target.clone(), + contract: target.to_string(), token_id: token_id.clone(), msg: msg.clone(), }; - let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("random"), &[]); let err = contract .execute(deps.as_mut(), mock_env(), random, send_msg.clone()) .unwrap_err(); assert_eq!(err, Cw721ContractError::Ownership(OwnershipError::NotOwner)); // but owner can - let random = mock_info(deps.api.addr_make("venus").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("venus"), &[]); let res = contract .execute(deps.as_mut(), mock_env(), random, send_msg) .unwrap(); @@ -548,7 +546,7 @@ fn sending_nft() { fn approving_revoking() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); // Mint a token @@ -562,7 +560,7 @@ fn approving_revoking() { extension: None, }; - let minter = mock_info(minter.as_ref(), &[]); + let minter = message_info(&minter, &[]); contract .execute(deps.as_mut(), mock_env(), minter, mint_msg) .unwrap(); @@ -581,7 +579,7 @@ fn approving_revoking() { res, ApprovalResponse { approval: Approval { - spender: deps.api.addr_make("demeter").to_string(), + spender: deps.api.addr_make("demeter"), expires: Expiration::Never {} } } @@ -593,7 +591,7 @@ fn approving_revoking() { token_id: token_id.clone(), expires: None, }; - let owner = mock_info(deps.api.addr_make("demeter").as_ref(), &[]); + let owner = message_info(&deps.api.addr_make("demeter"), &[]); let res = contract .execute(deps.as_mut(), mock_env(), owner, approve_msg) .unwrap(); @@ -620,14 +618,14 @@ fn approving_revoking() { res, ApprovalResponse { approval: Approval { - spender: deps.api.addr_make("random").to_string(), + spender: deps.api.addr_make("random"), expires: Expiration::Never {} } } ); // random can now transfer - let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("random"), &[]); let transfer_msg = Cw721ExecuteMsg::TransferNft { recipient: deps.api.addr_make("person").to_string(), token_id: token_id.clone(), @@ -661,7 +659,7 @@ fn approving_revoking() { token_id: token_id.clone(), expires: None, }; - let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); + let owner = message_info(&deps.api.addr_make("person"), &[]); contract .execute(deps.as_mut(), mock_env(), owner.clone(), approve_msg) .unwrap(); @@ -694,7 +692,7 @@ fn approving_revoking() { fn approving_all_revoking_all() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter); // Mint a couple tokens (from the same owner) @@ -711,7 +709,7 @@ fn approving_all_revoking_all() { extension: None, }; - let minter = mock_info(deps.api.addr_make(MINTER).as_ref(), &[]); + let minter = message_info(&deps.api.addr_make(MINTER_ADDR), &[]); contract .execute(deps.as_mut(), mock_env(), minter.clone(), mint_msg1) .unwrap(); @@ -745,7 +743,7 @@ fn approving_all_revoking_all() { operator: deps.api.addr_make("random").to_string(), expires: None, }; - let owner = mock_info(deps.api.addr_make("demeter").as_ref(), &[]); + let owner = message_info(&deps.api.addr_make("demeter"), &[]); let res = contract .execute(deps.as_mut(), mock_env(), owner, approve_all_msg) .unwrap(); @@ -758,7 +756,7 @@ fn approving_all_revoking_all() { ); // random can now transfer - let random = mock_info(deps.api.addr_make("random").as_ref(), &[]); + let random = message_info(&deps.api.addr_make("random"), &[]); let transfer_msg = Cw721ExecuteMsg::TransferNft { recipient: deps.api.addr_make("person").to_string(), token_id: token_id1, @@ -790,7 +788,7 @@ fn approving_all_revoking_all() { expires: None, }; // person is now the owner of the tokens - let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); + let owner = message_info(&deps.api.addr_make("person"), &[]); contract .execute(deps.as_mut(), mock_env(), owner, approve_all_msg) .unwrap(); @@ -809,7 +807,7 @@ fn approving_all_revoking_all() { res, OperatorResponse { approval: Approval { - spender: deps.api.addr_make("operator").to_string(), + spender: deps.api.addr_make("operator"), expires: Expiration::Never {} } } @@ -842,7 +840,7 @@ fn approving_all_revoking_all() { res, OperatorsResponse { operators: vec![Approval { - spender: deps.api.addr_make("operator").to_string(), + spender: deps.api.addr_make("operator"), expires: Expiration::Never {} }] } @@ -854,7 +852,7 @@ fn approving_all_revoking_all() { operator: deps.api.addr_make("buddy").to_string(), expires: Some(buddy_expires), }; - let owner = mock_info(deps.api.addr_make("person").as_ref(), &[]); + let owner = message_info(&deps.api.addr_make("person"), &[]); contract .execute(deps.as_mut(), mock_env(), owner.clone(), approve_all_msg) .unwrap(); @@ -876,7 +874,7 @@ fn approving_all_revoking_all() { res, OperatorsResponse { operators: vec![Approval { - spender: deps.api.addr_make("buddy").to_string(), + spender: deps.api.addr_make("buddy"), expires: buddy_expires, }] } @@ -896,7 +894,7 @@ fn approving_all_revoking_all() { res, OperatorsResponse { operators: vec![Approval { - spender: deps.api.addr_make("operator").to_string(), + spender: deps.api.addr_make("operator"), expires: Expiration::Never {} }] } @@ -937,7 +935,7 @@ fn approving_all_revoking_all() { res, OperatorsResponse { operators: vec![Approval { - spender: deps.api.addr_make("buddy").to_string(), + spender: deps.api.addr_make("buddy"), expires: buddy_expires, }] } @@ -978,7 +976,7 @@ fn test_set_withdraw_address() { let mut deps = mock_dependencies(); // other than minter cant set let creator = deps.api.addr_make("creator"); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let other = deps.api.addr_make("other"); // other cant set @@ -1009,8 +1007,8 @@ fn test_set_withdraw_address() { fn test_remove_withdraw_address() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); - let contract = setup_contract(deps.as_mut(), creator, minter); + let minter = deps.api.addr_make(MINTER_ADDR); + let contract = setup_contract(deps.as_mut(), creator, minter.clone()); let other = deps.api.addr_make("other"); let foo = deps.api.addr_make("foo"); @@ -1028,11 +1026,10 @@ fn test_remove_withdraw_address() { // set and remove contract - .set_withdraw_address(deps.as_mut(), &minter, foo.to_string()) .set_withdraw_address( deps.as_mut(), &minter, - "foo".to_string(), + foo.to_string(), ) .unwrap(); contract @@ -1059,7 +1056,7 @@ fn test_remove_withdraw_address() { fn test_withdraw_funds() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make("creator"); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let foo = deps.api.addr_make("foo"); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); @@ -1082,10 +1079,10 @@ fn test_withdraw_funds() { fn query_tokens_by_owner() { let mut deps = mock_dependencies(); let creator = deps.api.addr_make(CREATOR); - let minter = deps.api.addr_make(MINTER); + let minter = deps.api.addr_make(MINTER_ADDR); let contract = setup_contract(deps.as_mut(), creator, minter.clone()); - let minter = mock_info(minter.as_ref(), &[]); + let minter = message_info(&minter, &[]); // Mint a couple tokens (from the same owner) let token_id1 = "grow1".to_string(); @@ -1146,7 +1143,7 @@ fn query_tokens_by_owner() { let by_demeter = vec![token_id1, token_id3]; // all tokens by owner let tokens = contract - .query_tokens(deps.as_ref(), demeter.to_string(), None, None) + .query_tokens(deps.as_ref(), env.clone(), demeter.to_string(), None, None) .unwrap(); assert_eq!(&by_demeter, &tokens.tokens); let tokens = contract diff --git a/packages/cw721/src/testing/multi_tests.rs b/packages/cw721/src/testing/multi_tests.rs index 4bbd08228..5bc5bc7e7 100644 --- a/packages/cw721/src/testing/multi_tests.rs +++ b/packages/cw721/src/testing/multi_tests.rs @@ -65,7 +65,7 @@ fn cw721_base_latest_contract() -> Box> { let contract = ContractWrapper::new(execute, instantiate, query).with_migrate(migrate); Box::new(contract) } - +/* cw16 not supported fn cw721_base_016_contract() -> Box> { use cw721_base_016 as v16; let contract = ContractWrapper::new( @@ -76,6 +76,8 @@ fn cw721_base_016_contract() -> Box> { Box::new(contract) } + */ + fn cw721_base_017_contract() -> Box> { use cw721_base_017 as v17; let contract = ContractWrapper::new( @@ -124,7 +126,7 @@ fn mint_transfer_and_burn(app: &mut App, cw721: Addr, sender: Addr, token_id: St .unwrap(); let owner = query_owner(app.wrap(), &cw721, token_id.clone()); - assert_eq!(owner, sender.to_string()); + assert_eq!(owner.to_string(), sender.to_string()); app.execute_contract( sender, @@ -138,7 +140,7 @@ fn mint_transfer_and_burn(app: &mut App, cw721: Addr, sender: Addr, token_id: St .unwrap(); let owner = query_owner(app.wrap(), &cw721, token_id.clone()); - assert_eq!(owner, "burner".to_string()); + assert_eq!(owner.to_string(), "burner".to_string()); app.execute_contract( Addr::unchecked("burner"), @@ -334,20 +336,20 @@ fn test_operator() { fn test_migration_legacy_to_latest() { // case 1: migrate from v0.16 to latest by using existing minter addr { - use cw721_base_016 as v16; + use cw721_base_017 as v17; let mut app = App::default(); let admin = Addr::unchecked("admin"); - let code_id_016 = app.store_code(cw721_base_016_contract()); + let code_id_017 = app.store_code(cw721_base_017_contract()); let code_id_latest = app.store_code(cw721_base_latest_contract()); let legacy_creator_and_minter = Addr::unchecked("legacy_creator_and_minter"); let cw721 = app .instantiate_contract( - code_id_016, + code_id_017, legacy_creator_and_minter.clone(), - &v16::InstantiateMsg { + &v17::InstantiateMsg { name: "collection".to_string(), symbol: "symbol".to_string(), minter: legacy_creator_and_minter.to_string(), @@ -417,11 +419,11 @@ fn test_migration_legacy_to_latest() { // check that the new response is backwards compatable when minter // is not None. - let m: v16::MinterResponse = app + let m: v17::MinterResponse = app .wrap() .query_wasm_smart(&cw721, &Cw721QueryMsg::::Minter {}) .unwrap(); - assert_eq!(m.minter, legacy_creator_and_minter.to_string()); + assert_eq!(m.minter, Some(legacy_creator_and_minter.to_string())); // check minter ownership query works let minter_ownership: Ownership = app @@ -432,20 +434,20 @@ fn test_migration_legacy_to_latest() { } // case 2: migrate from v0.16 to latest by providing new creator and minter addr { - use cw721_base_016 as v16; + use cw721_base_017 as v17; let mut app = App::default(); let admin = Addr::unchecked("admin"); - let code_id_016 = app.store_code(cw721_base_016_contract()); + let code_id_017 = app.store_code(cw721_base_017_contract()); let code_id_latest = app.store_code(cw721_base_latest_contract()); let legacy_creator_and_minter = Addr::unchecked("legacy_creator_and_minter"); let cw721 = app .instantiate_contract( - code_id_016, + code_id_017, legacy_creator_and_minter.clone(), - &v16::InstantiateMsg { + &v17::InstantiateMsg { name: "collection".to_string(), symbol: "symbol".to_string(), minter: legacy_creator_and_minter.to_string(), @@ -510,11 +512,11 @@ fn test_migration_legacy_to_latest() { // check that the new response is backwards compatable when minter // is not None. - let m: v16::MinterResponse = app + let m: v17::MinterResponse = app .wrap() .query_wasm_smart(&cw721, &Cw721QueryMsg::::Minter {}) .unwrap(); - assert_eq!(m.minter, minter.to_string()); + assert_eq!(m.minter,Some(minter.to_string())); // check minter ownership query works let minter_ownership: Ownership = app diff --git a/packages/cw721/src/testing/unit_tests.rs b/packages/cw721/src/testing/unit_tests.rs index dcac842f0..636480539 100644 --- a/packages/cw721/src/testing/unit_tests.rs +++ b/packages/cw721/src/testing/unit_tests.rs @@ -1,15 +1,15 @@ use crate::{ execute::Cw721Execute, msg::{Cw721ExecuteMsg, Cw721InstantiateMsg}, - query::{Cw721Query, MAX_LIMIT}, - state::{CollectionInfo, DefaultOptionMetadataExtension, Metadata, MINTER}, + query::{Cw721Query, }, + state::{DefaultOptionMetadataExtension, Metadata, MINTER}, }; use cosmwasm_std::{ - testing::{mock_dependencies, mock_env, mock_info}, - Addr, Empty, + testing::{mock_dependencies, mock_env}, + Empty, }; +use cosmwasm_std::testing::message_info; use cw2::ContractVersion; -use cw_storage_plus::Item; use unit_tests::{contract::Cw721Contract, multi_tests::CREATOR_ADDR}; use super::*; @@ -23,7 +23,7 @@ fn proper_cw2_initialization() { .instantiate( deps.as_mut(), mock_env(), - mock_info("larry", &[]), + message_info(&deps.api.addr_make("larry"), &[]), Cw721InstantiateMsg { name: "collection_name".into(), symbol: "collection_symbol".into(), @@ -56,7 +56,7 @@ fn proper_cw2_initialization() { fn proper_owner_initialization() { let mut deps = mock_dependencies(); - let info_owner = mock_info("owner", &[]); + let info_owner = message_info(&deps.api.addr_make("owner"), &[]); Cw721Contract::::default() .instantiate( deps.as_mut(), @@ -82,7 +82,7 @@ fn use_metadata_extension() { let mut deps = mock_dependencies(); let contract = Cw721Contract::::default(); - let info = mock_info(CREATOR_ADDR, &[]); + let info = message_info(&deps.api.addr_make(CREATOR_ADDR), &[]); let init_msg = Cw721InstantiateMsg { name: "collection_name".into(), symbol: "collection_symbol".into(), @@ -125,6 +125,7 @@ fn use_metadata_extension() { assert_eq!(res.extension, extension); } +/* v16 Migrations aren't supported. #[test] fn test_migrate() { let mut deps = mock_dependencies(); @@ -134,7 +135,7 @@ fn test_migrate() { v16::entry::instantiate( deps.as_mut(), env.clone(), - mock_info("owner", &[]), + message_info(&deps.api.addr_make("owner"), &[]), v16::InstantiateMsg { name: "legacy_name".into(), symbol: "legacy_symbol".into(), @@ -145,7 +146,7 @@ fn test_migrate() { // mint 200 NFTs before migration for i in 0..200 { - let info = mock_info("legacy_minter", &[]); + let info = message_info(&deps.api.addr_make("legacy_minter"), &[]); let msg = v16::ExecuteMsg::Mint(v16::msg::MintMsg { token_id: i.to_string(), owner: "owner".into(), @@ -252,4 +253,6 @@ fn test_migrate() { .unwrap(); assert_eq!(token.owner.as_str(), "owner"); } + } + */