From f030849f53f77fd96fc4d1702840b0d9fd1624da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Tue, 5 Mar 2024 13:52:20 +0100 Subject: [PATCH] feat: Update deps to 2.0.0 (#308) --- Cargo.lock | 83 +++---- Cargo.toml | 9 + README.md | 8 +- examples/Cargo.lock | 174 +++++++------- examples/Cargo.toml | 22 +- examples/contracts/custom/src/contract.rs | 2 +- .../custom/src/multitest/custom_module.rs | 2 +- .../contracts/custom/src/multitest/tests.rs | 9 +- .../contracts/cw1-subkeys/src/contract.rs | 4 +- .../cw1-subkeys/src/multitest/tests.rs | 156 ++++++------ .../contracts/cw1-whitelist/src/contract.rs | 43 ++-- .../contracts/cw1-whitelist/src/multitest.rs | 42 ++-- .../contracts/cw20-base/src/allowances.rs | 2 +- examples/contracts/cw20-base/src/contract.rs | 12 +- .../src/multitest/allowances_tests.rs | 227 +++++++++--------- .../cw20-base/src/multitest/base_tests.rs | 95 ++++---- .../src/multitest/marketing_tests.rs | 125 +++++----- .../cw20-base/src/multitest/minting_tests.rs | 73 +++--- .../entry-points-overriding/src/contract.rs | 2 +- .../entry-points-overriding/src/multitest.rs | 12 +- .../generic_contract/src/contract.rs | 15 +- .../src/custom_and_generic.rs | 11 +- .../contracts/generic_contract/src/cw1.rs | 9 +- .../contracts/generic_contract/src/generic.rs | 11 +- .../generic_iface_on_contract/src/contract.rs | 15 +- .../generics_forwarded/src/contract.rs | 15 +- .../src/custom_and_generic.rs | 11 +- .../contracts/generics_forwarded/src/cw1.rs | 9 +- .../generics_forwarded/src/generic.rs | 11 +- sylvia-derive/Cargo.toml | 14 +- sylvia-derive/src/lib.rs | 8 +- sylvia-derive/src/multitest.rs | 6 +- sylvia/Cargo.toml | 44 ++-- sylvia/examples/basic.rs | 4 +- sylvia/src/into_response.rs | 5 +- sylvia/src/multitest.rs | 39 ++- sylvia/tests/custom_msg.rs | 21 +- sylvia/tests/custom_query.rs | 22 +- sylvia/tests/dispatching.rs | 6 +- sylvia/tests/entry_points.rs | 21 +- sylvia/tests/multitest.rs | 5 +- sylvia/tests/querier.rs | 17 +- sylvia/tests/replies.rs | 14 +- 43 files changed, 734 insertions(+), 701 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9953ca0a..39b933d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" @@ -108,12 +114,11 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9934c79e58d9676edfd592557dee765d2a6ef54c09d5aa2edb06156b00148966" +checksum = "3e5fd9485d4f1f4330547a8a5aaf0958c68b4d620975ded2c15f2ed5c49e8e74" dependencies = [ "digest 0.10.7", - "ecdsa", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -122,18 +127,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5e72e330bd3bdab11c52b5ecbdeb6a8697a004c57964caeb5d876f0b088b3c" +checksum = "d692944045feabbf46c75e8f072024bb885a7742025e40d46913296fe9fbbd06" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e3a2136e2a60e8b6582f5dffca5d1a683ed77bf38537d330bc1dfccd69010" +checksum = "a67c099aba9e334bbc1fc8037fe8e7ba91d06b215d9ffa7af91893c44aa420c6" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -144,9 +149,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d803bea6bd9ed61bd1ee0b4a2eb09ee20dbb539cc6e0b8795614d20952ebb1" +checksum = "8a2bb09168f6e86bf583361fdb0a0fed2625652e9edcfce731cb55ef4cb8de3d" dependencies = [ "proc-macro2", "quote", @@ -155,12 +160,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8666e572a3a2519010dde88c04d16e9339ae751b56b2bb35081fe3f7d6be74" +checksum = "464f484b3f289935a41e374560c66c59a8f881aefc74742558e42008f1b0b7f3" dependencies = [ "base64", - "bech32", + "bech32 0.9.1", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -169,7 +174,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm 0.5.2", + "serde-json-wasm", "sha2 0.10.8", "static_assertions", "thiserror", @@ -221,12 +226,12 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.20.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc392a5cb7e778e3f90adbf7faa43c4db7f35b6623224b08886d796718edb875" +checksum = "b7b69c1ba533753a2c90e60f4c803f52ee80cf3ba183c3ca0645fd1796561951" dependencies = [ "anyhow", - "bech32", + "bech32 0.11.0", "cosmwasm-std", "cw-storage-plus", "cw-utils", @@ -241,9 +246,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ "cosmwasm-std", "schemars", @@ -252,30 +257,13 @@ dependencies = [ [[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", "schemars", - "semver", - "serde", - "thiserror", -] - -[[package]] -name = "cw2" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "schemars", - "semver", "serde", "thiserror", ] @@ -503,9 +491,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", @@ -720,12 +708,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "semver" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" - [[package]] name = "serde" version = "1.0.197" @@ -744,15 +726,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde-json-wasm" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" -dependencies = [ - "serde", -] - [[package]] name = "serde-json-wasm" version = "1.0.1" @@ -866,7 +839,7 @@ dependencies = [ "schemars", "serde", "serde-cw-value", - "serde-json-wasm 1.0.1", + "serde-json-wasm", "sylvia-derive", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 2c5304a5..39d1c80d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,15 @@ version = "0.10.1" [workspace.dependencies] sylvia-derive = { version = "0.10.1", path = "sylvia-derive" } +anyhow = "1.0.81" +cosmwasm-schema = "2.0.0" +cosmwasm-std = "2.0.0" +cw-multi-test = "2.0.0" +cw-storage-plus = "2.0.0" +schemars = "0.8.16" +cw-utils = "2.0.0" +serde = { version = "1.0.197", default-features = false, features = ["derive"] } +thiserror = "1.0.58" [workspace.metadata.docs.rs] all-features = true diff --git a/README.md b/README.md index ea6c2493..383f1df6 100644 --- a/README.md +++ b/README.md @@ -521,13 +521,13 @@ mod tests { let contract = code_id.instantiate(3) .with_label("My contract") - .call(owner) + .call(&owner) .unwrap(); let counter = contract.counter().unwrap(); assert_eq!(counter, contract::CounterResp { counter: 3}); - contract.increment().call(owner).unwrap(); + contract.increment().call(&owner).unwrap(); let counter = contract.counter().unwrap(); assert_eq!(counter, contract::CounterResp { counter: 4}); @@ -594,11 +594,11 @@ fn member_test() { let contract = code_id.instantiate(0) .with_label("My contract") - .call(owner); + .call(&owner); contract .add_member(member.to_owned()) - .call(owner); + .call(&owner); let resp = contract .is_member(member.to_owned()) diff --git a/examples/Cargo.lock b/examples/Cargo.lock index e2ff1814..632b967d 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", @@ -15,9 +15,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "assert_matches" @@ -49,6 +49,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" @@ -75,9 +81,9 @@ checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "byteorder" @@ -120,12 +126,11 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9934c79e58d9676edfd592557dee765d2a6ef54c09d5aa2edb06156b00148966" +checksum = "3e5fd9485d4f1f4330547a8a5aaf0958c68b4d620975ded2c15f2ed5c49e8e74" dependencies = [ "digest 0.10.7", - "ecdsa", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -134,18 +139,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5e72e330bd3bdab11c52b5ecbdeb6a8697a004c57964caeb5d876f0b088b3c" +checksum = "d692944045feabbf46c75e8f072024bb885a7742025e40d46913296fe9fbbd06" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e3a2136e2a60e8b6582f5dffca5d1a683ed77bf38537d330bc1dfccd69010" +checksum = "a67c099aba9e334bbc1fc8037fe8e7ba91d06b215d9ffa7af91893c44aa420c6" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -156,9 +161,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d803bea6bd9ed61bd1ee0b4a2eb09ee20dbb539cc6e0b8795614d20952ebb1" +checksum = "8a2bb09168f6e86bf583361fdb0a0fed2625652e9edcfce731cb55ef4cb8de3d" dependencies = [ "proc-macro2", "quote", @@ -167,12 +172,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.5.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8666e572a3a2519010dde88c04d16e9339ae751b56b2bb35081fe3f7d6be74" +checksum = "464f484b3f289935a41e374560c66c59a8f881aefc74742558e42008f1b0b7f3" dependencies = [ "base64", - "bech32", + "bech32 0.9.1", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -181,7 +186,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm 0.5.2", + "serde-json-wasm", "sha2 0.10.8", "static_assertions", "thiserror", @@ -259,12 +264,12 @@ dependencies = [ [[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", "cw-utils", @@ -279,9 +284,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ "cosmwasm-std", "schemars", @@ -290,15 +295,13 @@ dependencies = [ [[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", "schemars", - "semver", "serde", "thiserror", ] @@ -356,9 +359,9 @@ dependencies = [ [[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", @@ -484,9 +487,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "ecdsa" @@ -519,9 +522,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elliptic-curve" @@ -708,9 +711,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -742,18 +745,18 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[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", @@ -798,9 +801,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" @@ -816,9 +819,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "pkcs8" @@ -893,7 +896,7 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -932,9 +935,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "schemars" @@ -976,15 +979,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -998,15 +1001,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde-json-wasm" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" -dependencies = [ - "serde", -] - [[package]] name = "serde-json-wasm" version = "1.0.1" @@ -1018,13 +1012,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1040,9 +1034,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -1118,7 +1112,7 @@ dependencies = [ "schemars", "serde", "serde-cw-value", - "serde-json-wasm 1.0.1", + "serde-json-wasm", "sylvia-derive", ] @@ -1132,7 +1126,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1148,9 +1142,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1159,22 +1153,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1223,9 +1217,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "version_check" @@ -1241,9 +1235,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1251,24 +1245,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1276,22 +1270,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "whitelist" @@ -1307,9 +1301,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.36" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 6c386ae2..fb4ccfba 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -27,15 +27,15 @@ version = "0.5.0" edition = "2021" [workspace.dependencies] -anyhow = "1.0.75" -cosmwasm-schema = "1.5.0" -cosmwasm-std = "1.5.0" -cw-multi-test = "0.20.0" -cw-storage-plus = "1.2.0" -cw-utils = "1.0.2" -cw2 = "1.1.2" -getrandom = "0.2.11" -semver = "1.0.20" -serde = { version = "1.0.192", default-features = false, features = ["derive"] } -thiserror = "1.0.50" +anyhow = "1.0.81" +cosmwasm-schema = "2.0.0" +cosmwasm-std = "2.0.0" +cw-multi-test = "2.0.0" +cw-storage-plus = "2.0.0" +cw-utils = "2.0.0" +cw2 = "2.0.0" +getrandom = "0.2.12" +semver = "1.0.22" +serde = { version = "1.0.197", default-features = false, features = ["derive"] } +thiserror = "1.0.58" assert_matches = "1.5.0" diff --git a/examples/contracts/custom/src/contract.rs b/examples/contracts/custom/src/contract.rs index 55a16d6d..1d15d674 100644 --- a/examples/contracts/custom/src/contract.rs +++ b/examples/contracts/custom/src/contract.rs @@ -9,7 +9,7 @@ use sylvia::entry_points; use crate::messages::{CountResponse, CounterMsg, CounterQuery}; pub struct CustomContract { - pub(crate) sudo_counter: Item<'static, u64>, + pub(crate) sudo_counter: Item, } #[cfg_attr(not(feature = "library"), entry_points)] diff --git a/examples/contracts/custom/src/multitest/custom_module.rs b/examples/contracts/custom/src/multitest/custom_module.rs index 177f168a..ca9719b5 100644 --- a/examples/contracts/custom/src/multitest/custom_module.rs +++ b/examples/contracts/custom/src/multitest/custom_module.rs @@ -11,7 +11,7 @@ use std::fmt::Debug; use crate::messages::{CountResponse, CounterMsg, CounterQuery}; pub struct CustomModule { - pub counter: Item<'static, u64>, + pub counter: Item, } impl Default for CustomModule { diff --git a/examples/contracts/custom/src/multitest/tests.rs b/examples/contracts/custom/src/multitest/tests.rs index 78d86f65..8d980c98 100644 --- a/examples/contracts/custom/src/multitest/tests.rs +++ b/examples/contracts/custom/src/multitest/tests.rs @@ -1,3 +1,4 @@ +use cw_multi_test::IntoBech32; use sylvia::multitest::App; use crate::contract::sv::mt::CodeId; @@ -11,7 +12,7 @@ use cw1::sv::mt::Cw1Proxy; #[test] fn test_custom() { - let owner = "owner"; + let owner = "owner".into_bech32(); let mt_app = cw_multi_test::BasicAppBuilder::new_custom() .with_custom(CustomModule::default()) @@ -23,14 +24,14 @@ fn test_custom() { let code_id = CodeId::store_code(&app); - let contract = code_id.instantiate().call(owner).unwrap(); + let contract = code_id.instantiate().call(&owner).unwrap(); - contract.send_custom().call(owner).unwrap(); + contract.send_custom().call(&owner).unwrap(); contract .can_execute("".to_string(), CosmosMsg::Custom(cosmwasm_std::Empty {})) .unwrap(); - contract.execute(vec![]).call(owner).unwrap(); + contract.execute(vec![]).call(&owner).unwrap(); let count = contract.query_custom().unwrap().count; assert_eq!(count, 1); diff --git a/examples/contracts/cw1-subkeys/src/contract.rs b/examples/contracts/cw1-subkeys/src/contract.rs index 4e7d8fc3..30deacb4 100644 --- a/examples/contracts/cw1-subkeys/src/contract.rs +++ b/examples/contracts/cw1-subkeys/src/contract.rs @@ -27,8 +27,8 @@ const DEFAULT_LIMIT: u32 = 10; pub struct Cw1SubkeysContract<'a> { pub(crate) whitelist: Cw1WhitelistContract<'a>, - pub(crate) permissions: Map<'static, &'a Addr, Permissions>, - pub(crate) allowances: Map<'static, &'a Addr, Allowance>, + pub(crate) permissions: Map<&'a Addr, Permissions>, + pub(crate) allowances: Map<&'a Addr, Allowance>, } #[cfg_attr(not(feature = "library"), entry_points)] diff --git a/examples/contracts/cw1-subkeys/src/multitest/tests.rs b/examples/contracts/cw1-subkeys/src/multitest/tests.rs index 63d0f743..12b4fbef 100644 --- a/examples/contracts/cw1-subkeys/src/multitest/tests.rs +++ b/examples/contracts/cw1-subkeys/src/multitest/tests.rs @@ -1,5 +1,6 @@ use cosmwasm_std::{coin, coins, Addr}; use cw2::{query_contract_info, ContractVersion}; +use cw_multi_test::IntoBech32; use cw_utils::{Expiration, NativeBalance}; use sylvia::multitest::App; @@ -35,14 +36,14 @@ macro_rules! assert_sorted_eq { fn get_contract_version_works() { let app = App::default(); - let owner = "owner"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned()], true) + .instantiate(vec![owner.to_string()], true) .with_label("Sublist contract") - .call(owner) + .call(&owner) .unwrap(); let version: ContractVersion = @@ -69,25 +70,27 @@ mod allowance { fn query() { let app = App::default(); - let owner = "owner"; - let spenders = ["spender1", "spender2", "spender3"]; + let owner = "owner".into_bech32(); + let spender1 = "spender1".into_bech32(); + let spender2 = "spender2".into_bech32(); + let spender3 = "spender3".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned()], false) + .instantiate(vec![owner.to_string()], false) .with_label("Sublist contract") - .call(owner) + .call(&owner) .unwrap(); contract - .increase_allowance(spenders[0].to_owned(), coin(1, ATOM), None) - .call(owner) + .increase_allowance(spender1.to_string(), coin(1, ATOM), None) + .call(&owner) .unwrap(); contract - .increase_allowance(spenders[1].to_owned(), coin(2, ATOM), None) - .call(owner) + .increase_allowance(spender2.to_string(), coin(2, ATOM), None) + .call(&owner) .unwrap(); assert_eq!( @@ -95,7 +98,7 @@ mod allowance { balance: NativeBalance(coins(1, ATOM)), expires: Expiration::Never {}, }, - contract.allowance(spenders[0].to_owned()).unwrap() + contract.allowance(spender1.to_string()).unwrap() ); assert_eq!( @@ -103,12 +106,12 @@ mod allowance { balance: NativeBalance(coins(2, ATOM)), expires: Expiration::Never {}, }, - contract.allowance(spenders[1].to_owned()).unwrap() + contract.allowance(spender2.to_string()).unwrap() ); assert_eq!( Allowance::default(), - contract.allowance(spenders[2].to_owned()).unwrap() + contract.allowance(spender3.to_string()).unwrap() ); } @@ -116,25 +119,25 @@ mod allowance { fn query_expired() { let app = App::default(); - let owner = "owner"; - let spender = "spender"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned()], false) + .instantiate(vec![owner.to_string()], false) .with_label("Sublist contract") - .call(owner) + .call(&owner) .unwrap(); let height = app.block_info().height; contract .increase_allowance( - spender.to_owned(), + spender.to_string(), coin(1, ATOM), Some(Expiration::AtHeight(height + 1)), ) - .call(owner) + .call(&owner) .unwrap(); app.update_block(next_block); @@ -145,7 +148,7 @@ mod allowance { balance: NativeBalance(vec![]), expires: Expiration::Never {}, }, - contract.allowance(spender.to_owned()).unwrap() + contract.allowance(spender.to_string()).unwrap() ); } @@ -153,51 +156,51 @@ mod allowance { fn query_all() { let app = App::default(); - let owner = "owner"; - let spender1 = "spender1"; - let spender2 = "spender2"; - let spender3 = "spender3"; - let spender4 = "spender4"; + let owner = "owner".into_bech32(); + let spender1 = "spender1".into_bech32(); + let spender2 = "spender2".into_bech32(); + let spender3 = "spender3".into_bech32(); + let spender4 = "spender4".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned()], false) + .instantiate(vec![owner.to_string()], false) .with_label("Sublist contract") - .call(owner) + .call(&owner) .unwrap(); let height = app.block_info().height; contract - .increase_allowance(spender1.to_owned(), coin(1234, ATOM), None) - .call(owner) + .increase_allowance(spender1.to_string(), coin(1234, ATOM), None) + .call(&owner) .unwrap(); contract .increase_allowance( - spender2.to_owned(), + spender2.to_string(), coin(2345, ATOM), Some(Expiration::Never {}), ) - .call(owner) + .call(&owner) .unwrap(); contract .increase_allowance( - spender3.to_owned(), + spender3.to_string(), coin(3456, ATOM), Some(Expiration::AtHeight(height + 2)), ) - .call(owner) + .call(&owner) .unwrap(); contract .increase_allowance( - spender4.to_owned(), + spender4.to_string(), coin(2222, ATOM), Some(Expiration::AtHeight(height + 1)), ) - .call(owner) + .call(&owner) .unwrap(); app.update_block(next_block); @@ -263,27 +266,27 @@ mod permissions { fn query() { let app = App::default(); - let owner = "owner"; - let spender1 = "spender1"; - let spender2 = "spender2"; - let spender3 = "spender2"; + let owner = "owner".into_bech32(); + let spender1 = "spender1".into_bech32(); + let spender2 = "spender2".into_bech32(); + let spender3 = "spender3".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id .instantiate(vec![owner.to_string()], false) .with_label("Subkeys contract") - .call(owner) + .call(&owner) .unwrap(); contract .set_permissions(spender1.to_string(), ALL_PERMS) - .call(owner) + .call(&owner) .unwrap(); contract .set_permissions(spender2.to_string(), NO_PERMS) - .call(owner) + .call(&owner) .unwrap(); assert_eq!( @@ -304,40 +307,46 @@ mod permissions { fn query_all() { let app = App::default(); - let owner = "owner"; - let spender1 = "spender1"; - let spender2 = "spender2"; - let spender3 = "spender3"; + let owner = "owner".into_bech32(); + let spender1 = "spender1".into_bech32(); + let spender2 = "spender2".into_bech32(); + let spender3 = "spender3".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned()], false) + .instantiate(vec![owner.to_string()], false) .with_label("Subkeys contract") - .call(owner) + .call(&owner) .unwrap(); contract - .set_permissions(spender1.to_owned(), ALL_PERMS) - .call(owner) + .set_permissions(spender1.to_string(), ALL_PERMS) + .call(&owner) .unwrap(); contract - .set_permissions(spender2.to_owned(), NO_PERMS) - .call(owner) + .set_permissions(spender2.to_string(), NO_PERMS) + .call(&owner) .unwrap(); contract - .set_permissions(spender3.to_owned(), NO_PERMS) - .call(owner) + .set_permissions(spender3.to_string(), NO_PERMS) + .call(&owner) .unwrap(); assert_eq!( ALL_PERMS, - contract.permissions(spender1.to_owned()).unwrap() + contract.permissions(spender1.to_string()).unwrap() + ); + assert_eq!( + NO_PERMS, + contract.permissions(spender2.to_string()).unwrap() + ); + assert_eq!( + NO_PERMS, + contract.permissions(spender3.to_string()).unwrap() ); - assert_eq!(NO_PERMS, contract.permissions(spender2.to_owned()).unwrap()); - assert_eq!(NO_PERMS, contract.permissions(spender3.to_owned()).unwrap()); let batch1 = contract.all_permissions(None, Some(2)).unwrap().permissions; assert_eq!(2, batch1.len()); @@ -381,20 +390,19 @@ mod cw1_execute { fn can_execute() { let app = App::default(); - let owner = "owner"; - let admin = "admin"; - let non_admin = "non_admin"; + let owner = "owner".into_bech32(); + let admin = "admin".into_bech32(); + let non_admin = "non_admin".into_bech32(); let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned(), admin.to_owned()], false) + .instantiate(vec![owner.to_string(), admin.to_string()], false) .with_label("Subkeys contract") - .call(owner) + .call(&owner) .unwrap(); - let msg = BankMsg::Send { - to_address: "owner".to_owned(), + to_address: owner.to_string(), amount: vec![], }; @@ -413,18 +421,18 @@ mod cw1_execute { #[test] fn execute() { - let owner = "owner"; - let admin = "admin"; - let non_admin = "non_admin"; + let owner = "owner".into_bech32(); + let admin = "admin".into_bech32(); + let non_admin = Addr::unchecked("non_admin"); let app = cw_multi_test::App::new(|router, _api, storage| { router .bank - .init_balance(storage, &Addr::unchecked(admin), coins(2345, ATOM)) + .init_balance(storage, &admin, coins(2345, ATOM)) .unwrap(); router .bank - .init_balance(storage, &Addr::unchecked(non_admin), coins(2345, ATOM)) + .init_balance(storage, &non_admin, coins(2345, ATOM)) .unwrap(); }); @@ -433,9 +441,9 @@ mod cw1_execute { let code_id = CodeId::store_code(&app); let contract = code_id - .instantiate(vec![owner.to_owned(), admin.to_string()], false) + .instantiate(vec![owner.to_string(), admin.to_string()], false) .with_label("Subkeys contract") - .call(owner) + .call(&owner) .unwrap(); let msg = BankMsg::Send { @@ -446,13 +454,13 @@ mod cw1_execute { contract .execute(vec![msg.clone().into()]) .with_funds(&[coin(2345, ATOM)]) - .call(admin) + .call(&admin) .unwrap(); contract .execute(vec![msg.into()]) .with_funds(&[coin(2345, ATOM)]) - .call(non_admin) + .call(&non_admin) .unwrap_err(); } } diff --git a/examples/contracts/cw1-whitelist/src/contract.rs b/examples/contracts/cw1-whitelist/src/contract.rs index 1d11375f..a1738d31 100644 --- a/examples/contracts/cw1-whitelist/src/contract.rs +++ b/examples/contracts/cw1-whitelist/src/contract.rs @@ -13,8 +13,8 @@ const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); pub struct Cw1WhitelistContract<'a> { - pub(crate) admins: Map<'static, &'a Addr, Empty>, - pub(crate) mutable: Item<'static, bool>, + pub(crate) admins: Map<&'a Addr, Empty>, + pub(crate) mutable: Item, } #[cfg_attr(not(feature = "library"), entry_points)] @@ -61,6 +61,7 @@ mod tests { coin, coins, to_json_binary, BankMsg, CosmosMsg, StakingMsg, SubMsg, WasmMsg, }; use cw1::Cw1; + use cw_multi_test::IntoBech32; use whitelist::responses::AdminListResponse; use whitelist::Whitelist; @@ -68,9 +69,11 @@ mod tests { fn instantiate_and_modify_config() { let mut deps = mock_dependencies(); - let alice = "alice"; - let bob = "bob"; - let carl = "carl"; + let alice = "alice".into_bech32(); + let bob = "bob".into_bech32(); + let carl = "carl".into_bech32(); + let mut admins = vec![alice.to_string(), bob.to_string(), carl.to_string()]; + admins.sort(); let anyone = "anyone"; @@ -88,7 +91,7 @@ mod tests { // ensure expected config let expected = AdminListResponse { - admins: vec![alice.to_string(), bob.to_string(), carl.to_string()], + admins, mutable: true, }; assert_eq!( @@ -109,7 +112,7 @@ mod tests { assert_eq!(err, ContractError::Unauthorized); // but alice can kick out carl - let info = mock_info(alice, &[]); + let info = mock_info(alice.as_str(), &[]); contract .update_admins( (deps.as_mut(), mock_env(), info).into(), @@ -130,14 +133,14 @@ mod tests { ); // carl cannot freeze it - let info = mock_info(carl, &[]); + let info = mock_info(carl.as_str(), &[]); let err = contract .freeze((deps.as_mut(), mock_env(), info).into()) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized); // but bob can - let info = mock_info(bob, &[]); + let info = mock_info(bob.as_str(), &[]); contract .freeze((deps.as_mut(), mock_env(), info).into()) .unwrap(); @@ -153,7 +156,7 @@ mod tests { ); // and now alice cannot change it again - let info = mock_info(alice, &[]); + let info = mock_info(alice.as_str(), &[]); let err = contract .update_admins( (deps.as_mut(), mock_env(), info).into(), @@ -167,14 +170,14 @@ mod tests { fn execute_messages_has_proper_permissions() { let mut deps = mock_dependencies(); - let alice = "alice"; - let bob = "bob"; - let carl = "carl"; + let alice = "alice".into_bech32(); + let bob = "bob".into_bech32(); + let carl = "carl".into_bech32(); let contract = Cw1WhitelistContract::new(); // instantiate the contract - let info = mock_info(bob, &[]); + let info = mock_info(bob.as_str(), &[]); contract .instantiate( (deps.as_mut(), mock_env(), info).into(), @@ -199,14 +202,14 @@ mod tests { ]; // bob cannot execute them - let info = mock_info(bob, &[]); + let info = mock_info(bob.as_str(), &[]); let err = contract .execute((deps.as_mut(), mock_env(), info).into(), msgs.clone()) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized); // but carl can - let info = mock_info(carl, &[]); + let info = mock_info(carl.as_str(), &[]); let res = contract .execute((deps.as_mut(), mock_env(), info).into(), msgs.clone()) .unwrap(); @@ -221,15 +224,15 @@ mod tests { fn can_execute_query_works() { let mut deps = mock_dependencies(); - let alice = "alice"; - let bob = "bob"; + let alice = "alice".into_bech32(); + let bob = "bob".into_bech32(); - let anyone = "anyone"; + let anyone = "anyone".into_bech32(); let contract = Cw1WhitelistContract::new(); // instantiate the contract - let info = mock_info(anyone, &[]); + let info = mock_info(anyone.as_str(), &[]); contract .instantiate( (deps.as_mut(), mock_env(), info).into(), diff --git a/examples/contracts/cw1-whitelist/src/multitest.rs b/examples/contracts/cw1-whitelist/src/multitest.rs index 3eddd0a2..78aa3915 100644 --- a/examples/contracts/cw1-whitelist/src/multitest.rs +++ b/examples/contracts/cw1-whitelist/src/multitest.rs @@ -1,6 +1,7 @@ #[cfg(test)] mod test { - use cosmwasm_std::{to_json_binary, WasmMsg}; + use cosmwasm_std::{to_json_binary, Addr, WasmMsg}; + use cw_multi_test::IntoBech32; use whitelist::responses::AdminListResponse; use crate::contract::sv::mt::CodeId; @@ -16,18 +17,18 @@ mod test { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let first_contract = code_id - .instantiate(vec![owner.to_owned()], true) + .instantiate(vec![owner.to_string()], true) .with_label("First contract") - .call(owner) + .call(&owner) .unwrap(); let second_contract = code_id .instantiate(vec![first_contract.contract_addr.to_string()], true) .with_label("Second contract") - .call(owner) + .call(&owner) .unwrap(); let freeze = whitelist::sv::ExecMsg::Freeze {}; @@ -39,7 +40,7 @@ mod test { first_contract .execute(vec![freeze.into()]) - .call(owner) + .call(&owner) .unwrap(); let resp = second_contract.admin_list().unwrap(); @@ -58,21 +59,26 @@ mod test { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; - let mut admins = vec!["admin1".to_owned(), "admin2".to_owned()]; + let owner = "owner".into_bech32(); + let admin1 = "admin1".into_bech32(); + let admin2 = "admin2".into_bech32(); + let admin3 = "admin3".into_bech32(); + let mut admins = vec![admin1.to_string(), admin2.to_string()]; + admins.sort(); let contract = code_id .instantiate(admins.clone(), true) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.admin_list().unwrap(); assert_eq!(resp.admins, admins); - admins.push("admin3".to_owned()); + admins.push(admin3.to_string()); + admins.sort(); contract .update_admins(admins.clone()) - .call("admin1") + .call(&admin1) .unwrap(); let resp = contract.admin_list().unwrap(); @@ -84,25 +90,25 @@ mod test { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(vec![owner.to_string()], true) - .call(owner) + .call(&owner) .unwrap(); let err = contract - .update_admins(vec![owner.to_owned(), "fake_admin".to_owned()]) - .call("fake_admin") + .update_admins(vec![owner.to_string(), "fake_admin".to_owned()]) + .call(&Addr::unchecked("fake_admin")) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized); - contract.freeze().call(owner).unwrap(); + contract.freeze().call(&owner).unwrap(); let err = contract - .update_admins(vec![owner.to_owned(), "admin".to_owned()]) - .call(owner) + .update_admins(vec![owner.to_string(), "admin".to_owned()]) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::ContractFrozen); diff --git a/examples/contracts/cw20-base/src/allowances.rs b/examples/contracts/cw20-base/src/allowances.rs index 80c1ab4f..15ac5f8c 100644 --- a/examples/contracts/cw20-base/src/allowances.rs +++ b/examples/contracts/cw20-base/src/allowances.rs @@ -135,7 +135,7 @@ impl Cw20Allowances for Cw20Base<'_> { return Ok(resp); } - if ctx.info.sender != owner { + if ctx.info.sender != owner_addr { // deduct allowance before doing anything else have enough allowance self.deduct_allowance( ctx.deps.storage, diff --git a/examples/contracts/cw20-base/src/contract.rs b/examples/contracts/cw20-base/src/contract.rs index bf974f09..8979c729 100644 --- a/examples/contracts/cw20-base/src/contract.rs +++ b/examples/contracts/cw20-base/src/contract.rs @@ -63,13 +63,13 @@ pub struct InstantiateMsgData { } pub struct Cw20Base<'a> { - pub(crate) token_info: Item<'static, TokenInfo>, - pub(crate) marketing_info: Item<'static, MarketingInfoResponse>, - pub(crate) logo: Item<'static, Logo>, - pub(crate) balances: Map<'static, &'a Addr, Uint128>, - pub(crate) allowances: Map<'static, (&'a Addr, &'a Addr), AllowanceResponse>, + pub(crate) token_info: Item, + pub(crate) marketing_info: Item, + pub(crate) logo: Item, + pub(crate) balances: Map<&'a Addr, Uint128>, + pub(crate) allowances: Map<(&'a Addr, &'a Addr), AllowanceResponse>, // TODO: After https://github.com/CosmWasm/cw-plus/issues/670 is implemented, replace this with a `MultiIndex` over `ALLOWANCES` - pub(crate) allowances_spender: Map<'static, (&'a Addr, &'a Addr), AllowanceResponse>, + pub(crate) allowances_spender: Map<(&'a Addr, &'a Addr), AllowanceResponse>, } #[cfg_attr(not(feature = "library"), entry_points)] diff --git a/examples/contracts/cw20-base/src/multitest/allowances_tests.rs b/examples/contracts/cw20-base/src/multitest/allowances_tests.rs index a4cac4b7..f4983bf7 100644 --- a/examples/contracts/cw20-base/src/multitest/allowances_tests.rs +++ b/examples/contracts/cw20-base/src/multitest/allowances_tests.rs @@ -3,7 +3,7 @@ use cw20_allowances::responses::{ AllAllowancesResponse, AllSpenderAllowancesResponse, AllowanceInfo, AllowanceResponse, SpenderAllowanceInfo, }; -use cw_multi_test::next_block; +use cw_multi_test::{next_block, IntoBech32}; use cw_utils::Expiration; use sylvia::multitest::App; @@ -20,8 +20,8 @@ use cw20_allowances::sv::mt::Cw20AllowancesProxy; fn increase_decrease_allowances() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); let code_id = CodeId::store_code(&app); @@ -31,14 +31,14 @@ fn increase_decrease_allowances() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: Uint128::new(12340000), }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // no allowance to start @@ -52,7 +52,7 @@ fn increase_decrease_allowances() { let expires = Expiration::AtHeight(123_456); contract .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // ensure it looks good @@ -67,7 +67,7 @@ fn increase_decrease_allowances() { let allowance = allowance.checked_sub(lower).unwrap(); contract .decrease_allowance(spender.to_string(), lower, None) - .call(owner) + .call(&owner) .unwrap(); let allowance_resp = contract @@ -82,7 +82,7 @@ fn increase_decrease_allowances() { let expires = Expiration::AtTime(Timestamp::from_seconds(8888888888)); contract .increase_allowance(spender.to_string(), raise, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); let allowance_resp = contract @@ -93,7 +93,7 @@ fn increase_decrease_allowances() { // decrease it below 0 contract .decrease_allowance(spender.to_string(), Uint128::new(99988647623876347), None) - .call(owner) + .call(&owner) .unwrap(); let allowance_resp = contract @@ -106,9 +106,9 @@ fn increase_decrease_allowances() { fn allowances_independent() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; - let spender2 = "addr0003"; + let owner = "owner".into_bech32(); + let spender1 = "spender1".into_bech32(); + let spender2 = "spender2".into_bech32(); let code_id = CodeId::store_code(&app); @@ -118,19 +118,19 @@ fn allowances_independent() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: Uint128::new(12340000), }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // no allowance to start let allowance_resp = contract - .allowance(owner.to_string(), spender.to_string()) + .allowance(owner.to_string(), spender1.to_string()) .unwrap(); assert_eq!(allowance_resp, AllowanceResponse::default()); @@ -143,15 +143,15 @@ fn allowances_independent() { let allowance = Uint128::new(7777); let expires = Expiration::AtHeight(123_456); contract - .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .increase_allowance(spender1.to_string(), allowance, Some(expires)) + .call(&owner) .unwrap(); // set other allowance with no expiration let allowance2 = Uint128::new(87654); contract .increase_allowance(spender2.to_string(), allowance2, None) - .call(owner) + .call(&owner) .unwrap(); // check they are proper @@ -161,7 +161,7 @@ fn allowances_independent() { expires: Expiration::Never {}, }; let allowance_resp = contract - .allowance(owner.to_string(), spender.to_string()) + .allowance(owner.to_string(), spender1.to_string()) .unwrap(); assert_eq!(allowance_resp, expect_one); @@ -175,7 +175,7 @@ fn allowances_independent() { let expires3 = Expiration::AtTime(Timestamp::from_seconds(3767626296)); contract .increase_allowance(spender2.to_string(), allowance3, Some(expires3)) - .call(spender) + .call(&spender1) .unwrap(); let expect_three = AllowanceResponse { @@ -183,7 +183,7 @@ fn allowances_independent() { expires: expires3, }; let allowance_resp = contract - .allowance(owner.to_string(), spender.to_string()) + .allowance(owner.to_string(), spender1.to_string()) .unwrap(); assert_eq!(allowance_resp, expect_one); let allowance_resp = contract @@ -191,7 +191,7 @@ fn allowances_independent() { .unwrap(); assert_eq!(allowance_resp, expect_two); let allowance_resp = contract - .allowance(spender.to_string(), spender2.to_string()) + .allowance(spender1.to_string(), spender2.to_string()) .unwrap(); assert_eq!(allowance_resp, expect_three); } @@ -200,7 +200,7 @@ fn allowances_independent() { fn no_self_allowance() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -210,20 +210,20 @@ fn no_self_allowance() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: Uint128::new(12340000), }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // self-allowance let err = contract .increase_allowance(owner.to_string(), Uint128::new(7777), None) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::CannotSetOwnAccount); @@ -231,7 +231,7 @@ fn no_self_allowance() { // decrease self-allowance let err = contract .decrease_allowance(owner.to_string(), Uint128::new(7777), None) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::CannotSetOwnAccount); @@ -241,7 +241,7 @@ fn no_self_allowance() { fn transfer_from_self_to_self() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let amount = Uint128::new(999999); let code_id = CodeId::store_code(&app); @@ -252,21 +252,21 @@ fn transfer_from_self_to_self() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // valid transfer of part of the allowance let transfer = Uint128::new(44444); contract .transfer_from(owner.to_string(), owner.to_string(), transfer) - .call(owner) + .call(&owner) .unwrap(); // make sure amount of money is the same @@ -278,8 +278,8 @@ fn transfer_from_self_to_self() { fn transfer_from_owner_requires_no_allowance() { let app = App::default(); - let owner = "addr0001"; - let rcpt = "addr0003"; + let owner = "owner".into_bech32(); + let rcpt = "rcpt".into_bech32(); let start_amount = Uint128::new(999999); let code_id = CodeId::store_code(&app); @@ -290,21 +290,21 @@ fn transfer_from_owner_requires_no_allowance() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // valid transfer of part of the allowance let transfer = Uint128::new(44444); contract .transfer_from(owner.to_string(), rcpt.to_string(), transfer) - .call(owner) + .call(&owner) .unwrap(); // make sure money arrived @@ -322,9 +322,9 @@ fn transfer_from_owner_requires_no_allowance() { fn transfer_from_respects_limits() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; - let rcpt = "addr0003"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); + let rcpt = "rcpt".into_bech32(); let start_amount = Uint128::new(999999); let code_id = CodeId::store_code(&app); @@ -335,28 +335,28 @@ fn transfer_from_respects_limits() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // provide an allowance let allowance = Uint128::new(77777); contract .increase_allowance(spender.to_string(), allowance, None) - .call(owner) + .call(&owner) .unwrap(); // valid transfer of part of the allowance let transfer = Uint128::new(44444); contract .transfer_from(owner.to_string(), rcpt.to_string(), transfer) - .call(spender) + .call(&spender) .unwrap(); // make sure money arrived @@ -384,7 +384,7 @@ fn transfer_from_respects_limits() { // cannot send more than the allowance let err = contract .transfer_from(owner.to_string(), rcpt.to_string(), Uint128::new(33443)) - .call(spender) + .call(&spender) .unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); @@ -396,7 +396,7 @@ fn transfer_from_respects_limits() { Uint128::new(1000), Some(Expiration::AtHeight(next_block_height)), ) - .call(owner) + .call(&owner) .unwrap(); // move to next block @@ -405,7 +405,7 @@ fn transfer_from_respects_limits() { // we should now get the expiration error let err = contract .transfer_from(owner.to_string(), rcpt.to_string(), Uint128::new(33443)) - .call(spender) + .call(&spender) .unwrap_err(); assert!(matches!(err, ContractError::Expired)); } @@ -414,8 +414,8 @@ fn transfer_from_respects_limits() { fn burn_from_respects_limits() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); let start_amount = Uint128::new(999999); let code_id = CodeId::store_code(&app); @@ -426,28 +426,28 @@ fn burn_from_respects_limits() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // provide an allowance let allowance = Uint128::new(77777); contract .increase_allowance(spender.to_string(), allowance, None) - .call(owner) + .call(&owner) .unwrap(); // valid burn of part of the allowance let transfer = Uint128::new(44444); contract .burn_from(owner.to_string(), transfer) - .call(spender) + .call(&spender) .unwrap(); // make sure money burnt @@ -473,7 +473,7 @@ fn burn_from_respects_limits() { // cannot burn more than the allowance let err = contract .burn_from(owner.to_string(), Uint128::new(33443)) - .call(spender) + .call(&spender) .unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); @@ -486,7 +486,7 @@ fn burn_from_respects_limits() { Uint128::new(1000), Some(Expiration::AtHeight(next_block_height)), ) - .call(owner) + .call(&owner) .unwrap(); // move to next block @@ -495,7 +495,7 @@ fn burn_from_respects_limits() { // we should now get the expiration error let err = contract .burn_from(owner.to_string(), Uint128::new(33443)) - .call(spender) + .call(&spender) .unwrap_err(); assert!(matches!(err, ContractError::Expired)); } @@ -505,9 +505,9 @@ fn burn_from_respects_limits() { fn send_from_respects_limits() { let app = App::default(); - let owner = "addr0001"; - let owner2 = "addr0003"; - let spender = "addr0002"; + let owner = "owner".into_bech32(); + let owner2 = "owner2".into_bech32(); + let spender = "spender".into_bech32(); let send_msg = Binary::from(r#"{"some":123}"#.as_bytes()); let start_amount = Uint128::new(999999); @@ -520,27 +520,27 @@ fn send_from_respects_limits() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let receiver_contract = receiver_code_id .instantiate() .with_label("cool-dex") - .call(owner2) + .call(&owner2) .unwrap(); // provide an allowance let allowance = Uint128::new(77777); contract .increase_allowance(spender.to_string(), allowance, None) - .call(owner) + .call(&owner) .unwrap(); // valid send of part of the allowance @@ -552,7 +552,7 @@ fn send_from_respects_limits() { transfer, send_msg.clone(), ) - .call(spender) + .call(&spender) .unwrap(); // make sure money burnt @@ -583,7 +583,7 @@ fn send_from_respects_limits() { Uint128::new(33443), send_msg.clone(), ) - .call(spender) + .call(&spender) .unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); @@ -595,7 +595,7 @@ fn send_from_respects_limits() { Uint128::new(1000), Some(Expiration::AtHeight(next_block_height)), ) - .call(owner) + .call(&owner) .unwrap(); // move to next block @@ -609,7 +609,7 @@ fn send_from_respects_limits() { Uint128::new(33443), send_msg, ) - .call(spender) + .call(&spender) .unwrap_err(); assert!(matches!(err, ContractError::Expired)); @@ -619,8 +619,8 @@ fn send_from_respects_limits() { fn no_past_expiration() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); let start_amount = Uint128::new(999999); let allowance = Uint128::new(7777); @@ -632,14 +632,14 @@ fn no_past_expiration() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // set allowance with height expiration at current block height @@ -648,7 +648,7 @@ fn no_past_expiration() { let err = contract .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap_err(); // ensure it is rejected @@ -660,7 +660,7 @@ fn no_past_expiration() { let err = contract .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap_err(); // ensure it is rejected @@ -672,7 +672,7 @@ fn no_past_expiration() { contract .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // ensure it looks good @@ -688,7 +688,7 @@ fn no_past_expiration() { contract .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // ensure it looks good @@ -710,7 +710,7 @@ fn no_past_expiration() { let err = contract .increase_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap_err(); // ensure it is rejected @@ -722,7 +722,7 @@ fn no_past_expiration() { contract .decrease_allowance(spender.to_string(), allowance, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // ensure it looks good @@ -737,9 +737,9 @@ fn no_past_expiration() { fn query_allowances() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; - let spender2 = "addr0003"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); + let spender2 = "spender2".into_bech32(); let start_amount = Uint128::new(999999); let allowance = Uint128::new(7777); @@ -751,14 +751,14 @@ fn query_allowances() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // check all allowances @@ -774,7 +774,7 @@ fn query_allowances() { // increase spender allowances contract .increase_allowance(spender.to_string(), allowance, None) - .call(owner) + .call(&owner) .unwrap(); // check all allowances @@ -813,7 +813,7 @@ fn query_allowances() { let increased_allowances = allowance + allowance; contract .increase_allowance(spender2.to_string(), increased_allowances, None) - .call(owner) + .call(&owner) .unwrap(); // check all allowances @@ -860,9 +860,9 @@ fn query_allowances() { fn query_all_allowances_works() { let app = App::default(); - let owner = "addr0001"; - let spender = "addr0002"; - let spender2 = "addr0003"; + let owner = "owner".into_bech32(); + let spender = "spender".into_bech32(); + let spender2 = "spender2".into_bech32(); let start_amount = Uint128::new(12340000); let code_id = CodeId::store_code(&app); @@ -873,14 +873,14 @@ fn query_all_allowances_works() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // no allowance to start @@ -894,14 +894,14 @@ fn query_all_allowances_works() { let expires = Expiration::AtHeight(123_456); contract .increase_allowance(spender.to_string(), allow1, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // set allowance with no expiration let allow2 = Uint128::new(54321); contract .increase_allowance(spender2.to_string(), allow2, None) - .call(owner) + .call(&owner) .unwrap(); // query list gets 2 @@ -945,9 +945,9 @@ fn query_all_allowances_works() { fn all_spender_allowances_on_two_contracts() { let app = App::default(); - let owner = "addr0001"; - let owner2 = "addr0003"; - let spender = "addr0002"; + let owner = "owner".into_bech32(); + let owner2 = "owner2".into_bech32(); + let spender = "spender".into_bech32(); let start_amount = Uint128::new(12340000); let code_id = CodeId::store_code(&app); @@ -958,14 +958,14 @@ fn all_spender_allowances_on_two_contracts() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // no allowance to start @@ -979,7 +979,7 @@ fn all_spender_allowances_on_two_contracts() { let expires = Expiration::AtHeight(123_456); contract .increase_allowance(spender.to_string(), allow1, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // set allowance with no expiration, from the other owner @@ -989,20 +989,20 @@ fn all_spender_allowances_on_two_contracts() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner2) + .call(&owner2) .unwrap(); let allow2 = Uint128::new(54321); contract2 .increase_allowance(spender.to_string(), allow2, None) - .call(owner2) + .call(&owner2) .unwrap(); // query list on both contracts @@ -1022,17 +1022,18 @@ fn query_all_accounts_works() { let app = App::default(); // insert order and lexicographical order are different - let owner = "owner"; - let acct2 = "zebra"; - let acct3 = "nice"; - let acct4 = "aaaardvark"; + let owner = "owner".into_bech32(); + let acct2 = "zebra".into_bech32(); + let acct3 = "nice".into_bech32(); + let acct4 = "aaaardvark".into_bech32(); let start_amount = Uint128::new(12340000); - let expected_order = [ + let mut accounts = [ acct4.to_string(), acct3.to_string(), owner.to_string(), acct2.to_string(), ]; + accounts.sort(); let code_id = CodeId::store_code(&app); @@ -1042,45 +1043,45 @@ fn query_all_accounts_works() { symbol: "AUTO".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount: start_amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // put money everywhere (to create balanaces) contract .transfer(acct2.to_string(), Uint128::new(222222)) - .call(owner) + .call(&owner) .unwrap(); contract .transfer(acct3.to_string(), Uint128::new(333333)) - .call(owner) + .call(&owner) .unwrap(); contract .transfer(acct4.to_string(), Uint128::new(444444)) - .call(owner) + .call(&owner) .unwrap(); // make sure we get the proper results let resp = contract.all_accounts(None, None).unwrap(); - assert_eq!(resp.accounts, expected_order); + assert_eq!(resp.accounts, accounts); // let's do pagination let resp = contract.all_accounts(None, Some(2)).unwrap(); - assert_eq!(resp.accounts, expected_order[0..2].to_vec()); + assert_eq!(resp.accounts, accounts[0..2].to_vec()); let resp = contract .all_accounts(Some(resp.accounts[1].clone()), Some(1)) .unwrap(); - assert_eq!(resp.accounts, expected_order[2..3].to_vec()); + assert_eq!(resp.accounts, accounts[2..3].to_vec()); let resp = contract .all_accounts(Some(resp.accounts[0].clone()), Some(777)) .unwrap(); - assert_eq!(resp.accounts, expected_order[3..].to_vec()); + assert_eq!(resp.accounts, accounts[3..].to_vec()); } diff --git a/examples/contracts/cw20-base/src/multitest/base_tests.rs b/examples/contracts/cw20-base/src/multitest/base_tests.rs index 0c5ecfde..00693292 100644 --- a/examples/contracts/cw20-base/src/multitest/base_tests.rs +++ b/examples/contracts/cw20-base/src/multitest/base_tests.rs @@ -1,5 +1,6 @@ -use cosmwasm_std::{Addr, Binary, StdError, Uint128}; +use cosmwasm_std::{Binary, StdError, Uint128}; use cw20_allowances::responses::{AllAllowancesResponse, SpenderAllowanceInfo}; +use cw_multi_test::IntoBech32; use cw_utils::Expiration; use sylvia::multitest::App; @@ -15,7 +16,7 @@ fn basic() { let app = App::default(); let amount = Uint128::from(11223344u128); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -25,14 +26,14 @@ fn basic() { symbol: "CASH".to_string(), decimals: 9, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let resp = contract.token_info().unwrap(); @@ -56,11 +57,11 @@ fn basic() { fn instantiate_multiple_accounts() { let app = App::default(); - let owner = "addr0000"; + let owner = "addr0000".into_bech32(); let amount1 = Uint128::from(11223344u128); - let addr1 = "addr0001"; + let addr1 = "addr0001".into_bech32(); let amount2 = Uint128::from(7890987u128); - let addr2 = "addr0002"; + let addr2 = "addr0002".into_bech32(); let code_id = CodeId::store_code(&app); @@ -72,11 +73,11 @@ fn instantiate_multiple_accounts() { decimals: 6, initial_balances: vec![ Cw20Coin { - address: addr1.to_owned(), + address: addr1.to_string(), amount: amount1, }, Cw20Coin { - address: addr1.to_owned(), + address: addr1.to_string(), amount: amount2, }, ], @@ -84,7 +85,7 @@ fn instantiate_multiple_accounts() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::DuplicateInitialBalanceAddresses); @@ -97,11 +98,11 @@ fn instantiate_multiple_accounts() { decimals: 6, initial_balances: vec![ Cw20Coin { - address: addr1.into(), + address: addr1.to_string(), amount: amount1, }, Cw20Coin { - address: addr2.into(), + address: addr2.to_string(), amount: amount2, }, ], @@ -109,7 +110,7 @@ fn instantiate_multiple_accounts() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let resp = contract.token_info().unwrap(); @@ -132,9 +133,9 @@ fn instantiate_multiple_accounts() { fn queries_work() { let app = App::default(); - let owner = "addr0000"; + let owner = "addr0000".into_bech32(); let amount = Uint128::from(12340000u128); - let addr = Addr::unchecked("addr0001"); + let addr = "addr0001".into_bech32(); let code_id = CodeId::store_code(&app); @@ -144,14 +145,14 @@ fn queries_work() { symbol: "CASH".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let resp = contract.token_info().unwrap(); @@ -182,8 +183,8 @@ fn queries_work() { fn transfer() { let app = App::default(); - let owner = "addr0000"; - let addr = "addr0001"; + let owner = "addr0000".into_bech32(); + let addr = "addr0001".into_bech32(); let amount = Uint128::from(12340000u128); let transfer = Uint128::from(76543u128); let too_much = Uint128::from(12340321u128); @@ -196,27 +197,27 @@ fn transfer() { symbol: "CASH".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // cannot transfer nothing let err = contract .transfer(addr.to_string(), Uint128::zero()) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::InvalidZeroAmount); // cannot send more than we have let err = contract .transfer(addr.to_string(), too_much) - .call(owner) + .call(&owner) .unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); @@ -224,7 +225,7 @@ fn transfer() { // cannot send from empty account let err = contract .transfer(owner.to_string(), transfer) - .call(addr) + .call(&addr) .unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); @@ -232,7 +233,7 @@ fn transfer() { // valid transfer contract .transfer(addr.to_string(), transfer) - .call(owner) + .call(&owner) .unwrap(); // Check balance @@ -250,8 +251,8 @@ fn transfer() { fn burn() { let app = App::default(); - let owner = "addr0000"; - let addr = "addr0001"; + let owner = "addr0000".into_bech32(); + let addr = "addr0001".into_bech32(); let amount = Uint128::from(12340000u128); let burn = Uint128::from(76543u128); let too_much = Uint128::from(12340321u128); @@ -264,37 +265,37 @@ fn burn() { symbol: "CASH".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // cannot burn nothing - let err = contract.burn(Uint128::zero()).call(owner).unwrap_err(); + let err = contract.burn(Uint128::zero()).call(&owner).unwrap_err(); assert_eq!(err, ContractError::InvalidZeroAmount); let resp = contract.token_info().unwrap(); assert_eq!(resp.total_supply, amount); // cannot burn more than we have - let err = contract.burn(too_much).call(owner).unwrap_err(); + let err = contract.burn(too_much).call(&owner).unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); let resp = contract.token_info().unwrap(); assert_eq!(resp.total_supply, amount); // cannot send from empty account - let err = contract.burn(burn).call(addr).unwrap_err(); + let err = contract.burn(burn).call(&addr).unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); // valid burn reduces total supply - contract.burn(burn).call(owner).unwrap(); + contract.burn(burn).call(&owner).unwrap(); // check balance let remainder = amount.checked_sub(burn).unwrap(); @@ -308,7 +309,7 @@ fn burn() { fn send() { let app = App::default(); - let owner = "addr0000"; + let owner = "addr0000".into_bech32(); let amount = Uint128::from(12340000u128); let too_much = Uint128::from(12340321u128); let transfer = Uint128::from(76543u128); @@ -321,7 +322,7 @@ fn send() { let receiver_contract = receiver_code_id .instantiate() .with_label("cool-dex") - .call(owner) + .call(&owner) .unwrap(); let contract = code_id @@ -330,14 +331,14 @@ fn send() { symbol: "CASH".to_string(), decimals: 3, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract @@ -346,7 +347,7 @@ fn send() { Uint128::zero(), send_msg.clone(), ) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::InvalidZeroAmount); @@ -358,7 +359,7 @@ fn send() { too_much, send_msg.clone(), ) - .call(owner) + .call(&owner) .unwrap_err(); assert!(matches!(err, ContractError::Std(StdError::Overflow { .. }))); @@ -369,7 +370,7 @@ fn send() { transfer, send_msg, ) - .call(owner) + .call(&owner) .unwrap(); // ensure balance is properly transferred @@ -388,8 +389,8 @@ fn send() { fn migrate() { let app = App::default(); - let owner = "addr0000"; - let spender = "addr0001"; + let owner = "addr0000".into_bech32(); + let spender = "addr0001".into_bech32(); let code_id = CodeId::store_code(&app); let amount = Uint128::new(100); @@ -399,15 +400,15 @@ fn migrate() { symbol: "TOKEN".to_string(), decimals: 6, initial_balances: vec![Cw20Coin { - address: owner.into(), + address: owner.to_string(), amount, }], mint: None, marketing: None, }) .with_label("Cw20 contract") - .with_admin(Some(owner)) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); // no allowance to start @@ -421,11 +422,11 @@ fn migrate() { let expires = Expiration::AtHeight(123_456); contract .increase_allowance(spender.to_string(), allow1, Some(expires)) - .call(owner) + .call(&owner) .unwrap(); // Now migrate - contract.migrate().call(owner, code_id.code_id()).unwrap(); + contract.migrate().call(&owner, code_id.code_id()).unwrap(); // Smoke check that the contract still works. let resp = contract.balance(owner.to_string()).unwrap(); diff --git a/examples/contracts/cw20-base/src/multitest/marketing_tests.rs b/examples/contracts/cw20-base/src/multitest/marketing_tests.rs index 781de52e..eb050e1f 100644 --- a/examples/contracts/cw20-base/src/multitest/marketing_tests.rs +++ b/examples/contracts/cw20-base/src/multitest/marketing_tests.rs @@ -1,6 +1,7 @@ use cosmwasm_std::{Addr, StdError}; use cw20_marketing::responses::{DownloadLogoResponse, LogoInfo, MarketingInfoResponse}; use cw20_marketing::{EmbeddedLogo, Logo}; +use cw_multi_test::IntoBech32; use sylvia::multitest::App; use crate::contract::sv::mt::CodeId; @@ -14,7 +15,8 @@ const PNG_HEADER: [u8; 8] = [0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a]; fn update_unauthorised() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); + let marketing = "marketing".into_bech32(); let code_id = CodeId::store_code(&app); @@ -28,12 +30,12 @@ fn update_unauthorised() { marketing: Some(InstantiateMarketingInfo { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some("marketing".to_owned()), + marketing: Some(marketing.to_string()), logo: Some(Logo::Url("url".to_owned())), }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract @@ -42,7 +44,7 @@ fn update_unauthorised() { Some("Better description".to_owned()), Some("creator".to_owned()), ) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized); @@ -55,7 +57,7 @@ fn update_unauthorised() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked("marketing")), + marketing: Some(marketing), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -72,7 +74,7 @@ fn update_unauthorised() { fn update_project() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -91,12 +93,12 @@ fn update_project() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .update_marketing(Some("New project".to_owned()), None, None) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -106,7 +108,7 @@ fn update_project() { MarketingInfoResponse { project: Some("New project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -123,7 +125,7 @@ fn update_project() { fn clear_project() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -142,12 +144,12 @@ fn clear_project() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .update_marketing(Some("".to_owned()), None, None) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -156,7 +158,7 @@ fn clear_project() { MarketingInfoResponse { project: None, description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -173,7 +175,7 @@ fn clear_project() { fn update_description() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -192,12 +194,12 @@ fn update_description() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .update_marketing(None, Some("Better description".to_owned()), None) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -206,7 +208,7 @@ fn update_description() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Better description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -223,7 +225,7 @@ fn update_description() { fn clear_description() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -242,12 +244,12 @@ fn clear_description() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .update_marketing(None, Some("".to_owned()), None) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -257,7 +259,7 @@ fn clear_description() { MarketingInfoResponse { project: Some("Project".to_owned()), description: None, - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -274,7 +276,8 @@ fn clear_description() { fn update_marketing() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); + let marketing = "marketing".into_bech32(); let code_id = CodeId::store_code(&app); @@ -293,12 +296,12 @@ fn update_marketing() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract - .update_marketing(None, None, Some("marketing".to_owned())) - .call(owner) + .update_marketing(None, None, Some(marketing.to_string())) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -308,7 +311,7 @@ fn update_marketing() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked("marketing")), + marketing: Some(marketing), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -325,7 +328,7 @@ fn update_marketing() { fn update_marketing_invalid() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -344,12 +347,12 @@ fn update_marketing_invalid() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract .update_marketing(None, None, Some("m".to_owned())) - .call(owner) + .call(&owner) .unwrap_err(); assert!( @@ -365,7 +368,7 @@ fn update_marketing_invalid() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -382,7 +385,7 @@ fn update_marketing_invalid() { fn clear_marketing() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -401,12 +404,12 @@ fn clear_marketing() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .update_marketing(None, None, Some("".to_owned())) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -432,7 +435,7 @@ fn clear_marketing() { fn update_logo_url() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -451,12 +454,12 @@ fn update_logo_url() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .upload_logo(Logo::Url("new_url".to_owned())) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -466,7 +469,7 @@ fn update_logo_url() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("new_url".to_owned())), } ); @@ -483,7 +486,7 @@ fn update_logo_url() { fn update_logo_png() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let code_id = CodeId::store_code(&app); @@ -502,12 +505,12 @@ fn update_logo_png() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .upload_logo(Logo::Embedded(EmbeddedLogo::Png(PNG_HEADER.into()))) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -517,7 +520,7 @@ fn update_logo_png() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Embedded), } ); @@ -536,7 +539,7 @@ fn update_logo_png() { fn update_logo_svg() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let img = "".as_bytes(); let code_id = CodeId::store_code(&app); @@ -556,12 +559,12 @@ fn update_logo_svg() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); contract .upload_logo(Logo::Embedded(EmbeddedLogo::Svg(img.into()))) - .call(owner) + .call(&owner) .unwrap(); let resp = contract.marketing_info().unwrap(); @@ -571,7 +574,7 @@ fn update_logo_svg() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Embedded), } ); @@ -590,7 +593,7 @@ fn update_logo_svg() { fn update_logo_png_oversized() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let img = [&PNG_HEADER[..], &[1; 6000][..]].concat(); let code_id = CodeId::store_code(&app); @@ -610,12 +613,12 @@ fn update_logo_png_oversized() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract .upload_logo(Logo::Embedded(EmbeddedLogo::Png(img.into()))) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::LogoTooBig); @@ -627,7 +630,7 @@ fn update_logo_png_oversized() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -644,7 +647,7 @@ fn update_logo_png_oversized() { fn update_logo_svg_oversized() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let img = [ "", std::str::from_utf8(&[b'x'; 6000]).unwrap(), @@ -670,12 +673,12 @@ fn update_logo_svg_oversized() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract .upload_logo(Logo::Embedded(EmbeddedLogo::Svg(img.into()))) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::LogoTooBig); @@ -686,7 +689,7 @@ fn update_logo_svg_oversized() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -703,7 +706,7 @@ fn update_logo_svg_oversized() { fn update_logo_png_invalid() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let img = &[1]; let code_id = CodeId::store_code(&app); @@ -723,12 +726,12 @@ fn update_logo_png_invalid() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract .upload_logo(Logo::Embedded(EmbeddedLogo::Png(img.into()))) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::InvalidPngHeader); @@ -738,7 +741,7 @@ fn update_logo_png_invalid() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); @@ -755,7 +758,7 @@ fn update_logo_png_invalid() { fn update_logo_svg_invalid() { let app = App::default(); - let owner = "addr0001"; + let owner = "owner".into_bech32(); let img = &[1]; let code_id = CodeId::store_code(&app); @@ -775,12 +778,12 @@ fn update_logo_svg_invalid() { }), }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract .upload_logo(Logo::Embedded(EmbeddedLogo::Svg(img.into()))) - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!(err, ContractError::InvalidXmlPreamble); @@ -790,7 +793,7 @@ fn update_logo_svg_invalid() { MarketingInfoResponse { project: Some("Project".to_owned()), description: Some("Description".to_owned()), - marketing: Some(Addr::unchecked(owner)), + marketing: Some(Addr::unchecked(&owner)), logo: Some(LogoInfo::Url("url".to_owned())), } ); diff --git a/examples/contracts/cw20-base/src/multitest/minting_tests.rs b/examples/contracts/cw20-base/src/multitest/minting_tests.rs index 4eeb7b65..54c90ea8 100644 --- a/examples/contracts/cw20-base/src/multitest/minting_tests.rs +++ b/examples/contracts/cw20-base/src/multitest/minting_tests.rs @@ -1,5 +1,6 @@ -use cosmwasm_std::{StdError, Uint128}; +use cosmwasm_std::{Addr, StdError, Uint128}; use cw20_minting::responses::MinterResponse; +use cw_multi_test::IntoBech32; use sylvia::multitest::App; use crate::contract::sv::mt::{CodeId, Cw20BaseProxy}; @@ -12,8 +13,8 @@ use cw20_minting::sv::mt::Cw20MintingProxy; fn mintable() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); let amount = Uint128::new(11223344); let limit = Uint128::new(511223344); @@ -35,7 +36,7 @@ fn mintable() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // read token info @@ -77,8 +78,8 @@ fn mintable() { fn mintable_over_cap() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); let amount = Uint128::new(11223344); let limit = Uint128::new(11223300); @@ -100,7 +101,7 @@ fn mintable_over_cap() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap_err(); assert_eq!( @@ -113,9 +114,9 @@ fn mintable_over_cap() { fn can_mint_by_minter() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; - let winner = "lucky"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); + let winner = "lucky".into_bech32(); let prize = Uint128::new(222_222_222); let limit = Uint128::new(511223344); let amount = Uint128::new(11223344); @@ -138,19 +139,19 @@ fn can_mint_by_minter() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // minter can mint coins to some winner contract .mint(winner.to_string(), prize) - .call(minter) + .call(&minter) .unwrap(); // but cannot mint nothing let err = contract .mint(winner.to_string(), Uint128::zero()) - .call(minter) + .call(&minter) .unwrap_err(); assert_eq!(err, ContractError::InvalidZeroAmount); @@ -159,7 +160,7 @@ fn can_mint_by_minter() { // cap is enforced let err = contract .mint(winner.to_string(), Uint128::new(333_222_222)) - .call(minter) + .call(&minter) .unwrap_err(); assert_eq!(err, ContractError::CannotExceedCap); @@ -169,9 +170,9 @@ fn can_mint_by_minter() { fn others_cannot_mint() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; - let winner = "lucky"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); + let winner = "lucky".into_bech32(); let prize = Uint128::new(222_222_222); let limit = Uint128::new(511223344); let amount = Uint128::new(1234); @@ -194,19 +195,19 @@ fn others_cannot_mint() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // minter can mint coins to some winner contract .mint(winner.to_string(), prize) - .call(minter) + .call(&minter) .unwrap(); // but cannot mint nothing let err = contract .mint(winner.to_string(), Uint128::zero()) - .call(minter) + .call(&minter) .unwrap_err(); assert_eq!(err, ContractError::InvalidZeroAmount); @@ -215,7 +216,7 @@ fn others_cannot_mint() { // cap is enforced let err = contract .mint(winner.to_string(), Uint128::new(333_222_222)) - .call(minter) + .call(&minter) .unwrap_err(); assert_eq!(err, ContractError::CannotExceedCap); @@ -225,9 +226,9 @@ fn others_cannot_mint() { fn minter_can_update_minter_but_not_cap() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; - let new_minter = "new_minter"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); + let new_minter = "new_minter".into_bech32(); let amount = Uint128::new(1234); let cap = Some(Uint128::from(3000000u128)); @@ -249,13 +250,13 @@ fn minter_can_update_minter_but_not_cap() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // minter can mint coins to some winner contract .update_minter(Some(new_minter.to_string())) - .call(minter) + .call(&minter) .unwrap(); let resp = contract.minter().unwrap().unwrap(); @@ -272,9 +273,9 @@ fn minter_can_update_minter_but_not_cap() { fn others_cannot_update_minter() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; - let new_minter = "new_minter"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); + let new_minter = Addr::unchecked("new_minter"); let amount = Uint128::new(1234); let code_id = CodeId::store_code(&app); @@ -295,12 +296,12 @@ fn others_cannot_update_minter() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); let err = contract .update_minter(Some(new_minter.to_string())) - .call(new_minter) + .call(&new_minter) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized); } @@ -309,8 +310,8 @@ fn others_cannot_update_minter() { fn unset_minter() { let app = App::default(); - let owner = "addr0001"; - let minter = "addr0002"; + let owner = "owner".into_bech32(); + let minter = "minter".into_bech32(); let winner = "lucky"; let amount = Uint128::new(1234); @@ -332,11 +333,11 @@ fn unset_minter() { marketing: None, }) .with_label("Cw20 contract") - .call(owner) + .call(&owner) .unwrap(); // Unset minter - contract.update_minter(None).call(minter).unwrap(); + contract.update_minter(None).call(&minter).unwrap(); let resp = contract.minter().unwrap(); assert_eq!(resp, None); @@ -344,7 +345,7 @@ fn unset_minter() { // Old minter can no longer mint let err = contract .mint(winner.to_string(), amount) - .call(minter) + .call(&minter) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized); diff --git a/examples/contracts/entry-points-overriding/src/contract.rs b/examples/contracts/entry-points-overriding/src/contract.rs index 5bd21751..54fcb258 100644 --- a/examples/contracts/entry-points-overriding/src/contract.rs +++ b/examples/contracts/entry-points-overriding/src/contract.rs @@ -9,7 +9,7 @@ use sylvia::entry_points; use crate::messages::CountResponse; pub struct CounterContract { - pub(crate) counter: Item<'static, u32>, + pub(crate) counter: Item, } #[cfg_attr(not(feature = "library"), entry_points)] diff --git a/examples/contracts/entry-points-overriding/src/multitest.rs b/examples/contracts/entry-points-overriding/src/multitest.rs index 66d79525..bc3f7ed7 100644 --- a/examples/contracts/entry-points-overriding/src/multitest.rs +++ b/examples/contracts/entry-points-overriding/src/multitest.rs @@ -4,7 +4,7 @@ mod test { use crate::contract::sv::{ContractExecMsg, ExecMsg}; use crate::messages::{CustomExecMsg, SudoMsg, UserExecMsg}; use cosmwasm_std::Addr; - use cw_multi_test::Executor; + use cw_multi_test::{Executor, IntoBech32}; use sylvia::multitest::App; #[test] @@ -12,13 +12,13 @@ mod test { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate() .with_label("Contract") - .with_admin(Some(owner)) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); let count = contract.count().unwrap().count; @@ -40,7 +40,7 @@ mod test { (*contract.app) .app_mut() .execute_contract( - Addr::unchecked(owner), + Addr::unchecked(&owner), contract.contract_addr.clone(), &msg, &[], @@ -57,7 +57,7 @@ mod test { (*contract.app) .app_mut() .execute_contract( - Addr::unchecked(owner), + Addr::unchecked(&owner), contract.contract_addr.clone(), &msg, &[], diff --git a/examples/contracts/generic_contract/src/contract.rs b/examples/contracts/generic_contract/src/contract.rs index c0d6bbce..cf97a4ad 100644 --- a/examples/contracts/generic_contract/src/contract.rs +++ b/examples/contracts/generic_contract/src/contract.rs @@ -29,7 +29,7 @@ pub struct GenericContract< MigrateT, FieldT, > { - _field: Item<'static, FieldT>, + _field: Item, #[allow(clippy::type_complexity)] _phantom: std::marker::PhantomData<( InstantiateT, @@ -196,6 +196,7 @@ mod tests { use super::sv::mt::CodeId; use super::{SvCustomMsg, SvCustomQuery}; use crate::contract::sv::mt::GenericContractProxy; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -218,22 +219,22 @@ mod tests { _, > = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); contract .contract_execute_one(SvCustomMsg, SvCustomMsg) - .call(owner) + .call(&owner) .unwrap(); contract .contract_execute_two(SvCustomMsg, SvCustomMsg) - .call(owner) + .call(&owner) .unwrap(); contract .contract_query_one(SvCustomMsg, SvCustomMsg) @@ -249,7 +250,7 @@ mod tests { .unwrap(); contract .migrate(SvCustomMsg) - .call(owner, code_id.code_id()) + .call(&owner, code_id.code_id()) .unwrap(); } } diff --git a/examples/contracts/generic_contract/src/custom_and_generic.rs b/examples/contracts/generic_contract/src/custom_and_generic.rs index 3a3db88d..ba635625 100644 --- a/examples/contracts/generic_contract/src/custom_and_generic.rs +++ b/examples/contracts/generic_contract/src/custom_and_generic.rs @@ -107,6 +107,7 @@ mod tests { use super::{SvCustomMsg, SvCustomQuery}; use crate::contract::sv::mt::CodeId; use custom_and_generic::sv::mt::CustomAndGenericProxy; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -128,22 +129,22 @@ mod tests { _, >::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); contract .custom_generic_execute_one(vec![], vec![]) - .call(owner) + .call(&owner) .unwrap(); contract .custom_generic_execute_two(vec![], vec![]) - .call(owner) + .call(&owner) .unwrap(); contract .custom_generic_query_one(SvCustomMsg {}, SvCustomMsg {}) diff --git a/examples/contracts/generic_contract/src/cw1.rs b/examples/contracts/generic_contract/src/cw1.rs index 92449e29..fddbacf0 100644 --- a/examples/contracts/generic_contract/src/cw1.rs +++ b/examples/contracts/generic_contract/src/cw1.rs @@ -53,6 +53,7 @@ mod tests { use crate::contract::{SvCustomMsg, SvCustomQuery}; use cosmwasm_std::{CosmosMsg, Empty}; use cw1::sv::mt::Cw1Proxy; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -74,16 +75,16 @@ mod tests { _, >::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); - contract.execute(vec![]).call(owner).unwrap(); + contract.execute(vec![]).call(&owner).unwrap(); contract .can_execute("sender".to_owned(), CosmosMsg::Custom(Empty {})) .unwrap(); diff --git a/examples/contracts/generic_contract/src/generic.rs b/examples/contracts/generic_contract/src/generic.rs index ede067de..4c073c85 100644 --- a/examples/contracts/generic_contract/src/generic.rs +++ b/examples/contracts/generic_contract/src/generic.rs @@ -119,6 +119,7 @@ mod tests { use crate::contract::sv::mt::CodeId; use crate::contract::{SvCustomMsg, SvCustomQuery}; use cosmwasm_std::CosmosMsg; + use cw_multi_test::IntoBech32; use generic::sv::mt::GenericProxy; use sylvia::multitest::App; @@ -142,13 +143,13 @@ mod tests { _, > = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); contract @@ -156,14 +157,14 @@ mod tests { vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .generic_exec_two( vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .generic_query_one(SvCustomMsg, SvCustomMsg) diff --git a/examples/contracts/generic_iface_on_contract/src/contract.rs b/examples/contracts/generic_iface_on_contract/src/contract.rs index 4afeba08..1d89d3c8 100644 --- a/examples/contracts/generic_iface_on_contract/src/contract.rs +++ b/examples/contracts/generic_iface_on_contract/src/contract.rs @@ -40,6 +40,7 @@ impl NonGenericContract { mod tests { use super::{SvCustomMsg, SvCustomQuery}; use cosmwasm_std::{CosmosMsg, Empty}; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; use super::NonGenericContract; @@ -53,12 +54,12 @@ mod tests { let app = App::>::custom(|_, _, _| {}); let code_id = super::sv::mt::CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate() .with_label("Cw1Contract") - .call(owner) + .call(&owner) .unwrap(); // Non custom non generic interface @@ -67,7 +68,7 @@ mod tests { .unwrap(); contract .execute(vec![CosmosMsg::Custom(Empty {})]) - .call(owner) + .call(&owner) .unwrap(); // Non-Custom generic Interface @@ -82,14 +83,14 @@ mod tests { vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .generic_exec_two( vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .generic_sudo_one( @@ -116,14 +117,14 @@ mod tests { vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .custom_generic_execute_two( vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .custom_generic_sudo_one( diff --git a/examples/contracts/generics_forwarded/src/contract.rs b/examples/contracts/generics_forwarded/src/contract.rs index a9124a70..67b300a6 100644 --- a/examples/contracts/generics_forwarded/src/contract.rs +++ b/examples/contracts/generics_forwarded/src/contract.rs @@ -30,7 +30,7 @@ pub struct GenericsForwardedContract< CustomQueryT, FieldT, > { - _field: Item<'static, FieldT>, + _field: Item, #[allow(clippy::type_complexity)] _phantom: std::marker::PhantomData<( InstantiateT, @@ -204,6 +204,7 @@ mod tests { use super::sv::mt::CodeId; use super::{SvCustomMsg, SvCustomQuery}; use crate::contract::sv::mt::GenericsForwardedContractProxy; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -228,22 +229,22 @@ mod tests { _, > = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); contract .contract_execute_one(SvCustomMsg, SvCustomMsg) - .call(owner) + .call(&owner) .unwrap(); contract .contract_execute_two(SvCustomMsg, SvCustomMsg) - .call(owner) + .call(&owner) .unwrap(); contract .contract_query_one(SvCustomMsg, SvCustomMsg) @@ -259,7 +260,7 @@ mod tests { .unwrap(); contract .migrate(SvCustomMsg) - .call(owner, code_id.code_id()) + .call(&owner, code_id.code_id()) .unwrap(); } } diff --git a/examples/contracts/generics_forwarded/src/custom_and_generic.rs b/examples/contracts/generics_forwarded/src/custom_and_generic.rs index 2e0c4b38..d2293f37 100644 --- a/examples/contracts/generics_forwarded/src/custom_and_generic.rs +++ b/examples/contracts/generics_forwarded/src/custom_and_generic.rs @@ -128,6 +128,7 @@ mod tests { use crate::contract::{SvCustomMsg, SvCustomQuery}; use cosmwasm_std::CosmosMsg; use custom_and_generic::sv::mt::CustomAndGenericProxy; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -151,22 +152,22 @@ mod tests { _, >::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); contract .custom_generic_execute_one(vec![], vec![]) - .call(owner) + .call(&owner) .unwrap(); contract .custom_generic_execute_two(vec![], vec![]) - .call(owner) + .call(&owner) .unwrap(); contract .custom_generic_query_one(SvCustomMsg {}, SvCustomMsg {}) diff --git a/examples/contracts/generics_forwarded/src/cw1.rs b/examples/contracts/generics_forwarded/src/cw1.rs index 33fadeb8..89dc4ba3 100644 --- a/examples/contracts/generics_forwarded/src/cw1.rs +++ b/examples/contracts/generics_forwarded/src/cw1.rs @@ -75,6 +75,7 @@ mod tests { use crate::contract::{SvCustomMsg, SvCustomQuery}; use cosmwasm_std::{CosmosMsg, Empty}; use cw1::sv::mt::Cw1Proxy; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -98,16 +99,16 @@ mod tests { _, >::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); - contract.execute(vec![]).call(owner).unwrap(); + contract.execute(vec![]).call(&owner).unwrap(); contract .can_execute("sender".to_owned(), CosmosMsg::Custom(Empty {})) .unwrap(); diff --git a/examples/contracts/generics_forwarded/src/generic.rs b/examples/contracts/generics_forwarded/src/generic.rs index 63bf0c22..59306179 100644 --- a/examples/contracts/generics_forwarded/src/generic.rs +++ b/examples/contracts/generics_forwarded/src/generic.rs @@ -125,6 +125,7 @@ mod tests { use crate::contract::sv::mt::CodeId; use crate::contract::{SvCustomMsg, SvCustomQuery}; use cosmwasm_std::CosmosMsg; + use cw_multi_test::IntoBech32; use generic::sv::mt::GenericProxy; use sylvia::multitest::App; @@ -150,13 +151,13 @@ mod tests { _, > = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let contract = code_id .instantiate(SvCustomMsg {}) .with_label("GenericContract") - .with_admin(owner) - .call(owner) + .with_admin(owner.as_str()) + .call(&owner) .unwrap(); contract @@ -164,7 +165,7 @@ mod tests { vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract @@ -172,7 +173,7 @@ mod tests { vec![CosmosMsg::Custom(SvCustomMsg {})], vec![CosmosMsg::Custom(SvCustomMsg {})], ) - .call(owner) + .call(&owner) .unwrap(); contract .generic_query_one(SvCustomMsg, SvCustomMsg) diff --git a/sylvia-derive/Cargo.toml b/sylvia-derive/Cargo.toml index d5fe488a..b79dc25d 100644 --- a/sylvia-derive/Cargo.toml +++ b/sylvia-derive/Cargo.toml @@ -43,13 +43,13 @@ sylvia = { path = "../sylvia", features = [ "cosmwasm_1_3", "cosmwasm_1_4", ] } -serde = { version = "1.0", default-features = false, features = ["derive"] } -cosmwasm-schema = "1.5" -schemars = "0.8" -cw-storage-plus = "1.2.0" -thiserror = "1.0.58" -cw-multi-test = "0.20.0" -cw-utils = "1.0.2" +serde = { workspace = true } +cosmwasm-schema = { workspace = true } +schemars = { workspace = true } +cw-storage-plus = { workspace = true } +thiserror = { workspace = true } +cw-multi-test = { workspace = true } +cw-utils = { workspace = true } [package.metadata.docs.rs] all-features = true diff --git a/sylvia-derive/src/lib.rs b/sylvia-derive/src/lib.rs index f51d5a27..e9fc14f8 100644 --- a/sylvia-derive/src/lib.rs +++ b/sylvia-derive/src/lib.rs @@ -269,7 +269,7 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// # /// # /// pub struct SvContract { -/// data: Item<'static, ContractData>, +/// data: Item, /// } /// /// ##[sylvia::contract] @@ -330,7 +330,7 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// # pub struct ContractData; /// # /// # pub struct SvContract { -/// # data: Item<'static, ContractData>, +/// # data: Item, /// # } /// # /// # impl SvContract { @@ -444,7 +444,7 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// # pub struct QueryResponse; /// # /// pub struct SvContract { -/// data: Item<'static, ContractData>, +/// data: Item, /// } /// /// ##[sylvia::contract] @@ -694,7 +694,7 @@ fn contract_impl(attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// # impl sylvia::cw_std::CustomMsg for SvCustomMsg {} /// # /// pub struct SvContract { -/// data: Item<'static, DataT>, +/// data: Item, /// _phantom: PhantomData, /// } /// diff --git a/sylvia-derive/src/multitest.rs b/sylvia-derive/src/multitest.rs index d251e85c..b6f5714d 100644 --- a/sylvia-derive/src/multitest.rs +++ b/sylvia-derive/src/multitest.rs @@ -407,7 +407,7 @@ impl<'a> ContractMtHelpers<'a> { } #[track_caller] - pub fn call(self, sender: &str) -> Result<#sylvia ::multitest::Proxy<'app, MtApp, #contract_name >, #error_type> { + pub fn call(self, sender: &#sylvia ::cw_std::Addr ) -> Result<#sylvia ::multitest::Proxy<'app, MtApp, #contract_name >, #error_type> { let Self {code_id, funds, label, admin, salt, msg} = self; match salt { @@ -418,7 +418,7 @@ impl<'a> ContractMtHelpers<'a> { .app_mut() .instantiate_contract( code_id.code_id, - #sylvia ::cw_std::Addr::unchecked(sender), + sender.clone(), &msg, funds, label, @@ -703,7 +703,7 @@ impl<'a> TraitMtHelpers<'a> { impl #trait_name < #mt_app, #custom_msg > for #sylvia ::multitest::Proxy<'_, #mt_app, ContractT > where ContractT:: #error_type : std::fmt::Debug + std::fmt::Display + Send + Sync + 'static, - #custom_msg: Clone + std::fmt::Debug + std::cmp::PartialEq + cosmwasm_schema::schemars::JsonSchema + 'static, + #custom_msg: #sylvia ::types::CustomMsg + 'static, CustomT: #sylvia ::cw_multi_test::Module, WasmT: #sylvia ::cw_multi_test::Wasm, BankT: #sylvia ::cw_multi_test::Bank, diff --git a/sylvia/Cargo.toml b/sylvia/Cargo.toml index 605032fd..4e09ba00 100644 --- a/sylvia/Cargo.toml +++ b/sylvia/Cargo.toml @@ -15,45 +15,37 @@ readme = "../README.md" mt = ["sylvia-derive/mt", "dep:cw-multi-test", "dep:anyhow", "dep:derivative"] stargate = ["cosmwasm-std/stargate"] iterator = ["cosmwasm-std/iterator"] -cosmwasm_1_1 = ["cosmwasm-std/cosmwasm_1_1", "cw-multi-test?/cosmwasm_1_1"] +cosmwasm_1_1 = ["cosmwasm-std/cosmwasm_1_1"] cosmwasm_1_2 = [ "cosmwasm-std/cosmwasm_1_2", - "cw-multi-test?/cosmwasm_1_2", "dep:cw-utils", "sylvia-derive/cosmwasm_1_2", "cosmwasm_1_1", ] -cosmwasm_1_3 = [ - "cosmwasm-std/cosmwasm_1_3", - "cw-multi-test?/cosmwasm_1_3", - "cosmwasm_1_2", -] -cosmwasm_1_4 = [ - "cosmwasm-std/cosmwasm_1_4", - "cw-multi-test?/cosmwasm_1_4", - "cosmwasm_1_3", -] +cosmwasm_1_3 = ["cosmwasm-std/cosmwasm_1_3", "cosmwasm_1_2"] +cosmwasm_1_4 = ["cosmwasm-std/cosmwasm_1_4", "cosmwasm_1_3"] +cosmwasm_2_0 = ["cosmwasm-std/cosmwasm_2_0", "cosmwasm_1_4"] [dependencies] sylvia-derive = { workspace = true } -cosmwasm-std = { version = "1.5", features = ["staking"] } -cosmwasm-schema = "1.5" -schemars = "0.8" -serde = { version = "1.0", default-features = false, features = ["derive"] } +cosmwasm-std = { workspace = true, features = ["staking"] } +cosmwasm-schema = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } serde-cw-value = "0.7.0" -serde-json-wasm = "1.0.0" -konst = "0.3" -cw-multi-test = { version = "0.20.0", optional = true } -anyhow = { version = "1.0", optional = true } +serde-json-wasm = "1.0.1" +konst = "0.3.8" +cw-multi-test = { workspace = true, optional = true } +anyhow = { workspace = true, optional = true } derivative = { version = "2.2.0", optional = true } -cw-utils = { version = "1.0.2", optional = true } +cw-utils = { workspace = true, optional = true } [dev-dependencies] -anyhow = "1.0" -cw-multi-test = "0.20.0" -cw-storage-plus = "1.2.0" -cw-utils = "1.0.2" -thiserror = "1.0.50" +anyhow = { workspace = true } +cw-multi-test = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +thiserror = { workspace = true } [package.metadata.docs.rs] all-features = true diff --git a/sylvia/examples/basic.rs b/sylvia/examples/basic.rs index 4b7aee19..9ccd252d 100644 --- a/sylvia/examples/basic.rs +++ b/sylvia/examples/basic.rs @@ -97,8 +97,8 @@ mod impl_group { } pub struct GroupContract { - admin: Item<'static, Addr>, - _members: Map<'static, Addr, u64>, + admin: Item, + _members: Map, } impl Default for GroupContract { diff --git a/sylvia/src/into_response.rs b/sylvia/src/into_response.rs index a2bacfce..8311ce4b 100644 --- a/sylvia/src/into_response.rs +++ b/sylvia/src/into_response.rs @@ -20,8 +20,8 @@ impl IntoMsg for SubMsg { ))?, #[cfg(feature = "stargate")] CosmosMsg::Ibc(ibc) => CosmosMsg::Ibc(ibc), - #[cfg(feature = "stargate")] - CosmosMsg::Stargate { type_url, value } => CosmosMsg::Stargate { type_url, value }, + #[cfg(feature = "cosmwasm_2_0")] + CosmosMsg::Any(any) => CosmosMsg::Any(any), #[cfg(feature = "stargate")] CosmosMsg::Gov(msg) => CosmosMsg::Gov(msg), _ => return Err(StdError::generic_err(format!( @@ -35,6 +35,7 @@ impl IntoMsg for SubMsg { id: self.id, gas_limit: self.gas_limit, reply_on: self.reply_on, + payload: self.payload, }) } } diff --git a/sylvia/src/multitest.rs b/sylvia/src/multitest.rs index 3a06bad1..90946dad 100644 --- a/sylvia/src/multitest.rs +++ b/sylvia/src/multitest.rs @@ -62,10 +62,9 @@ use cosmwasm_std::{CodeInfoResponse, StdResult}; use cw_multi_test::{ Bank, BankKeeper, Distribution, DistributionKeeper, Executor, FailingModule, Gov, GovFailingModule, Ibc, IbcFailingModule, Module, Router, StakeKeeper, Staking, Stargate, - StargateFailing, Wasm, WasmKeeper, + StargateFailingModule, Wasm, WasmKeeper, }; use derivative::Derivative; -use schemars::JsonSchema; use serde::Serialize; use crate::types::{CustomMsg, CustomQuery}; @@ -127,7 +126,7 @@ impl App> { DistributionKeeper, IbcFailingModule, GovFailingModule, - StargateFailing, + StargateFailingModule, >, &dyn Api, &mut dyn Storage, @@ -157,8 +156,21 @@ impl App { } } -impl - App> +impl + App< + cw_multi_test::App< + BankT, + ApiT, + StorageT, + CustomT, + WasmT, + StakingT, + DistrT, + IbcT, + GovT, + StargateT, + >, + > where CustomT::ExecT: CustomMsg + 'static, CustomT::QueryT: CustomQuery + 'static, @@ -171,6 +183,7 @@ where DistrT: Distribution, IbcT: Ibc, GovT: Gov, + StargateT: Stargate, { /// Returns the info of the current block on the chain. pub fn block_info(&self) -> BlockInfo { @@ -254,7 +267,7 @@ impl<'a, 'app, Error, Msg, MtApp, ExecC> ExecProxy<'a, 'app, Error, Msg, MtApp, where Msg: Serialize + Debug, Error: Debug + Display + Send + Sync + 'static, - ExecC: Debug + Clone + JsonSchema + PartialEq + 'static, + ExecC: cosmwasm_std::CustomMsg + 'static, MtApp: Executor, { pub fn new(contract_addr: &'a Addr, msg: Msg, app: &'app App) -> Self { @@ -274,11 +287,11 @@ where /// Sends the execute message to the contract. #[track_caller] - pub fn call(self, sender: &'a str) -> Result { + pub fn call(self, sender: &'a Addr) -> Result { (*self.app) .app_mut() .execute_contract( - Addr::unchecked(sender), + sender.clone(), Addr::unchecked(self.contract_addr), &self.msg, self.funds, @@ -305,7 +318,7 @@ impl<'a, 'app, Error, Msg, MtApp, ExecC> MigrateProxy<'a, 'app, Error, Msg, MtAp where Msg: Serialize + Debug, Error: Debug + Display + Send + Sync + 'static, - ExecC: Debug + Clone + JsonSchema + PartialEq + 'static, + ExecC: cosmwasm_std::CustomMsg + 'static, MtApp: Executor, { pub fn new(contract_addr: &'a Addr, msg: Msg, app: &'app App) -> Self { @@ -319,11 +332,15 @@ where /// Sends the migrate message to the contract. #[track_caller] - pub fn call(self, sender: &str, new_code_id: u64) -> Result { + pub fn call( + self, + sender: &Addr, + new_code_id: u64, + ) -> Result { (*self.app) .app_mut() .migrate_contract( - Addr::unchecked(sender), + sender.clone(), Addr::unchecked(self.contract_addr), &self.msg, new_code_id, diff --git a/sylvia/tests/custom_msg.rs b/sylvia/tests/custom_msg.rs index 989b3ea7..dffc02d7 100644 --- a/sylvia/tests/custom_msg.rs +++ b/sylvia/tests/custom_msg.rs @@ -247,6 +247,8 @@ mod tests { use crate::some_interface::sv::mt::SomeInterfaceProxy; use crate::sv::mt::MyContractProxy; use crate::{MyContract, MyMsg}; + use cosmwasm_std::Addr; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -255,41 +257,42 @@ mod tests { let app = App::>::custom(|_, _, _| {}); let code_id = crate::sv::mt::CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); + let admin = Addr::unchecked("admin"); let contract = code_id .instantiate() .with_label("MyContract") - .with_admin(owner) - .call(owner) + .with_admin(admin.as_str()) + .call(&owner) .unwrap(); - contract.some_exec().call(owner).unwrap(); + contract.some_exec().call(&owner).unwrap(); contract.some_query().unwrap(); contract.some_sudo().unwrap(); contract .some_migrate() - .call(owner, code_id.code_id()) + .call(&admin, code_id.code_id()) .unwrap(); // Interface messsages contract.interface_query().unwrap(); - contract.interface_exec().call(owner).unwrap(); + contract.interface_exec().call(&owner).unwrap(); contract.interface_sudo().unwrap(); // Other interface messages contract.other_interface_query().unwrap(); - contract.other_interface_exec().call(owner).unwrap(); + contract.other_interface_exec().call(&owner).unwrap(); contract.other_interface_sudo().unwrap(); // Associated interface messages contract.associated_query().unwrap(); - contract.associated_exec().call(owner).unwrap(); + contract.associated_exec().call(&owner).unwrap(); contract.associated_sudo().unwrap(); // Both associated type and custom attr used contract.query().unwrap(); - contract.exec().call(owner).unwrap(); + contract.exec().call(&owner).unwrap(); contract.sudo().unwrap(); } } diff --git a/sylvia/tests/custom_query.rs b/sylvia/tests/custom_query.rs index 21982d7d..8d9113bc 100644 --- a/sylvia/tests/custom_query.rs +++ b/sylvia/tests/custom_query.rs @@ -253,7 +253,8 @@ mod tests { use crate::sv::mt::MyContractProxy; use crate::{MyContract, MyQuery}; - use cosmwasm_std::Empty; + use cosmwasm_std::{Addr, Empty}; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; #[test] @@ -262,41 +263,42 @@ mod tests { let app = App::>::custom(|_, _, _| {}); let code_id = crate::sv::mt::CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); + let admin = Addr::unchecked("admin"); let contract = code_id .instantiate() .with_label("MyContract") - .with_admin(owner) - .call(owner) + .with_admin(admin.as_str()) + .call(&owner) .unwrap(); - contract.some_exec().call(owner).unwrap(); + contract.some_exec().call(&owner).unwrap(); contract.some_query().unwrap(); contract.some_sudo().unwrap(); contract .some_migrate() - .call(owner, code_id.code_id()) + .call(&admin, code_id.code_id()) .unwrap(); // `sv::custom` attribute interface contract.some_interface_query().unwrap(); - contract.some_interface_exec().call(owner).unwrap(); + contract.some_interface_exec().call(&owner).unwrap(); contract.some_interface_sudo().unwrap(); // Associated tyoe interface messages contract.associated_query().unwrap(); - contract.associated_exec().call(owner).unwrap(); + contract.associated_exec().call(&owner).unwrap(); contract.associated_sudo().unwrap(); // `sv::custom` attribute and associated type interface contract.interface_query().unwrap(); - contract.interface_exec().call(owner).unwrap(); + contract.interface_exec().call(&owner).unwrap(); contract.interface_sudo().unwrap(); // Neither `custom` attribute nor associated type contract.default_query().unwrap(); - contract.default_exec().call(owner).unwrap(); + contract.default_exec().call(&owner).unwrap(); contract.default_sudo().unwrap(); } } diff --git a/sylvia/tests/dispatching.rs b/sylvia/tests/dispatching.rs index 3254e326..b836f0ed 100644 --- a/sylvia/tests/dispatching.rs +++ b/sylvia/tests/dispatching.rs @@ -133,11 +133,11 @@ mod contract { use crate::QueryResponse; pub struct Contract { - pub(crate) execs: Item<'static, u64>, + pub(crate) execs: Item, pub(crate) queries: RefCell, - pub(crate) sudos: Item<'static, u64>, + pub(crate) sudos: Item, - pub(crate) data: Map<'static, Addr, QueryResponse>, + pub(crate) data: Map, } #[entry_points] diff --git a/sylvia/tests/entry_points.rs b/sylvia/tests/entry_points.rs index 11132177..c65a26b2 100644 --- a/sylvia/tests/entry_points.rs +++ b/sylvia/tests/entry_points.rs @@ -141,9 +141,9 @@ mod contract { use crate::CountResponse; pub struct Contract { - pub(crate) execs: Item<'static, u32>, - pub(crate) sudos: Item<'static, u32>, - pub(crate) migrates: Item<'static, u32>, + pub(crate) execs: Item, + pub(crate) sudos: Item, + pub(crate) migrates: Item, } #[contract] @@ -212,7 +212,7 @@ mod contract { #[cfg(all(test, feature = "mt"))] mod tests { use cosmwasm_std::Addr; - use cw_multi_test::Executor; + use cw_multi_test::{Executor, IntoBech32}; use sylvia::multitest::App; use crate::contract::sv::mt::{CodeId, ContractProxy}; @@ -225,13 +225,14 @@ mod tests { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); + let admin = Addr::unchecked("admin"); let contract = code_id .instantiate() .with_label("Contract") - .with_admin(Some(owner)) - .call(owner) + .with_admin(admin.as_str()) + .call(&owner) .unwrap(); let msg = SudoWrapperMsg::CustomSudo(crate::sudo::SudoMsg::MoveFunds { @@ -248,7 +249,7 @@ mod tests { let count = contract.sudos().unwrap().count; assert_eq!(count, 1); - contract.migrate().call(owner, code_id.code_id()).unwrap(); + contract.migrate().call(&admin, code_id.code_id()).unwrap(); let count = contract.migrates().unwrap().count; assert_eq!(count, 1); @@ -257,7 +258,7 @@ mod tests { (*contract.app) .app_mut() .execute_contract( - Addr::unchecked(owner), + Addr::unchecked(&owner), contract.contract_addr.clone(), &msg, &[], @@ -273,7 +274,7 @@ mod tests { (*contract.app) .app_mut() .execute_contract( - Addr::unchecked(owner), + Addr::unchecked(&owner), contract.contract_addr.clone(), &msg, &[], diff --git a/sylvia/tests/multitest.rs b/sylvia/tests/multitest.rs index 6b868835..d43671ac 100644 --- a/sylvia/tests/multitest.rs +++ b/sylvia/tests/multitest.rs @@ -1,6 +1,7 @@ #![cfg(feature = "mt")] use cosmwasm_std::{CodeInfoResponse, Empty, Response, StdResult}; +use cw_multi_test::IntoBech32; use std::marker::PhantomData; use sylvia::multitest::App; use sylvia::types::InstantiateCtx; @@ -29,7 +30,7 @@ where #[test] fn instantiate_with_salt() { - let owner = "owner"; + let owner = "owner".into_bech32(); let salt = "sylvia OP".as_bytes(); let app = App::default(); @@ -39,7 +40,7 @@ fn instantiate_with_salt() { let _: sylvia::multitest::Proxy<_, SomeContract> = code_id .instantiate(Empty {}) .with_salt(salt) - .call(owner) + .call(&owner) .unwrap(); } diff --git a/sylvia/tests/querier.rs b/sylvia/tests/querier.rs index f9841471..917ad90f 100644 --- a/sylvia/tests/querier.rs +++ b/sylvia/tests/querier.rs @@ -89,8 +89,8 @@ pub mod impl_counter { } pub struct CounterContract<'a> { - pub count: Item<'static, u64>, - pub remote: Item<'static, sylvia::types::Remote<'a, CounterContract<'a>>>, + pub count: Item, + pub remote: Item>>, } #[contract] @@ -117,6 +117,7 @@ impl CounterContract<'_> { mod tests { use cosmwasm_std::testing::mock_dependencies; use cosmwasm_std::{Addr, Empty, QuerierWrapper}; + use cw_multi_test::IntoBech32; use sylvia::multitest::App; use crate::counter::sv::mt::CounterProxy; @@ -149,31 +150,31 @@ mod tests { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_bech32(); let first_contract = code_id .instantiate(Addr::unchecked("remote")) .with_label("First Counter") - .call(owner) + .call(&owner) .unwrap(); let second_contract = code_id .instantiate(first_contract.contract_addr.clone()) .with_label("Second Counter") - .call(owner) + .call(&owner) .unwrap(); - first_contract.set_count(42).call(owner).unwrap(); + first_contract.set_count(42).call(&owner).unwrap(); let resp = second_contract.count().unwrap(); assert_eq!(resp.count, 0); - second_contract.copy_count().call(owner).unwrap(); + second_contract.copy_count().call(&owner).unwrap(); let resp = second_contract.count().unwrap(); assert_eq!(resp.count, 42); - second_contract.decrease_by_count().call(owner).unwrap(); + second_contract.decrease_by_count().call(&owner).unwrap(); let resp = second_contract.count().unwrap(); assert_eq!(resp.count, 0); diff --git a/sylvia/tests/replies.rs b/sylvia/tests/replies.rs index 79c8e7ee..89bc92d8 100644 --- a/sylvia/tests/replies.rs +++ b/sylvia/tests/replies.rs @@ -1,3 +1,5 @@ +#[cfg(all(test, feature = "mt"))] +use cw_multi_test::IntoBech32; use sylvia::cw_std::testing::{mock_dependencies, mock_env}; use sylvia::cw_std::{from_json, Reply, SubMsgResponse, SubMsgResult}; @@ -77,9 +79,13 @@ mod reply_contract { fn entry_point_generation() { let msg = Reply { id: 0, + payload: Default::default(), + gas_used: 0, + #[allow(deprecated)] result: SubMsgResult::Ok(SubMsgResponse { events: vec![], data: None, + msg_responses: vec![], }), }; let mut deps = mock_dependencies(); @@ -96,17 +102,17 @@ fn entry_point_generation() { fn mt_helper_generation() { use crate::reply_contract::sv::mt::ReplyContractProxy; let app = sylvia::multitest::App::default(); - let owner = "owner"; + let owner = "owner".into_bech32(); let noop_contract_code = noop_contract::sv::mt::CodeId::store_code(&app); - let noop_contract = noop_contract_code.instantiate().call(owner).unwrap(); + let noop_contract = noop_contract_code.instantiate().call(&owner).unwrap(); let reply_contract_code = reply_contract::sv::mt::CodeId::store_code(&app); - let reply_contract = reply_contract_code.instantiate().call(owner).unwrap(); + let reply_contract = reply_contract_code.instantiate().call(&owner).unwrap(); let resp = reply_contract .poke(noop_contract.contract_addr.to_string()) - .call(owner) + .call(&owner) .unwrap(); let data: String = from_json(resp.data.unwrap()).unwrap();