diff --git a/.circleci/config.yml b/.circleci/config.yml index b7ee57ee..50382cfa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -150,7 +150,6 @@ jobs: - /usr/local/cargo/registry - target key: cargocache-sg-name-rust:1.72.1-{{ checksum "~/project/Cargo.lock" }} - lint: docker: - image: rust:1.72.1 diff --git a/.gitignore b/.gitignore index b57a6875..07a0beb8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ tarpaulin-report.* *.env *.wasm *.json + +**/node_modules/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b4438298..e73fc80d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,11 +2,22 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "anyhow" -version = "1.0.58" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "base16ct" @@ -14,17 +25,29 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" -version = "0.13.0" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64ct" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdca834647821e0b13d9539a8634eb62d3501b6b6c2cec1722786ee6671b851" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] name = "block-buffer" @@ -37,24 +60,30 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] +[[package]] +name = "bnum" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" + [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cfg-if" @@ -64,37 +93,38 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const-oid" -version = "0.9.0" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cosmwasm-crypto" -version = "1.2.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecd74d3a0041114110d1260f77fcb644c5d2403549b37096c44f0e643a5177" +checksum = "9934c79e58d9676edfd592557dee765d2a6ef54c09d5aa2edb06156b00148966" dependencies = [ - "digest 0.10.5", + "digest 0.10.7", + "ecdsa 0.16.9", "ed25519-zebra", - "k256", - "rand_core 0.6.3", + "k256 0.13.1", + "rand_core 0.6.4", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.2.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5abeeb891e6d0098402e4d3d042f90451db52651d2fe14b170e69a1dd3e4115" +checksum = "bc5e72e330bd3bdab11c52b5ecbdeb6a8697a004c57964caeb5d876f0b088b3c" dependencies = [ - "syn", + "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.2.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9118e36843df6648fd0a626c46438f87038f296ec750cef3832cafc483c483f9" +checksum = "ac3e3a2136e2a60e8b6582f5dffca5d1a683ed77bf38537d330bc1dfccd69010" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -105,22 +135,24 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78d6fc9854ac14e46cb69b0f396547893f93d2847aef975950ebbe73342324f3" +checksum = "f5d803bea6bd9ed61bd1ee0b4a2eb09ee20dbb539cc6e0b8795614d20952ebb1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "cosmwasm-std" -version = "1.2.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5034c772c1369b160731aa00bb81f93733ab2884928edd8d588733d607ac5af4" +checksum = "ef8666e572a3a2519010dde88c04d16e9339ae751b56b2bb35081fe3f7d6be74" dependencies = [ "base64", + "bech32", + "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", @@ -129,34 +161,40 @@ dependencies = [ "schemars", "serde", "serde-json-wasm", - "sha2 0.10.6", + "sha2 0.10.8", + "static_assertions", "thiserror", - "uint", ] [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] -name = "crunchy" -version = "0.2.2" +name = "crypto-bigint" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] [[package]] name = "crypto-bigint" -version = "0.4.8" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2b443d17d49dad5ef0ede301c3179cc923b8822f3393b4d2c28c269dd4a122" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.3", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -192,8 +230,8 @@ checksum = "24bd6738c3fd59c87d2f84911c1cad1e4f2d1c58ecaa6e52549b4f78f4ed6f07" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", - "cw-utils", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", "schemars", "serde", "thiserror", @@ -201,16 +239,17 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.16.0" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7192aec80d0c01a0e5941392eea7e2b7e212ee74ca7f430bfdc899420c055ef6" +checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" dependencies = [ "anyhow", "cosmwasm-std", - "cw-storage-plus", - "cw-utils", + "cw-storage-plus 1.2.0", + "cw-utils 1.0.3", "derivative", "itertools", + "k256 0.11.6", "prost", "schemars", "serde", @@ -223,7 +262,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a3de01064d249a0e7028b63f8168470dac4bcd0c5dc3710d17486f843d1a8" dependencies = [ - "syn", + "syn 1.0.109", ] [[package]] @@ -237,6 +276,17 @@ dependencies = [ "serde", ] +[[package]] +name = "cw-storage-plus" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + [[package]] name = "cw-utils" version = "0.16.0" @@ -245,7 +295,22 @@ checksum = "d6a84c6c1c0acc3616398eba50783934bd6c964bad6974241eaee3460c8f5b26" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2", + "cw2 0.16.0", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "cw-utils" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw2 1.1.2", "schemars", "semver", "serde", @@ -260,11 +325,26 @@ checksum = "91398113b806f4d2a8d5f8d05684704a20ffd5968bf87e3473e1973710b884ad" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.16.0", "schemars", "serde", ] +[[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 1.2.0", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "cw721" version = "0.16.0" @@ -273,7 +353,7 @@ checksum = "94a1ea6e6277bdd6dfc043a9b1380697fe29d6e24b072597439523658d21d791" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-utils", + "cw-utils 0.16.0", "schemars", "serde", ] @@ -286,9 +366,9 @@ checksum = "77518e27431d43214cff4cdfbd788a7508f68d9b1f32389e6fce513e7eaccbef" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", "cw721", "schemars", "serde", @@ -297,9 +377,19 @@ dependencies = [ [[package]] name = "der" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", "zeroize", @@ -313,7 +403,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -327,20 +417,21 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] [[package]] name = "dyn-clone" -version = "1.0.6" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "140206b78fb2bc3edbcfc9b5ccbd0b30699cfe8d348b8b31b330e47df5291a5a" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "ecdsa" @@ -348,32 +439,46 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der 0.7.8", + "digest 0.10.7", + "elliptic-curve 0.13.8", + "rfc6979 0.4.0", + "signature 2.2.0", + "spki 0.7.3", ] [[package]] name = "ed25519-zebra" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek", + "hashbrown", "hex", - "rand_core 0.6.3", + "rand_core 0.6.4", "serde", "sha2 0.9.9", - "thiserror", "zeroize", ] [[package]] name = "either" -version = "1.6.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elliptic-curve" @@ -381,37 +486,65 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest 0.10.5", - "ff", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", + "digest 0.10.7", + "ff 0.12.1", "generic-array", - "group", - "pkcs8", - "rand_core 0.6.3", - "sec1", + "group 0.12.1", + "pkcs8 0.9.0", + "rand_core 0.6.4", + "sec1 0.3.0", "subtle", "zeroize", ] +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.5", + "digest 0.10.7", + "ff 0.13.0", + "generic-array", + "group 0.13.0", + "pkcs8 0.10.2", + "rand_core 0.6.4", + "sec1 0.7.3", + "subtle", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "ff" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df689201f395c6b90dfe87127685f8dbfc083a5e779e613575d8bd7314300c3e" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.3", + "rand_core 0.6.4", "subtle", ] [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ - "matches", "percent-encoding", ] @@ -423,47 +556,57 @@ checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] name = "getrandom" -version = "0.1.16" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", - "wasi 0.9.0+wasi-snapshot-preview1", + "wasi", ] [[package]] -name = "getrandom" -version = "0.2.7" +name = "group" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", ] [[package]] name = "group" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7391856def869c1c81063a03457c676fbcd419709c3dfb33d8d319de484b154d" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff", - "rand_core 0.6.3", + "ff 0.13.0", + "rand_core 0.6.4", "subtle", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + [[package]] name = "hex" version = "0.4.3" @@ -476,34 +619,33 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.5", + "digest 0.10.7", ] [[package]] name = "idna" -version = "0.2.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "k256" @@ -512,22 +654,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", ] [[package]] -name = "libc" -version = "0.2.126" +name = "k256" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", + "once_cell", + "sha2 0.10.8", + "signature 2.2.0", +] [[package]] -name = "matches" -version = "0.1.9" +name = "libc" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "name-marketplace" @@ -537,9 +687,9 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "cw-storage-macro", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", "cw721", "cw721-base", "schemars", @@ -566,9 +716,9 @@ dependencies = [ "cw-controllers", "cw-multi-test", "cw-storage-macro", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", "cw721", "cw721-base", "name-marketplace", @@ -585,8 +735,15 @@ dependencies = [ "sg721-name", "thiserror", "whitelist-updatable", + "whitelist-updatable-flatrate", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + [[package]] name = "opaque-debug" version = "0.3.0" @@ -595,9 +752,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pkcs8" @@ -605,15 +762,25 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.3", ] [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -638,14 +805,14 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "quote" -version = "1.0.20" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -655,41 +822,48 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom", ] [[package]] name = "rfc6979" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "schemars" -version = "0.8.11" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -699,14 +873,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.11" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.109", ] [[package]] @@ -715,47 +889,61 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", "generic-array", - "pkcs8", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.8", + "generic-array", + "pkcs8 0.10.2", "subtle", "zeroize", ] [[package]] name = "semver" -version = "1.0.13" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15bee9b04dd165c3f4e142628982ddde884c2022a89e8ddf99c4829bf2c3a58" +checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.52", ] [[package]] @@ -766,14 +954,14 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -782,14 +970,14 @@ dependencies = [ [[package]] name = "sg-controllers" -version = "0.22.9" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65a127edcada99ad543582a31b04998b1d6758b6b7cb12830ce98f150ea11a63" +checksum = "073a918d575f4513901c19a311a5fbaf3a7806594500fb7a3b77690720d3fc9e" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", - "cw-utils", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", "schemars", "serde", "sg-std", @@ -798,9 +986,9 @@ dependencies = [ [[package]] name = "sg-multi-test" -version = "0.22.9" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4954fddfcd9faaa9ffc9fd5c28b26890dfa5b6f85482ef603a9ae313a17dc3" +checksum = "7704c3607bcac9db6c2fc7810d4647268f29c7ea4368648846cbe6bef2bec2be" dependencies = [ "anyhow", "cosmwasm-std", @@ -855,13 +1043,13 @@ dependencies = [ [[package]] name = "sg-std" -version = "0.22.9" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc0a91b72ca7490db1cbccafee08d3a4d633d565077a894d5954550d5d86747" +checksum = "bd076abea035a2da34a770eb7a239a4fbffa59d3a193ab91e07fb81583937c5c" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-utils", + "cw-utils 0.16.0", "cw721", "schemars", "serde", @@ -880,12 +1068,12 @@ dependencies = [ [[package]] name = "sg1" -version = "0.22.9" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e73daf8b8679a082bc79a6e80769ccbacf3ca82282e96e5d218a0903435b6f8" +checksum = "8405692379911d16534d515f6848a52b85920f401de6414a57ef7a108bd5d67b" dependencies = [ "cosmwasm-std", - "cw-utils", + "cw-utils 0.16.0", "serde", "sg-std", "thiserror", @@ -893,13 +1081,13 @@ dependencies = [ [[package]] name = "sg721" -version = "0.22.9" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ad3311ed3fddb24ea3f4af6be935d7bc4273044136a5f1b39e665a151eeb4c" +checksum = "4a8c0cb5748e59d506cb7cf375d1f03769f1e3586a1542be8a199730721c6102" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-utils", + "cw-utils 0.16.0", "cw721-base", "serde", "thiserror", @@ -907,15 +1095,15 @@ dependencies = [ [[package]] name = "sg721-base" -version = "0.22.9" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a132e2bfd490e3d115d0fa7d4e181634e2deebdc4cde38e84118fcfc290c3014" +checksum = "a6c3ba2af031105758e21f94e8a1488bf810b33914b7e49d7ef5efcf1936cf96" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", "cw721", "cw721-base", "serde", @@ -932,9 +1120,9 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-controllers", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", "cw721", "cw721-base", "schemars", @@ -964,23 +1152,33 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", + "digest 0.10.7", ] [[package]] name = "signature" -version = "1.6.3" +version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb766570a2825fa972bceff0d195727876a9cdf2460ab2e52d455dc2de47fd9" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.5", - "rand_core 0.6.3", + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", ] [[package]] @@ -990,7 +1188,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der 0.7.8", ] [[package]] @@ -1001,9 +1209,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "subtle-encoding" @@ -1016,9 +1224,20 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.98" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1027,22 +1246,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.52", ] [[package]] @@ -1056,58 +1275,45 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "typenum" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "uint" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "url" -version = "2.2.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", - "matches", "percent-encoding", ] @@ -1117,12 +1323,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1137,9 +1337,33 @@ dependencies = [ "cosmwasm-std", "cw-controllers", "cw-multi-test", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", + "name-minter", + "schemars", + "semver", + "serde", + "sg-multi-test", + "sg-name", + "sg-name-minter", + "sg-std", + "sg-whitelist-basic", + "sg721-name", + "thiserror", +] + +[[package]] +name = "whitelist-updatable-flatrate" +version = "2.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-controllers", + "cw-multi-test", + "cw-storage-plus 0.16.0", + "cw-utils 0.16.0", + "cw2 0.16.0", "name-minter", "schemars", "semver", @@ -1155,6 +1379,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.5" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Makefile b/Makefile index 321ef8d3..e0da8e58 100644 --- a/Makefile +++ b/Makefile @@ -10,4 +10,7 @@ publish: sh scripts/publish.sh schema: - sh scripts/schema.sh \ No newline at end of file + sh scripts/schema.sh + +coverage: + cargo tarpaulin --verbose --workspace --timeout 120 --out Html --avoid-cfg-tarpaulin \ No newline at end of file diff --git a/README.md b/README.md index a16d534e..b13159ed 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,10 @@ The secondary marketplace for names. Names are automatically listed here once th Whitelist allows for flexible updating to add / remove addresses at any point in minting. Also adds helper to account for whitelist minting limits. +#### Coverage + +To run code coverage checks first install `tarpaulin` (`cargo install cargo-tarpaulin`), then run `make coverage` from the project root. + ## DISCLAIMER STARGAZE SOURCE CODE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in creating or instantiating Stargaze smart contracts will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of Stargaze, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. Although Public Awesome, LLC and it's affilliates developed the initial code for Stargaze, it does not own or control the Stargaze network, which is run by a decentralized validator set. diff --git a/contracts/name-minter/Cargo.toml b/contracts/name-minter/Cargo.toml index 41982101..b9e6ca5f 100644 --- a/contracts/name-minter/Cargo.toml +++ b/contracts/name-minter/Cargo.toml @@ -49,6 +49,7 @@ sg-name-common = { path = "../../packages/sg-name-common" } sg-name-minter = { path = "../../packages/sg-name-minter" } sg-std = { workspace = true } thiserror = { workspace = true } +whitelist-updatable-flatrate = { path = "../whitelist-updatable-flatrate", features = ["library"]} whitelist-updatable = { path = "../whitelist-updatable", features = [ "library", ] } diff --git a/contracts/name-minter/src/contract.rs b/contracts/name-minter/src/contract.rs index 9061aa73..2812cd80 100644 --- a/contracts/name-minter/src/contract.rs +++ b/contracts/name-minter/src/contract.rs @@ -10,7 +10,9 @@ use cw2::set_contract_version; use cw721_base::MintMsg; use cw_utils::{maybe_addr, must_pay, parse_reply_instantiate_data}; use name_marketplace::msg::ExecuteMsg as MarketplaceExecuteMsg; +use schemars::JsonSchema; use semver::Version; +use serde::{Deserialize, Serialize}; use sg721::{CollectionInfo, InstantiateMsg as Sg721InstantiateMsg}; use sg721_name::msg::{ ExecuteMsg as NameCollectionExecuteMsg, InstantiateMsg as NameCollectionInstantiateMsg, @@ -19,7 +21,7 @@ use sg_name::{Metadata, SgNameExecuteMsg}; use sg_name_common::{charge_fees, SECONDS_PER_YEAR}; use sg_name_minter::{Config, SudoParams, PUBLIC_MINT_START_TIME_IN_SECONDS}; use sg_std::{Response, SubMsg, NATIVE_DENOM}; -use whitelist_updatable::helpers::WhitelistUpdatableContract; +use whitelist_updatable_flatrate::helpers::WhitelistUpdatableFlatrateContract; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg}; @@ -52,7 +54,7 @@ pub fn instantiate( .whitelists .iter() .filter_map(|addr| api.addr_validate(addr).ok()) - .map(WhitelistUpdatableContract) + .map(WhitelistUpdatableFlatrateContract) .collect::>(); WHITELISTS.save(deps.storage, &lists)?; @@ -154,6 +156,7 @@ pub fn execute_mint_and_list( // Assumes no duplicate addresses between whitelists // Otherwise there will be edge cases with per addr limit between the whitelists + let list = whitelists.iter().find(|whitelist| { whitelist .includes(&deps.querier, sender.to_string()) @@ -169,13 +172,19 @@ pub fn execute_mint_and_list( .map(|list| { res.messages .push(SubMsg::new(list.process_address(sender)?)); - list.mint_discount_percent(&deps.querier) + list.mint_discount_amount(&deps.querier) }) .transpose()? .unwrap_or(None); let price = validate_payment(name.len(), &info, params.base_price.u128(), discount)?; - charge_fees(&mut res, params.fair_burn_percent, price.amount); + if price.clone().is_some() { + charge_fees( + &mut res, + params.fair_burn_percent, + price.clone().unwrap().amount, + ); + } let collection = NAME_COLLECTION.load(deps.storage)?; let marketplace = NAME_MARKETPLACE.load(deps.storage)?; @@ -205,7 +214,10 @@ pub fn execute_mint_and_list( let event = Event::new("mint-and-list") .add_attribute("name", name) .add_attribute("owner", sender) - .add_attribute("price", price.amount.to_string()); + .add_attribute( + "price", + price.unwrap_or(coin(0, NATIVE_DENOM)).amount.to_string(), + ); Ok(res .add_event(event) .add_message(mint_msg_exec) @@ -236,7 +248,8 @@ pub fn execute_add_whitelist( let whitelist = deps .api .addr_validate(&address) - .map(WhitelistUpdatableContract)?; + .map(WhitelistUpdatableFlatrateContract)?; + let mut lists = WHITELISTS.load(deps.storage)?; lists.push(whitelist); @@ -298,11 +311,11 @@ fn validate_name(name: &str, min: u32, max: u32) -> Result<(), ContractError> { name.find(invalid_char) .map_or(Ok(()), |_| Err(ContractError::InvalidName {}))?; - if name.starts_with('-') || name.ends_with('-') { + (if name.starts_with('-') || name.ends_with('-') { Err(ContractError::InvalidName {}) } else { Ok(()) - }?; + })?; if len > 4 && name[2..4].contains("--") { return Err(ContractError::InvalidName {}); @@ -315,20 +328,32 @@ fn validate_payment( name_len: usize, info: &MessageInfo, base_price: u128, - discount: Option, -) -> Result { + discount: Option, +) -> Result, ContractError> { // Because we know we are left with ASCII chars, a simple byte count is enough - let amount: Uint128 = match name_len { - 0..=2 => return Err(ContractError::NameTooShort {}), + let mut amount: Uint128 = (match name_len { + 0..=2 => { + return Err(ContractError::NameTooShort {}); + } 3 => base_price * 100, 4 => base_price * 10, _ => base_price, - } + }) .into(); - let amount = discount - .map(|d| amount * (Decimal::one() - d)) - .unwrap_or(amount); + if let Some(discount_value) = discount { + let discount_amount = Uint128::from(discount_value); + // TODO: should we handle the case where discount > amount (eg 1,000 discount but buying a 100 name) + if amount.ge(&discount_amount) { + amount = amount + .checked_sub(discount_amount) + .map_err(|_| StdError::generic_err("invalid discount amount"))?; + } + } + + if amount.is_zero() { + return Ok(None); + } let payment = must_pay(info, NATIVE_DENOM)?; if payment != amount { @@ -338,11 +363,11 @@ fn validate_payment( }); } - Ok(coin(amount.u128(), NATIVE_DENOM)) + Ok(Some(coin(amount.u128(), NATIVE_DENOM))) } fn invalid_char(c: char) -> bool { - let is_valid = c.is_ascii_digit() || c.is_ascii_lowercase() || (c == '-'); + let is_valid = c.is_ascii_digit() || c.is_ascii_lowercase() || c == '-'; !is_valid } @@ -362,9 +387,11 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Box> { let contract = ContractWrapper::new(execute, instantiate, query).with_reply(reply); @@ -55,9 +57,9 @@ pub fn contract_collection() -> Box> { pub fn contract_whitelist() -> Box> { let contract = ContractWrapper::new( - whitelist_updatable::contract::execute, - whitelist_updatable::contract::instantiate, - whitelist_updatable::contract::query, + whitelist_updatable_flatrate::contract::execute, + whitelist_updatable_flatrate::contract::instantiate, + whitelist_updatable_flatrate::contract::query, ); Box::new(contract) } @@ -186,12 +188,12 @@ fn instantiate_contracts( let res: Addr = app .wrap() - .query_wasm_smart(COLLECTION, &SgNameQueryMsg::NameMarketplace {}) + .query_wasm_smart(COLLECTION, &(SgNameQueryMsg::NameMarketplace {})) .unwrap(); assert_eq!(res, marketplace.to_string()); // 4. Instantiate Whitelist - let msg = whitelist_updatable::msg::InstantiateMsg { + let msg = whitelist_updatable_flatrate::msg::InstantiateMsg { per_address_limit: PER_ADDRESS_LIMIT, addresses: vec![ "addr0001".to_string(), @@ -200,7 +202,8 @@ fn instantiate_contracts( USER4.to_string(), ADMIN2.to_string(), ], - mint_discount_bps: None, + mint_discount_amount: None, + admin_list: None, }; let wl = app .instantiate_contract(wl_id, Addr::unchecked(ADMIN2), &msg, &[], "Whitelist", None) @@ -223,10 +226,10 @@ fn owner_of(app: &StargazeApp, token_id: String) -> String { .wrap() .query_wasm_smart( COLLECTION, - &sg721_base::msg::QueryMsg::OwnerOf { + &(sg721_base::msg::QueryMsg::OwnerOf { token_id, include_expired: None, - }, + }), ) .unwrap(); @@ -259,12 +262,12 @@ fn mint_and_list( ); assert!(res.is_ok()); - let amount: Uint128 = match name.len() { + let amount: Uint128 = (match name.len() { 0..=2 => BASE_PRICE, 3 => BASE_PRICE * 100, 4 => BASE_PRICE * 10, _ => BASE_PRICE, - } + }) .into(); let amount = discount @@ -273,14 +276,16 @@ fn mint_and_list( // give user some funds let name_fee = coins(amount.into(), NATIVE_DENOM); - app.sudo(CwSudoMsg::Bank({ - BankSudo::Mint { - to_address: user.to_string(), - amount: name_fee.clone(), - } - })) - .map_err(|err| println!("{:?}", err)) - .ok(); + if amount > Uint128::from(0u128) { + app.sudo(CwSudoMsg::Bank({ + BankSudo::Mint { + to_address: user.to_string(), + amount: name_fee.clone(), + } + })) + .map_err(|err| println!("{:?}", err)) + .ok(); + } let msg = ExecuteMsg::MintAndList { name: name.to_string(), @@ -319,10 +324,10 @@ fn bid(app: &mut StargazeApp, name: &str, bidder: &str, amount: u128) { .wrap() .query_wasm_smart( MKT, - &MarketplaceQueryMsg::Bid { + &(MarketplaceQueryMsg::Bid { token_id: name.to_string(), bidder: bidder.to_string(), - }, + }), ) .unwrap(); let bid = res.unwrap(); @@ -337,7 +342,7 @@ mod execute { use name_marketplace::state::{Ask, SudoParams}; use sg721_name::msg::QueryMsg as Sg721NameQueryMsg; use sg_name::Metadata; - use whitelist_updatable::msg::QueryMsg::IncludesAddress; + use whitelist_updatable_flatrate::msg::QueryMsg::IncludesAddress; use crate::msg::QueryMsg; @@ -355,12 +360,12 @@ mod execute { .wrap() .query_wasm_smart( COLLECTION, - &sg721_base::msg::QueryMsg::AllOperators { + &(sg721_base::msg::QueryMsg::AllOperators { owner: USER.to_string(), include_expired: None, start_after: None, limit: None, - }, + }), ) .unwrap(); assert_eq!(res.operators.len(), 1); @@ -378,9 +383,9 @@ mod execute { .wrap() .query_wasm_smart( MKT, - &MarketplaceQueryMsg::Ask { + &(MarketplaceQueryMsg::Ask { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.unwrap().token_id, NAME); @@ -390,7 +395,7 @@ mod execute { .wrap() .query_wasm_smart( Addr::unchecked(COLLECTION), - &sg721_base::msg::QueryMsg::NumTokens {}, + &(sg721_base::msg::QueryMsg::NumTokens {}), ) .unwrap(); @@ -434,10 +439,10 @@ mod execute { .wrap() .query_wasm_smart( MKT, - &MarketplaceQueryMsg::Bid { + &(MarketplaceQueryMsg::Bid { token_id: NAME.to_string(), bidder: BIDDER.to_string(), - }, + }), ) .unwrap(); assert!(res.is_none()); @@ -458,9 +463,9 @@ mod execute { .wrap() .query_wasm_smart( MKT, - &MarketplaceQueryMsg::Ask { + &(MarketplaceQueryMsg::Ask { token_id: NAME.to_string(), - }, + }), ) .unwrap(); let ask = res.unwrap(); @@ -521,9 +526,9 @@ mod execute { // when no associated address, query should throw error let res: Result = app.wrap().query_wasm_smart( COLLECTION, - &SgNameQueryMsg::AssociatedAddress { + &(SgNameQueryMsg::AssociatedAddress { name: NAME.to_string(), - }, + }), ); assert!(res.is_err()); @@ -544,9 +549,9 @@ mod execute { .wrap() .query_wasm_smart( COLLECTION, - &SgNameQueryMsg::AssociatedAddress { + &(SgNameQueryMsg::AssociatedAddress { name: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res, user.to_string()); @@ -575,9 +580,9 @@ mod execute { .wrap() .query_wasm_smart( Addr::unchecked(COLLECTION), - &SgNameQueryMsg::Name { + &(SgNameQueryMsg::Name { address: user.to_string(), - }, + }), ) .unwrap(); assert_eq!(res, name2.to_string()); @@ -587,9 +592,9 @@ mod execute { .wrap() .query_wasm_smart( Addr::unchecked(COLLECTION), - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.token_uri, None); @@ -599,9 +604,9 @@ mod execute { .wrap() .query_wasm_smart( Addr::unchecked(COLLECTION), - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: name2.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.token_uri, Some(user.to_string())); @@ -624,9 +629,9 @@ mod execute { .wrap() .query_wasm_smart( Addr::unchecked(COLLECTION), - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.token_uri, None); @@ -647,9 +652,9 @@ mod execute { // confirm removed from reverse names map let res: Result = app.wrap().query_wasm_smart( Addr::unchecked(COLLECTION), - &SgNameQueryMsg::Name { + &(SgNameQueryMsg::Name { address: user.to_string(), - }, + }), ); assert!(res.is_err()); } @@ -729,7 +734,7 @@ mod execute { // verify addr in wl let whitelists: Vec = app .wrap() - .query_wasm_smart(MINTER, &QueryMsg::Whitelists {}) + .query_wasm_smart(MINTER, &(QueryMsg::Whitelists {})) .unwrap(); assert_eq!(whitelists.len(), 1); @@ -739,9 +744,9 @@ mod execute { .wrap() .query_wasm_smart( Addr::unchecked(whitelist.to_string()), - &IncludesAddress { + &(IncludesAddress { address: USER.to_string(), - }, + }), ) .unwrap(); dbg!(included, whitelist); @@ -777,7 +782,7 @@ mod execute { let res: SudoParams = app .wrap() - .query_wasm_smart(Addr::unchecked(MKT), &QueryMsg::Params {}) + .query_wasm_smart(Addr::unchecked(MKT), &(QueryMsg::Params {})) .unwrap(); let params = res; @@ -788,7 +793,7 @@ mod execute { } mod admin { - use whitelist_updatable::state::Config; + use whitelist_updatable_flatrate::state::Config; use crate::msg::QueryMsg; @@ -828,7 +833,7 @@ mod admin { let msg = WhitelistQueryMsg::Config {}; let res: Config = app.wrap().query_wasm_smart(WHITELIST, &msg).unwrap(); - assert_eq!(res.admin, ADMIN2.to_string()); + assert_eq!(res.admins, [ADMIN2.to_string()]); let msg = WhitelistQueryMsg::AddressCount {}; let count: u64 = app.wrap().query_wasm_smart(WHITELIST, &msg).unwrap(); @@ -1032,9 +1037,9 @@ mod query { .wrap() .query_wasm_smart( MKT, - &MarketplaceQueryMsg::RenewalQueue { + &(MarketplaceQueryMsg::RenewalQueue { time: app.block_info().time.plus_seconds(SECONDS_PER_YEAR), - }, + }), ) .unwrap(); assert_eq!(res.len(), 2); @@ -1509,9 +1514,9 @@ mod query { // fails with "user" string, has to be a bech32 address let res: StdResult = app.wrap().query_wasm_smart( COLLECTION, - &SgNameQueryMsg::Name { + &(SgNameQueryMsg::Name { address: USER.to_string(), - }, + }), ); assert!(res.is_err()); @@ -1537,9 +1542,9 @@ mod query { .wrap() .query_wasm_smart( COLLECTION, - &SgNameQueryMsg::Name { + &(SgNameQueryMsg::Name { address: cosmos_address.to_string(), - }, + }), ) .unwrap(); assert_eq!(res, "yoyo".to_string()); @@ -1551,7 +1556,7 @@ mod query { let res: CollectionInfoResponse = app .wrap() - .query_wasm_smart(COLLECTION, &Sg721QueryMsg::CollectionInfo {}) + .query_wasm_smart(COLLECTION, &(Sg721QueryMsg::CollectionInfo {})) .unwrap(); assert_eq!( res.start_trading_time.unwrap(), @@ -1642,9 +1647,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.extension.records[0].name, name.to_string()); @@ -1681,9 +1686,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.extension.records[0].name, name.to_string()); @@ -1731,9 +1736,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.extension.records[0].name, name.to_string()); @@ -1772,9 +1777,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.extension.records[0].name, name.to_string()); @@ -1802,9 +1807,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.extension.records[0].name, name.to_string()); @@ -1815,9 +1820,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::NftInfo { + &(Sg721NameQueryMsg::NftInfo { token_id: NAME.to_string(), - }, + }), ) .unwrap(); assert_eq!(res.extension.records[0].name, name.to_string()); @@ -1828,9 +1833,9 @@ mod collection { .wrap() .query_wasm_smart( COLLECTION, - &Sg721NameQueryMsg::ImageNFT { + &(Sg721NameQueryMsg::ImageNFT { name: NAME.to_string(), - }, + }), ) .unwrap(); assert!(res.is_none()); @@ -2044,7 +2049,7 @@ mod collection { let mut app = instantiate_contracts(None, None, None); let params: SudoParams = app .wrap() - .query_wasm_smart(COLLECTION, &Sg721NameQueryMsg::Params {}) + .query_wasm_smart(COLLECTION, &(Sg721NameQueryMsg::Params {})) .unwrap(); let max_record_count = params.max_record_count; @@ -2055,7 +2060,7 @@ mod collection { assert!(res.is_ok()); let params: SudoParams = app .wrap() - .query_wasm_smart(COLLECTION, &Sg721NameQueryMsg::Params {}) + .query_wasm_smart(COLLECTION, &(Sg721NameQueryMsg::Params {})) .unwrap(); assert_eq!(params.max_record_count, max_record_count + 1); } @@ -2063,7 +2068,7 @@ mod collection { mod whitelist { use crate::msg::QueryMsg; - use whitelist_updatable::{msg::QueryMsg as WhitelistQueryMsg, state::Config}; + use whitelist_updatable_flatrate::{msg::QueryMsg as WhitelistQueryMsg, state::Config}; use super::*; @@ -2080,7 +2085,7 @@ mod whitelist { let whitelists: Vec = app .wrap() - .query_wasm_smart(MINTER, &QueryMsg::Whitelists {}) + .query_wasm_smart(MINTER, &(QueryMsg::Whitelists {})) .unwrap(); let wl_count = whitelists.len(); let msg = ExecuteMsg::AddWhitelist { @@ -2111,7 +2116,7 @@ mod whitelist { let wl_id = app.store_code(contract_whitelist()); // instantiate wl2 - let msg = whitelist_updatable::msg::InstantiateMsg { + let msg = whitelist_updatable_flatrate::msg::InstantiateMsg { per_address_limit: PER_ADDRESS_LIMIT, addresses: vec![ "addr0001".to_string(), @@ -2120,7 +2125,8 @@ mod whitelist { USER2.to_string(), ADMIN2.to_string(), ], - mint_discount_bps: None, + mint_discount_amount: None, + admin_list: None, }; let wl2 = app .instantiate_contract(wl_id, Addr::unchecked(ADMIN2), &msg, &[], "Whitelist", None) @@ -2148,9 +2154,9 @@ mod whitelist { .wrap() .query_wasm_smart( WHITELIST, - &WhitelistQueryMsg::MintCount { + &(WhitelistQueryMsg::MintCount { address: USER.to_string(), - }, + }), ) .unwrap(); assert_eq!(res, 1); @@ -2160,9 +2166,9 @@ mod whitelist { .wrap() .query_wasm_smart( WHITELIST2, - &WhitelistQueryMsg::MintCount { + &(WhitelistQueryMsg::MintCount { address: USER.to_string(), - }, + }), ) .unwrap(); assert_eq!(res, 0); @@ -2186,7 +2192,7 @@ mod whitelist { let wl_id = app.store_code(contract_whitelist()); // instantiate wl2 - let msg = whitelist_updatable::msg::InstantiateMsg { + let msg = whitelist_updatable_flatrate::msg::InstantiateMsg { per_address_limit: PER_ADDRESS_LIMIT, addresses: vec![ "addr0001".to_string(), @@ -2195,7 +2201,8 @@ mod whitelist { USER2.to_string(), ADMIN2.to_string(), ], - mint_discount_bps: Some(3500), + mint_discount_amount: Some(BASE_PRICE as u64), + admin_list: None, }; let wl2 = app @@ -2216,11 +2223,20 @@ mod whitelist { // mint and list with discount // query discount, pass to mint_and_list - let discount: Decimal = app + let discount: u64 = app .wrap() - .query_wasm_smart(wl2, &WhitelistQueryMsg::MintDiscountPercent {}) + .query_wasm_smart(wl2, &(WhitelistQueryMsg::MintDiscountAmount {})) .unwrap(); - let res = mint_and_list(&mut app, NAME, USER2, Some(discount)); + let res = mint_and_list( + &mut app, + NAME, + USER2, + Some(Decimal::from_ratio( + discount, + Uint128::from(1_000_000_000u128), + )), + ); + println!("result: {:?}", res); assert!(res.is_ok()); } @@ -2255,7 +2271,7 @@ mod whitelist { let msg = WhitelistQueryMsg::Config {}; let res: Config = app.wrap().query_wasm_smart(WHITELIST, &msg).unwrap(); - assert_eq!(res.admin, ADMIN2.to_string()); + assert_eq!(res.admins, [ADMIN2.to_string()]); let msg = WhitelistQueryMsg::AddressCount {}; let res: u64 = app.wrap().query_wasm_smart(WHITELIST, &msg).unwrap(); diff --git a/contracts/name-minter/src/state.rs b/contracts/name-minter/src/state.rs index 909f69c2..eff09504 100644 --- a/contracts/name-minter/src/state.rs +++ b/contracts/name-minter/src/state.rs @@ -1,8 +1,10 @@ use cosmwasm_std::Addr; use cw_controllers::Admin; use cw_storage_plus::Item; +use serde::{Deserialize, Serialize}; use sg_name_minter::{Config, SudoParams}; use whitelist_updatable::helpers::WhitelistUpdatableContract; +use whitelist_updatable_flatrate::helpers::WhitelistUpdatableFlatrateContract; pub const SUDO_PARAMS: Item = Item::new("params"); @@ -13,7 +15,7 @@ pub const NAME_MARKETPLACE: Item = Item::new("name-marketplace"); pub const ADMIN: Admin = Admin::new("admin"); /// Can only be updated by admin -pub const WHITELISTS: Item> = Item::new("whitelists"); +pub const WHITELISTS: Item> = Item::new("whitelists"); /// Controls if minting is paused or not by admin pub const PAUSED: Item = Item::new("paused"); diff --git a/contracts/sg721-name/src/contract.rs b/contracts/sg721-name/src/contract.rs index 952b3763..83de6c08 100644 --- a/contracts/sg721-name/src/contract.rs +++ b/contracts/sg721-name/src/contract.rs @@ -511,7 +511,7 @@ fn only_owner(deps: Deps, sender: &Addr, token_id: &str) -> Result StdResult { fn validate_address(deps: Deps, sender: &Addr, addr: Addr) -> Result { // we have an EOA registration - if sender == &addr { + if sender == addr { return Ok(addr); } diff --git a/contracts/sg721-name/src/unit_tests.rs b/contracts/sg721-name/src/unit_tests.rs index e0bd3066..c1cc8fd3 100644 --- a/contracts/sg721-name/src/unit_tests.rs +++ b/contracts/sg721-name/src/unit_tests.rs @@ -1,8 +1,7 @@ use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage}; use cosmwasm_std::{ - from_binary, from_slice, to_binary, Addr, ContractInfoResponse, ContractResult, Empty, - OwnedDeps, Querier, QuerierResult, QueryRequest, StdError, SystemError, SystemResult, - WasmQuery, + from_slice, to_binary, Addr, ContractInfoResponse, ContractResult, Empty, OwnedDeps, Querier, + QuerierResult, QueryRequest, StdError, SystemError, SystemResult, WasmQuery, }; use cw721::Cw721Query; use cw721_base::MintMsg; @@ -109,7 +108,7 @@ fn mint_and_update() { // retrieve max record count let params: SudoParams = - from_binary(&query(deps.as_ref(), mock_env(), QueryMsg::Params {}).unwrap()).unwrap(); + from_slice(&query(deps.as_ref(), mock_env(), QueryMsg::Params {}).unwrap()).unwrap(); let max_record_count = params.max_record_count; // mint token diff --git a/contracts/whitelist-updatable-flatrate/.cargo/config b/contracts/whitelist-updatable-flatrate/.cargo/config new file mode 100644 index 00000000..af5698e5 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/.cargo/config @@ -0,0 +1,4 @@ +[alias] +wasm = "build --release --lib --target wasm32-unknown-unknown" +unit-test = "test --lib" +schema = "run --bin schema" diff --git a/contracts/whitelist-updatable-flatrate/.gitignore b/contracts/whitelist-updatable-flatrate/.gitignore new file mode 100644 index 00000000..9095deaa --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/.gitignore @@ -0,0 +1,16 @@ +# Build results +/target +/schema + +# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) +.cargo-ok + +# Text file backups +**/*.rs.bk + +# macOS +.DS_Store + +# IDEs +*.iml +.idea diff --git a/contracts/whitelist-updatable-flatrate/Cargo.lock b/contracts/whitelist-updatable-flatrate/Cargo.lock new file mode 100644 index 00000000..91fb09ff --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/Cargo.lock @@ -0,0 +1,738 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "base64ct" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + +[[package]] +name = "cosmwasm-crypto" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" +dependencies = [ + "digest", + "ed25519-zebra", + "k256", + "rand_core 0.6.3", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" +dependencies = [ + "syn", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772e80bbad231a47a2068812b723a1ff81dd4a0d56c9391ac748177bea3a61da" +dependencies = [ + "schemars", + "serde_json", +] + +[[package]] +name = "cosmwasm-std" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" +dependencies = [ + "base64", + "cosmwasm-crypto", + "cosmwasm-derive", + "forward_ref", + "schemars", + "serde", + "serde-json-wasm", + "thiserror", + "uint", +] + +[[package]] +name = "cosmwasm-storage" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d18403b07304d15d304dad11040d45bbcaf78d603b4be3fb5e2685c16f9229b5" +dependencies = [ + "cosmwasm-std", + "serde", +] + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array", + "rand_core 0.6.3", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "cw-multi-test" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbea57e5be4a682268a5eca1a57efece57a54ff216bfd87603d5e864aad40e12" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus", + "cw-utils", + "derivative", + "itertools", + "prost", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw-storage-plus" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9336ecef1e19d56cf6e3e932475fc6a3dee35eec5a386e07917a1d1ba6bb0e35" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + +[[package]] +name = "cw-utils" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "babd2c090f39d07ce5bf2556962305e795daa048ce20a93709eb591476e4a29e" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw2" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993df11574f29574dd443eb0c189484bb91bc0638b6de3e32ab7f9319c92122d" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus", + "schemars", + "serde", +] + +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "dyn-clone" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" + +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" +dependencies = [ + "curve25519-dalek", + "hex", + "rand_core 0.6.3", + "serde", + "sha2", + "thiserror", + "zeroize", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array", + "group", + "rand_core 0.6.3", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +dependencies = [ + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac", + "digest", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "k256" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sec1", + "sha2", +] + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + +[[package]] +name = "proc-macro2" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.6", +] + +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "schemars" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d21ecb263bf75fc69d5e74b0f2a60b6dd80cfd9fb0eba15c4b9d1104ceffc77" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219b924f5b39f25b7d7c9203873a2698fdac8db2b396aaea6fa099b699cc40e9" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-json-wasm" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "signature" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "digest", + "rand_core 0.6.3", +] + +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "testgen-local" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-multi-test", + "cw-storage-plus", + "cw2", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "uint" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "zeroize" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" diff --git a/contracts/whitelist-updatable-flatrate/Cargo.toml b/contracts/whitelist-updatable-flatrate/Cargo.toml new file mode 100644 index 00000000..03059dec --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/Cargo.toml @@ -0,0 +1,54 @@ +[package] +name = "whitelist-updatable-flatrate" +authors = ["John Y ", "jason-c-child "] +version = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +license = { workspace = true } + +exclude = [ + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[features] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] + +[package.metadata.scripts] +optimize = """docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/rust-optimizer:0.12.6 +""" + +[dependencies] +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +cw-controllers = { workspace = true } +cw2 = { workspace = true } +cw-utils = { workspace = true } +schemars = { workspace = true } +semver = { workspace = true } +serde = { workspace = true } +sg-name-minter = { path = "../../packages/sg-name-minter" } +sg-std = { workspace = true } +sg-whitelist-basic = { path = "../../packages/sg-whitelist-basic" } +thiserror = { workspace = true } + +[dev-dependencies] +cw-multi-test = { workspace = true } +name-minter = { path = "../name-minter", features = ["library"] } +sg-name = { path = "../../packages/sg-name" } +sg-multi-test = { workspace = true } +sg721-name = { path = "../sg721-name" } diff --git a/contracts/whitelist-updatable-flatrate/LICENSE b/contracts/whitelist-updatable-flatrate/LICENSE new file mode 100644 index 00000000..f03c52ad --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2022 Public Awesome LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/contracts/whitelist-updatable-flatrate/README.md b/contracts/whitelist-updatable-flatrate/README.md new file mode 100644 index 00000000..9d355cf3 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/README.md @@ -0,0 +1,9 @@ +## Stargaze Whitelist Updatable, Flat-rate + +Admin controlled whitelist contract that: + +- holds a list of addresses. +- allows to add/remove addresses. +- holds a per address limit. +- throws error if per address limit reached. +- **includes an optional flate-rate discount to mint price** diff --git a/contracts/whitelist-updatable-flatrate/src/bin/schema.rs b/contracts/whitelist-updatable-flatrate/src/bin/schema.rs new file mode 100644 index 00000000..fb2d01c0 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/bin/schema.rs @@ -0,0 +1,11 @@ +use cosmwasm_schema::write_api; + +use whitelist_updatable_flatrate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + +fn main() { + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } +} diff --git a/contracts/whitelist-updatable-flatrate/src/contract.rs b/contracts/whitelist-updatable-flatrate/src/contract.rs new file mode 100644 index 00000000..e48bb21b --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/contract.rs @@ -0,0 +1,358 @@ +use crate::state::{Config, CONFIG, TOTAL_ADDRESS_COUNT, WHITELIST}; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cosmwasm_std::{ + ensure, to_binary, Addr, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Order, + StdError, StdResult, +}; +use cw2::set_contract_version; +use semver::Version; +use sg_name_minter::SgNameMinterQueryMsg; + +use crate::error::ContractError; +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use cw_utils::nonpayable; +use sg_std::Response; + +// version info for migration info +const CONTRACT_NAME: &str = "crates.io:whitelist-updatable-flatrate"; +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn instantiate( + deps: DepsMut, + env: Env, + info: MessageInfo, + mut msg: InstantiateMsg, +) -> Result { + nonpayable(&info)?; + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + + let admin_list: Vec = msg.admin_list.as_ref().map_or_else( + || Ok(vec![info.sender.clone()]), + |admins| { + admins + .iter() + .map(|addr| deps.api.addr_validate(addr)) + .collect() + }, + )?; + + let config = Config { + admins: admin_list, + per_address_limit: msg.per_address_limit, + mint_discount_amount: msg.mint_discount_amount, + }; + + // remove duplicate addresses + msg.addresses.sort_unstable(); + msg.addresses.dedup(); + + let mut count = 0u64; + for address in msg.addresses.into_iter() { + let addr = deps.api.addr_validate(&address.clone())?; + WHITELIST.save(deps.storage, addr, &0u32)?; + count += 1; + } + + TOTAL_ADDRESS_COUNT.save(deps.storage, &count)?; + CONFIG.save(deps.storage, &config)?; + + Ok(Response::default() + .add_attribute("action", "instantiate") + .add_attribute("whitelist_addr", env.contract.address.to_string())) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::UpdateAdmins { new_admin_list } => { + execute_update_admins(deps, info, new_admin_list) + } + ExecuteMsg::AddAddresses { addresses } => execute_add_addresses(deps, info, addresses), + ExecuteMsg::RemoveAddresses { addresses } => { + execute_remove_addresses(deps, info, addresses) + } + ExecuteMsg::ProcessAddress { address } => execute_process_address(deps, env, info, address), + ExecuteMsg::UpdatePerAddressLimit { limit } => { + execute_update_per_address_limit(deps, info, limit) + } + ExecuteMsg::Purge {} => execute_purge(deps, info), + } +} + +pub fn execute_update_admins( + deps: DepsMut, + info: MessageInfo, + new_admin_list: Vec, +) -> Result { + nonpayable(&info)?; + let mut config = CONFIG.load(deps.storage)?; + ensure!( + config.admins.contains(&info.sender), + ContractError::Unauthorized {} + ); + + config.admins = new_admin_list + .into_iter() + .map(|address| deps.api.addr_validate(&address)) + .collect::>>()?; + + CONFIG.save(deps.storage, &config)?; + let event = Event::new("update-admin") + .add_attribute( + "new_admin_list", + config + .admins + .into_iter() + .map(|x| x.to_string()) + .collect::(), + ) + .add_attribute("sender", info.sender); + Ok(Response::new().add_event(event)) +} + +pub fn execute_add_addresses( + deps: DepsMut, + info: MessageInfo, + mut addresses: Vec, +) -> Result { + let config = CONFIG.load(deps.storage)?; + let mut count = TOTAL_ADDRESS_COUNT.load(deps.storage)?; + ensure!( + config.admins.contains(&info.sender), + ContractError::Unauthorized {} + ); + + // dedupe + addresses.sort_unstable(); + addresses.dedup(); + + for address in addresses.into_iter() { + let addr = deps.api.addr_validate(&address.clone())?; + if !WHITELIST.has(deps.storage, addr.clone()) { + WHITELIST.save(deps.storage, addr, &0u32)?; + count += 1; + } + } + + TOTAL_ADDRESS_COUNT.save(deps.storage, &count)?; + + let event = Event::new("add-addresses") + .add_attribute("new-count", count.to_string()) + .add_attribute("sender", info.sender); + Ok(Response::new().add_event(event)) +} + +pub fn execute_remove_addresses( + deps: DepsMut, + info: MessageInfo, + mut addresses: Vec, +) -> Result { + nonpayable(&info)?; + let config = CONFIG.load(deps.storage)?; + let mut count = TOTAL_ADDRESS_COUNT.load(deps.storage)?; + ensure!( + config.admins.contains(&info.sender), + ContractError::Unauthorized {} + ); + + // dedupe + addresses.sort_unstable(); + addresses.dedup(); + + for address in addresses.into_iter() { + let addr = deps.api.addr_validate(&address.clone())?; + if WHITELIST.has(deps.storage, addr.clone()) { + WHITELIST.remove(deps.storage, addr); + count -= 1; + } else { + return Err(ContractError::AddressNotFound { + addr: addr.to_string(), + }); + } + } + + TOTAL_ADDRESS_COUNT.save(deps.storage, &count)?; + let event = Event::new("remove-addresses") + .add_attribute("new-count", count.to_string()) + .add_attribute("sender", info.sender); + Ok(Response::new().add_event(event)) +} + +pub fn execute_process_address( + deps: DepsMut, + env: Env, + info: MessageInfo, + address: String, +) -> Result { + nonpayable(&info)?; + let config = CONFIG.load(deps.storage)?; + let minter = info.sender; + + // query whitelists from minter to see if this one exists... + let whitelists: Vec = deps + .querier + .query_wasm_smart(&minter, &(SgNameMinterQueryMsg::Whitelists {}))?; + if !whitelists.contains(&env.contract.address) { + return Err(ContractError::Unauthorized {}); + } + + let addr = deps.api.addr_validate(&address)?; + if !WHITELIST.has(deps.storage, addr.clone()) { + return Err(ContractError::AddressNotFound { + addr: addr.to_string(), + }); + } + + if WHITELIST.load(deps.storage, addr.clone())? >= config.per_address_limit { + return Err(ContractError::OverPerAddressLimit {}); + } + + let count = WHITELIST.load(deps.storage, addr.clone())?; + WHITELIST.save(deps.storage, addr, &(count + 1))?; + + let event = Event::new("process-address") + .add_attribute("address", address) + .add_attribute("mint-count", (count + 1).to_string()) + .add_attribute("sender", minter); + Ok(Response::new().add_event(event)) +} + +pub fn execute_update_per_address_limit( + deps: DepsMut, + info: MessageInfo, + limit: u32, +) -> Result { + nonpayable(&info)?; + let mut config = CONFIG.load(deps.storage)?; + ensure!( + config.admins.contains(&info.sender), + ContractError::Unauthorized {} + ); + + config.per_address_limit = limit; + CONFIG.save(deps.storage, &config)?; + + let event = Event::new("update-per-address-limit") + .add_attribute("new-limit", limit.to_string()) + .add_attribute("sender", info.sender); + Ok(Response::new().add_event(event)) +} + +pub fn execute_purge(deps: DepsMut, info: MessageInfo) -> Result { + nonpayable(&info)?; + let config = CONFIG.load(deps.storage)?; + ensure!( + config.admins.contains(&info.sender), + ContractError::Unauthorized {} + ); + + let keys = WHITELIST + .keys(deps.as_ref().storage, None, None, Order::Ascending) + .map(|x| x.unwrap()) + .collect::>(); + + for key in keys { + WHITELIST.remove(deps.storage, key); + } + + TOTAL_ADDRESS_COUNT.save(deps.storage, &0u64)?; + + let event = Event::new("purge").add_attribute("sender", info.sender); + Ok(Response::new().add_event(event)) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::Config {} => to_binary(&query_config(deps)?), + QueryMsg::IncludesAddress { address } => to_binary(&query_includes_address(deps, address)?), + QueryMsg::MintCount { address } => to_binary(&query_mint_count(deps, address)?), + QueryMsg::Admins {} => to_binary(&query_admins(deps)?), + QueryMsg::AddressCount {} => to_binary(&query_address_count(deps)?), + QueryMsg::PerAddressLimit {} => to_binary(&query_per_address_limit(deps)?), + QueryMsg::IsProcessable { address } => to_binary(&query_is_processable(deps, address)?), + QueryMsg::MintDiscountAmount {} => to_binary(&query_mint_discount_amount(deps)?), + } +} + +pub fn query_config(deps: Deps) -> StdResult { + CONFIG.load(deps.storage) +} + +pub fn query_includes_address(deps: Deps, address: String) -> StdResult { + Ok(WHITELIST.has(deps.storage, Addr::unchecked(address))) +} + +pub fn query_mint_count(deps: Deps, address: String) -> StdResult { + let addr = deps.api.addr_validate(&address)?; + WHITELIST.load(deps.storage, addr) +} + +pub fn query_admins(deps: Deps) -> StdResult> { + let config = CONFIG.load(deps.storage)?; + Ok(config + .admins + .iter() + .map(|x| x.to_string()) + .collect::>()) +} + +pub fn query_address_count(deps: Deps) -> StdResult { + TOTAL_ADDRESS_COUNT.load(deps.storage) +} + +pub fn query_per_address_limit(deps: Deps) -> StdResult { + let config = CONFIG.load(deps.storage)?; + Ok(config.per_address_limit) +} + +pub fn query_is_processable(deps: Deps, address: String) -> StdResult { + let addr = deps.api.addr_validate(&address)?; + // address not in whitelist, it's not processable + if !WHITELIST.has(deps.storage, addr.clone()) { + return Ok(false); + } + // compare addr mint count to per address limit + let count = WHITELIST.load(deps.storage, addr)?; + let config = CONFIG.load(deps.storage)?; + Ok(count < config.per_address_limit) +} + +pub fn query_mint_discount_amount(deps: Deps) -> StdResult> { + let config = CONFIG.load(deps.storage)?; + Ok(config.mint_discount_amount) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result { + let current_version = cw2::get_contract_version(deps.storage)?; + if current_version.contract != CONTRACT_NAME { + return Err(StdError::generic_err("Cannot upgrade to a different contract").into()); + } + let version: Version = current_version + .version + .parse() + .map_err(|_| StdError::generic_err("Invalid contract version"))?; + let new_version: Version = CONTRACT_VERSION + .parse() + .map_err(|_| StdError::generic_err("Invalid contract version"))?; + + if version > new_version { + return Err(StdError::generic_err("Cannot upgrade to a previous contract version").into()); + } + // if same version return + if version == new_version { + return Ok(Response::new()); + } + + // set new contract version + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + Ok(Response::new()) +} diff --git a/contracts/whitelist-updatable-flatrate/src/error.rs b/contracts/whitelist-updatable-flatrate/src/error.rs new file mode 100644 index 00000000..b0c80bfe --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/error.rs @@ -0,0 +1,26 @@ +use cosmwasm_std::StdError; +use cw_utils::PaymentError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("{0}")] + PaymentError(#[from] PaymentError), + + #[error("Unauthorized")] + Unauthorized {}, + + #[error("AddressNotFound {addr}")] + AddressNotFound { addr: String }, + + #[error("OverPerAddressLimit")] + OverPerAddressLimit {}, + + #[error("AddressAlreadyExists {addr}")] + AddressAlreadyExists { addr: String }, + // Add any other custom errors you like here. + // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. +} diff --git a/contracts/whitelist-updatable-flatrate/src/helpers.rs b/contracts/whitelist-updatable-flatrate/src/helpers.rs new file mode 100644 index 00000000..ee52ea47 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/helpers.rs @@ -0,0 +1,60 @@ +use cosmwasm_schema::cw_serde; +use cosmwasm_std::{ + to_binary, Addr, Decimal, QuerierWrapper, QueryRequest, StdResult, WasmMsg, WasmQuery, +}; +use sg_std::CosmosMsg; + +use crate::{ + msg::{ExecuteMsg, QueryMsg}, + state::Config, +}; + +/// WhitelistUpdatableContract is a wrapper around Addr that provides a lot of helpers +#[cw_serde] +pub struct WhitelistUpdatableFlatrateContract(pub Addr); + +impl WhitelistUpdatableFlatrateContract { + pub fn addr(&self) -> Addr { + self.0.clone() + } + + pub fn call>(&self, msg: T) -> StdResult { + let msg = to_binary(&msg.into())?; + Ok(WasmMsg::Execute { + contract_addr: self.addr().into(), + msg, + funds: vec![], + } + .into()) + } + + pub fn process_address(&self, address: &str) -> StdResult { + self.call(ExecuteMsg::ProcessAddress { + address: address.to_string(), + }) + } + + pub fn includes(&self, querier: &QuerierWrapper, address: String) -> StdResult { + let includes: bool = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { + contract_addr: self.addr().into(), + msg: to_binary(&QueryMsg::IncludesAddress { address })?, + }))?; + Ok(includes) + } + + pub fn config(&self, querier: &QuerierWrapper) -> StdResult { + let res: Config = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { + contract_addr: self.addr().into(), + msg: to_binary(&QueryMsg::Config {})?, + }))?; + + Ok(res) + } + + pub fn mint_discount_amount(&self, querier: &QuerierWrapper) -> StdResult> { + querier.query(&QueryRequest::Wasm(WasmQuery::Smart { + contract_addr: self.addr().into(), + msg: to_binary(&QueryMsg::MintDiscountAmount {})?, + })) + } +} diff --git a/contracts/whitelist-updatable-flatrate/src/integration_tests.rs b/contracts/whitelist-updatable-flatrate/src/integration_tests.rs new file mode 100644 index 00000000..0392f1e2 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/integration_tests.rs @@ -0,0 +1,475 @@ +#[cfg(test)] +mod tests { + use crate::{msg::*, state::Config}; + + use cosmwasm_std::Addr; + use name_minter::msg::InstantiateMsg as NameMinterInstantiateMsg; + use sg_std::StargazeMsgWrapper; + + use cw_multi_test::{Contract, ContractWrapper, Executor}; + + use sg_multi_test::StargazeApp; + + const CREATOR: &str = "creator"; + const TEMP_ADMIN: &str = "temp_admin"; + const OTHER_ADMIN: &str = "other_admin"; + const PER_ADDRESS_LIMIT: u32 = 10; + + fn custom_mock_app() -> StargazeApp { + StargazeApp::default() + } + + pub fn wl_contract() -> Box> { + let contract = ContractWrapper::new( + crate::contract::execute, + crate::contract::instantiate, + crate::contract::query, + ); + Box::new(contract) + } + + pub fn contract_collection() -> Box> { + let contract = ContractWrapper::new( + sg721_name::entry::execute, + sg721_name::entry::instantiate, + sg721_name::entry::query, + ); + Box::new(contract) + } + + pub fn name_minter_contract() -> Box> { + let contract = ContractWrapper::new( + name_minter::contract::execute, + name_minter::contract::instantiate, + name_minter::query::query, + ) + .with_reply(name_minter::contract::reply) + .with_sudo(name_minter::sudo::sudo); + Box::new(contract) + } + + fn name_minter_init(collection_code_id: u64) -> NameMinterInstantiateMsg { + NameMinterInstantiateMsg { + admin: Some(CREATOR.to_string()), + verifier: None, + collection_code_id, + marketplace_addr: "marketplace".to_string(), + base_price: (100u128).into(), + min_name_length: 3, + max_name_length: 63, + fair_burn_bps: 5000, + whitelists: vec![], + } + } + + #[test] + pub fn init() { + let addrs = vec![ + "addr0001".to_string(), + "addr0002".to_string(), + "addr0003".to_string(), + "addr0004".to_string(), + "addr0005".to_string(), + ]; + + let msg = InstantiateMsg { + per_address_limit: PER_ADDRESS_LIMIT, + addresses: addrs.clone(), + mint_discount_amount: None, + admin_list: Some(vec![CREATOR.to_string(), TEMP_ADMIN.to_string()]), + }; + + let mut app = custom_mock_app(); + let wl_id = app.store_code(wl_contract()); + let sg721_id = app.store_code(contract_collection()); + let minter_id = app.store_code(name_minter_contract()); + + let wl_addr = app + .instantiate_contract( + wl_id, + Addr::unchecked(CREATOR), + &msg, + &[], + "wl-contract".to_string(), + None, + ) + .unwrap(); + + let msg = name_minter_init(sg721_id); + + let minter_addr = app + .instantiate_contract( + minter_id, + Addr::unchecked(CREATOR), + &msg, + &[], + "name-minter-contract".to_string(), + None, + ) + .unwrap(); + + let admins: Vec = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::Admins {})) + .unwrap(); + assert_eq!(admins, [CREATOR.to_string(), TEMP_ADMIN.to_string()]); + + let count: u64 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::AddressCount {})) + .unwrap(); + assert_eq!(count, addrs.len() as u64); + + let includes: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IncludesAddress { + address: addrs[0].clone(), + }), + ) + .unwrap(); + assert!(includes); + + let count: u32 = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::MintCount { + address: addrs[0].clone(), + }), + ) + .unwrap(); + assert_eq!(count, 0); + + let limit: u32 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::PerAddressLimit {})) + .unwrap(); + assert_eq!(limit, 10); + + // add wl_addr to minter + let msg = sg_name_minter::SgNameMinterExecuteMsg::AddWhitelist { + address: wl_addr.to_string(), + }; + let res = app.execute_contract(Addr::unchecked(CREATOR), minter_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + + // process_address to increase mint count and check mint count incremented + // execute_process_address + let msg = ExecuteMsg::ProcessAddress { + address: addrs[0].clone(), + }; + let res = app.execute_contract(Addr::unchecked(minter_addr), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: u32 = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::MintCount { + address: addrs[0].clone(), + }), + ) + .unwrap(); + assert_eq!(res, 1); + } + + #[test] + fn exec() { + let addrs = vec![ + "addr0001".to_string(), + "addr0002".to_string(), + "addr0003".to_string(), + "addr0004".to_string(), + "addr0005".to_string(), + ]; + + let msg = InstantiateMsg { + per_address_limit: 10, + addresses: addrs, + mint_discount_amount: None, + admin_list: None, + }; + + let mut app = custom_mock_app(); + let wl_id = app.store_code(wl_contract()); + let sg721_id = app.store_code(contract_collection()); + let minter_id = app.store_code(name_minter_contract()); + + let wl_addr = app + .instantiate_contract( + wl_id, + Addr::unchecked(CREATOR), + &msg, + &[], + "wl-contract".to_string(), + None, + ) + .unwrap(); + + let msg = name_minter_init(sg721_id); + + let minter_addr = app + .instantiate_contract( + minter_id, + Addr::unchecked(CREATOR), + &msg, + &[], + "name-minter-contract".to_string(), + None, + ) + .unwrap(); + + let msg = ExecuteMsg::UpdateAdmins { + new_admin_list: vec![OTHER_ADMIN.to_string(), TEMP_ADMIN.to_string()], + }; + let res = app.execute_contract(Addr::unchecked(TEMP_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_err()); + let res = app.execute_contract(Addr::unchecked(CREATOR), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: Vec = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::Admins {})) + .unwrap(); + assert_eq!(res, [OTHER_ADMIN.to_string(), TEMP_ADMIN.to_string()]); + + // add addresses + let msg = ExecuteMsg::AddAddresses { + addresses: vec![ + "addr0001".to_string(), + "addr0002".to_string(), + "addr0003".to_string(), + "addr0004".to_string(), + "addr0006".to_string(), + ], + }; + let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IncludesAddress { + address: "addr0006".to_string(), + }), + ) + .unwrap(); + assert!(res); + let res: u64 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::AddressCount {})) + .unwrap(); + assert_eq!(res, 6); + let msg = ExecuteMsg::AddAddresses { + addresses: vec!["addr0007".to_string(), "addr0006".to_string()], + }; + let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IncludesAddress { + address: "addr0006".to_string(), + }), + ) + .unwrap(); + assert!(res); + let res: u64 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::AddressCount {})) + .unwrap(); + assert_eq!(res, 7); + + // remove addresses + let msg = ExecuteMsg::RemoveAddresses { + addresses: vec![ + "addr0000".to_string(), + "addr0001".to_string(), + "addr0002".to_string(), + "addr0003".to_string(), + "addr0004".to_string(), + "addr0006".to_string(), + ], + }; + let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_err()); + let msg = ExecuteMsg::RemoveAddresses { + addresses: vec![ + "addr0001".to_string(), + "addr0002".to_string(), + "addr0003".to_string(), + "addr0004".to_string(), + "addr0006".to_string(), + ], + }; + let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IncludesAddress { + address: "addr0006".to_string(), + }), + ) + .unwrap(); + assert!(!res); + let res: u64 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::AddressCount {})) + .unwrap(); + assert_eq!(res, 2); + + // per address limit + let new_per_address_limit = 1; + let msg = ExecuteMsg::UpdatePerAddressLimit { + limit: new_per_address_limit, + }; + let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: u32 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::PerAddressLimit {})) + .unwrap(); + assert_eq!(res, 1); + + // surpass limit + let msg = sg_name_minter::SgNameMinterExecuteMsg::AddWhitelist { + address: wl_addr.to_string(), + }; + let res = app.execute_contract(Addr::unchecked(CREATOR), minter_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IsProcessable { + address: "addr0007".to_string(), + }), + ) + .unwrap(); + assert!(res); + let msg = ExecuteMsg::ProcessAddress { + address: "addr0007".to_string(), + }; + let res = app.execute_contract( + Addr::unchecked(minter_addr.clone()), + wl_addr.clone(), + &msg, + &[], + ); + assert!(res.is_ok()); + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IsProcessable { + address: "addr0007".to_string(), + }), + ) + .unwrap(); + assert!(!res); + let msg = ExecuteMsg::ProcessAddress { + address: "addr0007".to_string(), + }; + let res = app.execute_contract(Addr::unchecked(minter_addr), wl_addr.clone(), &msg, &[]); + assert!(res.is_err()); + + // purge + let msg = ExecuteMsg::Purge {}; + let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + let res: u32 = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::AddressCount {})) + .unwrap(); + assert_eq!(res, 0); + // does not include addr0007 + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IncludesAddress { + address: "addr0007".to_string(), + }), + ) + .unwrap(); + assert!(!res); + + // query config + let res: Config = app + .wrap() + .query_wasm_smart(&wl_addr, &(QueryMsg::Config {})) + .unwrap(); + assert_eq!( + res.admins, + vec![OTHER_ADMIN.to_string(), TEMP_ADMIN.to_string()] + ); + assert_eq!(res.per_address_limit, new_per_address_limit); + } + + #[test] + fn test_whitelist_doesnt_contain_address() { + let addrs = vec![ + "addr0001".to_string(), + "addr0002".to_string(), + "addr0003".to_string(), + "addr0004".to_string(), + "addr0005".to_string(), + ]; + + let msg = InstantiateMsg { + per_address_limit: PER_ADDRESS_LIMIT, + addresses: addrs.clone(), + mint_discount_amount: None, + admin_list: Some(vec![CREATOR.to_string(), TEMP_ADMIN.to_string()]), + }; + + let mut app = custom_mock_app(); + let wl_id = app.store_code(wl_contract()); + let sg721_id = app.store_code(contract_collection()); + let minter_id = app.store_code(name_minter_contract()); + + let wl_addr = app + .instantiate_contract( + wl_id, + Addr::unchecked(CREATOR), + &msg, + &[], + "wl-contract".to_string(), + None, + ) + .unwrap(); + + let msg = name_minter_init(sg721_id); + + let minter_addr = app + .instantiate_contract( + minter_id, + Addr::unchecked(CREATOR), + &msg, + &[], + "name-minter-contract".to_string(), + None, + ) + .unwrap(); + + let msg = sg_name_minter::SgNameMinterExecuteMsg::AddWhitelist { + address: wl_addr.to_string(), + }; + let res = app.execute_contract(Addr::unchecked(CREATOR), minter_addr.clone(), &msg, &[]); + assert!(res.is_ok()); + + let res: bool = app + .wrap() + .query_wasm_smart( + &wl_addr, + &(QueryMsg::IsProcessable { + address: "addr0006".to_string(), + }), + ) + .unwrap(); + assert!(!res); + } +} diff --git a/contracts/whitelist-updatable-flatrate/src/lib.rs b/contracts/whitelist-updatable-flatrate/src/lib.rs new file mode 100644 index 00000000..d6185c4e --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/lib.rs @@ -0,0 +1,8 @@ +pub mod contract; +mod error; +pub mod helpers; +pub mod integration_tests; +pub mod msg; +pub mod state; + +pub use crate::error::ContractError; diff --git a/contracts/whitelist-updatable-flatrate/src/msg.rs b/contracts/whitelist-updatable-flatrate/src/msg.rs new file mode 100644 index 00000000..aabc7e55 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/msg.rs @@ -0,0 +1,55 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; + +use crate::state::Config; + +#[cw_serde] +pub struct InstantiateMsg { + pub addresses: Vec, + pub per_address_limit: u32, + pub mint_discount_amount: Option, + pub admin_list: Option>, +} + +#[cw_serde] +pub enum ExecuteMsg { + UpdateAdmins { + new_admin_list: Vec, + }, + AddAddresses { + addresses: Vec, + }, + RemoveAddresses { + addresses: Vec, + }, + /// Only callable by minter contract. Increment mint count on whitelist map. + ProcessAddress { + address: String, + }, + UpdatePerAddressLimit { + limit: u32, + }, + Purge {}, +} + +#[cw_serde] +#[derive(QueryResponses)] +pub enum QueryMsg { + #[returns(Config)] + Config {}, + #[returns(bool)] + IncludesAddress { address: String }, + #[returns(u64)] + MintCount { address: String }, + /// Avoid processing addresses that will fail. Includes address and under per address limit + #[returns(bool)] + IsProcessable { address: String }, + #[returns(cw_controllers::AdminResponse)] + Admins {}, + #[returns(u64)] + AddressCount {}, + #[returns(u64)] + PerAddressLimit {}, + // Mint discount converts bps to decimal percentage + #[returns(Option)] + MintDiscountAmount {}, +} diff --git a/contracts/whitelist-updatable-flatrate/src/state.rs b/contracts/whitelist-updatable-flatrate/src/state.rs new file mode 100644 index 00000000..740ce4b7 --- /dev/null +++ b/contracts/whitelist-updatable-flatrate/src/state.rs @@ -0,0 +1,21 @@ +use cosmwasm_schema::cw_serde; +use cosmwasm_std::Addr; +use cw_storage_plus::{Item, Map}; + +#[cw_serde] +pub struct Config { + pub admins: Vec, + pub per_address_limit: u32, + pub mint_discount_amount: Option, +} + +impl Config { + pub fn mint_discount(&self) -> Option { + self.mint_discount_amount + } +} + +pub const CONFIG: Item = Item::new("config"); +pub const TOTAL_ADDRESS_COUNT: Item = Item::new("total_address_count"); +// Holds all addresses and mint count +pub const WHITELIST: Map = Map::new("wl_fr"); diff --git a/contracts/whitelist-updatable/src/contract.rs b/contracts/whitelist-updatable/src/contract.rs index 2e055b0e..44de4067 100644 --- a/contracts/whitelist-updatable/src/contract.rs +++ b/contracts/whitelist-updatable/src/contract.rs @@ -30,7 +30,7 @@ pub fn instantiate( let config = Config { admin: info.sender, per_address_limit: msg.per_address_limit, - /// 1% = 100, 50% = 5000 + // 1% = 100, 50% = 5000 mint_discount_bps: msg.mint_discount_bps, }; @@ -176,7 +176,7 @@ pub fn execute_process_address( // query whitelists from minter to see if this one exists... let whitelists: Vec = deps .querier - .query_wasm_smart(&minter, &SgNameMinterQueryMsg::Whitelists {})?; + .query_wasm_smart(&minter, &(SgNameMinterQueryMsg::Whitelists {}))?; if !whitelists.contains(&env.contract.address) { return Err(ContractError::Unauthorized {}); } diff --git a/ts/src/WhitelistUpdatableFlatrate.client.ts b/ts/src/WhitelistUpdatableFlatrate.client.ts new file mode 100644 index 00000000..253f9471 --- /dev/null +++ b/ts/src/WhitelistUpdatableFlatrate.client.ts @@ -0,0 +1,217 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; +import { Coin, StdFee } from "@cosmjs/amino"; +import { InstantiateMsg, ExecuteMsg, QueryMsg, Uint64, AdminResponse, Addr, Config, Boolean, Nullableuint64 } from "./WhitelistUpdatableFlatrate.types"; +export interface WhitelistUpdatableFlatrateReadOnlyInterface { + contractAddress: string; + config: () => Promise; + includesAddress: ({ + address + }: { + address: string; + }) => Promise; + mintCount: ({ + address + }: { + address: string; + }) => Promise; + isProcessable: ({ + address + }: { + address: string; + }) => Promise; + admins: () => Promise; + addressCount: () => Promise; + perAddressLimit: () => Promise; + mintDiscountAmount: () => Promise; +} +export class WhitelistUpdatableFlatrateQueryClient implements WhitelistUpdatableFlatrateReadOnlyInterface { + client: CosmWasmClient; + contractAddress: string; + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client; + this.contractAddress = contractAddress; + this.config = this.config.bind(this); + this.includesAddress = this.includesAddress.bind(this); + this.mintCount = this.mintCount.bind(this); + this.isProcessable = this.isProcessable.bind(this); + this.admins = this.admins.bind(this); + this.addressCount = this.addressCount.bind(this); + this.perAddressLimit = this.perAddressLimit.bind(this); + this.mintDiscountAmount = this.mintDiscountAmount.bind(this); + } + + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {} + }); + }; + includesAddress = async ({ + address + }: { + address: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + includes_address: { + address + } + }); + }; + mintCount = async ({ + address + }: { + address: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + mint_count: { + address + } + }); + }; + isProcessable = async ({ + address + }: { + address: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + is_processable: { + address + } + }); + }; + admins = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + admins: {} + }); + }; + addressCount = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + address_count: {} + }); + }; + perAddressLimit = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + per_address_limit: {} + }); + }; + mintDiscountAmount = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + mint_discount_amount: {} + }); + }; +} +export interface WhitelistUpdatableFlatrateInterface extends WhitelistUpdatableFlatrateReadOnlyInterface { + contractAddress: string; + sender: string; + updateAdmins: ({ + newAdminList + }: { + newAdminList: string[]; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + addAddresses: ({ + addresses + }: { + addresses: string[]; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + removeAddresses: ({ + addresses + }: { + addresses: string[]; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + processAddress: ({ + address + }: { + address: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + updatePerAddressLimit: ({ + limit + }: { + limit: number; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + purge: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; +} +export class WhitelistUpdatableFlatrateClient extends WhitelistUpdatableFlatrateQueryClient implements WhitelistUpdatableFlatrateInterface { + client: SigningCosmWasmClient; + sender: string; + contractAddress: string; + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress); + this.client = client; + this.sender = sender; + this.contractAddress = contractAddress; + this.updateAdmins = this.updateAdmins.bind(this); + this.addAddresses = this.addAddresses.bind(this); + this.removeAddresses = this.removeAddresses.bind(this); + this.processAddress = this.processAddress.bind(this); + this.updatePerAddressLimit = this.updatePerAddressLimit.bind(this); + this.purge = this.purge.bind(this); + } + + updateAdmins = async ({ + newAdminList + }: { + newAdminList: string[]; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + update_admins: { + new_admin_list: newAdminList + } + }, fee, memo, _funds); + }; + addAddresses = async ({ + addresses + }: { + addresses: string[]; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + add_addresses: { + addresses + } + }, fee, memo, _funds); + }; + removeAddresses = async ({ + addresses + }: { + addresses: string[]; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + remove_addresses: { + addresses + } + }, fee, memo, _funds); + }; + processAddress = async ({ + address + }: { + address: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + process_address: { + address + } + }, fee, memo, _funds); + }; + updatePerAddressLimit = async ({ + limit + }: { + limit: number; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + update_per_address_limit: { + limit + } + }, fee, memo, _funds); + }; + purge = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + purge: {} + }, fee, memo, _funds); + }; +} \ No newline at end of file diff --git a/ts/src/WhitelistUpdatableFlatrate.types.ts b/ts/src/WhitelistUpdatableFlatrate.types.ts new file mode 100644 index 00000000..c9efa0c3 --- /dev/null +++ b/ts/src/WhitelistUpdatableFlatrate.types.ts @@ -0,0 +1,70 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +export interface InstantiateMsg { + addresses: string[]; + admin_list?: string[] | null; + mint_discount_amount?: number | null; + per_address_limit: number; +} +export type ExecuteMsg = { + update_admins: { + new_admin_list: string[]; + }; +} | { + add_addresses: { + addresses: string[]; + }; +} | { + remove_addresses: { + addresses: string[]; + }; +} | { + process_address: { + address: string; + }; +} | { + update_per_address_limit: { + limit: number; + }; +} | { + purge: {}; +}; +export type QueryMsg = { + config: {}; +} | { + includes_address: { + address: string; + }; +} | { + mint_count: { + address: string; + }; +} | { + is_processable: { + address: string; + }; +} | { + admins: {}; +} | { + address_count: {}; +} | { + per_address_limit: {}; +} | { + mint_discount_amount: {}; +}; +export type Uint64 = number; +export interface AdminResponse { + admin?: string | null; +} +export type Addr = string; +export interface Config { + admins: Addr[]; + mint_discount_amount?: number | null; + per_address_limit: number; +} +export type Boolean = boolean; +export type Nullableuint64 = number | null; \ No newline at end of file