diff --git a/.circleci/config.yml b/.circleci/config.yml index fe1c95dd..6aba5ee2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -113,7 +113,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 1.0.0-beta4 --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.0.0 --features iterator --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry diff --git a/Cargo.lock b/Cargo.lock index 792c461e..5eb14871 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,24 @@ # It is not intended for manual editing. version = 3 +[[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" @@ -31,15 +43,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "cosmwasm-crypto" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e70111e9701c3ec43bfbff0e523cd4cb115876b4d3433813436dd0934ee962" +checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" dependencies = [ "digest", "ed25519-zebra", @@ -50,18 +62,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc2ad5d86be5f6068833f63e20786768db6890019c095dd7775232184fb7b3" +checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d75f6a05667d8613b24171ef2c77a8bf6fb9c14f9e3aaa39aa10e0c6416ed67" +checksum = "772e80bbad231a47a2068812b723a1ff81dd4a0d56c9391ac748177bea3a61da" dependencies = [ "schemars", "serde_json", @@ -69,9 +81,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915ca82bd944f116f3a9717481f3fa657e4a73f28c4887288761ebb24e6fbe10" +checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" dependencies = [ "base64", "cosmwasm-crypto", @@ -86,9 +98,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4be9fd8c9d3ae7d0c32a925ecbc20707007ce0cba1f7538c0d78b7a2d3729b" +checksum = "d18403b07304d15d304dad11040d45bbcaf78d603b4be3fb5e2685c16f9229b5" dependencies = [ "cosmwasm-std", "serde", @@ -111,9 +123,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.2.11" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ "generic-array", "rand_core 0.6.3", @@ -146,9 +158,9 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc6d042b14823b0e9f33f5cdd67a1eb9b16a7d79f7547b1a73c8870b518b97b" +checksum = "4f0bc6019b4d3d81e11f5c384bcce7173e2210bd654d75c6c9668e12cca05dfa" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -160,9 +172,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9336ecef1e19d56cf6e3e932475fc6a3dee35eec5a386e07917a1d1ba6bb0e35" +checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" dependencies = [ "cosmwasm-std", "schemars", @@ -171,9 +183,9 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "babd2c090f39d07ce5bf2556962305e795daa048ce20a93709eb591476e4a29e" +checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b" dependencies = [ "cosmwasm-std", "schemars", @@ -183,9 +195,9 @@ dependencies = [ [[package]] name = "cw2" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993df11574f29574dd443eb0c189484bb91bc0638b6de3e32ab7f9319c92122d" +checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -195,9 +207,9 @@ dependencies = [ [[package]] name = "cw20" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356d364602c5fe763544ea00d485b825d6ef519a2fc6a3145528d7df3a603f40" +checksum = "4cb782b8f110819a4eb5dbbcfed25ffba49ec16bbe32b4ad8da50a5ce68fec05" dependencies = [ "cosmwasm-std", "cw-utils", @@ -207,9 +219,9 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2700b19cec661cbe243f62be9f35493f84929013b28f5819433aad2daf21cd9c" +checksum = "a8cd854000f897836dc941da0cb691643678c690f485823477c62b8597d08ea1" dependencies = [ "cosmwasm-std", "cw-controllers", @@ -235,11 +247,79 @@ dependencies = [ "serde", ] +[[package]] +name = "cw721-base" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b61200af4e027af2d7485dbdc37c2a9c4093b6b2f2b811732329ef456076f97e" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw721", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw721-base-ibc" +version = "0.13.4" +source = "git+https://github.com/public-awesome/cw721-ibc.git?branch=main#35615da5cd4f26869f481896e66f771ac4b5421b" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw721-ibc 0.13.4 (git+https://github.com/public-awesome/cw721-ibc.git?branch=main)", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw721-base-ibc" +version = "0.13.4" +source = "git+https://github.com/public-awesome/cw721-ibc.git#35615da5cd4f26869f481896e66f771ac4b5421b" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw721-ibc 0.13.4 (git+https://github.com/public-awesome/cw721-ibc.git)", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw721-ibc" +version = "0.13.4" +source = "git+https://github.com/public-awesome/cw721-ibc.git?branch=main#35615da5cd4f26869f481896e66f771ac4b5421b" +dependencies = [ + "cosmwasm-std", + "cw-utils", + "schemars", + "serde", +] + +[[package]] +name = "cw721-ibc" +version = "0.13.4" +source = "git+https://github.com/public-awesome/cw721-ibc.git#35615da5cd4f26869f481896e66f771ac4b5421b" +dependencies = [ + "cosmwasm-std", + "cw-utils", + "schemars", + "serde", +] + [[package]] name = "der" -version = "0.4.5" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ "const-oid", ] @@ -255,19 +335,19 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" +checksum = "140206b78fb2bc3edbcfc9b5ccbd0b30699cfe8d348b8b31b330e47df5291a5a" [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" dependencies = [ "der", "elliptic-curve", - "hmac", + "rfc6979", "signature", ] @@ -288,30 +368,61 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" dependencies = [ + "base16ct", "crypto-bigint", + "der", "ff", "generic-array", "group", - "pkcs8", "rand_core 0.6.3", + "sec1", "subtle", "zeroize", ] +[[package]] +name = "escrow721" +version = "0.12.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw20-ics20", + "cw721-base-ibc 0.13.4 (git+https://github.com/public-awesome/cw721-ibc.git?branch=main)", + "cw721-ibc 0.13.4 (git+https://github.com/public-awesome/cw721-ibc.git?branch=main)", + "schemars", + "serde", + "sg721", + "thiserror", +] + [[package]] name = "ff" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" dependencies = [ "rand_core 0.6.3", "subtle", ] +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + [[package]] name = "forward_ref" version = "1.0.0" @@ -341,20 +452,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "group" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" dependencies = [ "ff", "rand_core 0.6.3", @@ -388,35 +499,54 @@ dependencies = [ "cw-utils", "cw2", "cw20-ics20", - "cw721", + "cw721-base-ibc 0.13.4 (git+https://github.com/public-awesome/cw721-ibc.git)", + "cw721-ibc 0.13.4 (git+https://github.com/public-awesome/cw721-ibc.git)", "schemars", "serde", "thiserror", ] +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "k256" -version = "0.9.6" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "sec1", "sha2", ] [[package]] name = "libc" -version = "0.2.124" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "matches" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "opaque-debug" @@ -424,30 +554,37 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ "der", "spki", + "zeroize", ] [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] @@ -467,20 +604,31 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", +] + +[[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.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "schemars" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b5a3c80cea1ab61f4260238409510e814e38b4b563c06044edf91e7dc070e3" +checksum = "1847b767a3d62d95cbf3d8a9f0e421cf57a0d8aa4f411d4b16525afb0284d4ed" dependencies = [ "dyn-clone", "schemars_derive", @@ -490,9 +638,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ae4dce13e8614c46ac3c38ef1c0d668b101df6ac39817aebdaa26642ddae9b" +checksum = "af4d7e1b012cb3d9129567661a63755ea4b8a7386d339dc945ae187e403c6743" dependencies = [ "proc-macro2", "quote", @@ -500,35 +648,48 @@ dependencies = [ "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 = "semver" -version = "1.0.7" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" +checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" [[package]] name = "serde" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853" +checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -537,9 +698,9 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", @@ -548,15 +709,64 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "sg-std" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8333ebd66ab56cd6f83368598c3f810e95b41a10fd81ac3e447792996824deba" +dependencies = [ + "cosmwasm-std", + "cw-utils", + "cw721", + "cw721-base", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "sg1" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b9b26273bdcfd32e1f8adfd99a4d168717fa5adc570c8b67b4081037791e212" +dependencies = [ + "cosmwasm-std", + "cw-utils", + "serde", + "sg-std", + "thiserror", +] + +[[package]] +name = "sg721" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10578a37c6be874e4db80d9d9231d834c751154c6b2c8f1e5facff03edf4ab08" +dependencies = [ + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw721", + "cw721-base", + "schemars", + "serde", + "sg-std", + "sg1", + "thiserror", + "url", +] + [[package]] name = "sha2" version = "0.9.9" @@ -572,9 +782,9 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" dependencies = [ "digest", "rand_core 0.6.3", @@ -582,10 +792,11 @@ dependencies = [ [[package]] name = "spki" -version = "0.4.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ + "base64ct", "der", ] @@ -603,35 +814,50 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.91" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "typenum" version = "1.15.0" @@ -651,10 +877,37 @@ dependencies = [ ] [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] [[package]] name = "version_check" @@ -670,12 +923,12 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "zeroize" -version = "1.4.3" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" diff --git a/contracts/escrow721/.cargo/config b/contracts/escrow721/.cargo/config new file mode 100644 index 00000000..624255c7 --- /dev/null +++ b/contracts/escrow721/.cargo/config @@ -0,0 +1,4 @@ +[alias] +wasm = "build --release --target wasm32-unknown-unknown" +unit-test = "test --lib" +schema = "run --example schema" \ No newline at end of file diff --git a/contracts/escrow721/Cargo.toml b/contracts/escrow721/Cargo.toml new file mode 100644 index 00000000..6f898a99 --- /dev/null +++ b/contracts/escrow721/Cargo.toml @@ -0,0 +1,47 @@ +[package] +authors = ["Michael Scotto"] +edition = "2021" +name = "escrow721" +version = "0.12.0" + + +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.3 +""" + +[dependencies] +cosmwasm-std = { version = "1.0.0", features = ["stargate"] } +cosmwasm-storage = { version = "1.0.0" } +cw-storage-plus = "0.13.4" +cw-utils = "0.13.4" +cw2 = "0.13.4" +cw20-ics20 = { version = "0.13.4", features = ["library"] } +sg721 = { version = "0.12.0", features = ["library"] } +cw721-base-ibc = { git = "https://github.com/public-awesome/cw721-ibc.git", version = "0.13.4", branch="main", features = ["library"]} +cw721-ibc = { git = "https://github.com/public-awesome/cw721-ibc.git", branch="main", version = "0.13.4"} +schemars = "0.8.8" +serde = { version = "1.0.133", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.30" } + +[dev-dependencies] +cosmwasm-schema = { version = "1.0.0" } diff --git a/contracts/escrow721/src/contract.rs b/contracts/escrow721/src/contract.rs new file mode 100644 index 00000000..291b0dab --- /dev/null +++ b/contracts/escrow721/src/contract.rs @@ -0,0 +1,145 @@ +use cosmwasm_std::entry_point; +use cosmwasm_std::{attr, Response, StdError}; +#[cfg(not(feature = "library"))] +use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, StdResult}; +use cw721_base_ibc::msg::{ExecuteMsg, InstantiateMsg, MintMsg, QueryMsg}; +use cw721_base_ibc::{ContractError, Cw721Contract}; +use cw721_ibc::{Cw721Execute, Cw721Query, NftInfoResponse, OwnerOfResponse}; + +pub type CW721ContractWrapper<'a> = Cw721Contract<'a, Empty, Empty>; +use crate::state::CLASS_STORAGE; + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + msg: InstantiateMsg, +) -> StdResult { + CW721ContractWrapper::default().instantiate(deps, _env, _info, msg) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result, ContractError> { + match msg { + ExecuteMsg::SaveClass { + class_id, + class_uri, + } => save_class(deps, class_id, class_uri), + _ => CW721ContractWrapper::default().execute(deps, env, info, msg), + } +} + +pub fn save_class( + deps: DepsMut, + class_id: String, + class_uri: String, +) -> Result, ContractError> { + CLASS_STORAGE.save(deps.storage, &class_id, &class_uri)?; + Ok(Response::default().add_attributes(vec![ + attr("action", "save_class"), + attr("class_id", class_id), + attr("class_uri", class_uri), + ])) +} + +pub fn transfer( + deps: DepsMut, + env: Env, + info: MessageInfo, + recipient: String, + class_id: String, + token_id: String, +) -> Result { + CW721ContractWrapper::default().transfer_nft(deps, env, info, recipient, class_id, token_id) +} + +pub fn mint( + deps: DepsMut, + _env: Env, + info: MessageInfo, + class_id: String, + token_id: String, + token_uri: String, + receiver: String, +) -> Result { + let mint_msg = MintMsg { + class_id, + token_id, + owner: receiver, + token_uri: Some(token_uri), + extension: Empty {}, + }; + + CW721ContractWrapper::default().mint(deps, _env, info, mint_msg) +} + +pub fn burn( + deps: DepsMut, + _env: Env, + info: MessageInfo, + class_id: String, + token_id: String, +) -> Result { + CW721ContractWrapper::default().burn(deps, _env, info, class_id, token_id) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::OwnerOf { + class_id, + token_id, + include_expired, + } => to_binary(&get_owner( + deps, + _env, + class_id, + token_id, + include_expired.unwrap_or(false), + )?), + QueryMsg::NftInfo { class_id, token_id } => to_binary(&get_nft(deps, class_id, token_id)?), + QueryMsg::HasClass { class_id } => to_binary(&has_class(deps, class_id)), + QueryMsg::GetClass { class_id } => to_binary(&get_class(deps, class_id)?), + _ => Err(StdError::GenericErr { + msg: "Unsupported message type".to_string(), + }), + } +} + +pub fn get_owner( + deps: Deps, + env: Env, + class_id: String, + token_id: String, + include_expired: bool, +) -> StdResult { + CW721ContractWrapper::default().owner_of(deps, env, class_id, token_id, include_expired) +} + +pub fn get_nft( + deps: Deps, + class_id: String, + token_id: String, +) -> StdResult> { + CW721ContractWrapper::default().nft_info(deps, class_id, token_id) +} + +pub fn has_class(deps: Deps, class_id: String) -> bool { + CLASS_STORAGE.has(deps.storage, &class_id) +} + +pub fn get_class(deps: Deps, class_id: String) -> StdResult<(String, String)> { + match CLASS_STORAGE.load(deps.storage, &class_id.clone()) { + Ok(class_uri) => Ok((class_id, class_uri)), + Err(_) => Err(StdError::generic_err(format!( + "Class {} not found", + class_id + ))), + } +} diff --git a/contracts/escrow721/src/lib.rs b/contracts/escrow721/src/lib.rs new file mode 100644 index 00000000..3407c199 --- /dev/null +++ b/contracts/escrow721/src/lib.rs @@ -0,0 +1,2 @@ +pub mod contract; +pub mod state; diff --git a/contracts/escrow721/src/state.rs b/contracts/escrow721/src/state.rs new file mode 100644 index 00000000..48c55834 --- /dev/null +++ b/contracts/escrow721/src/state.rs @@ -0,0 +1,5 @@ +use cw_storage_plus::Map; + +// This map is used to store key: class_id to data: class_uri +// per the save_class method in contracts/escrow721/src/contract.rs +pub const CLASS_STORAGE: Map<&str, String> = Map::new("class_storage"); diff --git a/contracts/ics721/Cargo.toml b/contracts/ics721/Cargo.toml index b42a5800..a12fc3be 100644 --- a/contracts/ics721/Cargo.toml +++ b/contracts/ics721/Cargo.toml @@ -30,16 +30,17 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-std = { version = "1.0.0-beta8", features = ["stargate"] } -cosmwasm-storage = { version = "1.0.0-beta8" } -cw-storage-plus = "0.13.2" -cw-utils = "0.13.2" -cw2 = "0.13.2" -cw20-ics20 = { version = "0.13.2", features = ["library"] } -cw721 = "0.13.2" +cosmwasm-std = { version = "1.0.0", features = ["stargate"] } +cosmwasm-storage = { version = "1.0.0" } +cw-storage-plus = "0.13.4" +cw-utils = "0.13.4" +cw2 = "0.13.4" +cw20-ics20 = { version = "0.13.4", features = ["library"] } +cw721-base-ibc = { git = "https://github.com/public-awesome/cw721-ibc.git", version="0.13.4"} +cw721-ibc = { git = "https://github.com/public-awesome/cw721-ibc.git", version="0.13.4"} schemars = "0.8.8" serde = { version = "1.0.133", default-features = false, features = ["derive"] } thiserror = { version = "1.0.30" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/contracts/ics721/src/contract.rs b/contracts/ics721/src/contract.rs index 1dca045a..b1275363 100644 --- a/contracts/ics721/src/contract.rs +++ b/contracts/ics721/src/contract.rs @@ -1,18 +1,14 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; -use cosmwasm_std::{ - from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, MessageInfo, Order, - PortIdResponse, Response, StdResult, -}; +use cosmwasm_std::{from_binary, to_binary, Addr, DepsMut, Env, IbcMsg, MessageInfo, Response}; use cw2::set_contract_version; -use cw20_ics20::msg::{ListChannelsResponse, PortResponse}; -use cw721::Cw721ReceiveMsg; +use cw721_ibc::Cw721ReceiveMsg; use cw_utils::nonpayable; use crate::error::ContractError; use crate::ibc::Ics721Packet; -use crate::msg::{ChannelResponse, ExecuteMsg, InstantiateMsg, QueryMsg, TransferMsg}; -use crate::state::{Config, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; +use crate::msg::{ExecuteMsg, InstantiateMsg, TransferMsg}; +use crate::state::{Config, CHANNEL_INFO, CONFIG}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:sg721-ics721"; @@ -84,7 +80,7 @@ pub fn execute_transfer( // build ics721 packet let packet = Ics721Packet::new( - env.contract.address.as_ref(), + &msg.class_id, None, msg.token_ids .iter() @@ -118,68 +114,3 @@ pub fn execute_transfer( .add_attribute("token_ids", &packet.token_ids.join(",")); Ok(res) } - -// TODO: Alot of this query code is copy pasta. -// Find a way to make it generic or put into a package. -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::Port {} => to_binary(&query_port(deps)?), - QueryMsg::ListChannels {} => to_binary(&query_list(deps)?), - QueryMsg::Channel { id } => to_binary(&query_channel(deps, id)?), - QueryMsg::Tokens { - channel_id, - class_id, - } => to_binary(&query_tokens(deps, channel_id, class_id)?), - } -} - -fn query_port(deps: Deps) -> StdResult { - let query = IbcQuery::PortId {}.into(); - let PortIdResponse { port_id } = deps.querier.query(&query)?; - Ok(PortResponse { port_id }) -} - -fn query_list(deps: Deps) -> StdResult { - let channels: StdResult> = CHANNEL_INFO - .range(deps.storage, None, None, Order::Ascending) - .map(|r| r.map(|(_, v)| v)) - .collect(); - Ok(ListChannelsResponse { - channels: channels?, - }) -} - -pub fn query_channel(deps: Deps, id: String) -> StdResult { - let info = CHANNEL_INFO.load(deps.storage, &id)?; - let _class_ids: StdResult> = CHANNEL_STATE - .sub_prefix(&id) - .range(deps.storage, None, None, Order::Ascending) - .map(|r| { - let (class_id_token_id, _) = r?; - Ok(class_id_token_id.0) - }) - .collect(); - - let class_ids_resp = _class_ids; - match class_ids_resp { - Ok(mut class_id_vec) => Ok(ChannelResponse { - info, - class_ids: { - class_id_vec.sort(); - class_id_vec.dedup(); - class_id_vec - }, - }), - Err(msg) => Err(msg), - } -} - -// TODO: https://github.com/public-awesome/contracts/issues/59 -pub fn query_tokens( - _deps: Deps, - _channel_id: String, - _class_id: String, -) -> StdResult { - todo!() -} diff --git a/contracts/ics721/src/contract_test.rs b/contracts/ics721/src/contract_test.rs index 84e82560..62828c9b 100644 --- a/contracts/ics721/src/contract_test.rs +++ b/contracts/ics721/src/contract_test.rs @@ -1,14 +1,26 @@ #[cfg(test)] mod contact_testing { + use core::panic; + use super::super::*; + use crate::msg::{ChannelResponse, ExecuteMsg, InstantiateMsg, QueryMsg, TransferMsg}; + use crate::query; + use crate::state::CHANNEL_STATE; use crate::test_constants::*; use crate::test_helpers::*; use cosmwasm_std::testing::mock_env; - use cosmwasm_std::{from_binary, to_binary, Attribute, Coin, StdError}; + use cosmwasm_std::Deps; + use cosmwasm_std::{ + from_binary, to_binary, Addr, Attribute, Coin, MessageInfo, Response, StdError, + }; use cosmwasm_std::{CosmosMsg, IbcEndpoint}; use cw2::{get_contract_version, ContractVersion}; + use cw20_ics20::msg::ListChannelsResponse; use cw20_ics20::state::ChannelInfo; + use cw20_ics20::ContractError; + use cw721_ibc::Cw721ReceiveMsg; + use query::{query, query_channel}; use cosmwasm_std::testing::mock_dependencies; @@ -58,9 +70,8 @@ mod contact_testing { #[test] fn test_query_channel_list_success() { let deps = setup(&[TEST_CHANNEL_0_DATA, TEST_CHANNEL_1_DATA]); - let result = query_list(deps.as_ref()); - - let expected_list: StdResult = Ok(ListChannelsResponse { + let result = query(deps.as_ref(), mock_env(), QueryMsg::ListChannels {}); + let expected_list = ListChannelsResponse { channels: vec![ ChannelInfo { id: CHANNEL_FROM_STARS_TO_OMNI.to_string(), @@ -79,8 +90,12 @@ mod contact_testing { connection_id: CONNECTION_1.to_string(), }, ], - }); - assert_eq!(result, expected_list); + }; + let expected_list_bin = to_binary(&expected_list).unwrap(); + match result { + Ok(bin) => assert_eq!(bin, expected_list_bin), + Err(_err) => panic!("Query failed for test_query_channel_list_success"), + } } #[test] @@ -88,11 +103,14 @@ mod contact_testing { let mut deps = setup(&[TEST_CHANNEL_0_DATA, TEST_CHANNEL_1_DATA]); CHANNEL_INFO.remove(&mut deps.storage, CHANNEL_FROM_STARS_TO_OMNI); CHANNEL_INFO.remove(&mut deps.storage, CHANNEL_FROM_STARS_TO_GB); - let result = query_list(deps.as_ref()); + let result = query(deps.as_ref(), mock_env(), QueryMsg::ListChannels {}); - let expected_list: StdResult = - Ok(ListChannelsResponse { channels: vec![] }); - assert_eq!(result, expected_list); + let expected_list = ListChannelsResponse { channels: vec![] }; + let expected_list_bin = to_binary(&expected_list).unwrap(); + match result { + Ok(bin) => assert_eq!(bin, expected_list_bin), + Err(_err) => panic!("Query failed for test_query_channel_list_empty"), + } } #[test] @@ -342,7 +360,7 @@ mod contact_testing { }, Attribute { key: "class_id".into(), - value: "cosmos2contract".into(), + value: "abc/123/collection-addr".into(), }, Attribute { key: "token_ids".into(), @@ -350,7 +368,7 @@ mod contact_testing { }, ]; let expected_ics721_packet = Ics721Packet::new( - mock_env().contract.address.as_ref(), + "abc/123/collection-addr", None, transfer_msg .token_ids @@ -399,6 +417,7 @@ mod contact_testing { let cw721_receive_msg = Cw721ReceiveMsg { sender: sender_address_str.to_string(), + class_id: "abc/123/collection-addr".to_string(), token_id: "1".to_string(), msg: to_binary(&transfer_msg).unwrap(), }; @@ -425,7 +444,7 @@ mod contact_testing { }, Attribute { key: "class_id".into(), - value: "cosmos2contract".into(), + value: "abc/123/collection-addr".into(), }, Attribute { key: "token_ids".into(), @@ -433,7 +452,7 @@ mod contact_testing { }, ]; let expected_ics721_packet = Ics721Packet::new( - mock_env().contract.address.as_ref(), + "abc/123/collection-addr", None, transfer_msg .token_ids @@ -484,6 +503,7 @@ mod contact_testing { let cw721_receive_msg = Cw721ReceiveMsg { sender: sender_address_str.to_string(), + class_id: "class_id_1".to_string(), token_id: "1".to_string(), msg: to_binary(&transfer_msg).unwrap(), }; @@ -525,6 +545,7 @@ mod contact_testing { let cw_721_receive_sender = "sender_address_receive_path"; let cw721_receive_msg = ExecuteMsg::Receive(Cw721ReceiveMsg { sender: cw_721_receive_sender.to_string(), + class_id: "abc/123/collection-addr".to_string(), token_id: "1".to_string(), msg: to_binary(&transfer_msg).unwrap(), }); @@ -551,7 +572,7 @@ mod contact_testing { }, Attribute { key: "class_id".into(), - value: "cosmos2contract".into(), + value: "abc/123/collection-addr".into(), }, Attribute { key: "token_ids".into(), @@ -560,7 +581,7 @@ mod contact_testing { ]; let expected_ics721_packet = Ics721Packet::new( - mock_env().contract.address.as_ref(), + "abc/123/collection-addr", None, transfer_msg .token_ids @@ -628,7 +649,7 @@ mod contact_testing { }, Attribute { key: "class_id".into(), - value: "cosmos2contract".into(), + value: "abc/123/collection-addr".into(), }, Attribute { key: "token_ids".into(), diff --git a/contracts/ics721/src/ibc.rs b/contracts/ics721/src/ibc.rs index c48b9f9e..af5b6517 100644 --- a/contracts/ics721/src/ibc.rs +++ b/contracts/ics721/src/ibc.rs @@ -1,6 +1,6 @@ use cw20_ics20::ibc::Ics20Ack; use cw20_ics20::state::ChannelInfo; -use cw721::Cw721ExecuteMsg; +use cw721_ibc::Cw721ExecuteMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/contracts/ics721/src/ibc_test.rs b/contracts/ics721/src/ibc_test.rs index 3cd00f1d..170d3709 100644 --- a/contracts/ics721/src/ibc_test.rs +++ b/contracts/ics721/src/ibc_test.rs @@ -4,15 +4,17 @@ mod ibc_testing { use std::vec; use super::super::*; + use crate::query; use crate::test_constants::{ CHANNEL_FROM_OMNI_TO_STARS, CHANNEL_FROM_STARS_TO_OMNI, CONNECTION_0, TEST_CHANNEL_0_DATA, TEST_CHANNEL_1_DATA, }; use crate::test_helpers::*; + use cosmwasm_std::CosmosMsg::Wasm; use cosmwasm_std::WasmMsg::Execute; + use query::query_channel; - use crate::contract::query_channel; use cosmwasm_std::testing::mock_dependencies; use cosmwasm_std::testing::mock_env; use cosmwasm_std::{ diff --git a/contracts/ics721/src/lib.rs b/contracts/ics721/src/lib.rs index 9d7f63d5..ac4c8e78 100644 --- a/contracts/ics721/src/lib.rs +++ b/contracts/ics721/src/lib.rs @@ -2,6 +2,7 @@ pub mod contract; mod error; pub mod ibc; pub mod msg; +pub mod query; pub mod state; mod test_constants; mod test_helpers; diff --git a/contracts/ics721/src/msg.rs b/contracts/ics721/src/msg.rs index b057b33d..997c0294 100644 --- a/contracts/ics721/src/msg.rs +++ b/contracts/ics721/src/msg.rs @@ -1,5 +1,5 @@ use cw20_ics20::state::ChannelInfo; -use cw721::Cw721ReceiveMsg; +use cw721_ibc::Cw721ReceiveMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/contracts/ics721/src/query.rs b/contracts/ics721/src/query.rs new file mode 100644 index 00000000..8eb89e3d --- /dev/null +++ b/contracts/ics721/src/query.rs @@ -0,0 +1,70 @@ +use crate::msg::{ChannelResponse, QueryMsg}; +use crate::state::{CHANNEL_INFO, CHANNEL_STATE}; + +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cosmwasm_std::{to_binary, Binary, Deps, Env, IbcQuery, Order, PortIdResponse, StdResult}; +use cw20_ics20::msg::{ListChannelsResponse, PortResponse}; + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::Port {} => to_binary(&query_port(deps)?), + QueryMsg::ListChannels {} => to_binary(&query_list(deps)?), + QueryMsg::Channel { id } => to_binary(&query_channel(deps, id)?), + QueryMsg::Tokens { + channel_id, + class_id, + } => to_binary(&query_tokens(deps, channel_id, class_id)?), + } +} + +fn query_port(deps: Deps) -> StdResult { + let query = IbcQuery::PortId {}.into(); + let PortIdResponse { port_id } = deps.querier.query(&query)?; + Ok(PortResponse { port_id }) +} + +fn query_list(deps: Deps) -> StdResult { + let channels: StdResult> = CHANNEL_INFO + .range(deps.storage, None, None, Order::Ascending) + .map(|r| r.map(|(_, v)| v)) + .collect(); + Ok(ListChannelsResponse { + channels: channels?, + }) +} + +pub fn query_channel(deps: Deps, id: String) -> StdResult { + let info = CHANNEL_INFO.load(deps.storage, &id)?; + let _class_ids: StdResult> = CHANNEL_STATE + .sub_prefix(&id) + .range(deps.storage, None, None, Order::Ascending) + .map(|r| { + let (class_id_token_id, _) = r?; + Ok(class_id_token_id.0) + }) + .collect(); + + let class_ids_resp = _class_ids; + match class_ids_resp { + Ok(mut class_id_vec) => Ok(ChannelResponse { + info, + class_ids: { + class_id_vec.sort(); + class_id_vec.dedup(); + class_id_vec + }, + }), + Err(msg) => Err(msg), + } +} + +// TODO: https://github.com/public-awesome/contracts/issues/59 +pub fn query_tokens( + _deps: Deps, + _channel_id: String, + _class_id: String, +) -> StdResult { + todo!() +} diff --git a/e2e/account.go b/e2e/account.go new file mode 100644 index 00000000..cf61867e --- /dev/null +++ b/e2e/account.go @@ -0,0 +1,13 @@ +package e2e_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/secp256k1" +) + +type Account struct { + PrivKey secp256k1.PrivKey + PubKey crypto.PubKey + Address sdk.AccAddress +} diff --git a/e2e/execute.go b/e2e/execute.go new file mode 100644 index 00000000..3fd6c4ad --- /dev/null +++ b/e2e/execute.go @@ -0,0 +1,113 @@ +package e2e_test + +import ( + "fmt" + "testing" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/public-awesome/stargaze/v4/app" + "github.com/stretchr/testify/require" +) + +func InstantiateEscrow721(t *testing.T, ctx sdk.Context, + msgServer wasmtypes.MsgServer, accs []Account) ( + instantiateRes *wasmtypes.MsgInstantiateContractResponse) { + creator := accs[0] + + instantiateMsgRaw := []byte( + fmt.Sprintf(escrow721Template, + creator.Address.String(), + ), + ) + instantiateRes, err := msgServer.InstantiateContract(sdk.WrapSDKContext(ctx), &wasmtypes.MsgInstantiateContract{ + Sender: creator.Address.String(), + Admin: creator.Address.String(), + CodeID: 2, + Label: "Escrow721", + Msg: instantiateMsgRaw, + Funds: sdk.NewCoins(sdk.NewInt64Coin("ustars", 1_000_000_000)), + }) + require.NoError(t, err) + require.NotNil(t, instantiateRes) + require.NotEmpty(t, instantiateRes.Address) + return instantiateRes +} + +func ExecuteMint(t *testing.T, ctx sdk.Context, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, mintMsgRaw []byte, err error) (mintErr error) { + escrow721Address := instantiateRes.Address + + _, mintErr = msgServer.ExecuteContract(sdk.WrapSDKContext(ctx), &wasmtypes.MsgExecuteContract{ + Contract: escrow721Address, + Sender: accs[0].Address.String(), + Msg: mintMsgRaw, + }) + require.NoError(t, err) + require.NotNil(t, instantiateRes) + require.NotEmpty(t, instantiateRes.Address) + require.NoError(t, mintErr) + return mintErr +} + +func ExecuteBurn(t *testing.T, ctx sdk.Context, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, burnMsgRaw []byte, err error) (burnErr error) { + escrow721Address := instantiateRes.Address + + _, burnErr = msgServer.ExecuteContract(sdk.WrapSDKContext(ctx), &wasmtypes.MsgExecuteContract{ + Contract: escrow721Address, + Sender: accs[0].Address.String(), + Msg: burnMsgRaw, + }) + require.NoError(t, err) + require.NotNil(t, instantiateRes) + require.NotEmpty(t, instantiateRes.Address) + require.NoError(t, burnErr) + return burnErr +} + +func ExecuteBurnError(t *testing.T, ctx sdk.Context, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, burnMsgRaw []byte, err error) (burnErr error) { + escrow721Address := instantiateRes.Address + + _, burnErr = msgServer.ExecuteContract(sdk.WrapSDKContext(ctx), &wasmtypes.MsgExecuteContract{ + Contract: escrow721Address, + Sender: accs[0].Address.String(), + Msg: burnMsgRaw, + }) + require.NoError(t, err) + require.NotNil(t, instantiateRes) + require.NotEmpty(t, instantiateRes.Address) + require.EqualError(t, burnErr, "cw721_base_ibc::state::TokenInfo not found: execute wasm contract failed") + return burnErr +} + +func ExecuteTransferNFT(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, transferMsgRaw []byte, err error) { + escrow721Address := instantiateRes.Address + + _, transferErr := msgServer.ExecuteContract(sdk.WrapSDKContext(ctx), &wasmtypes.MsgExecuteContract{ + Contract: escrow721Address, + Sender: accs[0].Address.String(), + Msg: transferMsgRaw, + }) + require.NoError(t, err) + require.NotNil(t, instantiateRes) + require.NotEmpty(t, instantiateRes.Address) + require.NoError(t, transferErr) +} + +func ExecuteSaveClass(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, saveClassMsgRaw []byte, err error) { + escrow721Address := instantiateRes.Address + + _, transferErr := msgServer.ExecuteContract(sdk.WrapSDKContext(ctx), &wasmtypes.MsgExecuteContract{ + Contract: escrow721Address, + Sender: accs[0].Address.String(), + Msg: saveClassMsgRaw, + }) + require.NoError(t, err) + require.NotNil(t, instantiateRes) + require.NotEmpty(t, instantiateRes.Address) + require.NoError(t, transferErr) +} diff --git a/e2e/full_test.go b/e2e/full_test.go index 6ee854a3..94407882 100644 --- a/e2e/full_test.go +++ b/e2e/full_test.go @@ -1,6 +1,7 @@ package e2e_test import ( + "fmt" "io/ioutil" "testing" "time" @@ -10,68 +11,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/public-awesome/stargaze/v4/app" "github.com/public-awesome/stargaze/v4/testutil/simapp" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) -var ( - // whitelist - - instantiateWhiteListTemplate = ` - { - "members":[%s], - "start_time": "%d", - "end_time": "%d", - "unit_price": { - "amount": "50000000", - "denom": "ustars" - }, - "per_address_limit": 1, - "member_limit": 1000 - } - ` - - instantiateMinterTemplate = ` - { - "base_token_uri": "ipfs://...", - "num_tokens": 100, - "sg721_code_id": 3, - "sg721_instantiate_msg": { - "name": "Collection Name", - "symbol": "SYM", - "minter": "%s", - "collection_info": { - "contract_uri": "ipfs://...", - "creator": "%s", - "description": "Stargaze Monkeys", - "image": "https://example.com/image.png", - "external_link" : "https://stargaze.zone", - "royalty_info": { - "payment_address": "%s", - "share": "0.1" - } - } - }, - "start_time": "%d", - "whitelist" : %s, - "per_address_limit": %d, - "unit_price": { - "amount": "100000000", - "denom": "ustars" - } - } - ` -) - -type Account struct { - PrivKey secp256k1.PrivKey - PubKey crypto.PubKey - Address sdk.AccAddress -} - func GetAccounts() []Account { accounts := make([]Account, 0, 150) for i := 0; i < 150; i++ { @@ -104,16 +50,16 @@ func GetAccountsAndBalances(accs []Account) ([]authtypes.GenesisAccount, []bankt } return genAccs, balances } -func TestMinter(t *testing.T) { - accs := GetAccounts() +func LoadChain(t *testing.T) (addr1 sdk.AccAddress, ctx sdk.Context, app *app.App, accs []Account) { + accs = GetAccounts() genAccs, balances := GetAccountsAndBalances(accs) - app := simapp.SetupWithGenesisAccounts(t, t.TempDir(), genAccs, balances...) + app = simapp.SetupWithGenesisAccounts(t, t.TempDir(), genAccs, balances...) startDateTime, err := time.Parse(time.RFC3339Nano, "2022-03-11T20:59:00Z") require.NoError(t, err) - ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "stargaze-1", Time: startDateTime}) + ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "stargaze-1", Time: startDateTime}) // wasm params wasmParams := app.WasmKeeper.GetParams(ctx) @@ -123,13 +69,16 @@ func TestMinter(t *testing.T) { priv1 := secp256k1.GenPrivKey() pub1 := priv1.PubKey() - addr1 := sdk.AccAddress(pub1.Address()) + addr1 = sdk.AccAddress(pub1.Address()) + return addr1, ctx, app, accs +} - // minter +func LoadICS721(t *testing.T, addr1 sdk.AccAddress, ctx sdk.Context, app *app.App) ( + msgServer wasmtypes.MsgServer, err error) { b, err := ioutil.ReadFile("contracts/ics721.wasm") require.NoError(t, err) - msgServer := wasmkeeper.NewMsgServerImpl(wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)) + msgServer = wasmkeeper.NewMsgServerImpl(wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)) res, err := msgServer.StoreCode(sdk.WrapSDKContext(ctx), &wasmtypes.MsgStoreCode{ Sender: addr1.String(), WASMByteCode: b, @@ -138,4 +87,174 @@ func TestMinter(t *testing.T) { require.NotNil(t, res) require.Equal(t, res.CodeID, uint64(1)) println("ICS721.wasm has loaded!") + return msgServer, err +} + +func LoadEscrow721(t *testing.T, addr1 sdk.AccAddress, ctx sdk.Context, + app *app.App, msgServer wasmtypes.MsgServer) { + b, err := ioutil.ReadFile("contracts/escrow721.wasm") + require.NoError(t, err) + + res, err := msgServer.StoreCode(sdk.WrapSDKContext(ctx), &wasmtypes.MsgStoreCode{ + Sender: addr1.String(), + WASMByteCode: b, + }) + require.NoError(t, err) + require.NotNil(t, res) + require.Equal(t, res.CodeID, uint64(2)) + println("escrow721.wasm has loaded!") +} + +func MintTwoNFTs(t *testing.T) ( + app *app.App, ctx sdk.Context, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, accs []Account, + msgServer wasmtypes.MsgServer, err error) { + addr1, ctx, app, accs := LoadChain(t) + msgServer, err = LoadICS721(t, addr1, ctx, app) + LoadEscrow721(t, addr1, ctx, app, msgServer) + instantiateRes = InstantiateEscrow721(t, ctx, msgServer, accs) + creator := accs[0] + + mintMsgRaw := []byte( + fmt.Sprintf(escrow721MintTemplate, + "omni/stars/transfer-nft", + "1", + creator.Address.String(), + ), + ) + ExecuteMint(t, ctx, msgServer, accs, instantiateRes, mintMsgRaw, err) + mintMsgRaw = []byte( + fmt.Sprintf(escrow721MintTemplate, + "omni/stars/transfer-nft", + "2", + creator.Address.String(), + ), + ) + ExecuteMint(t, ctx, msgServer, accs, instantiateRes, mintMsgRaw, err) + return app, ctx, instantiateRes, accs, msgServer, err +} + +func SaveClass(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, err error) { + saveClassMsgRaw := []byte(fmt.Sprintf(escrow721SaveClassTemplate, + "omni/stars/transfer-nft", + "abc123_class_uri", + )) + ExecuteSaveClass(t, ctx, app, msgServer, accs, instantiateRes, saveClassMsgRaw, err) +} + +func TestLoadChain(t *testing.T) { + LoadChain(t) +} + +func TestMinting(t *testing.T) { + MintTwoNFTs(t) +} + +func TestBurn(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + burnMsgRaw := []byte( + fmt.Sprintf(escrow721BurnTemplate, + "omni/stars/transfer-nft", + "1", + ), + ) + ExecuteBurn(t, ctx, msgServer, accs, instantiateRes, burnMsgRaw, err) + query_msg := []byte(`{"owner_of": {"token_id": "1", "class_id": "omni/stars/transfer-nft"}}`) + RunQueryEmpty(t, ctx, app, instantiateRes, accs[0], query_msg) + ExecuteBurnError(t, ctx, msgServer, accs, instantiateRes, burnMsgRaw, err) + + burnMsgRawFake := []byte( + fmt.Sprintf(escrow721BurnTemplate, + "super_fake_class", + "1", + ), + ) + ExecuteBurnError(t, ctx, msgServer, accs, instantiateRes, burnMsgRawFake, err) +} + +func TestGetOwner(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, _ := MintTwoNFTs(t) + getOwnerMsgRaw := []byte(fmt.Sprintf(escrow721GetOwnerTemplate, + "omni/stars/transfer-nft", + "1", + )) + expected_response := string(fmt.Sprintf(`{"owner":"%s","approvals":[]}`, accs[0].Address.String())) + RunGetOwner(t, ctx, app, msgServer, accs, instantiateRes, getOwnerMsgRaw, expected_response) + +} + +func TestGetNFTInfo(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, _ := MintTwoNFTs(t) + getNFTInfoMsgRaw := []byte(fmt.Sprintf(escrow721GetNFTInfoTemplate, + "omni/stars/transfer-nft", + "1", + )) + expected_result := string(`{"token_uri":"ipfs://abc123","extension":{}}`) + RunGetNFTInfo(t, ctx, app, msgServer, accs, instantiateRes, getNFTInfoMsgRaw, expected_result) + +} + +func TestTransfer(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + transferMsgRaw := []byte(fmt.Sprintf(escrow721TransferNFTTemplate, + "omni/stars/transfer-nft", + "1", + accs[1].Address.String(), + )) + ExecuteTransferNFT(t, ctx, app, msgServer, accs, instantiateRes, transferMsgRaw, err) + + getOwnerMsgRaw := []byte(fmt.Sprintf(escrow721GetOwnerTemplate, + "omni/stars/transfer-nft", + "1", + )) + expected_response := string(fmt.Sprintf(`{"owner":"%s","approvals":[]}`, accs[1].Address.String())) + RunGetOwner(t, ctx, app, msgServer, accs, instantiateRes, getOwnerMsgRaw, expected_response) +} + +func TestSaveClass(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + SaveClass(t, ctx, app, msgServer, accs, instantiateRes, err) +} + +func TestHasClassTrue(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + SaveClass(t, ctx, app, msgServer, accs, instantiateRes, err) + + hasClassMsgRaw := []byte(fmt.Sprintf(escrow721HasClassTemplate, + "omni/stars/transfer-nft", + )) + RunHasClass(t, ctx, app, msgServer, accs, instantiateRes, hasClassMsgRaw, "true") +} + +func TestHasClassFalse(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + SaveClass(t, ctx, app, msgServer, accs, instantiateRes, err) + + hasClassMsgRaw := []byte(fmt.Sprintf(escrow721HasClassTemplate, + "omni/fake-channel/transfer-nft", + )) + RunHasClass(t, ctx, app, msgServer, accs, instantiateRes, hasClassMsgRaw, "false") +} + +func TestGetClassSuccess(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + SaveClass(t, ctx, app, msgServer, accs, instantiateRes, err) + + getClassMsgRaw := []byte(fmt.Sprintf(escrow721GetClassTemplate, + "omni/stars/transfer-nft", + )) + expected := `["omni/stars/transfer-nft","abc123_class_uri"]` + RunGetClass(t, ctx, app, msgServer, accs, instantiateRes, getClassMsgRaw, expected) +} + +func TestGetClassFail(t *testing.T) { + app, ctx, instantiateRes, accs, msgServer, err := MintTwoNFTs(t) + SaveClass(t, ctx, app, msgServer, accs, instantiateRes, err) + + getClassMsgRaw := []byte(fmt.Sprintf(escrow721GetClassTemplate, + "omni/some_fake_class/transfer-nft", + )) + expected := `Generic error: Class omni/some_fake_class/transfer-nft not found: query wasm contract failed` + RunGetClassError(t, ctx, app, msgServer, accs, instantiateRes, getClassMsgRaw, expected) } diff --git a/e2e/query.go b/e2e/query.go new file mode 100644 index 00000000..7316ccc6 --- /dev/null +++ b/e2e/query.go @@ -0,0 +1,76 @@ +package e2e_test + +import ( + "testing" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/public-awesome/stargaze/v4/app" + "github.com/stretchr/testify/require" +) + +func RunQueryEmpty(t *testing.T, ctx sdk.Context, app *app.App, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, creator Account, queryMsgRaw []byte) { + escrow721Address := instantiateRes.Address + + addr, _ := sdk.AccAddressFromBech32(escrow721Address) + result, err := app.WasmKeeper.QuerySmart( + ctx, addr, queryMsgRaw) + expected_result := "" + require.Equal(t, string(result), expected_result) + require.EqualError(t, err, "cw721_base_ibc::state::TokenInfo not found: query wasm contract failed") +} + +func RunGetOwner(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, getOwnerMsgRaw []byte, expected_response string) { + escrow721Address := instantiateRes.Address + + addr, _ := sdk.AccAddressFromBech32(escrow721Address) + result, _ := app.WasmKeeper.QuerySmart( + ctx, addr, getOwnerMsgRaw) + require.Equal(t, string(result), expected_response) +} + +func RunGetNFTInfo(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, getNFTInfoMsgRaw []byte, expected_response string) { + escrow721Address := instantiateRes.Address + + addr, _ := sdk.AccAddressFromBech32(escrow721Address) + result, _ := app.WasmKeeper.QuerySmart( + ctx, addr, getNFTInfoMsgRaw) + + require.Equal(t, string(result), expected_response) +} + +func RunHasClass(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, hasClassMsgRaw []byte, expected string) { + escrow721Address := instantiateRes.Address + + addr, _ := sdk.AccAddressFromBech32(escrow721Address) + result, _ := app.WasmKeeper.QuerySmart( + ctx, addr, hasClassMsgRaw) + + require.Equal(t, string(expected), string(result)) +} + +func RunGetClass(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, getClassMsgRaw []byte, expected string) { + escrow721Address := instantiateRes.Address + + addr, _ := sdk.AccAddressFromBech32(escrow721Address) + result, _ := app.WasmKeeper.QuerySmart( + ctx, addr, getClassMsgRaw) + + require.Equal(t, string(expected), string(result)) +} + +func RunGetClassError(t *testing.T, ctx sdk.Context, app *app.App, msgServer wasmtypes.MsgServer, accs []Account, + instantiateRes *wasmtypes.MsgInstantiateContractResponse, getClassMsgRaw []byte, expected string) { + escrow721Address := instantiateRes.Address + + addr, _ := sdk.AccAddressFromBech32(escrow721Address) + _, err := app.WasmKeeper.QuerySmart( + ctx, addr, getClassMsgRaw) + + require.EqualError(t, err, expected) +} diff --git a/e2e/template.go b/e2e/template.go new file mode 100644 index 00000000..0a5341af --- /dev/null +++ b/e2e/template.go @@ -0,0 +1,75 @@ +package e2e_test + +var ( + escrow721Template = ` + { + "name": "escrow721Channel1transfer-nft", + "symbol": "esw721_1_transfer-nft", + "minter": "%s" + } + ` + + escrow721MintTemplate = ` + { "mint": { + "class_id": "%s", + "token_id": "%s", + "owner": "%s", + "token_uri": "ipfs://abc123", + "extension": {} + } + } + ` + + escrow721BurnTemplate = ` + { "burn": { + "class_id": "%s", + "token_id": "%s" + } + } + ` + + escrow721GetOwnerTemplate = ` + { + "owner_of": { + "class_id": "%s", + "token_id": "%s"} + } + ` + + escrow721GetNFTInfoTemplate = ` + { + "nft_info": { + "class_id": "%s", + "token_id": "%s"} + } + ` + + escrow721TransferNFTTemplate = ` + { + "transfer_nft": { + "class_id": "%s", + "token_id": "%s", + "recipient": "%s"} + } + ` + escrow721SaveClassTemplate = ` + { + "save_class": { + "class_id": "%s", + "class_uri": "%s"} + } + ` + + escrow721HasClassTemplate = ` + { + "has_class": { + "class_id": "%s"} + } + ` + escrow721GetClassTemplate = ` + { + "get_class": { + "class_id": "%s"} + } + ` +) diff --git a/schema/execute_msg.json b/schema/execute_msg.json index 3e6c2efc..b742bffa 100644 --- a/schema/execute_msg.json +++ b/schema/execute_msg.json @@ -36,11 +36,15 @@ "description": "Cw721ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", "type": "object", "required": [ + "class_id", "msg", "sender", "token_id" ], "properties": { + "class_id": { + "type": "string" + }, "msg": { "$ref": "#/definitions/Binary" },