diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2bc01b0..fca0ead 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: inputs: toolchain: description: 'Default Rust Toolchain' - default: "1.73.0" + default: "1.78.0" required: true type: string target: @@ -31,7 +31,7 @@ on: type: string env: - TOOLCHAIN: ${{ inputs.toolchain || '1.73.0' }} + TOOLCHAIN: ${{ inputs.toolchain || '1.78.0' }} TARGET: ${{ inputs.target || 'wasm32-unknown-unknown' }} REF: ${{ github.event_name == 'push' && github.ref || inputs.branch || 'main' }} ID: ${{ inputs.id || 'scheduled' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 18a4d9a..e683412 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.73.0 + toolchain: 1.78.0 components: clippy profile: minimal override: true @@ -31,7 +31,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.73.0 + toolchain: 1.78.0 components: rustfmt profile: minimal override: true @@ -49,7 +49,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.73.0 + toolchain: 1.78.0 profile: minimal - run: cargo fetch --verbose - run: cargo build diff --git a/Cargo.lock b/Cargo.lock index c0ba3f0..c068646 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,77 +14,197 @@ dependencies = [ ] [[package]] -name = "android-tzdata" -version = "0.1.1" +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] -name = "android_system_properties" -version = "0.1.5" +name = "anyhow" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "ark-bls12-381" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" dependencies = [ - "libc", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", ] [[package]] -name = "anyhow" -version = "1.0.86" +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", + "rayon", +] [[package]] name = "astroport" -version = "4.0.3" -source = "git+https://github.com/astroport-fi/astroport-core#a0a71af801be3f72c64b81f798e1b0805cf0f594" +version = "5.5.0" +source = "git+https://github.com/astroport-fi/astroport-core#b9566f26ed21c85904a866697fb3cc13e9096478" dependencies = [ "astroport-circular-buffer", - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", + "cosmos-sdk-proto 0.19.0", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-asset", "cw-storage-plus 1.2.0", "cw-utils", "cw20", "itertools 0.12.1", + "prost 0.11.9", "uint", ] [[package]] name = "astroport-circular-buffer" version = "0.2.0" -source = "git+https://github.com/astroport-fi/astroport-core#a0a71af801be3f72c64b81f798e1b0805cf0f594" +source = "git+https://github.com/astroport-fi/astroport-core#b9566f26ed21c85904a866697fb3cc13e9096478" dependencies = [ - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "thiserror", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "balance-tracker" version = "0.1.0" dependencies = [ "astroport", - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "cw2 1.1.2", "thiserror", ] -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base16ct" version = "0.2.0" @@ -115,12 +235,18 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "before-send-hook-test" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "schemars", "serde", @@ -144,12 +270,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bnum" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" - [[package]] name = "bnum" version = "0.10.0" @@ -157,10 +277,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" [[package]] -name = "bumpalo" -version = "3.16.0" +name = "bnum" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "byteorder" @@ -170,19 +290,13 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] -[[package]] -name = "cc" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" - [[package]] name = "cfg-if" version = "1.0.0" @@ -195,24 +309,7 @@ version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ - "android-tzdata", - "iana-time-zone", "num-traits", - "serde", - "windows-targets", -] - -[[package]] -name = "client_updater" -version = "0.1.0" -dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", - "cw-storage-plus 2.0.0", - "cw2 2.0.0", - "neutron-sdk 0.10.0", - "schemars", - "serde", ] [[package]] @@ -221,12 +318,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cosmos-sdk-proto" version = "0.19.0" @@ -249,58 +340,75 @@ dependencies = [ "tendermint-proto 0.34.1", ] +[[package]] +name = "cosmwasm-core" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6ceb8624260d0d3a67c4e1a1d43fc7e9406720afbcb124521501dd138f90aa" + [[package]] name = "cosmwasm-crypto" -version = "1.5.2" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ed6aa9f904de106fa16443ad14ec2abe75e94ba003bb61c681c0e43d4c58d2a" +checksum = "58535cbcd599b3c193e3967c8292fe1dbbb5de7c2a2d87380661091dd4744044" dependencies = [ "digest 0.10.7", - "ecdsa 0.16.9", - "ed25519-zebra", - "k256 0.13.1", + "ed25519-zebra 3.1.0", + "k256", "rand_core 0.6.4", "thiserror", ] [[package]] name = "cosmwasm-crypto" -version = "2.0.4" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a339f6b59ff7ad4ae05a70512a4f3c19bf8fcc845d46bfef90f4ec0810f72c" +checksum = "4125381e5fd7fefe9f614640049648088015eca2b60d861465329a5d87dfa538" dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", "digest 0.10.7", - "ed25519-zebra", + "ecdsa", + "ed25519-zebra 4.0.3", "k256", + "num-traits", + "p256", "rand_core 0.6.4", + "rayon", + "sha2 0.10.8", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.5.5" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "242e98e7a231c122e08f300d9db3262d1007b51758a8732cd6210b3e9faa4f3a" +checksum = "a8e07de16c800ac82fd188d055ecdb923ead0cf33960d3350089260bb982c09f" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-derive" -version = "2.0.4" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3bfea6af94a83880fb05478135ed0c256d9a2fcde58c595a10d64dcb9c925d" +checksum = "1b5658b1dc64e10b56ae7a449f678f96932a96f6cfad1769d608d1d1d656480a" dependencies = [ - "syn 1.0.109", + "proc-macro2", + "quote", + "syn 2.0.79", ] [[package]] name = "cosmwasm-schema" -version = "1.5.5" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7879036156092ad1c22fe0d7316efc5a5eceec2bc3906462a2560215f2a2f929" +checksum = "93d388adfa9cb449557a92e9318121ac1a481fc4f599213b03a5b62699b403b4" dependencies = [ - "cosmwasm-schema-derive 1.5.5", + "cosmwasm-schema-derive 1.5.8", "schemars", "serde", "serde_json", @@ -309,11 +417,11 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "2.0.4" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "101d0739564bd34cba9b84bf73665f0822487ae3b29b2dd59930608ed3aafd43" +checksum = "f86b4d949b6041519c58993a73f4bbfba8083ba14f7001eae704865a09065845" dependencies = [ - "cosmwasm-schema-derive 2.0.4", + "cosmwasm-schema-derive 2.1.4", "schemars", "serde", "serde_json", @@ -322,9 +430,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.5" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb57855fbfc83327f8445ae0d413b1a05ac0d68c396ab4d122b2abd7bb82cb6" +checksum = "2411b389e56e6484f81ba955b758d02522d620c98fc960c4bd2251d48b7aa19f" dependencies = [ "proc-macro2", "quote", @@ -333,26 +441,26 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "2.0.4" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4be75f60158478da2c5d319ed59295bca1687ad50c18215a0485aa91a995ea" +checksum = "c8ef1b5835a65fcca3ab8b9a02b4f4dacc78e233a5c2f20b270efb9db0666d12" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.79", ] [[package]] name = "cosmwasm-std" -version = "1.5.2" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad011ae7447188e26e4a7dbca2fcd0fc186aa21ae5c86df0503ea44c78f9e469" +checksum = "c21fde95ccd20044a23c0ac6fd8c941f3e8c158169dc94b5aa6491a2d9551a8d" dependencies = [ "base64 0.21.7", - "bech32", - "bnum 0.8.1", - "cosmwasm-crypto 1.5.2", - "cosmwasm-derive 1.5.5", + "bech32 0.9.1", + "bnum 0.10.0", + "cosmwasm-crypto 1.5.8", + "cosmwasm-derive 1.5.8", "derivative", "forward_ref", "hex", @@ -366,18 +474,19 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "2.0.4" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded932165de44cd0717979c34fc3b84d8e8066b8dde4f5bd78f96a643b090f90" +checksum = "70eb7ab0c1e99dd6207496963ba2a457c4128ac9ad9c72a83f8d9808542b849b" dependencies = [ - "base64", - "bech32", - "bnum 0.10.0", - "cosmwasm-crypto 2.0.4", - "cosmwasm-derive 2.0.4", - "derivative", - "forward_ref", + "base64 0.22.1", + "bech32 0.11.0", + "bnum 0.11.0", + "cosmwasm-core", + "cosmwasm-crypto 2.1.4", + "cosmwasm-derive 2.1.4", + "derive_more", "hex", + "rand_core 0.6.4", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -387,42 +496,58 @@ dependencies = [ ] [[package]] -name = "cosmwasm-storage" -version = "1.5.2" +name = "cpufeatures" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66de2ab9db04757bcedef2b5984fbe536903ada4a8a9766717a4a71197ef34f6" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ - "cosmwasm-std", - "serde", + "libc", ] [[package]] -name = "cpufeatures" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +name = "cron" +version = "0.1.0" dependencies = [ - "libc", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "cw-storage-plus 2.0.0", + "cw2 2.0.0", + "neutron-sdk", + "schemars", + "serde", ] [[package]] -name = "crunchy" -version = "0.2.2" +name = "crossbeam-deque" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] [[package]] -name = "crypto-bigint" -version = "0.4.9" +name = "crossbeam-epoch" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", + "crossbeam-utils", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[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.5.5" @@ -459,59 +584,52 @@ dependencies = [ ] [[package]] -name = "cw-address-like" -version = "1.0.4" +name = "curve25519-dalek" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "cosmwasm-std 1.5.2", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", ] [[package]] -name = "cw-asset" -version = "3.1.1" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c999a12f8cd8736f6f86e9a4ede5905530cb23cfdef946b9da1c506ad1b70799" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", - "cw-address-like", - "cw-storage-plus 1.2.0", - "cw20", - "thiserror", + "proc-macro2", + "quote", + "syn 2.0.79", ] [[package]] -name = "cw-controllers" -version = "1.1.2" +name = "cw-address-like" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57de8d3761e46be863e3ac1eba8c8a976362a48c6abf240df1e26c3e421ee9e8" +checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "schemars", - "serde", - "thiserror", + "cosmwasm-std 1.5.8", ] [[package]] -name = "cw-multi-test" -version = "0.16.5" +name = "cw-asset" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" +checksum = "c999a12f8cd8736f6f86e9a4ede5905530cb23cfdef946b9da1c506ad1b70799" dependencies = [ - "anyhow", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "derivative", - "itertools 0.10.5", - "k256 0.11.6", - "prost 0.9.0", - "schemars", - "serde", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", + "cw-address-like", + "cw-storage-plus 1.2.0", + "cw20", "thiserror", ] @@ -521,7 +639,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ - "cosmwasm-std 1.5.2", + "cosmwasm-std 1.5.8", "schemars", "serde", ] @@ -532,7 +650,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ - "cosmwasm-std 2.0.4", + "cosmwasm-std 2.1.4", "schemars", "serde", ] @@ -543,8 +661,8 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" dependencies = [ - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw2 1.1.2", "schemars", "semver", @@ -558,8 +676,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" dependencies = [ - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "schemars", "semver", @@ -573,8 +691,8 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "schemars", "semver", @@ -588,58 +706,13 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" dependencies = [ - "cosmwasm-schema 1.5.5", - "cosmwasm-std 1.5.2", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-utils", "schemars", "serde", ] -[[package]] -name = "darling" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.66", -] - -[[package]] -name = "darling_macro" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.66", -] - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "der" version = "0.7.9" @@ -657,7 +730,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -672,26 +744,36 @@ dependencies = [ ] [[package]] -name = "dex" -version = "0.1.0" +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", - "cw2 2.0.0", - "neutron-sdk 0.10.0", - "schemars", - "serde", + "derive_more-impl", ] [[package]] -name = "dex_stargate" +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", + "unicode-xid", +] + +[[package]] +name = "dex_grpc" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -725,49 +807,46 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "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.9", + "der", "digest 0.10.7", - "elliptic-curve 0.13.8", - "rfc6979 0.4.0", - "signature 2.2.0", - "spki 0.7.3", + "elliptic-curve", + "rfc6979", + "signature", + "spki", ] [[package]] name = "echo" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "schemars", "serde", ] +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + [[package]] name = "ed25519-zebra" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 3.2.0", "hashbrown 0.12.3", "hex", "rand_core 0.6.4", @@ -777,75 +856,60 @@ dependencies = [ ] [[package]] -name = "either" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" +name = "ed25519-zebra" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array", - "group 0.12.1", - "pkcs8 0.9.0", + "curve25519-dalek 4.1.3", + "ed25519", + "hashbrown 0.14.5", + "hex", "rand_core 0.6.4", - "sec1 0.3.0", - "subtle", + "sha2 0.10.8", "zeroize", ] +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + [[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", + "base16ct", + "crypto-bigint", "digest 0.10.7", - "ff 0.13.0", + "ff", "generic-array", - "group 0.13.0", - "pkcs8 0.10.2", + "group", + "pkcs8", "rand_core 0.6.4", - "sec1 0.7.3", + "sec1", "subtle", "zeroize", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "ff" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", "subtle", ] [[package]] -name = "ff" -version = "0.13.0" +name = "fiat-crypto" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "flex-error" @@ -856,12 +920,6 @@ dependencies = [ "paste", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "forward_ref" version = "1.0.0" @@ -892,24 +950,28 @@ dependencies = [ [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.12.1", + "ff", "rand_core 0.6.4", "subtle", ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +name = "grpc_querier" +version = "0.1.0" dependencies = [ - "ff 0.13.0", - "rand_core 0.6.4", - "subtle", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "cw2 2.0.0", + "neutron-sdk", + "neutron-std", + "prost 0.12.6", + "schemars", + "serde", + "serde-json-wasm 1.0.1", ] [[package]] @@ -918,7 +980,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.11", ] [[package]] @@ -926,6 +997,10 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] [[package]] name = "heck" @@ -948,71 +1023,21 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "ibc_transfer" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown 0.14.5", - "serde", -] - [[package]] name = "itertools" version = "0.10.5" @@ -1028,117 +1053,73 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", + "either", ] [[package]] -name = "k256" -version = "0.11.6" +name = "itoa" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.8", -] +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", + "ecdsa", + "elliptic-curve", "once_cell", "sha2 0.10.8", - "signature 2.2.0", + "signature", ] [[package]] name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "log" -version = "0.4.22" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "marketmap" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", + "neutron-std", "schemars", "serde", ] +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + [[package]] name = "msg_receiver" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", - "neutron-sdk 0.10.0", - "schemars", - "serde", -] - -[[package]] -name = "neutron-flashloans-user" -version = "0.3.0" -dependencies = [ - "anyhow", - "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cw-controllers", - "cw-multi-test", - "cw-storage-plus", - "cw-utils", - "cw2", - "neutron-sdk 0.8.0", - "prost 0.12.6", - "prost-types 0.12.6", + "neutron-sdk", "schemars", "serde", - "serde-json-wasm 1.0.1", - "serde_with", - "thiserror", ] [[package]] name = "neutron-price-feed-mock" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "thiserror", @@ -1146,39 +1127,45 @@ dependencies = [ [[package]] name = "neutron-sdk" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f60e477bd71007d9ff78ae020ec1c6b3b47798578af6151429434d86472efc" +version = "0.11.0" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#b83c182e8688f826c313cae318ff8ae908b87c81" dependencies = [ - "bech32", + "bech32 0.9.1", + "chrono", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "protobuf", "schemars", "serde", + "serde-cw-value", "serde-json-wasm 1.0.1", + "serde_json", "speedate", "tendermint-proto 0.34.1", "thiserror", ] [[package]] -name = "neutron-sdk" -version = "0.10.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#039d33c22590bf481a9a716c0842c2930829fffd" +name = "neutron-std" +version = "5.0.0" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#25e0d0c1e7f56d40ba62908d9e2c03b5d3779bd2" dependencies = [ - "bech32", + "bech32 0.9.1", + "chrono", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "neutron-std-derive", "prost 0.12.6", "prost-types 0.12.6", "protobuf", "schemars", "serde", + "serde-cw-value", "serde-json-wasm 1.0.1", "serde_json", "speedate", @@ -1186,17 +1173,30 @@ dependencies = [ "thiserror", ] +[[package]] +name = "neutron-std-derive" +version = "0.20.1" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#25e0d0c1e7f56d40ba62908d9e2c03b5d3779bd2" +dependencies = [ + "itertools 0.10.5", + "proc-macro2", + "prost-types 0.12.6", + "quote", + "syn 1.0.109", +] + [[package]] name = "neutron_interchain_queries" version = "0.1.0" dependencies = [ "base64 0.21.7", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", + "neutron-std", "prost 0.12.6", "schemars", "serde", @@ -1208,11 +1208,12 @@ name = "neutron_interchain_txs" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -1225,16 +1226,27 @@ name = "neutron_validators_test" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", ] +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -1252,6 +1264,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1263,9 +1284,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -1277,41 +1298,25 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" name = "oracle" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", - "neutron-sdk 0.10.0", - "schemars", - "serde", -] - -[[package]] -name = "osmosis-std" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "798fade51443a0e07eb25b59a11b320b9e8f03e6e8fbe14c520258f04742fe13" -dependencies = [ - "chrono", - "cosmwasm-std 1.5.2", - "osmosis-std-derive", - "prost 0.11.9", - "prost-types 0.11.9", + "neutron-sdk", + "neutron-std", "schemars", "serde", - "serde-cw-value", ] [[package]] -name = "osmosis-std-derive" -version = "0.16.2" +name = "p256" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47f0b2f22adb341bb59e5a3a1b464dde033181954bd055b9ae86d6511ba465b" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" dependencies = [ - "itertools 0.10.5", - "proc-macro2", - "prost-types 0.11.9", - "quote", - "syn 1.0.109", + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", ] [[package]] @@ -1320,24 +1325,14 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "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.9", - "spki 0.7.3", + "der", + "spki", ] [[package]] @@ -1347,22 +1342,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] -name = "proc-macro2" -version = "1.0.85" +name = "ppv-lite86" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "unicode-ident", + "zerocopy", ] [[package]] -name = "prost" -version = "0.9.0" +name = "primeorder" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" dependencies = [ - "bytes", - "prost-derive 0.9.0", + "elliptic-curve", +] + +[[package]] +name = "proc-macro2" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +dependencies = [ + "unicode-ident", ] [[package]] @@ -1385,19 +1388,6 @@ dependencies = [ "prost-derive 0.12.6", ] -[[package]] -name = "prost-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "prost-derive" version = "0.11.9" @@ -1418,10 +1408,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1464,13 +1454,33 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -1486,37 +1496,55 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "reflect" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", - "neutron-sdk 0.10.0", + "neutron-sdk", "schemars", "serde", ] [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "crypto-bigint 0.4.9", "hmac", - "zeroize", + "subtle", ] [[package]] -name = "rfc6979" -version = "0.4.0" +name = "rustc_version" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "hmac", - "subtle", + "semver", ] [[package]] @@ -1552,21 +1580,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", -] - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array", - "pkcs8 0.9.0", - "subtle", - "zeroize", + "syn 2.0.79", ] [[package]] @@ -1575,10 +1589,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "base16ct 0.2.0", - "der 0.7.9", + "base16ct", + "der", "generic-array", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -1591,9 +1605,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -1627,22 +1641,22 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1653,50 +1667,21 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] -[[package]] -name = "serde_with" -version = "3.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.2.6", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "sha2" version = "0.9.9" @@ -1721,16 +1706,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - [[package]] name = "signature" version = "2.2.0" @@ -1751,16 +1726,6 @@ dependencies = [ "strum_macros", ] -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - [[package]] name = "spki" version = "0.7.3" @@ -1768,23 +1733,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.9", -] - -[[package]] -name = "stargate_querier" -version = "0.1.0" -dependencies = [ - "cosmos-sdk-proto 0.19.0", - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", - "cw2 2.0.0", - "neutron-sdk 0.10.0", - "osmosis-std", - "prost 0.11.9", - "schemars", - "serde", - "serde-json-wasm 1.0.1", + "der", ] [[package]] @@ -1793,12 +1742,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - [[package]] name = "strum" version = "0.25.0" @@ -1818,14 +1761,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subtle-encoding" @@ -1849,9 +1792,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1896,22 +1839,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1921,10 +1864,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", - "itoa", "num-conv", "powerfmt", - "serde", "time-core", "time-macros", ] @@ -1949,9 +1890,10 @@ dependencies = [ name = "tokenfactory" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.0.4", - "cosmwasm-std 2.0.4", - "neutron-sdk 0.10.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "neutron-sdk", + "neutron-std", "schemars", "serde", ] @@ -1976,15 +1918,21 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-xid" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1993,134 +1941,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasm-bindgen" -version = "0.2.92" +name = "zerocopy" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "cfg-if", - "wasm-bindgen-macro", + "byteorder", + "zerocopy-derive", ] [[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" +name = "zerocopy-derive" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ - "bumpalo", - "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.66", - "wasm-bindgen-shared", + "syn 2.0.79", ] [[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" +name = "zeroize" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ - "quote", - "wasm-bindgen-macro-support", + "zeroize_derive", ] [[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" +name = "zeroize_derive" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "syn 2.0.79", ] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "zeroize" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index b9be99c..f9dfd2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,20 +14,25 @@ overflow-checks = true [workspace.dependencies] neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } +neutron-std = { git = "https://github.com/neutron-org/neutron-std", branch = "main" } + prost = "0.12.4" prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false } -cosmwasm-std = { version = "2.0.4", features = [ +cosmwasm-std = { version = "2.1.0", features = [ "stargate", "staking", "cosmwasm_1_1", "cosmwasm_1_2", + "cosmwasm_1_3", + "cosmwasm_1_4", + "cosmwasm_2_0", ] } cw2 = "2.0.0" cw-storage-plus = "2.0.0" schemars = "0.8.15" serde = { version = "1.0.189", default-features = false } -cosmwasm-schema = { version = "2.0.4", default-features = false } +cosmwasm-schema = { version = "2.1.0", default-features = false } serde-json-wasm = "1.0.0" base64 = "0.21.7" thiserror = "1.0.49" diff --git a/Makefile b/Makefile index 5458820..7f2ba67 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,10 @@ compile: --mount type=volume,source="$(notdir $(CURDIR))_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ --platform linux/amd64 \ - cosmwasm/workspace-optimizer:0.15.0 + cosmwasm/workspace-optimizer:0.16.0 check_contracts: - @cargo install cosmwasm-check --locked - @cosmwasm-check --available-capabilities iterator,staking,stargate,neutron,cosmwasm_1_1,cosmwasm_1_2 artifacts/*.wasm + @cargo install cosmwasm-check --version 2.0.4 --locked + @cosmwasm-check --available-capabilities iterator,staking,stargate,neutron,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,cosmwasm_2_0 artifacts/*.wasm build: schema clippy test fmt compile check_contracts diff --git a/README.md b/README.md index f05eebf..ae8f2e7 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ The following contracts are maintained here: | Contract | Reference | Description | |--------------------------------------------------|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Neutron Interchain Queries Example Contract | https://github.com/neutron-org/neutron-contracts/tree/main/contracts/neutron-interchain-queries | The contract shows how to properly work with [Interchain Queries Module](https://github.com/neutron-org/neutron/tree/master/x/interchainqueries) using [Interchain Queries SDK package](https://github.com/neutron-org/neutron-contracts/tree/main/packages/neutron-sdk/src/interchain_queries) via CosmWasm smart-contract. | -| Neutron Interchain Transactions Example Contract | https://github.com/neutron-org/neutron-contracts/tree/main/contracts/neutron_interchain_txs | The contract shows how to properly work with [Neutron Interchain Transactions Module](https://github.com/neutron-org/neutron/tree/master/x/interchaintxs) using [Interchain Transactions SDK package](https://github.com/neutron-org/neutron-contracts/tree/main/packages/neutron-sdk/src/interchain_txs) via CosmWasm smart-contract. | -| Neutron IBC Transfer Example Contract | https://github.com/neutron-org/neutron-contracts/tree/main/contracts/ibc_transfer | The contract shows how to properly work with [Neutron Sudo Package](https://github.com/neutron-org/neutron-contracts/tree/main/packages/neutron_sudo) to handle a callback from IBC transfer. | -| Neutron dex module + Stargate Example Contract | https://github.com/neutron-org/neutron-contracts/tree/main/contracts/dex_stargate | The contract shows a way to use [Neutron SDK's Stargate package](https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/stargate) to interact with Neutron dex module via stargate | -| Reflect | https://github.com/neutron-org/neutron-contracts/tree/main/contracts/reflect | This contract is used for tests in the main neutron repository. | +| Neutron Interchain Queries Example Contract | | The contract shows how to properly work with [Interchain Queries Module](https://github.com/neutron-org/neutron/tree/master/x/interchainqueries) using [Interchain Queries SDK package](https://github.com/neutron-org/neutron-contracts/tree/main/packages/neutron-sdk/src/interchain_queries) via CosmWasm smart-contract. | +| Neutron Interchain Transactions Example Contract | | The contract shows how to properly work with [Neutron Interchain Transactions Module](https://github.com/neutron-org/neutron/tree/master/x/interchaintxs) using [Interchain Transactions SDK package](https://github.com/neutron-org/neutron-contracts/tree/main/packages/neutron-sdk/src/interchain_txs) via CosmWasm smart-contract. | +| Neutron IBC Transfer Example Contract | | The contract shows how to properly work with [Neutron Sudo Package](https://github.com/neutron-org/neutron-contracts/tree/main/packages/neutron_sudo) to handle a callback from IBC transfer. | +| Neutron dex module + Grpc Example Contract | | The contract shows a way to use [Neutron SDK's Grpc package](https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/grpc) to interact with Neutron dex module via grpc | +| Reflect | | This contract is used for tests in the main neutron repository. | ## Development @@ -24,7 +24,7 @@ The following contracts are maintained here: - `wasm32-unknown-unknown` target - Docker -1. Install `rustup` via https://rustup.rs/ +1. Install `rustup` via 2. Run the following: diff --git a/contracts/balance-tracker/.cargo/config b/contracts/balance-tracker/.cargo/config index 52fc65f..444af15 100644 --- a/contracts/balance-tracker/.cargo/config +++ b/contracts/balance-tracker/.cargo/config @@ -3,4 +3,3 @@ wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" unit-test = "test --lib" integration-test = "test --test integration" -schema = "run --example tokenfactory_tracker_schema" diff --git a/contracts/balance-tracker/Cargo.toml b/contracts/balance-tracker/Cargo.toml index 1297d80..10287d4 100644 --- a/contracts/balance-tracker/Cargo.toml +++ b/contracts/balance-tracker/Cargo.toml @@ -27,4 +27,4 @@ cosmwasm-std = "1.5" cw-storage-plus = "1.2" cosmwasm-schema = "1.5" thiserror = "1" -astroport = { git = "https://github.com/astroport-fi/astroport-core", version = "4" } +astroport = { git = "https://github.com/astroport-fi/astroport-core", version = "5" } diff --git a/contracts/balance-tracker/src/query.rs b/contracts/balance-tracker/src/query.rs index fba34a1..d36cc15 100644 --- a/contracts/balance-tracker/src/query.rs +++ b/contracts/balance-tracker/src/query.rs @@ -9,34 +9,33 @@ use crate::state::{BALANCES, CONFIG, TOTAL_SUPPLY_HISTORY}; #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::BalanceAt { address, timestamp } => { - to_json_binary(&balance_at(deps, env, address, timestamp)?) - } - QueryMsg::TotalSupplyAt { timestamp } => { - to_json_binary(&total_supply_at(deps, env, timestamp)?) + QueryMsg::BalanceAt { address, unit } => { + to_json_binary(&balance_at(deps, env, address, unit)?) } + QueryMsg::TotalSupplyAt { unit } => to_json_binary(&total_supply_at(deps, env, unit)?), QueryMsg::Config {} => { let config = CONFIG.load(deps.storage)?; to_json_binary(&ConfigResponse { tracked_denom: config.d, token_factory_module: config.m, + track_over_seconds: true, }) } } } -fn balance_at(deps: Deps, env: Env, address: String, timestamp: Option) -> StdResult { +fn balance_at(deps: Deps, env: Env, address: String, unit: Option) -> StdResult { let block_time = env.block.time.seconds(); - match timestamp.unwrap_or(block_time) { + match unit.unwrap_or(block_time) { timestamp if timestamp == block_time => BALANCES.may_load(deps.storage, &address), timestamp => BALANCES.may_load_at_height(deps.storage, &address, timestamp), } .map(|balance| balance.unwrap_or_default()) } -fn total_supply_at(deps: Deps, env: Env, timestamp: Option) -> StdResult { +fn total_supply_at(deps: Deps, env: Env, unit: Option) -> StdResult { let block_time = env.block.time.seconds(); - match timestamp.unwrap_or(block_time) { + match unit.unwrap_or(block_time) { timestamp if timestamp == block_time => TOTAL_SUPPLY_HISTORY.may_load(deps.storage), timestamp => TOTAL_SUPPLY_HISTORY.may_load_at_height(deps.storage, timestamp), } diff --git a/contracts/before-send-hook/schema/instantiate_msg.json b/contracts/before-send-hook/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/before-send-hook/schema/instantiate_msg.json +++ b/contracts/before-send-hook/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/before-send-hook/schema/migrate_msg.json b/contracts/before-send-hook/schema/migrate_msg.json index 87b18ea..7fbe8c5 100644 --- a/contracts/before-send-hook/schema/migrate_msg.json +++ b/contracts/before-send-hook/schema/migrate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "MigrateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/before-send-hook/schema/query_msg.json b/contracts/before-send-hook/schema/query_msg.json index 77f598c..35b4989 100644 --- a/contracts/before-send-hook/schema/query_msg.json +++ b/contracts/before-send-hook/schema/query_msg.json @@ -9,7 +9,8 @@ ], "properties": { "sudo_result_block_before": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -21,7 +22,8 @@ ], "properties": { "sudo_result_track_before": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/client_updater/README.md b/contracts/client_updater/README.md deleted file mode 100644 index ddae8cf..0000000 --- a/contracts/client_updater/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Client updater - -Updates a client through a ClientUpdateProposal proposal to adminmodule diff --git a/contracts/client_updater/schema/execute_msg.json b/contracts/client_updater/schema/execute_msg.json deleted file mode 100644 index f78a903..0000000 --- a/contracts/client_updater/schema/execute_msg.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "submit_client_update_proposal" - ], - "properties": { - "submit_client_update_proposal": { - "type": "object", - "required": [ - "description", - "subject_client_id", - "substitute_client_id", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "subject_client_id": { - "type": "string" - }, - "substitute_client_id": { - "type": "string" - }, - "title": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/client_updater/src/contract.rs b/contracts/client_updater/src/contract.rs deleted file mode 100644 index 9193d31..0000000 --- a/contracts/client_updater/src/contract.rs +++ /dev/null @@ -1,78 +0,0 @@ -use cosmwasm_std::{entry_point, Addr, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; -use cw2::set_contract_version; -use cw_storage_plus::Item; -#[allow(deprecated)] -use neutron_sdk::bindings::msg::{ClientUpdateProposal, NeutronMsg}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -const OWNER: Item = Item::new("owner"); - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - SubmitClientUpdateProposal { - title: String, - description: String, - subject_client_id: String, - substitute_client_id: String, - }, -} - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - let owner = info.sender; - OWNER.save(deps.storage, &owner)?; - deps.api.debug("WASMDEBUG: instantiate"); - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - - let owner = OWNER.load(deps.storage)?; - if info.sender != owner { - return Err(StdError::generic_err("Unauthorized")); - } - - let mut resp = Response::default(); - match msg { - ExecuteMsg::SubmitClientUpdateProposal { - title, - description, - subject_client_id, - substitute_client_id, - } => { - #[allow(deprecated)] - let update_proposal_msg = - NeutronMsg::submit_client_update_proposal(ClientUpdateProposal { - title, - description, - subject_client_id, - substitute_client_id, - }); - - resp = resp.add_message(update_proposal_msg); - } - } - Ok(resp) -} diff --git a/contracts/client_updater/src/lib.rs b/contracts/client_updater/src/lib.rs deleted file mode 100644 index 2943dbb..0000000 --- a/contracts/client_updater/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod contract; diff --git a/contracts/client_updater/updater.sh b/contracts/client_updater/updater.sh deleted file mode 100644 index 05204ae..0000000 --- a/contracts/client_updater/updater.sh +++ /dev/null @@ -1,74 +0,0 @@ -# before execution: create baryon_testwallet in keyring-backend test in NEUTRON_DIR/data/baryon-1 directory -# test in pion-1 testnet -CONTRACT=./artifacts/client_updater.wasm -CHAINID=pion-1 -KEYS_HOME=~/.baryon-1 -NEUTROND_BIN=neutrond -NODE=https://rpc-palvus.pion-1.ntrn.tech:443 -TEST_WALLET=baryon_testwallet -TEST_ADDR=$(${NEUTROND_BIN} keys show ${TEST_WALLET} --keyring-backend test -a --home ${KEYS_HOME}) -GAS_PRICES=0.0025untrn - -echo "Store contract" -RES=$(${NEUTROND_BIN} tx wasm store ${CONTRACT} \ - --from ${TEST_ADDR} \ - --gas 50000000 \ - --chain-id ${CHAINID} \ - --broadcast-mode=block \ - --gas-prices ${GAS_PRICES} -y \ - --output json \ - --keyring-backend test \ - --home ${KEYS_HOME} \ - --node ${NODE}) -CONTRACT_CODE_ID=$(echo $RES | jq -r '.logs[0].events[1].attributes[1].value') -echo $RES -echo $CONTRACT_CODE_ID - -INIT_MSG="{}" - -echo "Instantiate" -RES=$(${NEUTROND_BIN} tx wasm instantiate $CONTRACT_CODE_ID \ - "$INIT_MSG" \ - --from ${TEST_ADDR} \ - --admin ${TEST_ADDR} -y \ - --chain-id ${CHAINID} \ - --output json \ - --broadcast-mode=block \ - --label "init" \ - --keyring-backend test \ - --gas-prices ${GAS_PRICES} \ - --home ${KEYS_HOME} \ - --node ${NODE}) -echo $RES -CONTRACT_ADDRESS=$(echo $RES | jq -r '.logs[0].events[0].attributes[0].value') -echo $CONTRACT_ADDRESS - -echo "Client update" -RES=$(${NEUTROND_BIN} tx wasm execute $CONTRACT_ADDRESS \ - '{"submit_client_update_proposal":{"title": "update pion-1 client 07-tendermint-4 to new one", "description": "update client", "subject_client_id": "07-tendermint-4", "substitute_client_id": "07-tendermint-9"}}' \ - --amount "500untrn" \ - --from ${TEST_ADDR} -y \ - --chain-id ${CHAINID} \ - --output json \ - --broadcast-mode=block \ - --gas-prices ${GAS_PRICES} \ - --gas 1000000 \ - --keyring-backend test \ - --home ${KEYS_HOME} \ - --node ${NODE}) -echo $RES | jq - -echo "Client update 2" -RES=$(${NEUTROND_BIN} tx wasm execute $CONTRACT_ADDRESS \ - '{"submit_client_update_proposal":{"title": "update pion-1 client 07-tendermint-5 to new one", "description": "update client 2", "subject_client_id": "07-tendermint-5", "substitute_client_id": "07-tendermint-10"}}' \ - --amount "500untrn" \ - --from ${TEST_ADDR} -y \ - --chain-id ${CHAINID} \ - --output json \ - --broadcast-mode=block \ - --gas-prices ${GAS_PRICES} \ - --gas 1000000 \ - --keyring-backend test \ - --home ${KEYS_HOME} \ - --node ${NODE}) -echo $RES | jq diff --git a/contracts/dex_stargate/.cargo/config b/contracts/cron/.cargo/config similarity index 85% rename from contracts/dex_stargate/.cargo/config rename to contracts/cron/.cargo/config index 8d4bc73..11c14fd 100644 --- a/contracts/dex_stargate/.cargo/config +++ b/contracts/cron/.cargo/config @@ -3,4 +3,4 @@ wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" unit-test = "test --lib" integration-test = "test --test integration" -schema = "run --example schema" +schema = "run --example schema" \ No newline at end of file diff --git a/contracts/client_updater/Cargo.toml b/contracts/cron/Cargo.toml similarity index 90% rename from contracts/client_updater/Cargo.toml rename to contracts/cron/Cargo.toml index 52a634b..67af7a1 100644 --- a/contracts/client_updater/Cargo.toml +++ b/contracts/cron/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "client_updater" +name = "cron" version = "0.1.0" +authors = ["joldie777 "] edition = "2021" - 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", @@ -16,16 +16,15 @@ exclude = [ crate-type = ["cdylib", "rlib"] [features] -# for quicker tests, cargo test --lib library = [] [dependencies] cosmwasm-std = { workspace = true } cw2 = { workspace = true } -cw-storage-plus = { workspace = true } schemars = { workspace = true } serde = { workspace = true } neutron-sdk = { workspace = true } +cw-storage-plus = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/cron/src/contract.rs b/contracts/cron/src/contract.rs new file mode 100644 index 0000000..83f7451 --- /dev/null +++ b/contracts/cron/src/contract.rs @@ -0,0 +1,73 @@ +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use crate::state::{BEGIN_BLOCKER_SCHEDULES, END_BLOCKER_SCHEDULES}; +use cosmwasm_std::{ + entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, + StdResult, +}; +use cw2::set_contract_version; + +const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +const MODULE_ACCOUNT: &str = "neutron1cd6wafvehv79pm2yxth40thpyc7dc0yrqkyk95"; + +#[entry_point] +pub fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: InstantiateMsg, +) -> StdResult { + deps.api.debug("WASMDEBUG: instantiate"); + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + Ok(Response::default()) +} + +#[entry_point] +pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult { + deps.api + .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); + + if info.sender.as_str() != MODULE_ACCOUNT { + return Err(StdError::generic_err("Unauthorized")); + } + + match msg { + ExecuteMsg::AddBeginBlockerSchedule { name } => { + let counter = BEGIN_BLOCKER_SCHEDULES + .may_load(deps.storage, name.clone())? + .unwrap_or_default() + .checked_add(1) + .unwrap_or_default(); + + BEGIN_BLOCKER_SCHEDULES.save(deps.storage, name, &counter)?; + + Ok(Response::default()) + } + ExecuteMsg::AddEndBlockerSchedule { name } => { + let counter = END_BLOCKER_SCHEDULES + .may_load(deps.storage, name.clone())? + .unwrap_or_default() + .checked_add(1) + .unwrap_or_default(); + + END_BLOCKER_SCHEDULES.save(deps.storage, name, &counter)?; + + Ok(Response::default()) + } + } +} + +#[entry_point] +pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetBeginBlockerScheduleCounter { name } => { + let res = BEGIN_BLOCKER_SCHEDULES.may_load(deps.storage, name)?; + to_json_binary(&res) + } + QueryMsg::GetEndBlockerScheduleCounter { name } => { + let res = END_BLOCKER_SCHEDULES.may_load(deps.storage, name)?; + to_json_binary(&res) + } + } +} diff --git a/contracts/stargate_querier/src/lib.rs b/contracts/cron/src/lib.rs similarity index 97% rename from contracts/stargate_querier/src/lib.rs rename to contracts/cron/src/lib.rs index fab37e5..9159fa3 100644 --- a/contracts/stargate_querier/src/lib.rs +++ b/contracts/cron/src/lib.rs @@ -16,5 +16,4 @@ pub mod contract; pub mod msg; -mod stargate; pub mod state; diff --git a/contracts/cron/src/msg.rs b/contracts/cron/src/msg.rs new file mode 100644 index 0000000..e75d6c4 --- /dev/null +++ b/contracts/cron/src/msg.rs @@ -0,0 +1,19 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg { + AddBeginBlockerSchedule { name: String }, + AddEndBlockerSchedule { name: String }, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + GetBeginBlockerScheduleCounter { name: String }, + GetEndBlockerScheduleCounter { name: String }, +} diff --git a/contracts/cron/src/state.rs b/contracts/cron/src/state.rs new file mode 100644 index 0000000..848be2a --- /dev/null +++ b/contracts/cron/src/state.rs @@ -0,0 +1,4 @@ +use cw_storage_plus::Map; + +pub const BEGIN_BLOCKER_SCHEDULES: Map = Map::new("begin_blocker_shedules"); +pub const END_BLOCKER_SCHEDULES: Map = Map::new("end_blocker_shedules"); diff --git a/contracts/dex/Cargo.toml b/contracts/dex/Cargo.toml deleted file mode 100644 index 632a96a..0000000 --- a/contracts/dex/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "dex" -version = "0.1.0" -edition = "2021" - - -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"] - -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - -[features] -# for quicker tests, cargo test --lib -library = [] - -[dependencies] -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -schemars = { workspace = true } -serde = { version = "1.0.180", default-features = false, features = ["derive"] } -neutron-sdk = { workspace = true } - -[dev-dependencies] -cosmwasm-schema = { workspace = true } diff --git a/contracts/dex/examples/schema.rs b/contracts/dex/examples/schema.rs deleted file mode 100644 index e6413d9..0000000 --- a/contracts/dex/examples/schema.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Neutron -// -// 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. - -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use dex::contract::InstantiateMsg; -use neutron_sdk::bindings::dex::msg::DexMsg; -use neutron_sdk::bindings::dex::query::DexQuery; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(DexMsg), &out_dir); - export_schema(&schema_for!(DexQuery), &out_dir); -} diff --git a/contracts/dex/schema/dex_msg.json b/contracts/dex/schema/dex_msg.json deleted file mode 100644 index ad925fb..0000000 --- a/contracts/dex/schema/dex_msg.json +++ /dev/null @@ -1,399 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DexMsg", - "oneOf": [ - { - "description": "Deposit provides liquidity to a specific trading pair by depositing tokens at a specific price into one or both sides of the pair in “a liquidity pool”", - "type": "object", - "required": [ - "deposit" - ], - "properties": { - "deposit": { - "type": "object", - "required": [ - "amounts_a", - "amounts_b", - "fees", - "options", - "receiver", - "tick_indexes_a_to_b", - "token_a", - "token_b" - ], - "properties": { - "amounts_a": { - "description": "Amounts of tokenA to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "amounts_b": { - "description": "Amounts of tokenB to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "fees": { - "description": "Fees to use for each deposit", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "options": { - "description": "Additional deposit options", - "type": "array", - "items": { - "$ref": "#/definitions/DepositOption" - } - }, - "receiver": { - "description": "The account to which PoolShares will be issued", - "type": "string" - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Withdraw is used to redeem PoolShares for the user’s pro-rata portion of tokens within a liquidity pool. Users can withdraw from a pool at any time", - "type": "object", - "required": [ - "withdrawal" - ], - "properties": { - "withdrawal": { - "type": "object", - "required": [ - "fees", - "receiver", - "shares_to_remove", - "tick_indexes_a_to_b", - "token_a", - "token_b" - ], - "properties": { - "fees": { - "description": "Fee for the target LiquidityPools", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "receiver": { - "description": "The account to which the tokens are credited", - "type": "string" - }, - "shares_to_remove": { - "description": "Amount of shares to remove from each pool", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to trade against preexisting liquidity (“Taker Limit Orders”)", - "type": "object", - "required": [ - "place_limit_order" - ], - "properties": { - "place_limit_order": { - "type": "object", - "required": [ - "amount_in", - "limit_sell_price", - "order_type", - "receiver", - "tick_index_in_to_out", - "token_in", - "token_out" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to be traded", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "expiration_time": { - "description": "Expiration time for order. Only valid for GOOD_TIL_TIME limit orders", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "limit_sell_price": { - "description": "Accepts standard decimals and decimals with scientific notation (ie. 1234.23E-7)", - "type": "string" - }, - "max_amount_out": { - "description": "Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - }, - "order_type": { - "description": "Type of limit order to be used. Must be one of: GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME", - "allOf": [ - { - "$ref": "#/definitions/LimitOrderType" - } - ] - }, - "receiver": { - "description": "Account to which TokenOut is credited or that will be allowed to withdraw or cancel a maker order", - "type": "string" - }, - "tick_index_in_to_out": { - "description": "Limit tick for a limit order, specified in terms of TokenIn to TokenOut", - "type": "integer", - "format": "int64" - }, - "token_in": { - "description": "Token being “sold”", - "type": "string" - }, - "token_out": { - "description": "Token being “bought”", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits all available proceeds to the user. Withdraw can be called on a limit order multiple times as new proceeds become available", - "type": "object", - "required": [ - "withdraw_filled_limit_order" - ], - "properties": { - "withdraw_filled_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time) can be canceled at any time if they have not been completely filled", - "type": "object", - "required": [ - "cancel_limit_order" - ], - "properties": { - "cancel_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "MultiHopSwap provides a swapping mechanism to achieve better prices by routing through a series of pools", - "type": "object", - "required": [ - "multi_hop_swap" - ], - "properties": { - "multi_hop_swap": { - "type": "object", - "required": [ - "amount_in", - "exit_limit_price", - "pick_best_route", - "receiver", - "routes" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to swap", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "exit_limit_price": { - "description": "Minimum price that that must be satisfied for a route to succeed", - "allOf": [ - { - "$ref": "#/definitions/PrecDec" - } - ] - }, - "pick_best_route": { - "description": "If true all routes are run and the route with the best price is used", - "type": "boolean" - }, - "receiver": { - "description": "Account to which TokenOut is credited", - "type": "string" - }, - "routes": { - "description": "Array of possible routes", - "type": "array", - "items": { - "$ref": "#/definitions/MultiHopRoute" - } - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "DepositOption": { - "type": "object", - "required": [ - "disable_swap" - ], - "properties": { - "disable_swap": { - "type": "boolean" - } - } - }, - "LimitOrderType": { - "oneOf": [ - { - "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", - "type": "string", - "enum": [ - "GOOD_TIL_CANCELLED" - ] - }, - { - "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` ( ErrGoodTilOrderWithoutExpiration).", - "type": "string", - "enum": [ - "FILL_OR_KILL" - ] - }, - { - "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", - "type": "string", - "enum": [ - "IMMEDIATE_OR_CANCEL" - ] - }, - { - "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", - "type": "string", - "enum": [ - "JUST_IN_TIME" - ] - }, - { - "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", - "type": "string", - "enum": [ - "GOOD_TIL_TIME" - ] - } - ] - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/dex/schema/dex_query.json b/contracts/dex/schema/dex_query.json deleted file mode 100644 index f1dae18..0000000 --- a/contracts/dex/schema/dex_query.json +++ /dev/null @@ -1,694 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DexQuery", - "oneOf": [ - { - "description": "Parameters queries the parameters of the module.", - "type": "object", - "required": [ - "params" - ], - "properties": { - "params": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Queries a LimitOrderTrancheUser by index.", - "type": "object", - "required": [ - "limit_order_tranche_user" - ], - "properties": { - "limit_order_tranche_user": { - "type": "object", - "required": [ - "address", - "tranche_key" - ], - "properties": { - "address": { - "type": "string" - }, - "tranche_key": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of LimitOrderTrancheMap items.", - "type": "object", - "required": [ - "limit_order_tranche_user_all" - ], - "properties": { - "limit_order_tranche_user_all": { - "type": "object", - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of LimitOrderTrancheUser items for a given address.", - "type": "object", - "required": [ - "limit_order_tranche_user_all_by_address" - ], - "properties": { - "limit_order_tranche_user_all_by_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - }, - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a LimitOrderTranche by index.", - "type": "object", - "required": [ - "limit_order_tranche" - ], - "properties": { - "limit_order_tranche": { - "type": "object", - "required": [ - "pair_id", - "tick_index", - "token_in", - "tranche_key" - ], - "properties": { - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - }, - "tranche_key": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of LimitOrderTranche items for a given pairID / TokenIn combination.", - "type": "object", - "required": [ - "limit_order_tranche_all" - ], - "properties": { - "limit_order_tranche_all": { - "type": "object", - "required": [ - "pair_id", - "token_in" - ], - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - }, - "pair_id": { - "type": "string" - }, - "token_in": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of UserDeposits items.", - "type": "object", - "required": [ - "user_deposit_all" - ], - "properties": { - "user_deposit_all": { - "type": "object", - "required": [ - "address", - "include_pool_data" - ], - "properties": { - "address": { - "type": "string" - }, - "include_pool_data": { - "type": "boolean" - }, - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of TickLiquidity items.", - "type": "object", - "required": [ - "tick_liquidity_all" - ], - "properties": { - "tick_liquidity_all": { - "type": "object", - "required": [ - "pair_id", - "token_in" - ], - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - }, - "pair_id": { - "type": "string" - }, - "token_in": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a InactiveLimitOrderTranche by index.", - "type": "object", - "required": [ - "inactive_limit_order_tranche" - ], - "properties": { - "inactive_limit_order_tranche": { - "type": "object", - "required": [ - "pair_id", - "tick_index", - "token_in", - "tranche_key" - ], - "properties": { - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - }, - "tranche_key": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of InactiveLimitOrderTranche items.", - "type": "object", - "required": [ - "inactive_limit_order_tranche_all" - ], - "properties": { - "inactive_limit_order_tranche_all": { - "type": "object", - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of PoolReserves items.", - "type": "object", - "required": [ - "pool_reserves_all" - ], - "properties": { - "pool_reserves_all": { - "type": "object", - "required": [ - "pair_id", - "token_in" - ], - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - }, - "pair_id": { - "type": "string" - }, - "token_in": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a PoolReserve by index", - "type": "object", - "required": [ - "pool_reserves" - ], - "properties": { - "pool_reserves": { - "type": "object", - "required": [ - "fee", - "pair_id", - "tick_index", - "token_in" - ], - "properties": { - "fee": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries the simulated result of a multihop swap", - "type": "object", - "required": [ - "estimate_multi_hop_swap" - ], - "properties": { - "estimate_multi_hop_swap": { - "type": "object", - "required": [ - "amount_in", - "creator", - "exit_limit_price", - "pick_best_route", - "receiver", - "routes" - ], - "properties": { - "amount_in": { - "$ref": "#/definitions/Int128" - }, - "creator": { - "type": "string" - }, - "exit_limit_price": { - "$ref": "#/definitions/PrecDec" - }, - "pick_best_route": { - "type": "boolean" - }, - "receiver": { - "type": "string" - }, - "routes": { - "type": "array", - "items": { - "$ref": "#/definitions/MultiHopRoute" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries the simulated result of a PlaceLimit order", - "type": "object", - "required": [ - "estimate_place_limit_order" - ], - "properties": { - "estimate_place_limit_order": { - "type": "object", - "required": [ - "amount_in", - "creator", - "order_type", - "receiver", - "tick_index_in_to_out", - "token_in", - "token_out" - ], - "properties": { - "amount_in": { - "$ref": "#/definitions/Int128" - }, - "creator": { - "type": "string" - }, - "expiration_time": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "max_amount_out": { - "anyOf": [ - { - "$ref": "#/definitions/Int128" - }, - { - "type": "null" - } - ] - }, - "order_type": { - "$ref": "#/definitions/LimitOrderType" - }, - "receiver": { - "type": "string" - }, - "tick_index_in_to_out": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - }, - "token_out": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a pool by pair, tick and fee", - "type": "object", - "required": [ - "pool" - ], - "properties": { - "pool": { - "type": "object", - "required": [ - "fee", - "pair_id", - "tick_index" - ], - "properties": { - "fee": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a pool by ID", - "type": "object", - "required": [ - "pool_by_id" - ], - "properties": { - "pool_by_id": { - "type": "object", - "required": [ - "pool_id" - ], - "properties": { - "pool_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a PoolMetadata by ID", - "type": "object", - "required": [ - "pool_metadata" - ], - "properties": { - "pool_metadata": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of PoolMetadata items.", - "type": "object", - "required": [ - "pool_metadata_all" - ], - "properties": { - "pool_metadata_all": { - "type": "object", - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" - }, - "Int128": { - "description": "An implementation of i128 that is using strings for JSON encoding/decoding, such that the full i128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `i128` to get the value out:\n\n``` # use cosmwasm_std::Int128; let a = Int128::from(258i128); assert_eq!(a.i128(), 258); ```", - "type": "string" - }, - "LimitOrderType": { - "oneOf": [ - { - "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", - "type": "string", - "enum": [ - "GOOD_TIL_CANCELLED" - ] - }, - { - "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` ( ErrGoodTilOrderWithoutExpiration).", - "type": "string", - "enum": [ - "FILL_OR_KILL" - ] - }, - { - "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", - "type": "string", - "enum": [ - "IMMEDIATE_OR_CANCEL" - ] - }, - { - "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", - "type": "string", - "enum": [ - "JUST_IN_TIME" - ] - }, - { - "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", - "type": "string", - "enum": [ - "GOOD_TIL_TIME" - ] - } - ] - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "PageRequest": { - "type": "object", - "required": [ - "count_total", - "key", - "limit", - "offset", - "reverse" - ], - "properties": { - "count_total": { - "description": "**count_total** is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set.", - "type": "boolean" - }, - "key": { - "description": "**key** is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set.", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "limit": { - "description": "**limit** is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "offset": { - "description": "**offset** is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "reverse": { - "description": "reverse is set to true if results are to be returned in the descending order.", - "type": "boolean" - } - } - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - } - } - } -} diff --git a/contracts/dex/src/contract.rs b/contracts/dex/src/contract.rs deleted file mode 100644 index 5d0f732..0000000 --- a/contracts/dex/src/contract.rs +++ /dev/null @@ -1,147 +0,0 @@ -use cosmwasm_std::{ - entry_point, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, -}; -use cw2::set_contract_version; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -use neutron_sdk::bindings::{ - dex::msg::DexMsg, - dex::query::{ - AllInactiveLimitOrderTrancheResponse, AllLimitOrderTrancheResponse, - AllLimitOrderTrancheUserResponse, AllPoolMetadataResponse, AllPoolReservesResponse, - AllTickLiquidityResponse, AllUserDepositsResponse, AllUserLimitOrdersResponse, DexQuery, - EstimateMultiHopSwapResponse, EstimatePlaceLimitOrderResponse, - InactiveLimitOrderTrancheResponse, LimitOrderTrancheResponse, - LimitOrderTrancheUserResponse, ParamsResponse, PoolMetadataResponse, PoolReservesResponse, - PoolResponse, - }, - msg::NeutronMsg, - query::NeutronQuery, -}; - -const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - deps.api.debug("WASMDEBUG: instantiate"); - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: DexMsg, -) -> StdResult> { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - execute_dex(deps, env, info, msg) -} - -fn execute_dex( - _deps: DepsMut, - _env: Env, - _: MessageInfo, - msg: DexMsg, -) -> StdResult> { - Ok(Response::default().add_message(CosmosMsg::Custom(NeutronMsg::Dex(msg)))) -} - -#[entry_point] -pub fn query(deps: Deps, env: Env, msg: DexQuery) -> StdResult { - query_dex(deps, env, msg) -} - -fn query_dex(deps: Deps, _env: Env, msg: DexQuery) -> StdResult { - match msg { - DexQuery::Params {} => { - let query_response: ParamsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheUser { .. } => { - let query_response: LimitOrderTrancheUserResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheUserAll { .. } => { - let query_response: AllLimitOrderTrancheUserResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheUserAllByAddress { .. } => { - let query_response: AllUserLimitOrdersResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTranche { .. } => { - let query_response: LimitOrderTrancheResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheAll { .. } => { - let query_response: AllLimitOrderTrancheResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::UserDepositAll { .. } => { - let query_response: AllUserDepositsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::TickLiquidityAll { .. } => { - let query_response: AllTickLiquidityResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::InactiveLimitOrderTranche { .. } => { - let query_response: InactiveLimitOrderTrancheResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::InactiveLimitOrderTrancheAll { .. } => { - let query_response: AllInactiveLimitOrderTrancheResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolReservesAll { .. } => { - let query_response: AllPoolReservesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolReserves { .. } => { - let query_response: PoolReservesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::EstimateMultiHopSwap { .. } => { - let query_response: EstimateMultiHopSwapResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::EstimatePlaceLimitOrder { .. } => { - let query_response: EstimatePlaceLimitOrderResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::Pool { .. } => { - let query_response: PoolResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolByID { .. } => { - let query_response: PoolResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolMetadata { .. } => { - let query_response: PoolMetadataResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolMetadataAll { .. } => { - let query_response: AllPoolMetadataResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - } -} diff --git a/contracts/dex/src/lib.rs b/contracts/dex/src/lib.rs deleted file mode 100644 index 2943dbb..0000000 --- a/contracts/dex/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod contract; diff --git a/contracts/dex/.cargo/config b/contracts/dex_grpc/.cargo/config similarity index 100% rename from contracts/dex/.cargo/config rename to contracts/dex_grpc/.cargo/config diff --git a/contracts/dex_stargate/Cargo.toml b/contracts/dex_grpc/Cargo.toml similarity index 91% rename from contracts/dex_stargate/Cargo.toml rename to contracts/dex_grpc/Cargo.toml index 093fabc..c36eb12 100644 --- a/contracts/dex_stargate/Cargo.toml +++ b/contracts/dex_grpc/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "dex_stargate" +name = "dex_grpc" version = "0.1.0" edition = "2021" @@ -32,7 +32,8 @@ library = [] [dependencies] neutron-sdk = { workspace = true } -cosmwasm-std = { workspace = true, features = ["stargate"] } +neutron-std = { workspace = true } +cosmwasm-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { version = "1.0.188", default-features = false, features = ["derive"] } diff --git a/contracts/dex/README.md b/contracts/dex_grpc/README.md similarity index 85% rename from contracts/dex/README.md rename to contracts/dex_grpc/README.md index 5fae2c9..9097799 100644 --- a/contracts/dex/README.md +++ b/contracts/dex_grpc/README.md @@ -1,3 +1,3 @@ -# Dex +# Dex Grpc This contract is used for tests in the main neutron repository. diff --git a/contracts/dex_stargate/examples/schema.rs b/contracts/dex_grpc/examples/schema.rs similarity index 94% rename from contracts/dex_stargate/examples/schema.rs rename to contracts/dex_grpc/examples/schema.rs index 55953d2..25b582a 100644 --- a/contracts/dex_stargate/examples/schema.rs +++ b/contracts/dex_grpc/examples/schema.rs @@ -16,7 +16,7 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use dex_stargate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use dex_grpc::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/dex_stargate/schema/execute_msg.json b/contracts/dex_grpc/schema/execute_msg.json similarity index 76% rename from contracts/dex_stargate/schema/execute_msg.json rename to contracts/dex_grpc/schema/execute_msg.json index 4fb2dd9..415e13e 100644 --- a/contracts/dex_stargate/schema/execute_msg.json +++ b/contracts/dex_grpc/schema/execute_msg.json @@ -63,7 +63,8 @@ "token_b": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -115,7 +116,8 @@ "token_b": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -131,6 +133,7 @@ "required": [ "amount_in", "limit_sell_price", + "max_amount_out", "order_type", "receiver", "tick_index_in_to_out", @@ -142,20 +145,20 @@ "type": "string" }, "expiration_time": { - "type": [ - "integer", - "null" - ], - "format": "int64" + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] }, "limit_sell_price": { "type": "string" }, "max_amount_out": { - "type": [ - "string", - "null" - ] + "type": "string" }, "order_type": { "type": "integer", @@ -174,7 +177,8 @@ "token_out": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -194,7 +198,8 @@ "tranche_key": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -214,7 +219,8 @@ "tranche_key": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -250,13 +256,11 @@ "routes": { "type": "array", "items": { - "type": "array", - "items": { - "type": "string" - } + "$ref": "#/definitions/MultiHopRoute" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -266,14 +270,53 @@ "DepositOptions": { "type": "object", "required": [ - "disable_autoswap" + "disable_autoswap", + "fail_tx_on_bel" ], "properties": { "disable_autoswap": { - "description": "Autoswap provides a mechanism for users to deposit the entirety of their specified deposit amounts by paying a small fee. By default the `autoswap` option is enabled.", "type": "boolean" + }, + "fail_tx_on_bel": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "MultiHopRoute": { + "type": "object", + "required": [ + "hops" + ], + "properties": { + "hops": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "Timestamp": { + "type": "object", + "required": [ + "nanos", + "seconds" + ], + "properties": { + "nanos": { + "description": "Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive.", + "type": "integer", + "format": "int32" + }, + "seconds": { + "description": "Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.", + "type": "integer", + "format": "int64" } - } + }, + "additionalProperties": false } } } diff --git a/contracts/client_updater/schema/instantiate_msg.json b/contracts/dex_grpc/schema/instantiate_msg.json similarity index 63% rename from contracts/client_updater/schema/instantiate_msg.json rename to contracts/dex_grpc/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/client_updater/schema/instantiate_msg.json +++ b/contracts/dex_grpc/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/dex_stargate/schema/query_msg.json b/contracts/dex_grpc/schema/query_msg.json similarity index 51% rename from contracts/dex_stargate/schema/query_msg.json rename to contracts/dex_grpc/schema/query_msg.json index 80e2940..7122ae1 100644 --- a/contracts/dex_stargate/schema/query_msg.json +++ b/contracts/dex_grpc/schema/query_msg.json @@ -9,7 +9,8 @@ ], "properties": { "params": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -37,7 +38,8 @@ "tranche_key": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -61,7 +63,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -91,7 +94,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -124,7 +128,8 @@ "tranche_key": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -158,7 +163,8 @@ "token_in": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -192,7 +198,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -226,7 +233,8 @@ "token_in": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -259,7 +267,8 @@ "tranche_key": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -283,7 +292,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -317,7 +327,8 @@ "token_in": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -352,7 +363,8 @@ "token_in": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -392,13 +404,11 @@ "routes": { "type": "array", "items": { - "type": "array", - "items": { - "type": "string" - } + "$ref": "#/definitions/MultiHopRoute" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -414,6 +424,7 @@ "required": [ "amount_in", "creator", + "max_amount_out", "order_type", "receiver", "tick_index_in_to_out", @@ -428,17 +439,17 @@ "type": "string" }, "expiration_time": { - "type": [ - "integer", - "null" - ], - "format": "int64" + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] }, "max_amount_out": { - "type": [ - "string", - "null" - ] + "type": "string" }, "order_type": { "type": "integer", @@ -457,7 +468,8 @@ "token_out": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -488,7 +500,8 @@ "type": "integer", "format": "int64" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -510,7 +523,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -532,7 +546,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -556,18 +571,415 @@ } ] } - } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_deposit" + ], + "properties": { + "simulate_deposit": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgDeposit" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_withdrawal" + ], + "properties": { + "simulate_withdrawal": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgWithdrawal" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_place_limit_order" + ], + "properties": { + "simulate_place_limit_order": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgPlaceLimitOrder" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_withdraw_filled_limit_order" + ], + "properties": { + "simulate_withdraw_filled_limit_order": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgWithdrawFilledLimitOrder" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_cancel_limit_order" + ], + "properties": { + "simulate_cancel_limit_order": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgCancelLimitOrder" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "simulate_multi_hop_swap" + ], + "properties": { + "simulate_multi_hop_swap": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/MsgMultiHopSwap" + } + }, + "additionalProperties": false } }, "additionalProperties": false } ], "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" + "DepositOptions": { + "type": "object", + "required": [ + "disable_autoswap", + "fail_tx_on_bel" + ], + "properties": { + "disable_autoswap": { + "type": "boolean" + }, + "fail_tx_on_bel": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "MsgCancelLimitOrder": { + "type": "object", + "required": [ + "creator", + "tranche_key" + ], + "properties": { + "creator": { + "type": "string" + }, + "tranche_key": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgDeposit": { + "type": "object", + "required": [ + "amounts_a", + "amounts_b", + "creator", + "fees", + "options", + "receiver", + "tick_indexes_a_to_b", + "token_a", + "token_b" + ], + "properties": { + "amounts_a": { + "type": "array", + "items": { + "type": "string" + } + }, + "amounts_b": { + "type": "array", + "items": { + "type": "string" + } + }, + "creator": { + "type": "string" + }, + "fees": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "options": { + "type": "array", + "items": { + "$ref": "#/definitions/DepositOptions" + } + }, + "receiver": { + "type": "string" + }, + "tick_indexes_a_to_b": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "token_a": { + "type": "string" + }, + "token_b": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgMultiHopSwap": { + "type": "object", + "required": [ + "amount_in", + "creator", + "exit_limit_price", + "pick_best_route", + "receiver", + "routes" + ], + "properties": { + "amount_in": { + "type": "string" + }, + "creator": { + "type": "string" + }, + "exit_limit_price": { + "type": "string" + }, + "pick_best_route": { + "description": "If pickBestRoute == true then all routes are run and the route with the best price is chosen otherwise, the first succesful route is used.", + "type": "boolean" + }, + "receiver": { + "type": "string" + }, + "routes": { + "type": "array", + "items": { + "$ref": "#/definitions/MultiHopRoute" + } + } + }, + "additionalProperties": false + }, + "MsgPlaceLimitOrder": { + "type": "object", + "required": [ + "amount_in", + "creator", + "limit_sell_price", + "max_amount_out", + "min_average_sell_price", + "order_type", + "receiver", + "tick_index_in_to_out", + "token_in", + "token_out" + ], + "properties": { + "amount_in": { + "type": "string" + }, + "creator": { + "type": "string" + }, + "expiration_time": { + "description": "expirationTime is only valid iff orderType == GOOD_TIL_TIME.", + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + }, + "limit_sell_price": { + "type": "string" + }, + "max_amount_out": { + "type": "string" + }, + "min_average_sell_price": { + "description": "min_average_sell_price is an optional parameter that sets a required minimum average price for the entire trade. if the min_average_sell_price is not met the trade will fail. If min_average_sell_price is omitted limit_sell_price will be used instead", + "type": "string" + }, + "order_type": { + "type": "integer", + "format": "int32" + }, + "receiver": { + "type": "string" + }, + "tick_index_in_to_out": { + "description": "DEPRECATED: tick_index_in_to_out will be removed in future release; limit_sell_price should be used instead.", + "deprecated": true, + "type": "integer", + "format": "int64" + }, + "token_in": { + "type": "string" + }, + "token_out": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgWithdrawFilledLimitOrder": { + "type": "object", + "required": [ + "creator", + "tranche_key" + ], + "properties": { + "creator": { + "type": "string" + }, + "tranche_key": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MsgWithdrawal": { + "type": "object", + "required": [ + "creator", + "fees", + "receiver", + "shares_to_remove", + "tick_indexes_a_to_b", + "token_a", + "token_b" + ], + "properties": { + "creator": { + "type": "string" + }, + "fees": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "receiver": { + "type": "string" + }, + "shares_to_remove": { + "type": "array", + "items": { + "type": "string" + } + }, + "tick_indexes_a_to_b": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "token_a": { + "type": "string" + }, + "token_b": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MultiHopRoute": { + "type": "object", + "required": [ + "hops" + ], + "properties": { + "hops": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false }, "PageRequest": { + "description": "PageRequest is to be embedded in gRPC request messages for efficient pagination. Ex:\n\nmessage SomeRequest { Foo some_parameter = 1; PageRequest pagination = 2; }", "type": "object", "required": [ "count_total", @@ -578,34 +990,56 @@ ], "properties": { "count_total": { - "description": "**count_total** is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set.", + "description": "count_total is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set.", "type": "boolean" }, "key": { - "description": "**key** is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set.", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] + "description": "key is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set.", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + } }, "limit": { - "description": "**limit** is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app.", + "description": "limit is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app.", "type": "integer", "format": "uint64", "minimum": 0.0 }, "offset": { - "description": "**offset** is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set.", + "description": "offset is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set.", "type": "integer", "format": "uint64", "minimum": 0.0 }, "reverse": { - "description": "reverse is set to true if results are to be returned in the descending order.", + "description": "reverse is set to true if results are to be returned in the descending order.\n\nSince: cosmos-sdk 0.43", "type": "boolean" } - } + }, + "additionalProperties": false + }, + "Timestamp": { + "type": "object", + "required": [ + "nanos", + "seconds" + ], + "properties": { + "nanos": { + "description": "Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive.", + "type": "integer", + "format": "int32" + }, + "seconds": { + "description": "Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.", + "type": "integer", + "format": "int64" + } + }, + "additionalProperties": false } } } diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs new file mode 100644 index 0000000..00dba8f --- /dev/null +++ b/contracts/dex_grpc/src/contract.rs @@ -0,0 +1,322 @@ +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use cosmwasm_std::{ + entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, +}; +use cw2::set_contract_version; +use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::dex::{ + DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, + MsgWithdrawFilledLimitOrder, MsgWithdrawal, +}; + +const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[entry_point] +pub fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: InstantiateMsg, +) -> StdResult { + deps.api.debug("WASMDEBUG: instantiate"); + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + Ok(Response::default()) +} + +#[entry_point] +pub fn execute( + deps: DepsMut, + env: Env, + _info: MessageInfo, + msg: ExecuteMsg, +) -> StdResult { + deps.api + .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); + match msg { + ExecuteMsg::Deposit { + receiver, + token_a, + token_b, + amounts_a, + amounts_b, + tick_indexes_a_to_b, + fees, + options, + } => Ok(Response::new().add_message(MsgDeposit { + creator: env.contract.address.to_string(), + receiver, + token_a, + token_b, + amounts_a, + amounts_b, + tick_indexes_a_to_b, + fees, + options, + })), + + ExecuteMsg::Withdrawal { + receiver, + token_a, + token_b, + shares_to_remove, + tick_indexes_a_to_b, + fees, + } => Ok(Response::new().add_message(MsgWithdrawal { + creator: env.contract.address.to_string(), + receiver, + token_a, + token_b, + shares_to_remove, + tick_indexes_a_to_b, + fees, + })), + #[allow(deprecated)] + ExecuteMsg::PlaceLimitOrder { + receiver, + token_in, + token_out, + tick_index_in_to_out, + limit_sell_price, + amount_in, + order_type, + expiration_time, + max_amount_out, + } => Ok(Response::new().add_message(MsgPlaceLimitOrder { + creator: env.contract.address.to_string(), + receiver, + token_in, + token_out, + tick_index_in_to_out, + limit_sell_price, + amount_in, + order_type, + expiration_time, + max_amount_out, + min_average_sell_price: "".to_string(), + })), + ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => { + Ok(Response::new().add_message(MsgWithdrawFilledLimitOrder { + creator: env.contract.address.to_string(), + tranche_key, + })) + } + + ExecuteMsg::CancelLimitOrder { tranche_key } => { + Ok(Response::new().add_message(MsgCancelLimitOrder { + creator: env.contract.address.to_string(), + tranche_key, + })) + } + + ExecuteMsg::MultiHopSwap { + receiver, + routes, + amount_in, + exit_limit_price, + pick_best_route, + } => Ok(Response::new().add_message(MsgMultiHopSwap { + creator: env.contract.address.to_string(), + receiver, + routes, + amount_in, + exit_limit_price, + pick_best_route, + })), + } +} + +#[entry_point] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + deps.api + .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); + + let dex_querier = DexQuerier::new(&deps.querier); + + match msg { + QueryMsg::Params {} => Ok(to_json_binary(&dex_querier.params()?)?), + + QueryMsg::GetLimitOrderTrancheUser { + address, + tranche_key, + calc_withdrawable_shares, + } => Ok(to_json_binary(&dex_querier.limit_order_tranche_user( + address, + tranche_key, + calc_withdrawable_shares, + )?)?), + + QueryMsg::AllLimitOrderTrancheUser { pagination } => Ok(to_json_binary( + &dex_querier.limit_order_tranche_user_all(pagination)?, + )?), + + QueryMsg::AllLimitOrderTrancheUserByAddress { + address, + pagination, + } => Ok(to_json_binary( + &dex_querier.limit_order_tranche_user_all_by_address(address, pagination)?, + )?), + + QueryMsg::GetLimitOrderTranche { + pair_id, + tick_index, + token_in, + tranche_key, + } => Ok(to_json_binary(&dex_querier.limit_order_tranche( + pair_id, + tick_index, + token_in, + tranche_key, + )?)?), + + QueryMsg::AllLimitOrderTranche { + pair_id, + token_in, + pagination, + } => Ok(to_json_binary( + &dex_querier.limit_order_tranche_all(pair_id, token_in, pagination)?, + )?), + + QueryMsg::AllUserDeposits { + address, + include_pool_data, + pagination, + } => Ok(to_json_binary(&dex_querier.user_deposits_all( + address, + pagination, + include_pool_data, + )?)?), + + QueryMsg::AllTickLiquidity { + pair_id, + token_in, + pagination, + } => Ok(to_json_binary( + &dex_querier.tick_liquidity_all(pair_id, token_in, pagination)?, + )?), + + QueryMsg::GetInactiveLimitOrderTranche { + pair_id, + token_in, + tick_index, + tranche_key, + } => Ok(to_json_binary(&dex_querier.inactive_limit_order_tranche( + pair_id, + token_in, + tick_index, + tranche_key, + )?)?), + + QueryMsg::AllInactiveLimitOrderTranche { pagination } => Ok(to_json_binary( + &dex_querier.inactive_limit_order_tranche_all(pagination)?, + )?), + + QueryMsg::AllPoolReserves { + pair_id, + token_in, + pagination, + } => Ok(to_json_binary( + &dex_querier.pool_reserves_all(pair_id, token_in, pagination)?, + )?), + + QueryMsg::GetPoolReserves { + pair_id, + token_in, + tick_index, + fee, + } => Ok(to_json_binary( + &dex_querier.pool_reserves(pair_id, token_in, tick_index, fee)?, + )?), + + #[allow(deprecated)] // Allow deprecated call until its remove from neutron-core + QueryMsg::EstimateMultiHopSwap { + creator, + receiver, + routes, + amount_in, + exit_limit_price, + pick_best_route, + } => Ok(to_json_binary(&dex_querier.estimate_multi_hop_swap( + creator, + receiver, + routes, + amount_in, + exit_limit_price, + pick_best_route, + )?)?), + + #[allow(deprecated)] // Allow deprecated call until its remove from neutron-core + QueryMsg::EstimatePlaceLimitOrder { + creator, + receiver, + token_in, + token_out, + tick_index_in_to_out, + amount_in, + order_type, + expiration_time, + max_amount_out, + } => Ok(to_json_binary(&dex_querier.estimate_place_limit_order( + creator, + receiver, + token_in, + token_out, + tick_index_in_to_out, + amount_in, + order_type, + expiration_time, + max_amount_out, + )?)?), + + QueryMsg::Pool { + pair_id, + tick_index, + fee, + } => Ok(to_json_binary( + &dex_querier.pool(pair_id, tick_index, fee)?, + )?), + + QueryMsg::PoolById { pool_id } => Ok(to_json_binary(&dex_querier.pool_by_id(pool_id)?)?), + + QueryMsg::GetPoolMetadata { id } => Ok(to_json_binary(&dex_querier.pool_metadata(id)?)?), + + QueryMsg::AllPoolMetadata { pagination } => { + Ok(to_json_binary(&dex_querier.pool_metadata_all(pagination)?)?) + } + + QueryMsg::SimulateDeposit { msg } => { + Ok(to_json_binary(&dex_querier.simulate_deposit(Some(msg))?)?) + } + + QueryMsg::SimulateWithdrawal { msg } => Ok(to_json_binary( + &dex_querier.simulate_withdrawal(Some(msg))?, + )?), + + QueryMsg::SimulatePlaceLimitOrder { msg } => Ok(to_json_binary( + &dex_querier.simulate_place_limit_order(Some(msg))?, + )?), + + QueryMsg::SimulateWithdrawFilledLimitOrder { msg } => Ok(to_json_binary( + &dex_querier.simulate_withdraw_filled_limit_order(Some(msg))?, + )?), + + QueryMsg::SimulateCancelLimitOrder { msg } => Ok(to_json_binary( + &dex_querier.simulate_cancel_limit_order(Some(msg))?, + )?), + + QueryMsg::SimulateMultiHopSwap { msg } => Ok(to_json_binary( + &dex_querier.simulate_multi_hop_swap(Some(msg))?, + )?), + } +} + +#[entry_point] +pub fn sudo(_deps: DepsMut, _env: Env, _msg: SudoMsg) -> StdResult { + Ok(Response::default()) +} + +#[entry_point] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { + deps.api.debug("WASMDEBUG: migrate"); + Ok(Response::default()) +} diff --git a/contracts/dex_stargate/src/lib.rs b/contracts/dex_grpc/src/lib.rs similarity index 100% rename from contracts/dex_stargate/src/lib.rs rename to contracts/dex_grpc/src/lib.rs diff --git a/contracts/dex_stargate/src/msg.rs b/contracts/dex_grpc/src/msg.rs similarity index 78% rename from contracts/dex_stargate/src/msg.rs rename to contracts/dex_grpc/src/msg.rs index b6c06fc..27aafb5 100644 --- a/contracts/dex_stargate/src/msg.rs +++ b/contracts/dex_grpc/src/msg.rs @@ -1,5 +1,9 @@ -use neutron_sdk::bindings::query::PageRequest; -use neutron_sdk::stargate::dex::types::DepositOptions; +use neutron_std::shim::Timestamp; +use neutron_std::types::cosmos::base::query::v1beta1::PageRequest; +use neutron_std::types::neutron::dex::{ + DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, + MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -34,8 +38,8 @@ pub enum ExecuteMsg { tick_index_in_to_out: i64, amount_in: String, order_type: i32, - expiration_time: Option, - max_amount_out: Option, + expiration_time: Option, + max_amount_out: String, limit_sell_price: String, }, WithdrawFilledLimitOrder { @@ -46,7 +50,7 @@ pub enum ExecuteMsg { }, MultiHopSwap { receiver: String, - routes: Vec>, + routes: Vec, amount_in: String, exit_limit_price: String, pick_best_route: bool, @@ -113,7 +117,7 @@ pub enum QueryMsg { EstimateMultiHopSwap { creator: String, receiver: String, - routes: Vec>, + routes: Vec, amount_in: String, exit_limit_price: String, pick_best_route: bool, @@ -126,8 +130,8 @@ pub enum QueryMsg { tick_index_in_to_out: i64, amount_in: String, order_type: i32, - expiration_time: Option, - max_amount_out: Option, + expiration_time: Option, + max_amount_out: String, }, Pool { pair_id: String, @@ -143,6 +147,24 @@ pub enum QueryMsg { AllPoolMetadata { pagination: Option, }, + SimulateDeposit { + msg: MsgDeposit, + }, + SimulateWithdrawal { + msg: MsgWithdrawal, + }, + SimulatePlaceLimitOrder { + msg: MsgPlaceLimitOrder, + }, + SimulateWithdrawFilledLimitOrder { + msg: MsgWithdrawFilledLimitOrder, + }, + SimulateCancelLimitOrder { + msg: MsgCancelLimitOrder, + }, + SimulateMultiHopSwap { + msg: MsgMultiHopSwap, + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/contracts/dex_stargate/README.md b/contracts/dex_stargate/README.md deleted file mode 100644 index 2a5d5da..0000000 --- a/contracts/dex_stargate/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Dex Stargate - -This contract is used for tests in the main neutron repository. diff --git a/contracts/dex_stargate/schema/instantiate_msg.json b/contracts/dex_stargate/schema/instantiate_msg.json deleted file mode 100644 index 44588cf..0000000 --- a/contracts/dex_stargate/schema/instantiate_msg.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object" -} diff --git a/contracts/dex_stargate/src/contract.rs b/contracts/dex_stargate/src/contract.rs deleted file mode 100644 index 7a8e314..0000000 --- a/contracts/dex_stargate/src/contract.rs +++ /dev/null @@ -1,384 +0,0 @@ -use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use cosmwasm_std::{ - entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, - StdResult, -}; -use cw2::set_contract_version; -use neutron_sdk::{ - bindings::msg::NeutronMsg, - stargate::dex::msg::{ - msg_cancel_limit_order, msg_deposit, msg_multi_hop_swap, msg_place_limit_order, - msg_withdraw_filled_limit_order, msg_withdrawal, - }, - stargate::dex::query::{ - get_estimate_multi_hop_swap, get_estimate_place_limit_order, - get_inactive_limit_order_tranche, get_inactive_limit_order_tranche_all, - get_limit_order_tranche, get_limit_order_tranche_all, get_limit_order_tranche_user, - get_limit_order_tranche_user_all, get_limit_order_tranche_user_all_by_address, get_params, - get_pool, get_pool_by_id, get_pool_metadata, get_pool_metadata_all, get_pool_reserves, - get_pool_reserves_all, get_tick_liquidity_all, get_user_deposits_all, - }, - stargate::dex::types::{ - AllInactiveLimitOrderTrancheRequest, AllLimitOrderTrancheRequest, AllPoolMetadataRequest, - AllPoolReservesRequest, AllTickLiquidityRequest, AllUserDepositsRequest, - AllUserLimitOrdersRequest, CancelLimitOrderRequest, DepositRequest, - EstimateMultiHopSwapRequest, EstimatePlaceLimitOrderRequest, - GetInactiveLimitOrderTrancheRequest, GetLimitOrderTrancheRequest, GetPoolMetadataRequest, - GetPoolReservesRequest, LimitOrderTrancheUserAllRequest, LimitOrderTrancheUserRequest, - LimitOrderType, MultiHopSwapRequest, ParamsRequest, PlaceLimitOrderRequest, - PoolByIdRequest, PoolRequest, WithdrawFilledLimitOrderRequest, WithdrawalRequest, - }, - sudo::msg::SudoMsg, -}; - -const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - deps.api.debug("WASMDEBUG: instantiate"); - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - _info: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - match msg { - ExecuteMsg::Deposit { - receiver, - token_a, - token_b, - amounts_a, - amounts_b, - tick_indexes_a_to_b, - fees, - options, - } => Ok(Response::new().add_message(msg_deposit(DepositRequest { - sender: env.contract.address.to_string(), - receiver, - token_a, - token_b, - amounts_a, - amounts_b, - tick_indexes_a_to_b, - fees, - options, - }))), - - ExecuteMsg::Withdrawal { - receiver, - token_a, - token_b, - shares_to_remove, - tick_indexes_a_to_b, - fees, - } => Ok( - Response::new().add_message(msg_withdrawal(WithdrawalRequest { - sender: env.contract.address.to_string(), - receiver, - token_a, - token_b, - shares_to_remove, - tick_indexes_a_to_b, - fees, - })), - ), - - ExecuteMsg::PlaceLimitOrder { - receiver, - token_in, - token_out, - tick_index_in_to_out, - limit_sell_price, - amount_in, - order_type, - expiration_time, - max_amount_out, - } => Ok( - Response::new().add_message(msg_place_limit_order(PlaceLimitOrderRequest { - sender: env.contract.address.to_string(), - receiver, - token_in, - token_out, - tick_index_in_to_out, - limit_sell_price, - amount_in, - order_type: LimitOrderType::try_from(order_type).map_err(StdError::generic_err)?, - expiration_time, - max_amount_out, - })), - ), - - ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message( - msg_withdraw_filled_limit_order(WithdrawFilledLimitOrderRequest { - sender: env.contract.address.to_string(), - tranche_key, - }), - )), - - ExecuteMsg::CancelLimitOrder { tranche_key } => Ok(Response::new().add_message( - msg_cancel_limit_order(CancelLimitOrderRequest { - sender: env.contract.address.to_string(), - tranche_key, - }), - )), - - ExecuteMsg::MultiHopSwap { - receiver, - routes, - amount_in, - exit_limit_price, - pick_best_route, - } => Ok( - Response::new().add_message(msg_multi_hop_swap(MultiHopSwapRequest { - sender: env.contract.address.to_string(), - receiver, - routes, - amount_in, - exit_limit_price, - pick_best_route, - })), - ), - } -} - -#[entry_point] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - deps.api - .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); - match msg { - QueryMsg::Params {} => Ok(to_json_binary(&get_params(deps, ParamsRequest {})?)?), - - QueryMsg::GetLimitOrderTrancheUser { - address, - tranche_key, - calc_withdrawable_shares, - } => Ok(to_json_binary(&get_limit_order_tranche_user( - deps, - LimitOrderTrancheUserRequest { - address, - tranche_key, - calc_withdrawable_shares, - }, - )?)?), - - QueryMsg::AllLimitOrderTrancheUser { pagination } => { - Ok(to_json_binary(&get_limit_order_tranche_user_all( - deps, - LimitOrderTrancheUserAllRequest { pagination }, - )?)?) - } - - QueryMsg::AllLimitOrderTrancheUserByAddress { - address, - pagination, - } => Ok(to_json_binary( - &get_limit_order_tranche_user_all_by_address( - deps, - AllUserLimitOrdersRequest { - address, - pagination, - }, - )?, - )?), - - QueryMsg::GetLimitOrderTranche { - pair_id, - tick_index, - token_in, - tranche_key, - } => Ok(to_json_binary(&get_limit_order_tranche( - deps, - GetLimitOrderTrancheRequest { - pair_id, - tick_index, - token_in, - tranche_key, - }, - )?)?), - - QueryMsg::AllLimitOrderTranche { - pair_id, - token_in, - pagination, - } => Ok(to_json_binary(&get_limit_order_tranche_all( - deps, - AllLimitOrderTrancheRequest { - pair_id, - token_in, - pagination, - }, - )?)?), - - QueryMsg::AllUserDeposits { - address, - include_pool_data, - pagination, - } => Ok(to_json_binary(&get_user_deposits_all( - deps, - AllUserDepositsRequest { - address, - include_pool_data, - pagination, - }, - )?)?), - - QueryMsg::AllTickLiquidity { - pair_id, - token_in, - pagination, - } => Ok(to_json_binary(&get_tick_liquidity_all( - deps, - AllTickLiquidityRequest { - pair_id, - token_in, - pagination, - }, - )?)?), - - QueryMsg::GetInactiveLimitOrderTranche { - pair_id, - token_in, - tick_index, - tranche_key, - } => Ok(to_json_binary(&get_inactive_limit_order_tranche( - deps, - GetInactiveLimitOrderTrancheRequest { - pair_id, - token_in, - tick_index, - tranche_key, - }, - )?)?), - - QueryMsg::AllInactiveLimitOrderTranche { pagination } => { - Ok(to_json_binary(&get_inactive_limit_order_tranche_all( - deps, - AllInactiveLimitOrderTrancheRequest { pagination }, - )?)?) - } - - QueryMsg::AllPoolReserves { - pair_id, - token_in, - pagination, - } => Ok(to_json_binary(&get_pool_reserves_all( - deps, - AllPoolReservesRequest { - pair_id, - token_in, - pagination, - }, - )?)?), - - QueryMsg::GetPoolReserves { - pair_id, - token_in, - tick_index, - fee, - } => Ok(to_json_binary(&get_pool_reserves( - deps, - GetPoolReservesRequest { - pair_id, - token_in, - tick_index, - fee, - }, - )?)?), - - QueryMsg::EstimateMultiHopSwap { - creator, - receiver, - routes, - amount_in, - exit_limit_price, - pick_best_route, - } => Ok(to_json_binary(&get_estimate_multi_hop_swap( - deps, - EstimateMultiHopSwapRequest { - creator, - receiver, - routes, - amount_in, - exit_limit_price, - pick_best_route, - }, - )?)?), - - QueryMsg::EstimatePlaceLimitOrder { - creator, - receiver, - token_in, - token_out, - tick_index_in_to_out, - amount_in, - order_type, - expiration_time, - max_amount_out, - } => Ok(to_json_binary(&get_estimate_place_limit_order( - deps, - EstimatePlaceLimitOrderRequest { - creator, - receiver, - token_in, - token_out, - tick_index_in_to_out, - amount_in, - order_type: LimitOrderType::try_from(order_type).map_err(StdError::generic_err)?, - expiration_time, - max_amount_out, - }, - )?)?), - - QueryMsg::Pool { - pair_id, - tick_index, - fee, - } => Ok(to_json_binary(&get_pool( - deps, - PoolRequest { - pair_id, - tick_index, - fee, - }, - )?)?), - - QueryMsg::PoolById { pool_id } => Ok(to_json_binary(&get_pool_by_id( - deps, - PoolByIdRequest { pool_id }, - )?)?), - - QueryMsg::GetPoolMetadata { id } => Ok(to_json_binary(&get_pool_metadata( - deps, - GetPoolMetadataRequest { id }, - )?)?), - - QueryMsg::AllPoolMetadata { pagination } => Ok(to_json_binary(&get_pool_metadata_all( - deps, - AllPoolMetadataRequest { pagination }, - )?)?), - } -} - -#[entry_point] -pub fn sudo(_deps: DepsMut, _env: Env, _msg: SudoMsg) -> StdResult { - Ok(Response::default()) -} - -#[entry_point] -pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { - deps.api.debug("WASMDEBUG: migrate"); - Ok(Response::default()) -} diff --git a/contracts/echo/schema/execute_msg.json b/contracts/echo/schema/execute_msg.json index 7748c24..5b8a8c9 100644 --- a/contracts/echo/schema/execute_msg.json +++ b/contracts/echo/schema/execute_msg.json @@ -17,7 +17,8 @@ "msg": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/echo/schema/instantiate_msg.json b/contracts/echo/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/echo/schema/instantiate_msg.json +++ b/contracts/echo/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/client_updater/.cargo/config b/contracts/grpc_querier/.cargo/config similarity index 80% rename from contracts/client_updater/.cargo/config rename to contracts/grpc_querier/.cargo/config index f5c196b..91d6153 100644 --- a/contracts/client_updater/.cargo/config +++ b/contracts/grpc_querier/.cargo/config @@ -3,4 +3,4 @@ wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" unit-test = "test --lib" integration-test = "test --test integration" -schema = "run --example client_updater-schema" +schema = "run --example grpc_querier-schema" diff --git a/contracts/stargate_querier/Cargo.toml b/contracts/grpc_querier/Cargo.toml similarity index 78% rename from contracts/stargate_querier/Cargo.toml rename to contracts/grpc_querier/Cargo.toml index 8f1b1d1..bab6fa9 100644 --- a/contracts/stargate_querier/Cargo.toml +++ b/contracts/grpc_querier/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "stargate_querier" +name = "grpc_querier" version = "0.1.0" edition = "2021" @@ -21,16 +21,13 @@ library = [] [dependencies] cosmwasm-std = { workspace = true } +neutron-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } serde-json-wasm = { workspace = true } neutron-sdk = { workspace = true } - -# These dependencies are slightly outdated because of osmosis-std -osmosis-std = "0.19.2" -prost = "=0.11" -cosmos-sdk-proto = { version = "0.19.0", default-features = false } +prost = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/grpc_querier/README.md b/contracts/grpc_querier/README.md new file mode 100644 index 0000000..d1be598 --- /dev/null +++ b/contracts/grpc_querier/README.md @@ -0,0 +1,5 @@ +# Description + +Simple contract for integration tests. + +Makes all kinds of grpc queries allowed for Neutron chain. diff --git a/contracts/stargate_querier/examples/stargate_querier-schema.rs b/contracts/grpc_querier/examples/grpc_querier-schema.rs similarity index 94% rename from contracts/stargate_querier/examples/stargate_querier-schema.rs rename to contracts/grpc_querier/examples/grpc_querier-schema.rs index 1f1a8dd..9fda562 100644 --- a/contracts/stargate_querier/examples/stargate_querier-schema.rs +++ b/contracts/grpc_querier/examples/grpc_querier-schema.rs @@ -17,7 +17,7 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use stargate_querier::msg::{ExecuteMsg, InstantiateMsg}; +use grpc_querier::msg::{ExecuteMsg, InstantiateMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/stargate_querier/schema/execute_msg.json b/contracts/grpc_querier/schema/execute_msg.json similarity index 62% rename from contracts/stargate_querier/schema/execute_msg.json rename to contracts/grpc_querier/schema/execute_msg.json index 9dcea53..d7e49d1 100644 --- a/contracts/stargate_querier/schema/execute_msg.json +++ b/contracts/grpc_querier/schema/execute_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "ExecuteMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/dex/schema/instantiate_msg.json b/contracts/grpc_querier/schema/instantiate_msg.json similarity index 63% rename from contracts/dex/schema/instantiate_msg.json rename to contracts/grpc_querier/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/dex/schema/instantiate_msg.json +++ b/contracts/grpc_querier/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/grpc_querier/src/contract.rs b/contracts/grpc_querier/src/contract.rs new file mode 100644 index 0000000..6ef3da6 --- /dev/null +++ b/contracts/grpc_querier/src/contract.rs @@ -0,0 +1,206 @@ +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use cosmwasm_std::{ + entry_point, to_json_binary, Binary, ContractResult, Deps, DepsMut, Empty, Env, MessageInfo, + QueryRequest, Response, StdError, StdResult, SystemResult, +}; +use cw2::set_contract_version; +use neutron_std::types::cosmos::auth::v1beta1::AuthQuerier; +use neutron_std::types::cosmos::bank::v1beta1::BankQuerier; +use neutron_std::types::ibc::applications::transfer::v1::TransferQuerier; +use neutron_std::types::ibc::core::client::v1::ClientQuerier; +use neutron_std::types::ibc::core::connection::v1::ConnectionQuerier; +use neutron_std::types::neutron::contractmanager::QueryFailuresRequest; +use neutron_std::types::neutron::feeburner::FeeburnerQuerier; +use neutron_std::types::neutron::interchainqueries::InterchainqueriesQuerier; +use neutron_std::types::neutron::interchaintxs::v1::InterchaintxsQuerier; +use neutron_std::types::osmosis::tokenfactory::v1beta1::TokenfactoryQuerier; +use prost::Message; +use serde_json_wasm::to_vec; +use std::str::from_utf8; + +const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[entry_point] +pub fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: InstantiateMsg, +) -> StdResult { + deps.api.debug("WASMDEBUG: instantiate"); + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + Ok(Response::default()) +} + +#[entry_point] +pub fn execute(_: DepsMut, _: Env, _: MessageInfo, _msg: ExecuteMsg) -> StdResult { + Ok(Response::default()) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { + deps.api + .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); + + let bank_querier = BankQuerier::new(&deps.querier); + let auth_querier = AuthQuerier::new(&deps.querier); + let transfer_querier = TransferQuerier::new(&deps.querier); + let client_querier = ClientQuerier::new(&deps.querier); + let connection_querier = ConnectionQuerier::new(&deps.querier); + let tokenfactory_querier = TokenfactoryQuerier::new(&deps.querier); + let interchaintxs_querier = InterchaintxsQuerier::new(&deps.querier); + let interchainqueries_querier = InterchainqueriesQuerier::new(&deps.querier); + let feeburner_querier = FeeburnerQuerier::new(&deps.querier); + + match msg { + QueryMsg::BankBalance { address, denom } => { + Ok(to_json_binary(&bank_querier.balance(address, denom)?)?) + } + + QueryMsg::BankDenomMetadata { denom } => { + Ok(to_json_binary(&bank_querier.denom_metadata(denom)?)?) + } + + QueryMsg::BankParams {} => Ok(to_json_binary(&bank_querier.params()?)?), + + QueryMsg::BankSupplyOf { denom } => Ok(to_json_binary(&bank_querier.supply_of(denom)?)?), + + QueryMsg::AuthAccount { address } => Ok(to_json_binary(&auth_querier.account(address)?)?), + + QueryMsg::TransferDenomTrace { hash } => { + Ok(to_json_binary(&transfer_querier.denom_trace(hash)?)?) + } + + QueryMsg::TransferEscrowAddress { + port_id, + channel_id, + } => Ok(to_json_binary( + &transfer_querier.escrow_address(port_id, channel_id)?, + )?), + + QueryMsg::IbcClientState { client_id } => { + Ok(to_json_binary(&client_querier.client_state(client_id)?)?) + } + + QueryMsg::IbcConsensusState { + client_id, + revision_number, + revision_height, + latest_height, + } => Ok(to_json_binary(&client_querier.consensus_state( + client_id, + revision_number, + revision_height, + latest_height, + )?)?), + + QueryMsg::IbcConnection { connection_id } => Ok(to_json_binary( + &connection_querier.connection(connection_id)?, + )?), + + QueryMsg::TokenfactoryParams {} => Ok(to_json_binary(&tokenfactory_querier.params()?)?), + + QueryMsg::TokenfactoryDenomAuthorityMetadata { creator, subdenom } => Ok(to_json_binary( + &tokenfactory_querier.denom_authority_metadata(creator, subdenom)?, + )?), + + QueryMsg::TokenfactoryDenomsFromCreator { creator } => Ok(to_json_binary( + &tokenfactory_querier.denoms_from_creator(creator)?, + )?), + + QueryMsg::ContractmanagerAddressFailures { address } => { + query_contractmanager_query_address_failures(deps, address) + } + + QueryMsg::ContractmanagerFailures { address } => { + query_contractmanager_query_failures(deps, address) + } + + QueryMsg::InterchaintxsParams {} => Ok(to_json_binary(&interchaintxs_querier.params()?)?), + + QueryMsg::InterchainqueriesParams {} => { + Ok(to_json_binary(&interchainqueries_querier.params()?)?) + } + + QueryMsg::FeeburnerParams {} => Ok(to_json_binary(&feeburner_querier.params()?)?), + + QueryMsg::FeeburnerTotalBurnedNeutronsAmount {} => { + // WARN: should not work since we did not allowlist it + // exists here only for testing purposes + Ok(to_json_binary( + &feeburner_querier.total_burned_neutrons_amount()?, + )?) + } + } +} + +// Can be refactored after https://hadronlabs.atlassian.net/browse/NTRN-359 is done +fn query_contractmanager_query_address_failures(deps: Deps, address: String) -> StdResult { + let msg = QueryFailuresRequest { + address, + pagination: None, + }; + let mut bytes = Vec::new(); + Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?; + + let resp = make_stargate_query( + deps, + "/neutron.contractmanager.Query/AddressFailures".to_string(), + bytes, + )?; + + to_json_binary(&resp) +} + +fn query_contractmanager_query_failures(deps: Deps, address: String) -> StdResult { + let msg = QueryFailuresRequest { + address, + pagination: None, + }; + let mut bytes = Vec::new(); + Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?; + + let resp = make_stargate_query( + deps, + "/neutron.contractmanager.Query/Failures".to_string(), + bytes, + )?; + + to_json_binary(&resp) +} + +// Can be removed after https://hadronlabs.atlassian.net/browse/NTRN-359 is done +pub fn make_stargate_query( + deps: Deps, + path: String, + encoded_query_data: Vec, +) -> StdResult { + #[allow(deprecated)] + let raw = to_vec::>(&QueryRequest::Stargate { + path, + data: encoded_query_data.into(), + }) + .map_err(|serialize_err| { + StdError::generic_err(format!("Serializing QueryRequest: {}", serialize_err)) + })?; + match deps.querier.raw_query(&raw) { + SystemResult::Err(system_err) => Err(StdError::generic_err(format!( + "Querier system error: {}", + system_err + ))), + SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err(format!( + "Querier contract error: {}", + contract_err + ))), + // response(value) is base64 encoded bytes + SystemResult::Ok(ContractResult::Ok(value)) => { + let str = value.to_base64(); + deps.api + .debug(format!("WASMDEBUG: make_stargate_query: {:?}", str).as_str()); + from_utf8(value.as_slice()) + .map(|s| s.to_string()) + .map_err(|_e| StdError::generic_err("Unable to encode from utf8")) + } + } +} diff --git a/contracts/client_updater/examples/client_updater-schema.rs b/contracts/grpc_querier/src/lib.rs similarity index 55% rename from contracts/client_updater/examples/client_updater-schema.rs rename to contracts/grpc_querier/src/lib.rs index 112c257..c7a7772 100644 --- a/contracts/client_updater/examples/client_updater-schema.rs +++ b/contracts/grpc_querier/src/lib.rs @@ -12,18 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::env::current_dir; -use std::fs::create_dir_all; +#![warn(clippy::unwrap_used, clippy::expect_used)] -use client_updater::contract::{ExecuteMsg, InstantiateMsg}; -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); -} +pub mod contract; +pub mod msg; diff --git a/contracts/stargate_querier/src/msg.rs b/contracts/grpc_querier/src/msg.rs similarity index 89% rename from contracts/stargate_querier/src/msg.rs rename to contracts/grpc_querier/src/msg.rs index 61b0022..b7848a1 100644 --- a/contracts/stargate_querier/src/msg.rs +++ b/contracts/grpc_querier/src/msg.rs @@ -28,6 +28,10 @@ pub enum QueryMsg { TransferDenomTrace { hash: String, }, + TransferEscrowAddress { + port_id: String, + channel_id: String, + }, IbcClientState { client_id: String, }, @@ -42,7 +46,8 @@ pub enum QueryMsg { }, TokenfactoryParams {}, TokenfactoryDenomAuthorityMetadata { - denom: String, + creator: String, + subdenom: String, }, TokenfactoryDenomsFromCreator { creator: String, @@ -53,7 +58,7 @@ pub enum QueryMsg { ContractmanagerFailures { address: String, }, - InterchaintxParams {}, + InterchaintxsParams {}, InterchainqueriesParams {}, FeeburnerParams {}, FeeburnerTotalBurnedNeutronsAmount {}, diff --git a/contracts/stargate_querier/src/state.rs b/contracts/grpc_querier/src/state.rs similarity index 100% rename from contracts/stargate_querier/src/state.rs rename to contracts/grpc_querier/src/state.rs diff --git a/contracts/ibc_transfer/Cargo.toml b/contracts/ibc_transfer/Cargo.toml index 6379685..2806e45 100644 --- a/contracts/ibc_transfer/Cargo.toml +++ b/contracts/ibc_transfer/Cargo.toml @@ -21,6 +21,7 @@ library = [] [dependencies] cosmwasm-std = { workspace = true } +neutron-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } diff --git a/contracts/ibc_transfer/schema/execute_msg.json b/contracts/ibc_transfer/schema/execute_msg.json index 97a22b7..a2b8c9e 100644 --- a/contracts/ibc_transfer/schema/execute_msg.json +++ b/contracts/ibc_transfer/schema/execute_msg.json @@ -37,7 +37,8 @@ "to": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -69,7 +70,8 @@ "timeout_fee": { "$ref": "#/definitions/Uint128" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -91,7 +93,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -112,7 +115,8 @@ "state": { "$ref": "#/definitions/IntegrationTestsSudoFailureMock" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -125,7 +129,8 @@ ], "properties": { "integration_tests_unset_sudo_failure_mock": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/ibc_transfer/schema/instantiate_msg.json b/contracts/ibc_transfer/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/ibc_transfer/schema/instantiate_msg.json +++ b/contracts/ibc_transfer/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/ibc_transfer/src/contract.rs b/contracts/ibc_transfer/src/contract.rs index d8ee8e4..4be0dc9 100644 --- a/contracts/ibc_transfer/src/contract.rs +++ b/contracts/ibc_transfer/src/contract.rs @@ -1,22 +1,22 @@ +use crate::state::{ + read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE, + IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM, +}; use cosmwasm_std::{ - coin, entry_point, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, - StdError, StdResult, SubMsg, Uint128, + entry_point, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, + StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; use neutron_sdk::interchain_txs::helpers::decode_message_response; -use neutron_sdk::proto_types::neutron::transfer::MsgTransferResponse; -use neutron_sdk::{ - bindings::msg::{IbcFee, NeutronMsg}, - sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg}, -}; +use neutron_sdk::sudo::msg::{RequestPacket, TransferSudoMsg}; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::ibc::core::client::v1::Height; +use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; +use neutron_std::types::neutron::feerefunder::Fee; +use neutron_std::types::neutron::transfer::{MsgTransfer, MsgTransferResponse}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::state::{ - read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE, - IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM, -}; - use crate::{ integration_tests_mock_handlers::{set_sudo_failure_mock, unset_sudo_failure_mock}, state::{IntegrationTestsSudoFailureMock, INTEGRATION_TESTS_SUDO_FAILURE_MOCK}, @@ -74,12 +74,7 @@ pub enum ExecuteMsg { } #[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - _: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -101,7 +96,9 @@ pub fn execute( denom, } => execute_set_fees(deps, recv_fee, ack_fee, timeout_fee, denom), - ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, failure_id), + ExecuteMsg::ResubmitFailure { failure_id } => { + execute_resubmit_failure(deps, env, failure_id) + } // Used only in integration tests framework to simulate failures. // After executing this message, contract fail, all of this happening @@ -181,11 +178,15 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> StdResult { } } -fn get_fee_item(denom: String, amount: Uint128) -> Vec { +fn get_fee_item(denom: String, amount: Uint128) -> Vec { if amount == Uint128::new(0) { vec![] } else { - vec![coin(amount.u128(), denom)] + let coin = StdCoin { + amount: amount.to_string(), + denom, + }; + vec![coin] } } @@ -195,8 +196,8 @@ fn execute_set_fees( ack_fee: Uint128, timeout_fee: Uint128, denom: String, -) -> StdResult> { - let fee = IbcFee { +) -> StdResult { + let fee = Fee { recv_fee: get_fee_item(denom.clone(), recv_fee), ack_fee: get_fee_item(denom.clone(), ack_fee), timeout_fee: get_fee_item(denom, timeout_fee), @@ -215,36 +216,42 @@ fn execute_send( denom: String, amount: Uint128, timeout_height: Option, -) -> StdResult> { +) -> StdResult { let fee = IBC_FEE.load(deps.storage)?; - let coin1 = coin(amount.u128(), denom.clone()); - let msg1 = NeutronMsg::IbcTransfer { + let coin1 = StdCoin { + amount: amount.to_string(), + denom: denom.clone(), + }; + let msg1 = MsgTransfer { source_port: "transfer".to_string(), source_channel: channel.clone(), sender: env.contract.address.to_string(), receiver: to.clone(), - token: coin1, - timeout_height: RequestPacketTimeoutHeight { - revision_number: Some(2), - revision_height: timeout_height.or(Some(DEFAULT_TIMEOUT_HEIGHT)), - }, + token: Some(coin1), + timeout_height: Some(Height { + revision_number: 2, + revision_height: timeout_height.unwrap_or(DEFAULT_TIMEOUT_HEIGHT), + }), timeout_timestamp: 0, - fee: fee.clone(), + fee: Some(fee.clone()), memo: "".to_string(), }; - let coin2 = coin(2 * amount.u128(), denom); - let msg2 = NeutronMsg::IbcTransfer { + let coin2 = StdCoin { + amount: (amount * Uint128::new(2)).to_string(), + denom: denom.clone(), + }; + let msg2 = MsgTransfer { source_port: "transfer".to_string(), source_channel: channel, sender: env.contract.address.to_string(), receiver: to, - token: coin2, - timeout_height: RequestPacketTimeoutHeight { - revision_number: Some(2), - revision_height: timeout_height.or(Some(DEFAULT_TIMEOUT_HEIGHT)), - }, + token: Some(coin2), + timeout_height: Some(Height { + revision_number: 2, + revision_height: timeout_height.unwrap_or(DEFAULT_TIMEOUT_HEIGHT), + }), timeout_timestamp: 0, - fee, + fee: Some(fee), memo: "".to_string(), }; let submsg1 = msg_with_sudo_callback( @@ -270,8 +277,12 @@ fn execute_send( Ok(Response::default().add_submessages(vec![submsg1, submsg2])) } -fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult> { - let msg = NeutronMsg::submit_resubmit_failure(failure_id); +fn execute_resubmit_failure(_: DepsMut, env: Env, failure_id: u64) -> StdResult { + let msg: CosmosMsg = MsgResubmitFailure { + sender: env.contract.address.to_string(), + failure_id, + } + .into(); Ok(Response::default().add_message(msg)) } diff --git a/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs b/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs index c86490a..be10ff6 100644 --- a/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs +++ b/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs @@ -1,16 +1,15 @@ use crate::state::{IntegrationTestsSudoFailureMock, INTEGRATION_TESTS_SUDO_FAILURE_MOCK}; use cosmwasm_std::{DepsMut, Response, StdResult}; -use neutron_sdk::bindings::msg::NeutronMsg; pub fn set_sudo_failure_mock( deps: DepsMut, state: IntegrationTestsSudoFailureMock, -) -> StdResult> { +) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK.save(deps.storage, &state)?; Ok(Response::default()) } -pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult> { +pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK .save(deps.storage, &IntegrationTestsSudoFailureMock::Disabled)?; Ok(Response::default()) diff --git a/contracts/ibc_transfer/src/state.rs b/contracts/ibc_transfer/src/state.rs index 74b1b60..1970e51 100644 --- a/contracts/ibc_transfer/src/state.rs +++ b/contracts/ibc_transfer/src/state.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{from_json, to_json_vec, Binary, StdResult, Storage}; use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::msg::IbcFee; +use neutron_std::types::neutron::feerefunder::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -10,7 +10,7 @@ pub const IBC_SUDO_ID_RANGE_START: u64 = 1_000_000_000; pub const IBC_SUDO_ID_RANGE_SIZE: u64 = 1_000; pub const IBC_SUDO_ID_RANGE_END: u64 = IBC_SUDO_ID_RANGE_START + IBC_SUDO_ID_RANGE_SIZE; -pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const IBC_FEE: Item = Item::new("ibc_fee"); pub const REPLY_QUEUE_ID: Map> = Map::new("reply_queue_id"); diff --git a/contracts/marketmap/Cargo.toml b/contracts/marketmap/Cargo.toml index a18ca2d..9153ceb 100644 --- a/contracts/marketmap/Cargo.toml +++ b/contracts/marketmap/Cargo.toml @@ -36,6 +36,7 @@ cw2 = { workspace = true } schemars = { workspace = true } serde = { version = "1.0.180", default-features = false, features = ["derive"] } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/marketmap/examples/schema.rs b/contracts/marketmap/examples/schema.rs index d83d7f1..b938f17 100644 --- a/contracts/marketmap/examples/schema.rs +++ b/contracts/marketmap/examples/schema.rs @@ -16,8 +16,7 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use marketmap::contract::InstantiateMsg; -use neutron_sdk::bindings::marketmap::query::MarketMapQuery; +use marketmap::msg::{InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); @@ -26,5 +25,5 @@ fn main() { remove_schemas(&out_dir).unwrap(); export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(MarketMapQuery), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); } diff --git a/contracts/marketmap/schema/instantiate_msg.json b/contracts/marketmap/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/marketmap/schema/instantiate_msg.json +++ b/contracts/marketmap/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/marketmap/schema/market_map_query.json b/contracts/marketmap/schema/query_msg.json similarity index 69% rename from contracts/marketmap/schema/market_map_query.json rename to contracts/marketmap/schema/query_msg.json index 7165aeb..10bd1f0 100644 --- a/contracts/marketmap/schema/market_map_query.json +++ b/contracts/marketmap/schema/query_msg.json @@ -1,16 +1,16 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MarketMapQuery", + "title": "QueryMsg", "oneOf": [ { - "description": "Parameters queries the parameters of the module.", "type": "object", "required": [ "params" ], "properties": { "params": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -22,7 +22,8 @@ ], "properties": { "last_updated": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -34,7 +35,8 @@ ], "properties": { "market_map": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -54,7 +56,8 @@ "currency_pair": { "$ref": "#/definitions/CurrencyPair" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -62,19 +65,21 @@ ], "definitions": { "CurrencyPair": { + "description": "CurrencyPair is the standard representation of a pair of assets, where one (Base) is priced in terms of the other (Quote)", "type": "object", "required": [ - "Base", - "Quote" + "base", + "quote" ], "properties": { - "Base": { + "base": { "type": "string" }, - "Quote": { + "quote": { "type": "string" } - } + }, + "additionalProperties": false } } } diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index 8598150..7c55ee2 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -1,23 +1,9 @@ +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg {} - -use neutron_sdk::bindings::marketmap::query::MarketResponse; -use neutron_sdk::bindings::{ - marketmap::query::{LastUpdatedResponse, MarketMapQuery, MarketMapResponse, ParamsResponse}, - msg::NeutronMsg, - query::NeutronQuery, -}; +use neutron_std::types::slinky::marketmap::v1::MarketmapQuerier; const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -40,32 +26,21 @@ pub fn execute( _env: Env, _info: MessageInfo, _msg: ExecuteMsg, -) -> StdResult> { +) -> StdResult { Ok(Default::default()) } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: MarketMapQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { query_marketmap(deps, env, msg) } -fn query_marketmap(deps: Deps, _env: Env, msg: MarketMapQuery) -> StdResult { +fn query_marketmap(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + let querier = MarketmapQuerier::new(&deps.querier); match msg { - MarketMapQuery::Params { .. } => { - let query_response: ParamsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - MarketMapQuery::LastUpdated { .. } => { - let query_response: LastUpdatedResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - MarketMapQuery::MarketMap { .. } => { - let query_response: MarketMapResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - MarketMapQuery::Market { .. } => { - let query_response: MarketResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } + QueryMsg::Params { .. } => to_json_binary(&querier.params()?), + QueryMsg::LastUpdated { .. } => to_json_binary(&querier.last_updated()?), + QueryMsg::MarketMap { .. } => to_json_binary(&querier.market_map()?), + QueryMsg::Market { currency_pair } => to_json_binary(&querier.market(Some(currency_pair))?), } } diff --git a/contracts/marketmap/src/lib.rs b/contracts/marketmap/src/lib.rs index 2943dbb..112ecad 100644 --- a/contracts/marketmap/src/lib.rs +++ b/contracts/marketmap/src/lib.rs @@ -1 +1,2 @@ pub mod contract; +pub mod msg; diff --git a/contracts/marketmap/src/msg.rs b/contracts/marketmap/src/msg.rs new file mode 100644 index 0000000..95edcaa --- /dev/null +++ b/contracts/marketmap/src/msg.rs @@ -0,0 +1,19 @@ +use neutron_std::types::slinky::types::v1::CurrencyPair; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + Params {}, + LastUpdated {}, + MarketMap {}, + Market { currency_pair: CurrencyPair }, +} diff --git a/contracts/msg_receiver/schema/execute_msg.json b/contracts/msg_receiver/schema/execute_msg.json index f069039..5826d6a 100644 --- a/contracts/msg_receiver/schema/execute_msg.json +++ b/contracts/msg_receiver/schema/execute_msg.json @@ -21,7 +21,8 @@ "return_err": { "type": "boolean" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -33,7 +34,8 @@ ], "properties": { "call_staking": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/msg_receiver/schema/instantiate_msg.json b/contracts/msg_receiver/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/msg_receiver/schema/instantiate_msg.json +++ b/contracts/msg_receiver/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/msg_receiver/src/contract.rs b/contracts/msg_receiver/src/contract.rs index 6ee543e..dc7c36f 100644 --- a/contracts/msg_receiver/src/contract.rs +++ b/contracts/msg_receiver/src/contract.rs @@ -5,7 +5,6 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; use crate::state::TEST_ARGS; @@ -25,12 +24,7 @@ pub fn instantiate( } #[entry_point] -pub fn execute( - deps: DepsMut, - _: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -55,7 +49,7 @@ fn execute_test_arg( info: MessageInfo, return_err: bool, arg: String, -) -> StdResult> { +) -> StdResult { if return_err { return Err(StdError::generic_err("return error")); } @@ -76,7 +70,7 @@ fn execute_test_arg( Ok(Response::default().add_attribute("arg", arg)) } -fn execute_call_staking(deps: DepsMut) -> StdResult> { +fn execute_call_staking(deps: DepsMut) -> StdResult { deps.querier.query_bonded_denom()?; // should fail since Neutron does not have staking module Ok(Response::default()) } diff --git a/contracts/neutron_interchain_queries/Cargo.toml b/contracts/neutron_interchain_queries/Cargo.toml index d3c2e85..53dc8e5 100644 --- a/contracts/neutron_interchain_queries/Cargo.toml +++ b/contracts/neutron_interchain_queries/Cargo.toml @@ -20,6 +20,7 @@ library = [] [dependencies] cosmwasm-std = { workspace = true, features = ["stargate", "staking"] } +neutron-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } diff --git a/contracts/neutron_interchain_queries/schema/execute_msg.json b/contracts/neutron_interchain_queries/schema/execute_msg.json index cc7022e..a8bfe55 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -34,7 +34,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -67,7 +68,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -93,7 +95,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -126,7 +129,8 @@ "type": "string" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -161,7 +165,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -203,7 +208,8 @@ "type": "string" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -218,7 +224,7 @@ "type": "object", "required": [ "connection_id", - "recipient", + "recipients", "update_period" ], "properties": { @@ -233,15 +239,19 @@ "format": "uint64", "minimum": 0.0 }, - "recipient": { - "type": "string" + "recipients": { + "type": "array", + "items": { + "type": "string" + } }, "update_period": { "type": "integer", "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -278,7 +288,8 @@ "type": "string" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -315,7 +326,8 @@ "type": "string" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -348,7 +360,8 @@ "type": "string" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -362,16 +375,15 @@ "update_interchain_query": { "type": "object", "required": [ + "new_keys", + "new_update_period", "query_id" ], "properties": { "new_keys": { - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "$ref": "#/definitions/KVKey" + "$ref": "#/definitions/KvKey" } }, "new_recipient": { @@ -381,10 +393,7 @@ ] }, "new_update_period": { - "type": [ - "integer", - "null" - ], + "type": "integer", "format": "uint64", "minimum": 0.0 }, @@ -393,7 +402,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -415,7 +425,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -436,7 +447,8 @@ "connection_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -457,7 +469,8 @@ "connection_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -478,7 +491,8 @@ "connection_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -491,7 +505,8 @@ ], "properties": { "integration_tests_set_query_mock": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -504,19 +519,15 @@ ], "properties": { "integration_tests_unset_query_mock": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false } ], "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" - }, - "KVKey": { - "description": "Describes a KV key for which you want to get value from the storage on remote chain", + "KvKey": { "type": "object", "required": [ "key", @@ -524,18 +535,20 @@ ], "properties": { "key": { - "description": "*key** is a key you want to read from the storage", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] + "description": "Key you want to read from the storage", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + } }, "path": { - "description": "*path** is a path to the storage (storage prefix) where you want to read value by key (usually name of cosmos-packages module: 'staking', 'bank', etc.)", + "description": "Path (storage prefix) to the storage where you want to read value by key (usually name of cosmos-sdk module: 'staking', 'bank', etc.)", "type": "string" } - } + }, + "additionalProperties": false } } } diff --git a/contracts/neutron_interchain_queries/schema/instantiate_msg.json b/contracts/neutron_interchain_queries/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/neutron_interchain_queries/schema/instantiate_msg.json +++ b/contracts/neutron_interchain_queries/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/neutron_interchain_queries/schema/query_msg.json b/contracts/neutron_interchain_queries/schema/query_msg.json index 8deb564..939d527 100644 --- a/contracts/neutron_interchain_queries/schema/query_msg.json +++ b/contracts/neutron_interchain_queries/schema/query_msg.json @@ -19,7 +19,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -41,7 +42,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -63,7 +65,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -85,7 +88,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -107,7 +111,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -129,7 +134,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -151,7 +157,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -173,7 +180,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -195,7 +203,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -217,7 +226,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -237,7 +247,8 @@ "recipient": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -259,7 +270,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -271,7 +283,8 @@ ], "properties": { "get_transfers_number": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 169e321..3027540 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -24,17 +24,20 @@ use crate::state::{ use cosmos_sdk_proto::cosmos::bank::v1beta1::MsgSend; use cosmos_sdk_proto::cosmos::tx::v1beta1::{TxBody, TxRaw}; use cosmwasm_std::{ - entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, + entry_point, to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; -use neutron_sdk::bindings::query::{NeutronQuery, QueryRegisteredQueryResponse}; -use neutron_sdk::bindings::types::{Height, KVKey}; use neutron_sdk::interchain_queries::get_registered_query; +use neutron_sdk::interchain_queries::helpers::register_interchain_query; +use neutron_sdk::interchain_queries::helpers::{ + remove_interchain_query as helpers_remove_interchain_query, + update_interchain_query as helpers_update_interchain_query, +}; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; +use neutron_sdk::interchain_queries::v045::types::HEIGHT_FIELD; use neutron_sdk::interchain_queries::v047::queries::{ query_balance, query_bank_total, query_delegations, query_distribution_fee_pool, query_government_proposal_votes, query_government_proposals, query_staking_validators, @@ -45,15 +48,17 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ new_register_delegator_delegations_query_msg, new_register_delegator_unbonding_delegations_query_msg, new_register_distribution_fee_pool_query_msg, new_register_gov_proposals_query_msg, - new_register_staking_validators_query_msg, new_register_transfers_query_msg, + new_register_staking_validators_query_msg, }; use neutron_sdk::interchain_queries::v047::register_queries::{ new_register_gov_proposals_voters_votes_query_msg, new_register_validators_signing_infos_query_msg, }; use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; +use neutron_sdk::sudo::msg::Height; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; +use neutron_std::types::neutron::interchainqueries::KvKey; use prost::Message as ProstMessage; /// defines the incoming transfers limit to make a case of failed callback possible. @@ -77,32 +82,50 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( - deps: DepsMut, + deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg, -) -> NeutronResult> { +) -> NeutronResult { match msg { ExecuteMsg::RegisterBalancesQuery { connection_id, addr, denoms, update_period, - } => register_balances_query(connection_id, addr, denoms, update_period), + } => register_balances_query( + env.contract.address, + connection_id, + addr, + denoms, + update_period, + ), ExecuteMsg::RegisterBankTotalSupplyQuery { connection_id, denoms, update_period, - } => register_bank_total_supply_query(connection_id, denoms, update_period), + } => register_bank_total_supply_query( + env.contract.address, + connection_id, + denoms, + update_period, + ), ExecuteMsg::RegisterDistributionFeePoolQuery { connection_id, update_period, - } => register_distribution_fee_pool_query(connection_id, update_period), + } => { + register_distribution_fee_pool_query(env.contract.address, connection_id, update_period) + } ExecuteMsg::RegisterGovernmentProposalsQuery { connection_id, proposals_ids, update_period, - } => register_gov_proposal_query(connection_id, proposals_ids, update_period), + } => register_gov_proposal_query( + env.contract.address, + connection_id, + proposals_ids, + update_period, + ), ExecuteMsg::RegisterGovernmentProposalVotesQuery { connection_id, proposals_ids, @@ -110,6 +133,7 @@ pub fn execute( update_period, } => register_gov_proposal_votes_query( deps, + env.contract.address, connection_id, proposals_ids, voters, @@ -119,19 +143,31 @@ pub fn execute( connection_id, validators, update_period, - } => register_staking_validators_query(connection_id, validators, update_period), + } => register_staking_validators_query( + env.contract.address, + connection_id, + validators, + update_period, + ), ExecuteMsg::RegisterDelegatorDelegationsQuery { connection_id, delegator, validators, update_period, - } => register_delegations_query(connection_id, delegator, validators, update_period), + } => register_delegations_query( + env.contract.address, + connection_id, + delegator, + validators, + update_period, + ), ExecuteMsg::RegisterDelegatorUnbondingDelegationsQuery { connection_id, delegator, validators, update_period, } => register_unbonding_delegations_query( + env.contract.address, connection_id, delegator, validators, @@ -141,20 +177,39 @@ pub fn execute( connection_id, validators, update_period, - } => register_validators_signing_infos_query(connection_id, validators, update_period), + } => register_validators_signing_infos_query( + env.contract.address, + connection_id, + validators, + update_period, + ), ExecuteMsg::RegisterTransfersQuery { connection_id, - recipient, + recipients, update_period, min_height, - } => register_transfers_query(connection_id, recipient, update_period, min_height), + } => register_transfers_query( + env.contract.address, + connection_id, + recipients, + update_period, + min_height, + ), ExecuteMsg::UpdateInterchainQuery { query_id, new_keys, new_update_period, new_recipient, - } => update_interchain_query(query_id, new_keys, new_update_period, new_recipient), - ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id), + } => update_interchain_query( + env.contract.address, + query_id, + new_keys, + new_update_period, + new_recipient, + ), + ExecuteMsg::RemoveInterchainQuery { query_id } => { + remove_interchain_query(env.contract.address, query_id) + } ExecuteMsg::IntegrationTestsSetQueryMock {} => set_query_mock(deps), ExecuteMsg::IntegrationTestsUnsetQueryMock {} => unset_query_mock(deps), ExecuteMsg::IntegrationTestsRegisterQueryEmptyId { connection_id } => { @@ -170,56 +225,69 @@ pub fn execute( } pub fn register_balances_query( + contract: Addr, connection_id: String, addr: String, denoms: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_balances_query_msg(connection_id, addr, denoms, update_period)?; +) -> NeutronResult { + let msg = + new_register_balances_query_msg(contract, connection_id, addr, denoms, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_bank_total_supply_query( + contract: Addr, connection_id: String, denoms: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_bank_total_supply_query_msg(connection_id, denoms, update_period)?; +) -> NeutronResult { + let msg = + new_register_bank_total_supply_query_msg(contract, connection_id, denoms, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_distribution_fee_pool_query( + contract: Addr, connection_id: String, update_period: u64, -) -> NeutronResult> { - let msg = new_register_distribution_fee_pool_query_msg(connection_id, update_period)?; +) -> NeutronResult { + let msg = new_register_distribution_fee_pool_query_msg(contract, connection_id, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_gov_proposal_query( + contract: Addr, connection_id: String, proposals_ids: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_gov_proposals_query_msg(connection_id, proposals_ids, update_period)?; +) -> NeutronResult { + let msg = new_register_gov_proposals_query_msg( + contract, + connection_id, + proposals_ids, + update_period, + )?; Ok(Response::new().add_message(msg)) } pub fn register_gov_proposal_votes_query( - deps: DepsMut, + deps: DepsMut, + contract: Addr, connection_id: String, proposals_ids: Vec, voters: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { deps.api .debug("WASMDEBUG: register_gov_proposal_votes_query"); let msg = new_register_gov_proposals_voters_votes_query_msg( + contract, connection_id, proposals_ids, voters, @@ -230,22 +298,30 @@ pub fn register_gov_proposal_votes_query( } pub fn register_staking_validators_query( + contract: Addr, connection_id: String, validators: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_staking_validators_query_msg(connection_id, validators, update_period)?; +) -> NeutronResult { + let msg = new_register_staking_validators_query_msg( + contract, + connection_id, + validators, + update_period, + )?; Ok(Response::new().add_message(msg)) } pub fn register_delegations_query( + contract: Addr, connection_id: String, delegator: String, validators: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { let msg = new_register_delegator_delegations_query_msg( + contract, connection_id, delegator, validators, @@ -256,12 +332,14 @@ pub fn register_delegations_query( } pub fn register_unbonding_delegations_query( + contract: Addr, connection_id: String, delegator: String, validators: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { let msg = new_register_delegator_unbonding_delegations_query_msg( + contract, connection_id, delegator, validators, @@ -272,72 +350,113 @@ pub fn register_unbonding_delegations_query( } pub fn register_validators_signing_infos_query( + contract: Addr, connection_id: String, validators: Vec, update_period: u64, -) -> NeutronResult> { - let msg = - new_register_validators_signing_infos_query_msg(connection_id, validators, update_period)?; +) -> NeutronResult { + let msg = new_register_validators_signing_infos_query_msg( + contract, + connection_id, + validators, + update_period, + )?; Ok(Response::new().add_message(msg)) } pub fn register_transfers_query( + contract: Addr, connection_id: String, - recipient: String, + recipients: Vec, update_period: u64, min_height: Option, -) -> NeutronResult> { - let msg = - new_register_transfers_query_msg(connection_id, recipient, update_period, min_height)?; +) -> NeutronResult { + let mut query_data: Vec = recipients + .into_iter() + .map(|r| TransactionFilterItem { + field: RECIPIENT_FIELD.to_string(), + op: TransactionFilterOp::Eq, + value: TransactionFilterValue::String(r), + }) + .collect(); + + if let Some(min_height) = min_height { + query_data.push(TransactionFilterItem { + field: HEIGHT_FIELD.to_string(), + op: TransactionFilterOp::Gte, + value: TransactionFilterValue::Int(min_height), + }) + } + + let msg = register_interchain_query( + contract, + QueryPayload::TX(query_data), + connection_id, + update_period, + )?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_id( - _: DepsMut, - _: Env, + _: DepsMut, + env: Env, connection_id: String, -) -> NeutronResult> { - let kv_key = KVKey { +) -> NeutronResult { + let kv_key = KvKey { path: "test".to_string(), - key: Binary::new(vec![]), + key: vec![], }; - let msg = - NeutronMsg::register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + let msg = register_interchain_query( + env.contract.address, + QueryPayload::KV(vec![kv_key]), + connection_id, + 10, + )?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_path( - _: DepsMut, - _: Env, + _: DepsMut, + env: Env, connection_id: String, -) -> NeutronResult> { - let kv_key = KVKey { +) -> NeutronResult { + let kv_key = KvKey { path: "".to_string(), - key: Binary::new("test".as_bytes().to_vec()), + key: "test".as_bytes().to_vec(), }; - let msg = - NeutronMsg::register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + let msg = register_interchain_query( + env.contract.address, + QueryPayload::KV(vec![kv_key]), + connection_id, + 10, + )?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_keys( - _: DepsMut, - _: Env, + _: DepsMut, + env: Env, connection_id: String, -) -> NeutronResult> { - let msg = NeutronMsg::register_interchain_query(QueryPayload::KV(vec![]), connection_id, 10)?; +) -> NeutronResult { + let msg = register_interchain_query( + env.contract.address, + QueryPayload::KV(vec![]), + connection_id, + 10, + )?; Ok(Response::new().add_message(msg)) } pub fn update_interchain_query( + contract: Addr, query_id: u64, - new_keys: Option>, - new_update_period: Option, + new_keys: Vec, + new_update_period: u64, new_recipient: Option, -) -> NeutronResult> { +) -> NeutronResult { let new_filter = new_recipient.map(|recipient| { vec![TransactionFilterItem { field: RECIPIENT_FIELD.to_string(), @@ -346,18 +465,23 @@ pub fn update_interchain_query( }] }); - let update_msg = - NeutronMsg::update_interchain_query(query_id, new_keys, new_update_period, new_filter)?; + let update_msg = helpers_update_interchain_query( + contract, + query_id, + new_keys, + new_update_period, + new_filter, + )?; Ok(Response::new().add_message(update_msg)) } -pub fn remove_interchain_query(query_id: u64) -> NeutronResult> { - let remove_msg = NeutronMsg::remove_interchain_query(query_id); +pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { + let remove_msg = helpers_remove_interchain_query(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { match msg { //TODO: check if query.result.height is too old (for all interchain queries) QueryMsg::Balance { query_id } => Ok(to_json_binary(&query_balance(deps, env, query_id)?)?), @@ -394,7 +518,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult } } -fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { +fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { let txs = RECIPIENT_TXS .load(deps.storage, &recipient) .unwrap_or_default(); @@ -402,7 +526,7 @@ fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronRe } /// Returns the number of transfers made on remote chain and queried with ICQ -fn query_transfers_number(deps: Deps) -> NeutronResult { +fn query_transfers_number(deps: Deps) -> NeutronResult { let transfers_number = TRANSFERS.load(deps.storage).unwrap_or_default(); Ok(to_json_binary(&GetTransfersAmountResponse { transfers_number, @@ -410,7 +534,7 @@ fn query_transfers_number(deps: Deps) -> NeutronResult { } /// Returns block height of last KV query callback execution -pub fn query_kv_callback_stats(deps: Deps, query_id: u64) -> NeutronResult { +pub fn query_kv_callback_stats(deps: Deps, query_id: u64) -> NeutronResult { Ok(to_json_binary(&KvCallbackStatsResponse { last_update_height: KV_CALLBACK_STATS .may_load(deps.storage, query_id)? @@ -425,7 +549,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult, env: Env, msg: SudoMsg) -> NeutronResult { +pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { match msg { SudoMsg::TxQueryResult { query_id, @@ -440,7 +564,7 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResul /// sudo_check_tx_query_result is an example callback for transaction query results that stores the /// deposits received as a result on the registered query in the contract's state. pub fn sudo_tx_query_result( - deps: DepsMut, + deps: DepsMut, _env: Env, query_id: u64, _height: Height, @@ -457,9 +581,8 @@ pub fn sudo_tx_query_result( let body: TxBody = TxBody::decode(tx.body_bytes.as_slice())?; // Get the registered query by ID and retrieve the raw query string - let registered_query: QueryRegisteredQueryResponse = - get_registered_query(deps.as_ref(), query_id)?; - let transactions_filter = registered_query.registered_query.transactions_filter; + let registered_query = get_registered_query(deps.as_ref(), query_id)?; + let transactions_filter = registered_query.transactions_filter; #[allow(clippy::match_single_binding)] // Depending of the query type, check the transaction data to see whether is satisfies @@ -467,7 +590,7 @@ pub fn sudo_tx_query_result( // all submitted results will be treated as valid. // // TODO: come up with solution to determine transactions filter type - match registered_query.registered_query.query_type { + match registered_query.query_type { _ => { // For transfer queries, query data looks like `[{"field:"transfer.recipient", "op":"eq", "value":"some_address"}]` let query_data: Vec = @@ -565,11 +688,7 @@ fn check_deposits_size(deposits: &Vec) -> StdResult<()> { /// sudo_kv_query_result is the contract's callback for KV query results. Note that only the query /// id is provided, so you need to read the query result from the state. -pub fn sudo_kv_query_result( - deps: DepsMut, - env: Env, - query_id: u64, -) -> NeutronResult { +pub fn sudo_kv_query_result(deps: DepsMut, env: Env, query_id: u64) -> NeutronResult { deps.api.debug( format!( "WASMDEBUG: sudo_kv_query_result received; query_id: {:?}", diff --git a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs index 6f1e690..356cd6f 100644 --- a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs +++ b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs @@ -1,15 +1,13 @@ use crate::state::{IntegrationTestsQueryMock, INTEGRATION_TESTS_QUERY_MOCK}; use cosmwasm_std::{DepsMut, Response}; -use neutron_sdk::bindings::msg::NeutronMsg; -use neutron_sdk::bindings::query::NeutronQuery; use neutron_sdk::NeutronResult; -pub fn set_query_mock(deps: DepsMut) -> NeutronResult> { +pub fn set_query_mock(deps: DepsMut) -> NeutronResult { INTEGRATION_TESTS_QUERY_MOCK.save(deps.storage, &IntegrationTestsQueryMock::Enabled)?; Ok(Response::default()) } -pub fn unset_query_mock(deps: DepsMut) -> NeutronResult> { +pub fn unset_query_mock(deps: DepsMut) -> NeutronResult { INTEGRATION_TESTS_QUERY_MOCK.save(deps.storage, &IntegrationTestsQueryMock::Disabled)?; Ok(Response::default()) } diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index ddc0971..a83b7ea 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -1,5 +1,5 @@ use crate::state::Transfer; -use neutron_sdk::bindings::types::KVKey; +use neutron_std::types::neutron::interchainqueries::KvKey; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -43,7 +43,7 @@ pub enum ExecuteMsg { RegisterTransfersQuery { connection_id: String, update_period: u64, - recipient: String, + recipients: Vec, min_height: Option, }, RegisterDelegatorDelegationsQuery { @@ -65,8 +65,8 @@ pub enum ExecuteMsg { }, UpdateInterchainQuery { query_id: u64, - new_keys: Option>, - new_update_period: Option, + new_keys: Vec, + new_update_period: u64, new_recipient: Option, }, RemoveInterchainQuery { diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 5474688..4c3d490 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -17,10 +17,12 @@ use std::marker::PhantomData; use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; use cosmwasm_std::{ - from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, OwnedDeps, Querier, - QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator, + from_json, Binary, Coin, ContractResult, CustomQuery, GrpcQuery, OwnedDeps, Querier, + QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, +}; +use neutron_std::types::neutron::interchainqueries::{ + QueryRegisteredQueryRequest, QueryRegisteredQueryResultRequest, }; -use neutron_sdk::bindings::query::NeutronQuery; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -35,7 +37,7 @@ impl CustomQuery for CustomQueryWrapper {} pub fn mock_dependencies( contract_balance: &[Coin], -) -> OwnedDeps { +) -> OwnedDeps { let contract_addr = MOCK_CONTRACT_ADDR; let custom_querier: WasmMockQuerier = WasmMockQuerier::new(MockQuerier::new(&[(contract_addr, contract_balance)])); @@ -49,14 +51,14 @@ pub fn mock_dependencies( } pub struct WasmMockQuerier { - base: MockQuerier, + base: MockQuerier, query_responses: HashMap, registered_queries: HashMap, } impl Querier for WasmMockQuerier { fn raw_query(&self, bin_request: &[u8]) -> QuerierResult { - let request: QueryRequest = match from_json(bin_request) { + let request: QueryRequest = match from_json(bin_request) { Ok(v) => v, Err(e) => { return QuerierResult::Err(SystemError::InvalidRequest { @@ -70,41 +72,29 @@ impl Querier for WasmMockQuerier { } impl WasmMockQuerier { - pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { + pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { match &request { - QueryRequest::Custom(NeutronQuery::InterchainQueryResult { query_id }) => { - SystemResult::Ok(ContractResult::Ok( - (*self.query_responses.get(query_id).unwrap()).clone(), - )) - } - QueryRequest::Custom(NeutronQuery::RegisteredInterchainQuery { query_id }) => { - SystemResult::Ok(ContractResult::Ok( - (*self.registered_queries.get(query_id).unwrap()).clone(), - )) - } - QueryRequest::Custom(NeutronQuery::RegisteredInterchainQueries { - owners: _owners, - connection_id: _connection_id, - pagination: _pagination, - }) => { - todo!() - } - QueryRequest::Custom(NeutronQuery::InterchainAccountAddress { .. }) => { - todo!() + QueryRequest::Grpc(GrpcQuery { path, data }) => { + if path == "/neutron.interchainqueries.Query/QueryResult" { + let request: QueryRegisteredQueryResultRequest = + ::prost::Message::decode(&data[..]).unwrap(); + SystemResult::Ok(ContractResult::Ok( + (*self.query_responses.get(&request.query_id).unwrap()).clone(), + )) + } else if path == "/neutron.interchainqueries.Query/RegisteredQuery" { + let request: QueryRegisteredQueryRequest = + ::prost::Message::decode(&data[..]).unwrap(); + SystemResult::Ok(ContractResult::Ok( + (*self.registered_queries.get(&request.query_id).unwrap()).clone(), + )) + } else { + self.base.handle_query(request) + } } _ => self.base.handle_query(request), } } - pub fn _update_staking( - &mut self, - denom: &str, - validators: &[Validator], - delegations: &[FullDelegation], - ) { - self.base.staking.update(denom, validators, delegations); - } - pub fn add_query_response(&mut self, query_id: u64, response: Binary) { self.query_responses.insert(query_id, response); } @@ -124,7 +114,7 @@ pub struct TokenQuerier { } impl WasmMockQuerier { - pub fn new(base: MockQuerier) -> Self { + pub fn new(base: MockQuerier) -> Self { WasmMockQuerier { base, query_responses: HashMap::new(), diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 04b0902..0f347f6 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -29,16 +29,11 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::Validator as CosmosValidator; use cosmos_sdk_proto::Any; use cosmwasm_std::testing::{message_info, mock_env, MockApi, MockStorage}; use cosmwasm_std::{ - from_json, to_json_binary, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, - Uint128, + from_json, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; -use neutron_sdk::bindings::query::{ - NeutronQuery, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, +use neutron_sdk::interchain_queries::helpers::{ + decode_and_convert, decode_hex, kv_key_from_string, }; -use neutron_sdk::bindings::types::{ - decode_hex, Height, InterchainQueryResult, KVKey, KVKeys, RegisteredQuery, StorageValue, -}; -use neutron_sdk::interchain_queries::helpers::decode_and_convert; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -56,13 +51,20 @@ use neutron_sdk::interchain_queries::v047::types::{ SigningInfo, StakingValidator, StdDelegation, TallyResult, TotalSupply, Validator, ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; +use neutron_sdk::sudo::msg::Height as QueriesHeight; use neutron_sdk::NeutronError; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::ibc::core::client::v1::Height; +use neutron_std::types::neutron::interchainqueries::{ + KvKey, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, QueryResult, + RegisteredQuery, StorageValue, +}; use prost::Message as ProstMessage; use schemars::_serde_json::to_string; use std::ops::Mul; enum QueryParam { - Keys(Vec), + Keys(Vec), TransactionsFilter(String), } @@ -72,36 +74,37 @@ fn build_registered_query_response( query_type: QueryType, last_submitted_result_local_height: u64, ) -> Binary { - let mut resp = QueryRegisteredQueryResponse { - registered_query: RegisteredQuery { + let mut registered_keys = vec![]; + let mut transactions_filter = "".to_string(); + match param { + QueryParam::Keys(keys) => registered_keys = keys, + QueryParam::TransactionsFilter(filter) => transactions_filter = filter, + } + + let resp = QueryRegisteredQueryResponse { + registered_query: Some(RegisteredQuery { id, owner: "".to_string(), - keys: vec![], - query_type, - transactions_filter: "".to_string(), + keys: registered_keys, + query_type: query_type.into(), + transactions_filter, connection_id: "".to_string(), update_period: 0, last_submitted_result_local_height, - last_submitted_result_remote_height: Height { + last_submitted_result_remote_height: Some(Height { revision_number: 0, revision_height: 0, - }, - deposit: Vec::from([Coin { + }), + deposit: Vec::from([StdCoin { denom: "stake".to_string(), - amount: Uint128::from_str("100").unwrap(), + amount: "100".to_string(), }]), submit_timeout: 0, registered_at_height: 0, - }, + }), }; - match param { - QueryParam::Keys(keys) => resp.registered_query.keys = keys, - QueryParam::TransactionsFilter(transactions_filter) => { - resp.registered_query.transactions_filter = transactions_filter - } - } - - Binary::from(to_string(&resp).unwrap().as_bytes()) + let res = ::prost::Message::encode_to_vec(&resp); + Binary::from(res.as_slice()) } fn build_interchain_query_bank_total_denom_value(denom: String, amount: String) -> StorageValue { @@ -111,8 +114,9 @@ fn build_interchain_query_bank_total_denom_value(denom: String, amount: String) StorageValue { storage_prefix: "".to_string(), - key: Binary::new(bank_total_key), - value: Binary::new(amount), + key: bank_total_key, + value: amount, + proof: None, } } @@ -133,20 +137,21 @@ fn build_interchain_query_distribution_fee_pool_response(denom: String, amount: let s = StorageValue { storage_prefix: "".to_string(), - key: Binary::new(fee_pool_key), - value: Binary::new(fee_pool.encode_to_vec()), + key: fee_pool_key, + value: fee_pool.encode_to_vec(), + proof: None, }; - Binary::from( - to_string(&QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { - kv_results: vec![s], - height: 123456, - revision: 1, - }, - }) - .unwrap() - .as_bytes(), - ) + + let res = ::prost::Message::encode_to_vec(&QueryRegisteredQueryResultResponse { + result: Some(QueryResult { + kv_results: vec![s], + block: None, + height: 123456, + revision: 1, + allow_kv_callbacks: false, + }), + }); + Binary::from(res.as_slice()) } fn build_interchain_query_staking_validator_value(validator: String) -> StorageValue { @@ -172,8 +177,9 @@ fn build_interchain_query_staking_validator_value(validator: String) -> StorageV StorageValue { storage_prefix: "".to_string(), - key: Binary::new(validator_key), - value: Binary::new(validator.encode_to_vec()), + key: validator_key, + value: validator.encode_to_vec(), + proof: None, } } @@ -192,8 +198,9 @@ fn build_interchain_query_validator_signing_info_value(validator: String) -> Sto StorageValue { storage_prefix: "".to_string(), - key: Binary::new(validator_key), - value: Binary::new(validator.encode_to_vec()), + key: validator_key, + value: validator.encode_to_vec(), + proof: None, } } @@ -225,8 +232,9 @@ fn build_interchain_query_gov_proposal_value(proposal_id: u64) -> StorageValue { StorageValue { storage_prefix: "".to_string(), - key: Binary::new(proposal_key), - value: Binary::new(proposal.encode_to_vec()), + key: proposal_key, + value: proposal.encode_to_vec(), + proof: None, } } @@ -246,8 +254,9 @@ fn build_interchain_query_gov_proposal_votes_value(proposal_id: u64) -> StorageV StorageValue { storage_prefix: "".to_string(), - key: Binary::new(votes_key), - value: Binary::new(vote.encode_to_vec()), + key: votes_key, + value: vote.encode_to_vec(), + proof: None, } } @@ -262,40 +271,41 @@ fn build_interchain_query_balances_response(addr: Addr, balances: Vec) -> .unwrap(); StorageValue { storage_prefix: "".to_string(), - key: Binary::new(balance_key), - value: Binary::new(c.amount.to_string().into_bytes()), + key: balance_key, + value: c.amount.to_string().into_bytes(), + proof: None, } }) .collect(); - Binary::from( - to_string(&QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { - kv_results: s, - height: 123456, - revision: 2, - }, - }) - .unwrap() - .as_bytes(), - ) + let resp = QueryRegisteredQueryResultResponse { + result: Some(QueryResult { + kv_results: s, + block: None, + height: 123456, + revision: 2, + allow_kv_callbacks: false, + }), + }; + let res = ::prost::Message::encode_to_vec(&resp); + Binary::from(res.as_slice()) } // registers an interchain query fn register_query( - deps: &mut OwnedDeps, + deps: &mut OwnedDeps, env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> KVKeys { +) -> Vec { let reg_msgs = execute(deps.as_mut(), env, info, msg).unwrap(); for attr in reg_msgs.attributes { if attr.key == "kv_keys" && !attr.value.is_empty() { - return KVKeys::from_string(attr.value).unwrap(); + return vec![kv_key_from_string(attr.value).unwrap()]; } } - KVKeys(vec![]) + vec![] } #[test] @@ -317,7 +327,7 @@ fn test_query_balance() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier.add_registered_queries(1, registered_query); deps.querier.add_query_response( @@ -360,7 +370,7 @@ fn test_query_balances() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier.add_registered_queries(1, registered_query); deps.querier.add_query_response( @@ -374,8 +384,8 @@ fn test_query_balances() { ), ); let query_balance = QueryMsg::Balance { query_id: 1 }; - let resp: BalanceResponse = - from_json(query(deps.as_ref(), mock_env(), query_balance).unwrap()).unwrap(); + let res = query(deps.as_ref(), mock_env(), query_balance); + let resp: BalanceResponse = from_json(res.unwrap()).unwrap(); assert_eq!( resp, BalanceResponse { @@ -410,7 +420,7 @@ fn test_bank_total_supply_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -421,16 +431,20 @@ fn test_bank_total_supply_query() { } let total_supply_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, to_json_binary(&total_supply_response).unwrap()); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&total_supply_response).as_slice()), + ); let bank_total_balance = QueryMsg::BankTotalSupply { query_id: 1 }; let resp: TotalSupplyResponse = @@ -466,7 +480,7 @@ fn test_distribution_fee_pool_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier.add_registered_queries(1, registered_query); deps.querier.add_query_response( @@ -510,7 +524,7 @@ fn test_gov_proposals_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -520,16 +534,20 @@ fn test_gov_proposals_query() { } let proposals_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, to_json_binary(&proposals_response).unwrap()); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&proposals_response).as_slice()), + ); let government_proposal = QueryMsg::GovernmentProposals { query_id: 1 }; let resp: ProposalResponse = @@ -628,7 +646,7 @@ fn test_gov_proposal_votes_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 325); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 325); let mut kv_results: Vec = vec![]; @@ -638,16 +656,20 @@ fn test_gov_proposal_votes_query() { } let proposals_votes_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, to_json_binary(&proposals_votes_response).unwrap()); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&proposals_votes_response).as_slice()), + ); let government_proposal_votes = QueryMsg::GovernmentProposalVotes { query_id: 1 }; let resp: ProposalVotesResponse = @@ -710,7 +732,7 @@ fn test_staking_validators_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -720,16 +742,20 @@ fn test_staking_validators_query() { } let validators_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, to_json_binary(&validators_response).unwrap()); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice()), + ); let staking_validators = QueryMsg::StakingValidators { query_id: 1 }; let resp: ValidatorResponse = from_json(query(deps.as_ref(), mock_env(), staking_validators).unwrap()).unwrap(); @@ -809,7 +835,7 @@ fn test_validators_signing_infos_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -819,16 +845,20 @@ fn test_validators_signing_infos_query() { } let validators_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, to_json_binary(&validators_response).unwrap()); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice()), + ); let validators_signing_infos = QueryMsg::ValidatorsSigningInfos { query_id: 1 }; let resp: ValidatorSigningInfoResponse = from_json(query(deps.as_ref(), mock_env(), validators_signing_infos).unwrap()).unwrap(); @@ -883,7 +913,7 @@ fn test_query_delegator_delegations() { ); let delegations_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { // response for `RegisterDelegatorDelegationsQuery` with necessary KV values to test reconstruction logic. // The values are taken from osmosis network kv_results: vec![ @@ -891,8 +921,9 @@ fn test_query_delegator_delegations() { // value: Params StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(BASE64_STANDARD.decode("UQ==").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CgQIgN9uEGQYByCQTioFdWF0b20yATA6FC0xMDAwMDAwMDAwMDAwMDAwMDAwQhMxMDAwMDAwMDAwMDAwMDAwMDAwShMxMDAwMDAwMDAwMDAwMDAwMDAw").unwrap()), + key: BASE64_STANDARD.decode("UQ==").unwrap(), + value: BASE64_STANDARD.decode("CgQIgN9uEGQYByCQTioFdWF0b20yATA6FC0xMDAwMDAwMDAwMDAwMDAwMDAwQhMxMDAwMDAwMDAwMDAwMDAwMDAwShMxMDAwMDAwMDAwMDAwMDAwMDAw").unwrap(), + proof: None, }, // delegation // from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs @@ -900,16 +931,18 @@ fn test_query_delegator_delegations() { // delegation_shares: "5177628000000000000000000" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b8141ab940697a73dd080edafeb538ad408b5cae0264").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxoZNTE3NzYyODAwMDAwMDAwMDAwMDAwMDAwMA==").unwrap()), + key: decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b8141ab940697a73dd080edafeb538ad408b5cae0264").unwrap(), + value: BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxoZNTE3NzYyODAwMDAwMDAwMDAwMDAwMDAwMA==").unwrap(), + proof: None, }, // validator: osmovaloper1r2u5q6t6w0wssrk6l66n3t2q3dw2uqny4gj2e3 // delegator_shares: "2845862840643000000000000000000" // total tokens: "2845862840643" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("21141ab940697a73dd080edafeb538ad408b5cae0264").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiCaZhCbacCetQorko3LfUUJX2UEyX38qBGVri8GyH8lcCADKg0yODQ1ODYyODQwNjQzMh8yODQ1ODYyODQwNjQzMDAwMDAwMDAwMDAwMDAwMDAwOqQCChRzdHJhbmdlbG92ZS12ZW50dXJlcxIQRDBEOEI4MEYxQzVDNzBCNRocaHR0cHM6Ly9zdHJhbmdlbG92ZS52ZW50dXJlcyrbAScuLi5iZWNhdXNlIG9mIHRoZSBhdXRvbWF0ZWQgYW5kIGlycmV2b2NhYmxlIGRlY2lzaW9uLW1ha2luZyBwcm9jZXNzIHdoaWNoIHJ1bGVzIG91dCBodW1hbiBtZWRkbGluZywgdGhlIERvb21zZGF5IG1hY2hpbmUgaXMgdGVycmlmeWluZyBhbmQgc2ltcGxlIHRvIHVuZGVyc3RhbmQgYW5kIGNvbXBsZXRlbHkgY3JlZGlibGUgYW5kIGNvbnZpbmNpbmcuJyAtIERyLiBTdHJhbmdlbG92ZUoAUkwKPAoRNTAwMDAwMDAwMDAwMDAwMDASEzEwMDAwMDAwMDAwMDAwMDAwMDAaEjUwMDAwMDAwMDAwMDAwMDAwMBIMCPetyYYGEKPoosUCWgEx").unwrap()), + key: decode_hex("21141ab940697a73dd080edafeb538ad408b5cae0264").unwrap(), + value: BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiCaZhCbacCetQorko3LfUUJX2UEyX38qBGVri8GyH8lcCADKg0yODQ1ODYyODQwNjQzMh8yODQ1ODYyODQwNjQzMDAwMDAwMDAwMDAwMDAwMDAwOqQCChRzdHJhbmdlbG92ZS12ZW50dXJlcxIQRDBEOEI4MEYxQzVDNzBCNRocaHR0cHM6Ly9zdHJhbmdlbG92ZS52ZW50dXJlcyrbAScuLi5iZWNhdXNlIG9mIHRoZSBhdXRvbWF0ZWQgYW5kIGlycmV2b2NhYmxlIGRlY2lzaW9uLW1ha2luZyBwcm9jZXNzIHdoaWNoIHJ1bGVzIG91dCBodW1hbiBtZWRkbGluZywgdGhlIERvb21zZGF5IG1hY2hpbmUgaXMgdGVycmlmeWluZyBhbmQgc2ltcGxlIHRvIHVuZGVyc3RhbmQgYW5kIGNvbXBsZXRlbHkgY3JlZGlibGUgYW5kIGNvbnZpbmNpbmcuJyAtIERyLiBTdHJhbmdlbG92ZUoAUkwKPAoRNTAwMDAwMDAwMDAwMDAwMDASEzEwMDAwMDAwMDAwMDAwMDAwMDAaEjUwMDAwMDAwMDAwMDAwMDAwMBIMCPetyYYGEKPoosUCWgEx").unwrap(), + proof: None, }, // delegation // from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs @@ -917,16 +950,18 @@ fn test_query_delegator_delegations() { // delegation_shares: "29620221000000000000000000" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814cc9598513212c12c36a1775e2233b962e4d5128e").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBoaMjk2MjAyMjEwMDAwMDAwMDAwMDAwMDAwMDA=").unwrap()), + key: decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814cc9598513212c12c36a1775e2233b962e4d5128e").unwrap(), + value: BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBoaMjk2MjAyMjEwMDAwMDAwMDAwMDAwMDAwMDA=").unwrap(), + proof: None, }, // validator: osmovaloper1ej2es5fjztqjcd4pwa0zyvaevtjd2y5w37wr9t // delegator_shares: "3054477259038000000000000000000" // total tokens: "3054477259038" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("2114cc9598513212c12c36a1775e2233b962e4d5128e").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiA27dgAuZV/uS9FdsILGWLBw8eYPy+ZEyv1Df2VsrjXDiADKg0zMDU0NDc3MjU5MDM4Mh8zMDU0NDc3MjU5MDM4MDAwMDAwMDAwMDAwMDAwMDAwOoEBChFGcmVucyAo8J+knSzwn6SdKRIQQzQ3ODQ1MjI2NjYyQUY0NxoSaHR0cHM6Ly9mcmVucy5hcm15IhtzZWN1cml0eUBraWRzb250aGVibG9jay54eXoqKVlvdXIgZnJpZW5kbHkgdmFsaWRhdG9yIGZvciBjb3Ntb3MgY2hhaW5zQP3HpQFKCwj3zq6PBhCfrO86UkoKOgoRNTAwMDAwMDAwMDAwMDAwMDASEjUwMDAwMDAwMDAwMDAwMDAwMBoRNTAwMDAwMDAwMDAwMDAwMDASDAjg1rSQBhDkudCDAVoDNTAw").unwrap()), + key: decode_hex("2114cc9598513212c12c36a1775e2233b962e4d5128e").unwrap(), + value: BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiA27dgAuZV/uS9FdsILGWLBw8eYPy+ZEyv1Df2VsrjXDiADKg0zMDU0NDc3MjU5MDM4Mh8zMDU0NDc3MjU5MDM4MDAwMDAwMDAwMDAwMDAwMDAwOoEBChFGcmVucyAo8J+knSzwn6SdKRIQQzQ3ODQ1MjI2NjYyQUY0NxoSaHR0cHM6Ly9mcmVucy5hcm15IhtzZWN1cml0eUBraWRzb250aGVibG9jay54eXoqKVlvdXIgZnJpZW5kbHkgdmFsaWRhdG9yIGZvciBjb3Ntb3MgY2hhaW5zQP3HpQFKCwj3zq6PBhCfrO86UkoKOgoRNTAwMDAwMDAwMDAwMDAwMDASEjUwMDAwMDAwMDAwMDAwMDAwMBoRNTAwMDAwMDAwMDAwMDAwMDASDAjg1rSQBhDkudCDAVoDNTAw").unwrap(), + proof: None, }, // delegation // from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs @@ -934,28 +969,34 @@ fn test_query_delegator_delegations() { // delegation_shares: "219920000000000000000000" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRoYMjE5OTIwMDAwMDAwMDAwMDAwMDAwMDAw").unwrap()), + key: decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap(), + value: BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRoYMjE5OTIwMDAwMDAwMDAwMDAwMDAwMDAw").unwrap(), + proof: None, }, // validator: osmovaloper1lzhlnpahvznwfv4jmay2tgaha5kmz5qxwmj9we // delegator_shares: "3201438898476000000000000000000" // total tokens: "3201438898476" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("2114f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiBPXCnkQvO+pU6oGbp4ZiJBBZ7RNoLYtXYFOEdpXGH+uSADKg0zMjAxNDM4ODk4NDc2Mh8zMjAxNDM4ODk4NDc2MDAwMDAwMDAwMDAwMDAwMDAwOp8CCgtDaXRhZGVsLm9uZRIQRUJCMDNFQjRCQjRDRkNBNxoTaHR0cHM6Ly9jaXRhZGVsLm9uZSroAUNpdGFkZWwub25lIGlzIGEgbXVsdGktYXNzZXQgbm9uLWN1c3RvZGlhbCBzdGFraW5nIHBsYXRmb3JtIHRoYXQgbGV0cyBhbnlvbmUgYmVjb21lIGEgcGFydCBvZiBkZWNlbnRyYWxpemVkIGluZnJhc3RydWN0dXJlIGFuZCBlYXJuIHBhc3NpdmUgaW5jb21lLiBTdGFrZSB3aXRoIG91ciBub2RlcyBvciBhbnkgb3RoZXIgdmFsaWRhdG9yIGFjcm9zcyBtdWx0aXBsZSBuZXR3b3JrcyBpbiBhIGZldyBjbGlja3NKAFJECjoKETUwMDAwMDAwMDAwMDAwMDAwEhIyMDAwMDAwMDAwMDAwMDAwMDAaETMwMDAwMDAwMDAwMDAwMDAwEgYIkKKzhgZaATE=").unwrap()), + key: decode_hex("2114f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap(), + value: BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiBPXCnkQvO+pU6oGbp4ZiJBBZ7RNoLYtXYFOEdpXGH+uSADKg0zMjAxNDM4ODk4NDc2Mh8zMjAxNDM4ODk4NDc2MDAwMDAwMDAwMDAwMDAwMDAwOp8CCgtDaXRhZGVsLm9uZRIQRUJCMDNFQjRCQjRDRkNBNxoTaHR0cHM6Ly9jaXRhZGVsLm9uZSroAUNpdGFkZWwub25lIGlzIGEgbXVsdGktYXNzZXQgbm9uLWN1c3RvZGlhbCBzdGFraW5nIHBsYXRmb3JtIHRoYXQgbGV0cyBhbnlvbmUgYmVjb21lIGEgcGFydCBvZiBkZWNlbnRyYWxpemVkIGluZnJhc3RydWN0dXJlIGFuZCBlYXJuIHBhc3NpdmUgaW5jb21lLiBTdGFrZSB3aXRoIG91ciBub2RlcyBvciBhbnkgb3RoZXIgdmFsaWRhdG9yIGFjcm9zcyBtdWx0aXBsZSBuZXR3b3JrcyBpbiBhIGZldyBjbGlja3NKAFJECjoKETUwMDAwMDAwMDAwMDAwMDAwEhIyMDAwMDAwMDAwMDAwMDAwMDAaETMwMDAwMDAwMDAwMDAwMDAwEgYIkKKzhgZaATE=").unwrap(), + proof: None, }, ], + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); - deps.querier - .add_query_response(1, to_json_binary(&delegations_response).unwrap()); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&delegations_response).as_slice()), + ); deps.querier.add_registered_queries(1, registered_query); let query_delegations = QueryMsg::GetDelegations { query_id: 1 }; @@ -993,14 +1034,14 @@ fn test_sudo_tx_query_result_callback() { let env = mock_env(); let watched_addr: String = "neutron1fj6yqrkpw6fmp7f7jhj57dujfpwal4m25dafzx".to_string(); let query_id: u64 = 1u64; - let height = Height { + let height = QueriesHeight { revision_number: 0u64, revision_height: 1u64, }; let msg = ExecuteMsg::RegisterTransfersQuery { connection_id: "connection".to_string(), update_period: 1u64, - recipient: watched_addr.clone(), + recipients: vec![watched_addr.clone()], min_height: None, }; execute( @@ -1097,14 +1138,14 @@ fn test_sudo_tx_query_result_min_height_callback() { let env = mock_env(); let watched_addr: String = "neutron1fj6yqrkpw6fmp7f7jhj57dujfpwal4m25dafzx".to_string(); let query_id: u64 = 1u64; - let height = Height { + let height = QueriesHeight { revision_number: 0u64, revision_height: 1u64, }; let msg = ExecuteMsg::RegisterTransfersQuery { connection_id: "connection".to_string(), update_period: 1u64, - recipient: watched_addr.clone(), + recipients: vec![watched_addr.clone()], min_height: Some(100000), }; execute( diff --git a/contracts/neutron_interchain_txs/Cargo.toml b/contracts/neutron_interchain_txs/Cargo.toml index 6ab180b..738dcc3 100644 --- a/contracts/neutron_interchain_txs/Cargo.toml +++ b/contracts/neutron_interchain_txs/Cargo.toml @@ -27,6 +27,7 @@ serde-json-wasm = { workspace = true } cw-storage-plus = { workspace = true } cosmos-sdk-proto = { workspace = true } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } prost = { workspace = true } prost-types = { workspace = true } diff --git a/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs b/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs index 9169e7a..fad1537 100644 --- a/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs +++ b/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs @@ -14,8 +14,8 @@ use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use neutron_interchain_txs::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::interchaintxs::v1::QueryInterchainAccountAddressResponse; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/contracts/neutron_interchain_txs/schema/execute_msg.json b/contracts/neutron_interchain_txs/schema/execute_msg.json index 4817dcc..297efea 100644 --- a/contracts/neutron_interchain_txs/schema/execute_msg.json +++ b/contracts/neutron_interchain_txs/schema/execute_msg.json @@ -20,8 +20,19 @@ }, "interchain_account_id": { "type": "string" + }, + "ordering": { + "anyOf": [ + { + "$ref": "#/definitions/Order" + }, + { + "type": "null" + } + ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -53,7 +64,8 @@ "timeout_fee": { "$ref": "#/definitions/Uint128" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -93,7 +105,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -133,7 +146,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -173,7 +187,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -185,7 +200,8 @@ ], "properties": { "clean_ack_results": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -207,7 +223,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -228,33 +245,36 @@ "state": { "$ref": "#/definitions/IntegrationTestsSudoFailureMock" } - } + }, + "additionalProperties": false } }, "additionalProperties": false }, { - "description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in an submessage processing error.", + "description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in a submessage processing error.", "type": "object", "required": [ "integration_tests_set_sudo_submsg_failure_mock" ], "properties": { "integration_tests_set_sudo_submsg_failure_mock": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false }, { - "description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in an submessage reply processing error.", + "description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in a submessage reply processing error.", "type": "object", "required": [ "integration_tests_set_sudo_submsg_reply_failure_mock" ], "properties": { "integration_tests_set_sudo_submsg_reply_failure_mock": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -267,7 +287,8 @@ ], "properties": { "integration_tests_unset_sudo_failure_mock": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -280,7 +301,8 @@ ], "properties": { "integration_tests_sudo_submsg": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -295,6 +317,32 @@ "disabled" ] }, + "Order": { + "description": "Order defines if a channel is ORDERED or UNORDERED", + "oneOf": [ + { + "description": "zero-value for channel ordering", + "type": "string", + "enum": [ + "NoneUnspecified" + ] + }, + { + "description": "packets can be delivered in any order, which may differ from the order in which they were sent.", + "type": "string", + "enum": [ + "Unordered" + ] + }, + { + "description": "packets are delivered exactly in the order which they were sent", + "type": "string", + "enum": [ + "Ordered" + ] + } + ] + }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" diff --git a/contracts/neutron_interchain_txs/schema/instantiate_msg.json b/contracts/neutron_interchain_txs/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/neutron_interchain_txs/schema/instantiate_msg.json +++ b/contracts/neutron_interchain_txs/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/neutron_interchain_txs/schema/migrate_msg.json b/contracts/neutron_interchain_txs/schema/migrate_msg.json index 87b18ea..7fbe8c5 100644 --- a/contracts/neutron_interchain_txs/schema/migrate_msg.json +++ b/contracts/neutron_interchain_txs/schema/migrate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "MigrateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json b/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json index acc40bc..1effeab 100644 --- a/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json +++ b/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json @@ -1,14 +1,16 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "QueryInterchainAccountAddressResponse", + "description": "Query response for an interchain account address", "type": "object", "required": [ "interchain_account_address" ], "properties": { "interchain_account_address": { - "description": "*interchain_account_address** is a interchain account address on the remote chain", + "description": "The corresponding interchain account address on the host chain", "type": "string" } - } + }, + "additionalProperties": false } diff --git a/contracts/neutron_interchain_txs/schema/query_msg.json b/contracts/neutron_interchain_txs/schema/query_msg.json index c0c6eff..dab456e 100644 --- a/contracts/neutron_interchain_txs/schema/query_msg.json +++ b/contracts/neutron_interchain_txs/schema/query_msg.json @@ -22,7 +22,8 @@ "interchain_account_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -42,7 +43,8 @@ "interchain_account_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -68,7 +70,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -80,7 +83,8 @@ ], "properties": { "acknowledgement_results": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -92,7 +96,8 @@ ], "properties": { "errors_queue": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/neutron_interchain_txs/schema/sudo_msg.json b/contracts/neutron_interchain_txs/schema/sudo_msg.json index 92582ab..9c5fab7 100644 --- a/contracts/neutron_interchain_txs/schema/sudo_msg.json +++ b/contracts/neutron_interchain_txs/schema/sudo_msg.json @@ -21,7 +21,8 @@ "request": { "$ref": "#/definitions/RequestPacket" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -45,7 +46,8 @@ "request": { "$ref": "#/definitions/RequestPacket" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -65,7 +67,8 @@ "request": { "$ref": "#/definitions/RequestPacket" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -97,7 +100,8 @@ "port_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -127,7 +131,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -149,7 +154,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -161,6 +167,7 @@ "type": "string" }, "Height": { + "description": "Height is used for sudo call for `TxQueryResult` enum variant type", "type": "object", "properties": { "revision_height": { @@ -177,7 +184,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false }, "RequestPacket": { "type": "object", @@ -242,7 +250,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false }, "RequestPacketTimeoutHeight": { "type": "object", @@ -263,7 +272,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } } } diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 20ff287..702f850 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -19,10 +19,11 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::{ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - coins, to_json_binary, Binary, Coin as CosmosCoin, CosmosMsg, CustomQuery, Deps, DepsMut, Env, - MessageInfo, Reply, ReplyOn, Response, StdError, StdResult, SubMsg, Uint128, + to_json_binary, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, + ReplyOn, Response, StdError, StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; use prost::Message; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -34,17 +35,6 @@ use crate::integration_tests_mock_handlers::{ use crate::msg::{ AcknowledgementResultsResponse, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, }; -use neutron_sdk::bindings::msg::{IbcFee, NeutronMsg}; -use neutron_sdk::bindings::query::{NeutronQuery, QueryInterchainAccountAddressResponse}; -use neutron_sdk::bindings::types::ProtobufAny; -use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id}; -use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; -use neutron_sdk::proto_types::neutron::interchaintxs::v1::{ - MsgRegisterInterchainAccountResponse, MsgSubmitTxResponse, -}; -use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; -use neutron_sdk::NeutronResult; - use crate::storage::{ add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, AcknowledgementResult, DoubleDelegateInfo, @@ -53,6 +43,19 @@ use crate::storage::{ INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK, INTERCHAIN_ACCOUNTS, REGISTER_FEE, REGISTER_ICA_REPLY_ID, SUDO_FAILING_SUBMSG_REPLY_ID, SUDO_PAYLOAD_REPLY_ID, TEST_COUNTER_ITEM, }; +use neutron_sdk::interchain_txs::helpers::{ + decode_message_response, get_port_id, register_interchain_account, submit_tx, +}; +use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; +use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; +use neutron_sdk::NeutronResult; +use neutron_std::shim::Any; +use neutron_std::types::ibc::core::channel::v1::Order; +use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; +use neutron_std::types::neutron::feerefunder::Fee; +use neutron_std::types::neutron::interchaintxs::v1::{ + InterchaintxsQuerier, MsgRegisterInterchainAccountResponse, MsgSubmitTxResponse, +}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -88,27 +91,29 @@ pub fn instantiate( _env: Env, _info: MessageInfo, _msg: InstantiateMsg, -) -> NeutronResult> { +) -> NeutronResult { deps.api.debug("WASMDEBUG: instantiate"); set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - REGISTER_FEE.save(deps.storage, &coins(1_000_000, "untrn"))?; + REGISTER_FEE.save( + deps.storage, + &vec![StdCoin { + amount: 1_000_000.to_string(), + denom: "untrn".to_string(), + }], + )?; Ok(Response::default()) } #[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - _: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { ExecuteMsg::Register { connection_id, interchain_account_id, - } => execute_register_ica(deps, env, connection_id, interchain_account_id), + ordering, + } => execute_register_ica(deps, env, connection_id, interchain_account_id, ordering), ExecuteMsg::Delegate { validator, interchain_account_id, @@ -172,7 +177,9 @@ pub fn execute( timeout_fee, } => execute_set_fees(deps, denom, recv_fee, ack_fee, timeout_fee), ExecuteMsg::CleanAckResults {} => execute_clean_ack_results(deps), - ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, failure_id), + ExecuteMsg::ResubmitFailure { failure_id } => { + execute_resubmit_failure(deps, env, failure_id) + } // The section below is used only in integration tests framework to simulate failures. ExecuteMsg::IntegrationTestsSetSudoFailureMock { state } => { @@ -190,7 +197,7 @@ pub fn execute( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { match msg { QueryMsg::InterchainAccountAddress { interchain_account_id, @@ -209,23 +216,22 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult } pub fn query_interchain_address( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, connection_id: String, ) -> NeutronResult { - let query = NeutronQuery::InterchainAccountAddress { - owner_address: env.contract.address.to_string(), + let querier = InterchaintxsQuerier::new(&deps.querier); + let res = querier.interchain_account_address( + env.contract.address.to_string(), interchain_account_id, connection_id, - }; - - let res: QueryInterchainAccountAddressResponse = deps.querier.query(&query.into())?; + )?; Ok(to_json_binary(&res)?) } pub fn query_interchain_address_contract( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, ) -> NeutronResult { @@ -237,7 +243,7 @@ pub fn query_interchain_address_contract( } pub fn query_acknowledgement_result( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, sequence_id: u64, @@ -247,7 +253,7 @@ pub fn query_acknowledgement_result( Ok(to_json_binary(&res)?) } -pub fn query_acknowledgement_results(deps: Deps) -> NeutronResult { +pub fn query_acknowledgement_results(deps: Deps) -> NeutronResult { let results: Vec = ACKNOWLEDGEMENT_RESULTS .range(deps.storage, None, None, cosmwasm_std::Order::Ascending) .take(100) @@ -263,7 +269,7 @@ pub fn query_acknowledgement_results(deps: Deps) -> NeutronResult< Ok(to_json_binary(&results)?) } -pub fn query_errors_queue(deps: Deps) -> NeutronResult { +pub fn query_errors_queue(deps: Deps) -> NeutronResult { let res = read_errors_from_queue(deps.storage)?; Ok(to_json_binary(&res)?) } @@ -283,19 +289,19 @@ fn execute_set_fees( recv_fee: Uint128, ack_fee: Uint128, timeout_fee: Uint128, -) -> StdResult> { - let fees = IbcFee { - recv_fee: vec![CosmosCoin { +) -> StdResult { + let fees = Fee { + recv_fee: vec![StdCoin { denom: denom.clone(), - amount: recv_fee, + amount: recv_fee.to_string(), }], - ack_fee: vec![CosmosCoin { + ack_fee: vec![StdCoin { denom: denom.clone(), - amount: ack_fee, + amount: ack_fee.to_string(), }], - timeout_fee: vec![CosmosCoin { + timeout_fee: vec![StdCoin { denom, - amount: timeout_fee, + amount: timeout_fee.to_string(), }], }; IBC_FEE.save(deps.storage, &fees)?; @@ -307,23 +313,22 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, -) -> StdResult> { + ordering: Option, +) -> StdResult { let register_fee = REGISTER_FEE.load(deps.storage)?; - let register = NeutronMsg::register_interchain_account( + let register = register_interchain_account( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), - Option::from(register_fee), + register_fee, + ordering, ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; Ok(Response::new().add_submessage(SubMsg::reply_on_success(register, REGISTER_ICA_REPLY_ID))) } -fn execute_delegate( - deps: DepsMut, - env: Env, - info: ExecuteDelegateInfo, -) -> StdResult> { +fn execute_delegate(deps: DepsMut, env: Env, info: ExecuteDelegateInfo) -> StdResult { do_delegate(deps, env, info) } @@ -335,7 +340,7 @@ fn execute_undelegate( amount: Uint128, denom: String, timeout: Option, -) -> StdResult> { +) -> StdResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &interchain_account_id)?; let delegate_msg = MsgUndelegate { @@ -346,19 +351,20 @@ fn execute_undelegate( amount: amount.to_string(), }), }; - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity(delegate_msg.encoded_len()); buf.reserve(delegate_msg.encoded_len()); if let Err(e) = delegate_msg.encode(&mut buf) { return Err(StdError::generic_err(format!("Encode error: {}", e))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgUndelegate".to_string(), - value: Binary::from(buf), + value: buf, }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), vec![any_msg], @@ -384,15 +390,11 @@ fn execute_delegate_double_ack( deps: DepsMut, env: Env, info: ExecuteDelegateInfo, -) -> StdResult> { +) -> StdResult { do_delegate(deps, env, info) } -fn do_delegate( - mut deps: DepsMut, - env: Env, - info: ExecuteDelegateInfo, -) -> StdResult> { +fn do_delegate(mut deps: DepsMut, env: Env, info: ExecuteDelegateInfo) -> StdResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &info.interchain_account_id)?; let delegate_msg = MsgDelegate { @@ -403,19 +405,20 @@ fn do_delegate( amount: info.amount.to_string(), }), }; - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity(delegate_msg.encoded_len()); buf.reserve(delegate_msg.encoded_len()); if let Err(e) = delegate_msg.encode(&mut buf) { return Err(StdError::generic_err(format!("Encode error: {}", e))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgDelegate".to_string(), - value: Binary::from(buf), + value: buf, }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, info.interchain_account_id.clone(), vec![any_msg], @@ -439,7 +442,7 @@ fn do_delegate( Ok(Response::default().add_submessages(vec![submsg])) } -fn execute_clean_ack_results(deps: DepsMut) -> StdResult> { +fn execute_clean_ack_results(deps: DepsMut) -> StdResult { let keys: Vec> = ACKNOWLEDGEMENT_RESULTS .keys(deps.storage, None, None, cosmwasm_std::Order::Descending) .collect(); @@ -449,12 +452,16 @@ fn execute_clean_ack_results(deps: DepsMut) -> StdResult> { Ok(Response::default()) } -fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult> { - let msg = NeutronMsg::submit_resubmit_failure(failure_id); +fn execute_resubmit_failure(_: DepsMut, env: Env, failure_id: u64) -> StdResult { + let msg: CosmosMsg = MsgResubmitFailure { + sender: env.contract.address.to_string(), + failure_id, + } + .into(); Ok(Response::default().add_message(msg)) } -fn integration_tests_sudo_submsg(deps: DepsMut) -> StdResult> { +fn integration_tests_sudo_submsg(deps: DepsMut) -> StdResult { if let Some(IntegrationTestsSudoSubmsgFailureMock::Enabled {}) = INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.may_load(deps.storage)? { @@ -470,10 +477,10 @@ fn integration_tests_sudo_submsg(deps: DepsMut) -> StdResult StdResult> { +pub fn sudo(mut deps: DepsMut, env: Env, msg: SudoMsg) -> StdResult { let api = deps.api; api.debug(format!("WASMDEBUG: sudo: received sudo msg: {:?}", msg).as_str()); @@ -485,7 +492,7 @@ pub fn sudo(mut deps: DepsMut, env: Env, msg: SudoMsg) -> StdResult = match msg.clone() { + let mut resp: Response = match msg.clone() { SudoMsg::Response { request, data } => { sudo_response(deps.branch(), env.clone(), request, data)? } @@ -572,7 +579,7 @@ fn sudo_open_ack( channel_id: String, _counterparty_channel_id: String, counterparty_version: String, -) -> StdResult> { +) -> StdResult { let expected_channel_id = ICA_CHANNELS.load(deps.storage, port_id.clone())?; if channel_id != expected_channel_id { @@ -600,7 +607,7 @@ fn sudo_response( env: Env, request: RequestPacket, data: Binary, -) -> StdResult> { +) -> StdResult { deps.api.debug( format!( "WASMDEBUG: sudo_response: sudo received: {:?} {:?}", @@ -712,11 +719,7 @@ fn sudo_response( Ok(Response::default()) } -fn sudo_timeout( - deps: DepsMut, - _env: Env, - request: RequestPacket, -) -> StdResult> { +fn sudo_timeout(deps: DepsMut, _env: Env, request: RequestPacket) -> StdResult { deps.api .debug(format!("WASMDEBUG: sudo timeout request: {:?}", request).as_str()); @@ -751,11 +754,7 @@ fn sudo_timeout( Ok(Response::default()) } -fn sudo_error( - deps: DepsMut, - request: RequestPacket, - details: String, -) -> StdResult> { +fn sudo_error(deps: DepsMut, request: RequestPacket, details: String) -> StdResult { deps.api .debug(format!("WASMDEBUG: sudo error: {}", details).as_str()); deps.api diff --git a/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs b/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs index 2648c6c..6b99bb4 100644 --- a/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs +++ b/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs @@ -3,17 +3,16 @@ use crate::storage::{ INTEGRATION_TESTS_SUDO_FAILURE_MOCK, INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK, }; use cosmwasm_std::{DepsMut, Response, StdResult}; -use neutron_sdk::bindings::msg::NeutronMsg; pub fn set_sudo_failure_mock( deps: DepsMut, state: IntegrationTestsSudoFailureMock, -) -> StdResult> { +) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK.save(deps.storage, &state)?; Ok(Response::default()) } -pub fn set_sudo_submsg_failure_mock(deps: DepsMut) -> StdResult> { +pub fn set_sudo_submsg_failure_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.save( deps.storage, &IntegrationTestsSudoSubmsgFailureMock::Enabled, @@ -21,7 +20,7 @@ pub fn set_sudo_submsg_failure_mock(deps: DepsMut) -> StdResult StdResult> { +pub fn set_sudo_submsg_failure_in_reply_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.save( deps.storage, &IntegrationTestsSudoSubmsgFailureMock::EnabledInReply, @@ -29,7 +28,7 @@ pub fn set_sudo_submsg_failure_in_reply_mock(deps: DepsMut) -> StdResult StdResult> { +pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK .save(deps.storage, &IntegrationTestsSudoFailureMock::Disabled)?; INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.save( diff --git a/contracts/neutron_interchain_txs/src/msg.rs b/contracts/neutron_interchain_txs/src/msg.rs index 298ba7b..7dd4d87 100644 --- a/contracts/neutron_interchain_txs/src/msg.rs +++ b/contracts/neutron_interchain_txs/src/msg.rs @@ -1,5 +1,6 @@ use crate::storage::{AcknowledgementResult, IntegrationTestsSudoFailureMock}; use cosmwasm_std::Uint128; +use neutron_std::types::ibc::core::channel::v1::Order; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -38,6 +39,7 @@ pub enum ExecuteMsg { Register { connection_id: String, interchain_account_id: String, + ordering: Option, }, SetFees { denom: String, @@ -76,11 +78,11 @@ pub enum ExecuteMsg { state: IntegrationTestsSudoFailureMock, }, /// Used only in integration tests framework to simulate failures. - /// After executing this message, any sudo call to the contract will result in an submessage + /// After executing this message, any sudo call to the contract will result in a submessage /// processing error. IntegrationTestsSetSudoSubmsgFailureMock {}, /// Used only in integration tests framework to simulate failures. - /// After executing this message, any sudo call to the contract will result in an submessage + /// After executing this message, any sudo call to the contract will result in a submessage /// reply processing error. IntegrationTestsSetSudoSubmsgReplyFailureMock {}, /// Used only in integration tests framework to simulate failures. diff --git a/contracts/neutron_interchain_txs/src/storage.rs b/contracts/neutron_interchain_txs/src/storage.rs index 5665ca2..fb95feb 100644 --- a/contracts/neutron_interchain_txs/src/storage.rs +++ b/contracts/neutron_interchain_txs/src/storage.rs @@ -1,7 +1,8 @@ use cosmwasm_std::Uint128; -use cosmwasm_std::{from_json, to_json_vec, Binary, Coin, Order, StdResult, Storage}; +use cosmwasm_std::{from_json, to_json_vec, Binary, Order, StdResult, Storage}; use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::msg::IbcFee; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::neutron::feerefunder::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -27,8 +28,8 @@ pub const SUDO_FAILING_SUBMSG_REPLY_ID: u64 = 2; // only used to make sure `sudo()` handler gets OpenAck message with correct port_id and channel_id pub const REGISTER_ICA_REPLY_ID: u64 = 3; -pub const IBC_FEE: Item = Item::new("ibc_fee"); -pub const REGISTER_FEE: Item> = Item::new("register_fee"); +pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const REGISTER_FEE: Item> = Item::new("register_fee"); pub const REPLY_ID_STORAGE: Item> = Item::new("reply_queue_id"); pub const SUDO_PAYLOAD: Map<(String, u64), Vec> = Map::new("sudo_payload"); pub const INTERCHAIN_ACCOUNTS: Map> = diff --git a/contracts/neutron_interchain_txs/src/testing/tests.rs b/contracts/neutron_interchain_txs/src/testing/tests.rs index 2bbbd2f..0d9f324 100644 --- a/contracts/neutron_interchain_txs/src/testing/tests.rs +++ b/contracts/neutron_interchain_txs/src/testing/tests.rs @@ -22,11 +22,10 @@ use cosmwasm_std::testing::{ MockStorage, }; use cosmwasm_std::{from_json, Addr, OwnedDeps, StdError}; -use neutron_sdk::bindings::query::NeutronQuery; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use std::marker::PhantomData; -pub fn mock_dependencies() -> OwnedDeps { +pub fn mock_dependencies() -> OwnedDeps { OwnedDeps { storage: MockStorage::default(), api: MockApi::default(), diff --git a/contracts/neutron_validator_test/Cargo.toml b/contracts/neutron_validator_test/Cargo.toml index 60b7be8..db6436f 100644 --- a/contracts/neutron_validator_test/Cargo.toml +++ b/contracts/neutron_validator_test/Cargo.toml @@ -27,6 +27,7 @@ serde-json-wasm = { workspace = true } cw-storage-plus = { workspace = true } cosmos-sdk-proto = { workspace = true } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs b/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs index cb365a0..9b83441 100644 --- a/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs +++ b/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs @@ -13,8 +13,8 @@ // limitations under the License. use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::interchaintxs::v1::QueryInterchainAccountAddressResponse; use neutron_validators_test::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/contracts/neutron_validator_test/schema/execute_msg.json b/contracts/neutron_validator_test/schema/execute_msg.json index a38c6d8..eb131e0 100644 --- a/contracts/neutron_validator_test/schema/execute_msg.json +++ b/contracts/neutron_validator_test/schema/execute_msg.json @@ -21,7 +21,8 @@ "interchain_account_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -61,7 +62,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -101,7 +103,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -113,7 +116,8 @@ ], "properties": { "clean_ack_results": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -125,7 +129,8 @@ ], "properties": { "clean_recipient_txs": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -157,7 +162,8 @@ "timeout_fee": { "$ref": "#/definitions/Uint128" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -191,7 +197,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -229,7 +236,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -251,7 +259,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/neutron_validator_test/schema/instantiate_msg.json b/contracts/neutron_validator_test/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/neutron_validator_test/schema/instantiate_msg.json +++ b/contracts/neutron_validator_test/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json b/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json index acc40bc..1effeab 100644 --- a/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json +++ b/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json @@ -1,14 +1,16 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "QueryInterchainAccountAddressResponse", + "description": "Query response for an interchain account address", "type": "object", "required": [ "interchain_account_address" ], "properties": { "interchain_account_address": { - "description": "*interchain_account_address** is a interchain account address on the remote chain", + "description": "The corresponding interchain account address on the host chain", "type": "string" } - } + }, + "additionalProperties": false } diff --git a/contracts/neutron_validator_test/schema/query_msg.json b/contracts/neutron_validator_test/schema/query_msg.json index a533a1b..dbcb377 100644 --- a/contracts/neutron_validator_test/schema/query_msg.json +++ b/contracts/neutron_validator_test/schema/query_msg.json @@ -22,7 +22,8 @@ "interchain_account_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -42,7 +43,8 @@ "interchain_account_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -68,7 +70,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -80,7 +83,8 @@ ], "properties": { "last_ack_seq_id": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -102,7 +106,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -122,7 +127,8 @@ "recipient": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/neutron_validator_test/schema/sudo_msg.json b/contracts/neutron_validator_test/schema/sudo_msg.json index 92582ab..9c5fab7 100644 --- a/contracts/neutron_validator_test/schema/sudo_msg.json +++ b/contracts/neutron_validator_test/schema/sudo_msg.json @@ -21,7 +21,8 @@ "request": { "$ref": "#/definitions/RequestPacket" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -45,7 +46,8 @@ "request": { "$ref": "#/definitions/RequestPacket" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -65,7 +67,8 @@ "request": { "$ref": "#/definitions/RequestPacket" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -97,7 +100,8 @@ "port_id": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -127,7 +131,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -149,7 +154,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -161,6 +167,7 @@ "type": "string" }, "Height": { + "description": "Height is used for sudo call for `TxQueryResult` enum variant type", "type": "object", "properties": { "revision_height": { @@ -177,7 +184,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false }, "RequestPacket": { "type": "object", @@ -242,7 +250,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false }, "RequestPacketTimeoutHeight": { "type": "object", @@ -263,7 +272,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } } } diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 9288521..57728fe 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use crate::storage::{ + read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, + AcknowledgementResult, GetRecipientTxsResponse, SudoPayload, Transfer, ACKNOWLEDGEMENT_RESULTS, + IBC_FEE, INTERCHAIN_ACCOUNTS, LAST_SEQ_ID, RECIPIENT_TXS, SUDO_PAYLOAD_REPLY_ID, +}; use cosmos_sdk_proto::{ cosmos::{ bank::v1beta1::MsgSend, @@ -24,19 +30,11 @@ use cosmos_sdk_proto::{ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - coin, to_json_binary, Binary, Coin as CosmosCoin, CosmosMsg, CustomQuery, Deps, DepsMut, Env, - MessageInfo, Reply, Response, StdError, StdResult, SubMsg, Uint128, + to_json_binary, Addr, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, + Response, StdError, StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use neutron_sdk::bindings::msg::{IbcFee, NeutronMsg}; -use neutron_sdk::bindings::query::{ - NeutronQuery, QueryInterchainAccountAddressResponse, QueryRegisteredQueryResponse, -}; -use neutron_sdk::bindings::types::{Height, ProtobufAny}; +use neutron_sdk::interchain_queries::helpers::remove_interchain_query as helpers_remove_interchain_query; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, @@ -46,17 +44,21 @@ use neutron_sdk::interchain_queries::v045::types::{COSMOS_SDK_TRANSFER_MSG_URL, use neutron_sdk::interchain_queries::v045::{ new_register_balances_query_msg, new_register_transfers_query_msg, }; -use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id}; +use neutron_sdk::interchain_txs::helpers::{ + decode_message_response, get_port_id, register_interchain_account, submit_tx, +}; use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; -use neutron_sdk::proto_types::neutron::interchaintxs::v1::MsgSubmitTxResponse; +use neutron_sdk::sudo::msg::Height; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; - -use crate::storage::{ - read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, - AcknowledgementResult, GetRecipientTxsResponse, SudoPayload, Transfer, ACKNOWLEDGEMENT_RESULTS, - IBC_FEE, INTERCHAIN_ACCOUNTS, LAST_SEQ_ID, RECIPIENT_TXS, SUDO_PAYLOAD_REPLY_ID, -}; +use neutron_std::shim::Any; +use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::ibc::core::channel::v1::Order; +use neutron_std::types::neutron::feerefunder::Fee; +use neutron_std::types::neutron::interchainqueries::RegisteredQuery; +use neutron_std::types::neutron::interchaintxs::v1::{InterchaintxsQuerier, MsgSubmitTxResponse}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -81,7 +83,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, _msg: InstantiateMsg, -) -> NeutronResult> { +) -> NeutronResult { deps.api.debug("WASMDEBUG: instantiate"); set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; Ok(Response::default()) @@ -93,7 +95,7 @@ pub fn execute( env: Env, _: MessageInfo, msg: ExecuteMsg, -) -> NeutronResult> { +) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -144,19 +146,33 @@ pub fn execute( addr, denom, update_period, - } => register_balance_query(connection_id, addr, denom, update_period), + } => register_balance_query( + env.contract.address, + connection_id, + addr, + denom, + update_period, + ), ExecuteMsg::RegisterTransfersQuery { connection_id, recipient, update_period, min_height, - } => register_transfers_query(connection_id, recipient, update_period, min_height), - ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id), + } => register_transfers_query( + env.contract.address, + connection_id, + recipient, + update_period, + min_height, + ), + ExecuteMsg::RemoveInterchainQuery { query_id } => { + remove_interchain_query(env.contract.address, query_id) + } } } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { match msg { QueryMsg::InterchainAccountAddress { interchain_account_id, @@ -176,23 +192,22 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult } pub fn query_interchain_address( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, connection_id: String, ) -> NeutronResult { - let query = NeutronQuery::InterchainAccountAddress { - owner_address: env.contract.address.to_string(), + let querier = InterchaintxsQuerier::new(&deps.querier); + let res = querier.interchain_account_address( + env.contract.address.to_string(), interchain_account_id, connection_id, - }; - - let res: QueryInterchainAccountAddressResponse = deps.querier.query(&query.into())?; + )?; Ok(to_json_binary(&res)?) } pub fn query_interchain_address_contract( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, ) -> NeutronResult { @@ -204,7 +219,7 @@ pub fn query_interchain_address_contract( } pub fn query_acknowledgement_result( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, sequence_id: u64, @@ -214,12 +229,12 @@ pub fn query_acknowledgement_result( Ok(to_json_binary(&res)?) } -pub fn query_last_ack_seq_id(deps: Deps) -> NeutronResult { +pub fn query_last_ack_seq_id(deps: Deps) -> NeutronResult { let res = LAST_SEQ_ID.may_load(deps.storage)?; Ok(to_json_binary(&res)?) } -fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { +fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { let txs = RECIPIENT_TXS .load(deps.storage, &recipient) .unwrap_or_default(); @@ -239,7 +254,10 @@ fn get_fee_item(denom: String, amount: Uint128) -> Vec { if amount == Uint128::new(0) { vec![] } else { - vec![coin(amount.u128(), denom)] + vec![CosmosCoin { + amount: amount.to_string(), + denom, + }] } } @@ -249,8 +267,8 @@ fn execute_set_fees( ack_fee: Uint128, timeout_fee: Uint128, denom: String, -) -> NeutronResult> { - let fee = IbcFee { +) -> NeutronResult { + let fee = Fee { recv_fee: get_fee_item(denom.clone(), recv_fee), ack_fee: get_fee_item(denom.clone(), ack_fee), timeout_fee: get_fee_item(denom, timeout_fee), @@ -266,9 +284,14 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, -) -> NeutronResult> { - let register = - NeutronMsg::register_interchain_account(connection_id, interchain_account_id.clone(), None); +) -> NeutronResult { + let register = register_interchain_account( + env.contract.address.clone(), + connection_id, + interchain_account_id.clone(), + vec![], + Some(Order::Ordered), + ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; Ok(Response::new().add_message(register)) @@ -282,7 +305,7 @@ fn execute_delegate( amount: Uint128, denom: String, timeout: Option, -) -> NeutronResult> { +) -> NeutronResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &interchain_account_id)?; let delegate_msg = MsgDelegate { @@ -302,12 +325,13 @@ fn execute_delegate( )))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgDelegate".to_string(), - value: Binary::from(buf), + value: buf, }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), vec![any_msg], @@ -339,7 +363,7 @@ fn execute_undelegate( amount: Uint128, denom: String, timeout: Option, -) -> NeutronResult> { +) -> NeutronResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &interchain_account_id)?; let delegate_msg = MsgUndelegate { @@ -350,7 +374,7 @@ fn execute_undelegate( amount: amount.to_string(), }), }; - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity(delegate_msg.encoded_len()); buf.reserve(delegate_msg.encoded_len()); if let Err(e) = delegate_msg.encode(&mut buf) { @@ -360,12 +384,13 @@ fn execute_undelegate( )))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgUndelegate".to_string(), - value: Binary::from(buf), + value: buf, }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), vec![any_msg], @@ -387,7 +412,7 @@ fn execute_undelegate( Ok(Response::default().add_submessages(vec![submsg])) } -fn execute_clean_ack_results(deps: DepsMut) -> NeutronResult> { +fn execute_clean_ack_results(deps: DepsMut) -> NeutronResult { let keys: Vec> = ACKNOWLEDGEMENT_RESULTS .keys(deps.storage, None, None, cosmwasm_std::Order::Descending) .collect(); @@ -398,7 +423,7 @@ fn execute_clean_ack_results(deps: DepsMut) -> NeutronResult NeutronResult> { +fn execute_clean_recipient_txs(deps: DepsMut) -> NeutronResult { let keys: Vec> = RECIPIENT_TXS .keys(deps.storage, None, None, cosmwasm_std::Order::Descending) .collect(); @@ -409,35 +434,43 @@ fn execute_clean_recipient_txs(deps: DepsMut) -> NeutronResult NeutronResult> { - let msg = new_register_balances_query_msg(connection_id, addr, vec![denom], update_period)?; +) -> NeutronResult { + let msg = + new_register_balances_query_msg(contract, connection_id, addr, vec![denom], update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_transfers_query( + contract: Addr, connection_id: String, recipient: String, update_period: u64, min_height: Option, -) -> NeutronResult> { - let msg = - new_register_transfers_query_msg(connection_id, recipient, update_period, min_height)?; +) -> NeutronResult { + let msg = new_register_transfers_query_msg( + contract, + connection_id, + recipient, + update_period, + min_height, + )?; Ok(Response::new().add_message(msg)) } -pub fn remove_interchain_query(query_id: u64) -> NeutronResult> { - let remove_msg = NeutronMsg::remove_interchain_query(query_id); +pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { + let remove_msg = helpers_remove_interchain_query(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { +pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: sudo: received sudo msg: {:?}", msg).as_str()); match msg { @@ -467,7 +500,7 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResul } fn sudo_open_ack( - deps: DepsMut, + deps: DepsMut, _env: Env, port_id: String, _channel_id: String, @@ -493,7 +526,7 @@ fn sudo_open_ack( } pub fn sudo_tx_query_result( - deps: DepsMut, + deps: DepsMut, _env: Env, query_id: u64, _height: Height, @@ -504,9 +537,8 @@ pub fn sudo_tx_query_result( let body: TxBody = TxBody::decode(tx.body_bytes.as_slice())?; // Get the registered query by ID and retrieve the raw query string - let registered_query: QueryRegisteredQueryResponse = - get_registered_query(deps.as_ref(), query_id)?; - let transactions_filter = registered_query.registered_query.transactions_filter; + let registered_query: RegisteredQuery = get_registered_query(deps.as_ref(), query_id)?; + let transactions_filter = registered_query.transactions_filter; #[allow(clippy::match_single_binding)] // Depending of the query type, check the transaction data to see whether is satisfies @@ -514,7 +546,7 @@ pub fn sudo_tx_query_result( // all submitted results will be treated as valid. // // TODO: come up with solution to determine transactions filter type - match registered_query.registered_query.query_type { + match registered_query.query_type { _ => { // For transfer queries, query data looks like `[{"field:"transfer.recipient", "op":"eq", "value":"some_address"}]` let query_data: Vec = @@ -581,11 +613,7 @@ fn recipient_deposits_from_tx_body( Ok(deposits) } -fn sudo_response( - deps: DepsMut, - request: RequestPacket, - data: Binary, -) -> NeutronResult { +fn sudo_response(deps: DepsMut, request: RequestPacket, data: Binary) -> NeutronResult { deps.api.debug( format!( "WASMDEBUG: sudo_response: sudo received: {:?} {:?}", @@ -635,11 +663,7 @@ fn sudo_response( Ok(Response::default()) } -fn sudo_timeout( - deps: DepsMut, - _env: Env, - request: RequestPacket, -) -> NeutronResult { +fn sudo_timeout(deps: DepsMut, _env: Env, request: RequestPacket) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: sudo timeout request: {:?}", request).as_str()); @@ -667,11 +691,7 @@ fn sudo_timeout( Ok(Response::default()) } -fn sudo_error( - deps: DepsMut, - request: RequestPacket, - details: String, -) -> NeutronResult { +fn sudo_error(deps: DepsMut, request: RequestPacket, details: String) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: sudo error: {}", details).as_str()); deps.api diff --git a/contracts/neutron_validator_test/src/storage.rs b/contracts/neutron_validator_test/src/storage.rs index cd3ca9c..8914345 100644 --- a/contracts/neutron_validator_test/src/storage.rs +++ b/contracts/neutron_validator_test/src/storage.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{from_json, to_json_vec, Binary, StdResult, Storage, Uint128}; use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::msg::IbcFee; +use neutron_std::types::neutron::feerefunder::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -14,7 +14,7 @@ pub struct SudoPayload { pub const SUDO_PAYLOAD_REPLY_ID: u64 = 1; -pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const IBC_FEE: Item = Item::new("ibc_fee"); pub const REPLY_ID_STORAGE: Item> = Item::new("reply_queue_id"); pub const SUDO_PAYLOAD: Map<(String, u64), Vec> = Map::new("sudo_payload"); pub const LAST_SEQ_ID: Item = Item::new("last_seq_id"); diff --git a/contracts/oracle/Cargo.toml b/contracts/oracle/Cargo.toml index 603ddc9..1e3e1ef 100644 --- a/contracts/oracle/Cargo.toml +++ b/contracts/oracle/Cargo.toml @@ -36,6 +36,7 @@ cw2 = { workspace = true } schemars = { workspace = true } serde = { version = "1.0.180", default-features = false, features = ["derive"] } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/oracle/examples/schema.rs b/contracts/oracle/examples/schema.rs index 5217d6d..9df07e3 100644 --- a/contracts/oracle/examples/schema.rs +++ b/contracts/oracle/examples/schema.rs @@ -16,8 +16,7 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use neutron_sdk::bindings::oracle::query::OracleQuery; -use oracle::contract::InstantiateMsg; +use oracle::msg::{InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); @@ -26,5 +25,5 @@ fn main() { remove_schemas(&out_dir).unwrap(); export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(OracleQuery), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); } diff --git a/contracts/oracle/schema/instantiate_msg.json b/contracts/oracle/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/oracle/schema/instantiate_msg.json +++ b/contracts/oracle/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/oracle/schema/oracle_query.json b/contracts/oracle/schema/query_msg.json similarity index 68% rename from contracts/oracle/schema/oracle_query.json rename to contracts/oracle/schema/query_msg.json index fd1d550..38d0902 100644 --- a/contracts/oracle/schema/oracle_query.json +++ b/contracts/oracle/schema/query_msg.json @@ -1,19 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "OracleQuery", + "title": "QueryMsg", "oneOf": [ - { - "type": "object", - "required": [ - "get_all_currency_pairs" - ], - "properties": { - "get_all_currency_pairs": { - "type": "object" - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -23,13 +11,18 @@ "get_price": { "type": "object", "required": [ - "currency_pair" + "base", + "quote" ], "properties": { - "currency_pair": { - "$ref": "#/definitions/CurrencyPair" + "base": { + "type": "string" + }, + "quote": { + "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -52,27 +45,24 @@ "type": "string" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false - } - ], - "definitions": { - "CurrencyPair": { + }, + { "type": "object", "required": [ - "Base", - "Quote" + "get_all_currency_pairs" ], "properties": { - "Base": { - "type": "string" - }, - "Quote": { - "type": "string" + "get_all_currency_pairs": { + "type": "object", + "additionalProperties": false } - } + }, + "additionalProperties": false } - } + ] } diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index fd78e97..eb683c1 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -1,24 +1,10 @@ +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg {} - -use neutron_sdk::bindings::{ - msg::NeutronMsg, - oracle::query::{ - GetAllCurrencyPairsResponse, GetPriceResponse, GetPricesResponse, OracleQuery, - }, - query::NeutronQuery, -}; +use neutron_std::types::slinky::oracle::v1::OracleQuerier; +use neutron_std::types::slinky::types::v1::CurrencyPair; const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -41,28 +27,24 @@ pub fn execute( _env: Env, _info: MessageInfo, _msg: ExecuteMsg, -) -> StdResult> { +) -> StdResult { Ok(Default::default()) } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: OracleQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { query_oracle(deps, env, msg) } -fn query_oracle(deps: Deps, _env: Env, msg: OracleQuery) -> StdResult { +fn query_oracle(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + let querier = OracleQuerier::new(&deps.querier); match msg { - OracleQuery::GetPrice { .. } => { - let query_response: GetPriceResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - OracleQuery::GetPrices { .. } => { - let query_response: GetPricesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::GetPrice { base, quote } => { + to_json_binary(&querier.get_price(Some(CurrencyPair { base, quote }))?) } - OracleQuery::GetAllCurrencyPairs { .. } => { - let query_response: GetAllCurrencyPairsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::GetPrices { currency_pair_ids } => { + to_json_binary(&querier.get_prices(currency_pair_ids)?) } + QueryMsg::GetAllCurrencyPairs { .. } => to_json_binary(&querier.get_all_currency_pairs()?), } } diff --git a/contracts/oracle/src/lib.rs b/contracts/oracle/src/lib.rs index 2943dbb..112ecad 100644 --- a/contracts/oracle/src/lib.rs +++ b/contracts/oracle/src/lib.rs @@ -1 +1,2 @@ pub mod contract; +pub mod msg; diff --git a/contracts/oracle/src/msg.rs b/contracts/oracle/src/msg.rs new file mode 100644 index 0000000..98eb798 --- /dev/null +++ b/contracts/oracle/src/msg.rs @@ -0,0 +1,17 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + GetPrice { base: String, quote: String }, + GetPrices { currency_pair_ids: Vec }, + GetAllCurrencyPairs {}, +} diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index 70d05fb..a9c70df 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -21,7 +21,8 @@ "to": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -41,172 +42,33 @@ "msgs": { "type": "array", "items": { - "$ref": "#/definitions/CosmosMsg_for_NeutronMsg" + "$ref": "#/definitions/CosmosMsg_for_Empty" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false } ], "definitions": { - "AdminProposal": { - "description": "AdminProposal defines the struct for various proposals which Neutron's Admin Module may accept.", - "oneOf": [ - { - "description": "Proposal to change params. Note that this works for old params. New params has their own `MsgUpdateParams` msgs that can be supplied to `ProposalExecuteMessage`", - "type": "object", - "required": [ - "param_change_proposal" - ], - "properties": { - "param_change_proposal": { - "$ref": "#/definitions/ParamChangeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to upgrade IBC client", - "deprecated": true, - "type": "object", - "required": [ - "upgrade_proposal" - ], - "properties": { - "upgrade_proposal": { - "$ref": "#/definitions/UpgradeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to update IBC client", - "deprecated": true, - "type": "object", - "required": [ - "client_update_proposal" - ], - "properties": { - "client_update_proposal": { - "$ref": "#/definitions/ClientUpdateProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Proposal to execute CosmosMsg.", - "type": "object", - "required": [ - "proposal_execute_message" - ], - "properties": { - "proposal_execute_message": { - "$ref": "#/definitions/ProposalExecuteMessage" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to upgrade network", - "deprecated": true, - "type": "object", - "required": [ - "software_upgrade_proposal" - ], - "properties": { - "software_upgrade_proposal": { - "$ref": "#/definitions/SoftwareUpgradeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to cancel existing software upgrade", - "deprecated": true, - "type": "object", - "required": [ - "cancel_software_upgrade_proposal" - ], - "properties": { - "cancel_software_upgrade_proposal": { - "$ref": "#/definitions/CancelSoftwareUpgradeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Will fail to execute if you use it. Deprecated. Proposal to pin wasm contract codes", - "deprecated": true, - "type": "object", - "required": [ - "pin_codes_proposal" - ], - "properties": { - "pin_codes_proposal": { - "$ref": "#/definitions/PinCodesProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Deprecated. Proposal to unpin wasm contract codes.", - "deprecated": true, - "type": "object", - "required": [ - "unpin_codes_proposal" - ], - "properties": { - "unpin_codes_proposal": { - "$ref": "#/definitions/UnpinCodesProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to call sudo on contract.", - "deprecated": true, - "type": "object", - "required": [ - "sudo_contract_proposal" - ], - "properties": { - "sudo_contract_proposal": { - "$ref": "#/definitions/SudoContractProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to update contract admin.", - "deprecated": true, - "type": "object", - "required": [ - "update_admin_proposal" - ], - "properties": { - "update_admin_proposal": { - "$ref": "#/definitions/UpdateAdminProposal" - } - }, - "additionalProperties": false + "AnyMsg": { + "description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" }, - { - "description": "Deprecated. Proposal to clear contract admin.", - "deprecated": true, - "type": "object", - "required": [ - "clear_admin_proposal" - ], - "properties": { - "clear_admin_proposal": { - "$ref": "#/definitions/ClearAdminProposal" - } - }, - "additionalProperties": false + "value": { + "$ref": "#/definitions/Binary" } - ] + }, + "additionalProperties": false }, "BankMsg": { "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", @@ -234,7 +96,8 @@ "to_address": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -258,7 +121,8 @@ "$ref": "#/definitions/Coin" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -269,78 +133,6 @@ "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", "type": "string" }, - "CancelSoftwareUpgradeProposal": { - "description": "Deprecated. CancelSoftwareUpgradeProposal defines the struct for cancel software upgrade proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal. Non unique.", - "type": "string" - } - } - }, - "ClearAdminProposal": { - "description": "Deprecated. SudoContractProposal defines the struct for clear admin proposal.", - "deprecated": true, - "type": "object", - "required": [ - "contract", - "description", - "title" - ], - "properties": { - "contract": { - "description": "*contract** is an address of contract admin will be removed.", - "type": "string" - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - } - }, - "ClientUpdateProposal": { - "description": "ClientUpdateProposal defines the struct for client update proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "subject_client_id", - "substitute_client_id", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "subject_client_id": { - "description": "*subject_client_id** is a subject client id.", - "type": "string" - }, - "substitute_client_id": { - "description": "*substitute_client_id** is a substitute client id.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - } - }, "Coin": { "type": "object", "required": [ @@ -354,9 +146,10 @@ "denom": { "type": "string" } - } + }, + "additionalProperties": false }, - "CosmosMsg_for_NeutronMsg": { + "CosmosMsg_for_Empty": { "oneOf": [ { "type": "object", @@ -377,7 +170,7 @@ ], "properties": { "custom": { - "$ref": "#/definitions/NeutronMsg" + "$ref": "#/definitions/Empty" } }, "additionalProperties": false @@ -427,7 +220,21 @@ "value": { "$ref": "#/definitions/Binary" } - } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "`CosmosMsg::Any` is the replaces the \"stargate message\" – a message wrapped in a [protobuf Any](https://protobuf.dev/programming-guides/proto3/#any) that is suppored by the chain. It behaves the same as `CosmosMsg::Stargate` but has a better name and slightly improved syntax.\n\nThis is feature-gated at compile time with `cosmwasm_2_0` because a chain running CosmWasm < 2.0 cannot process this.", + "type": "object", + "required": [ + "any" + ], + "properties": { + "any": { + "$ref": "#/definitions/AnyMsg" } }, "additionalProperties": false @@ -474,406 +281,87 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "DenomUnit": { - "description": "Replicates the cosmos-sdk bank module DenomUnit type", - "type": "object", - "required": [ - "aliases", - "denom", - "exponent" - ], - "properties": { - "aliases": { - "type": "array", - "items": { - "type": "string" - } - }, - "denom": { - "type": "string" - }, - "exponent": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - }, - "DepositOption": { - "type": "object", - "required": [ - "disable_swap" - ], - "properties": { - "disable_swap": { - "type": "boolean" - } - } - }, - "DexMsg": { + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", "oneOf": [ { - "description": "Deposit provides liquidity to a specific trading pair by depositing tokens at a specific price into one or both sides of the pair in “a liquidity pool”", + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "deposit" + "set_withdraw_address" ], "properties": { - "deposit": { + "set_withdraw_address": { "type": "object", "required": [ - "amounts_a", - "amounts_b", - "fees", - "options", - "receiver", - "tick_indexes_a_to_b", - "token_a", - "token_b" + "address" ], "properties": { - "amounts_a": { - "description": "Amounts of tokenA to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "amounts_b": { - "description": "Amounts of tokenB to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "fees": { - "description": "Fees to use for each deposit", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "options": { - "description": "Additional deposit options", - "type": "array", - "items": { - "$ref": "#/definitions/DepositOption" - } - }, - "receiver": { - "description": "The account to which PoolShares will be issued", - "type": "string" - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", + "address": { + "description": "The `withdraw_address`", "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false }, { - "description": "Withdraw is used to redeem PoolShares for the user’s pro-rata portion of tokens within a liquidity pool. Users can withdraw from a pool at any time", + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "withdrawal" + "withdraw_delegator_reward" ], "properties": { - "withdrawal": { + "withdraw_delegator_reward": { "type": "object", "required": [ - "fees", - "receiver", - "shares_to_remove", - "tick_indexes_a_to_b", - "token_a", - "token_b" + "validator" ], "properties": { - "fees": { - "description": "Fee for the target LiquidityPools", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "receiver": { - "description": "The account to which the tokens are credited", - "type": "string" - }, - "shares_to_remove": { - "description": "Amount of shares to remove from each pool", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", + "validator": { + "description": "The `validator_address`", "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false }, { - "description": "PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to trade against preexisting liquidity (“Taker Limit Orders”)", + "description": "This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). `depositor` is automatically filled with the current contract's address.", "type": "object", "required": [ - "place_limit_order" + "fund_community_pool" ], "properties": { - "place_limit_order": { + "fund_community_pool": { "type": "object", "required": [ - "amount_in", - "limit_sell_price", - "order_type", - "receiver", - "tick_index_in_to_out", - "token_in", - "token_out" + "amount" ], "properties": { - "amount_in": { - "description": "Amount of TokenIn to be traded", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "expiration_time": { - "description": "Expiration time for order. Only valid for GOOD_TIL_TIME limit orders", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "limit_sell_price": { - "description": "Accepts standard decimals and decimals with scientific notation (ie. 1234.23E-7)", - "type": "string" - }, - "max_amount_out": { - "description": "Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - }, - "order_type": { - "description": "Type of limit order to be used. Must be one of: GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME", - "allOf": [ - { - "$ref": "#/definitions/LimitOrderType" - } - ] - }, - "receiver": { - "description": "Account to which TokenOut is credited or that will be allowed to withdraw or cancel a maker order", - "type": "string" - }, - "tick_index_in_to_out": { - "description": "Limit tick for a limit order, specified in terms of TokenIn to TokenOut", - "type": "integer", - "format": "int64" - }, - "token_in": { - "description": "Token being “sold”", - "type": "string" - }, - "token_out": { - "description": "Token being “bought”", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits all available proceeds to the user. Withdraw can be called on a limit order multiple times as new proceeds become available", - "type": "object", - "required": [ - "withdraw_filled_limit_order" - ], - "properties": { - "withdraw_filled_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time) can be canceled at any time if they have not been completely filled", - "type": "object", - "required": [ - "cancel_limit_order" - ], - "properties": { - "cancel_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "MultiHopSwap provides a swapping mechanism to achieve better prices by routing through a series of pools", - "type": "object", - "required": [ - "multi_hop_swap" - ], - "properties": { - "multi_hop_swap": { - "type": "object", - "required": [ - "amount_in", - "exit_limit_price", - "pick_best_route", - "receiver", - "routes" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to swap", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "exit_limit_price": { - "description": "Minimum price that that must be satisfied for a route to succeed", - "allOf": [ - { - "$ref": "#/definitions/PrecDec" - } - ] - }, - "pick_best_route": { - "description": "If true all routes are run and the route with the best price is used", - "type": "boolean" - }, - "receiver": { - "description": "Account to which TokenOut is credited", - "type": "string" - }, - "routes": { - "description": "Array of possible routes", + "amount": { + "description": "The amount to spend", "type": "array", "items": { - "$ref": "#/definitions/MultiHopRoute" + "$ref": "#/definitions/Coin" } } - } + }, + "additionalProperties": false } }, "additionalProperties": false } ] }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object", + "additionalProperties": false }, "GovMsg": { "description": "This message type allows the contract interact with the [x/gov] module in order to cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, option: VoteOption::Yes, })) } ```\n\nCast a weighted vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); # #[cfg(feature = \"cosmwasm_1_2\")] use cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};\n\n# #[cfg(feature = \"cosmwasm_1_2\")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::VoteWeighted { proposal_id: 4, options: vec![ WeightedVoteOption { option: VoteOption::Yes, weight: Decimal::percent(65), }, WeightedVoteOption { option: VoteOption::Abstain, weight: Decimal::percent(35), }, ], })) } ```", @@ -905,7 +393,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -935,1106 +424,178 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false } ] }, - "IbcFee": { - "description": "IbcFee defines struct for fees that refund the relayer for `SudoMsg` messages submission. Unused fee kind will be returned back to message sender. Please refer to these links for more information: IBC transaction structure - General mechanics of fee payments - ", - "type": "object", - "required": [ - "ack_fee", - "recv_fee", - "timeout_fee" - ], - "properties": { - "ack_fee": { - "description": "*ack_fee** is an amount of coins to refund relayer for submitting ack message for a particular IBC packet.", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "recv_fee": { - "description": "**recv_fee** currently is used for compatibility with ICS-29 interface only and must be set to zero (i.e. 0untrn), because Neutron's fee module can't refund relayer for submission of Recv IBC packets due to compatibility with target chains.", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "timeout_fee": { - "description": "*timeout_fee** amount of coins to refund relayer for submitting timeout message for a particular IBC packet.", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "type": "object", - "required": [ - "amount", - "channel_id", - "timeout", - "to_address" - ], - "properties": { - "amount": { - "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", - "allOf": [ - { - "$ref": "#/definitions/Coin" - } - ] - }, - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", - "type": "object", - "required": [ - "send_packet" - ], - "properties": { - "send_packet": { - "type": "object", - "required": [ - "channel_id", - "data", - "timeout" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "data": { - "$ref": "#/definitions/Binary" - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", - "type": "object", - "required": [ - "close_channel" - ], - "properties": { - "close_channel": { - "type": "object", - "required": [ - "channel_id" - ], - "properties": { - "channel_id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "IbcTimeout": { - "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", - "type": "object", - "properties": { - "block": { - "anyOf": [ - { - "$ref": "#/definitions/IbcTimeoutBlock" - }, - { - "type": "null" - } - ] - }, - "timestamp": { - "anyOf": [ - { - "$ref": "#/definitions/Timestamp" - }, - { - "type": "null" - } - ] - } - } - }, - "IbcTimeoutBlock": { - "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", - "type": "object", - "required": [ - "height", - "revision" - ], - "properties": { - "height": { - "description": "block height after which the packet times out. the height within the given revision", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "revision": { - "description": "the version that the client is currently on (e.g. after resetting the chain this could increment 1 as height drops to 0)", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - }, - "KVKey": { - "description": "Describes a KV key for which you want to get value from the storage on remote chain", - "type": "object", - "required": [ - "key", - "path" - ], - "properties": { - "key": { - "description": "*key** is a key you want to read from the storage", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "path": { - "description": "*path** is a path to the storage (storage prefix) where you want to read value by key (usually name of cosmos-packages module: 'staking', 'bank', etc.)", - "type": "string" - } - } - }, - "LimitOrderType": { - "oneOf": [ - { - "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", - "type": "string", - "enum": [ - "GOOD_TIL_CANCELLED" - ] - }, - { - "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` ( ErrGoodTilOrderWithoutExpiration).", - "type": "string", - "enum": [ - "FILL_OR_KILL" - ] - }, - { - "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", - "type": "string", - "enum": [ - "IMMEDIATE_OR_CANCEL" - ] - }, - { - "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", - "type": "string", - "enum": [ - "JUST_IN_TIME" - ] - }, - { - "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", - "type": "string", - "enum": [ - "GOOD_TIL_TIME" - ] - } - ] - }, - "MsgExecuteContract": { - "description": "MsgExecuteContract defines a call to the contract execution", - "type": "object", - "required": [ - "contract", - "msg" - ], - "properties": { - "contract": { - "description": "*contract** is a contract address that will be called", - "type": "string" - }, - "msg": { - "description": "*msg** is a contract call message", - "type": "string" - } - } - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "NeutronMsg": { - "description": "A number of Custom messages that can call into the Neutron bindings.", - "oneOf": [ - { - "description": "RegisterInterchainAccount registers an interchain account on remote chain.", - "type": "object", - "required": [ - "register_interchain_account" - ], - "properties": { - "register_interchain_account": { - "type": "object", - "required": [ - "connection_id", - "interchain_account_id" - ], - "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" - }, - "interchain_account_id": { - "description": "**interchain_account_id** is an identifier of your new interchain account. Can be any string. This identifier allows contracts to have multiple interchain accounts on remote chains.", - "type": "string" - }, - "register_fee": { - "description": "*register_fee** is a fees required to be payed to register interchain account", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "SubmitTx starts the process of executing any Cosmos-SDK *msgs* on remote chain.", - "type": "object", - "required": [ - "submit_tx" - ], - "properties": { - "submit_tx": { - "type": "object", - "required": [ - "connection_id", - "fee", - "interchain_account_id", - "memo", - "msgs", - "timeout" - ], - "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" - }, - "fee": { - "description": "**fee** is an ibc fee for the transaction.", - "allOf": [ - { - "$ref": "#/definitions/IbcFee" - } - ] - }, - "interchain_account_id": { - "description": "*interchain_account_id** is an identifier of your interchain account from which you want to execute msgs.", - "type": "string" - }, - "memo": { - "description": "*memo** is a memo you want to attach to your interchain transaction.It behaves like a memo in usual Cosmos transaction.", - "type": "string" - }, - "msgs": { - "description": "*msgs** is a list of protobuf encoded Cosmos-SDK messages you want to execute on remote chain.", - "type": "array", - "items": { - "$ref": "#/definitions/ProtobufAny" - } - }, - "timeout": { - "description": "*timeout** is a timeout in seconds after which the packet times out.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "RegisterInterchainQuery registers an interchain query.", - "type": "object", - "required": [ - "register_interchain_query" - ], - "properties": { - "register_interchain_query": { - "type": "object", - "required": [ - "connection_id", - "keys", - "query_type", - "transactions_filter", - "update_period" - ], - "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" - }, - "keys": { - "description": "*keys** is the KV-storage keys for which we want to get values from remote chain.", - "type": "array", - "items": { - "$ref": "#/definitions/KVKey" - } - }, - "query_type": { - "description": "*query_type** is a query type identifier ('tx' or 'kv' for now).", - "type": "string" - }, - "transactions_filter": { - "description": "*transactions_filter** is the filter for transaction search ICQ.", - "type": "string" - }, - "update_period": { - "description": "*update_period** is used to say how often the query must be updated.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "RegisterInterchainQuery updates an interchain query.", - "type": "object", - "required": [ - "update_interchain_query" - ], - "properties": { - "update_interchain_query": { - "type": "object", - "required": [ - "query_id" - ], - "properties": { - "new_keys": { - "description": "*new_keys** is the new query keys to retrive.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/KVKey" - } - }, - "new_transactions_filter": { - "description": "*new_transactions_filter** is a new transactions filter of the query.", - "type": [ - "string", - "null" - ] - }, - "new_update_period": { - "description": "*new_update_period** is a new update period of the query.", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "query_id": { - "description": "*query_id** is the ID of the query we want to update.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "RemoveInterchainQuery removes as interchain query.", - "type": "object", - "required": [ - "remove_interchain_query" - ], - "properties": { - "remove_interchain_query": { - "type": "object", - "required": [ - "query_id" - ], - "properties": { - "query_id": { - "description": "*query_id** is ID of the query we want to remove.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "IbcTransfer sends a fungible token packet over IBC.", - "type": "object", - "required": [ - "ibc_transfer" - ], - "properties": { - "ibc_transfer": { - "type": "object", - "required": [ - "fee", - "memo", - "receiver", - "sender", - "source_channel", - "source_port", - "timeout_height", - "timeout_timestamp", - "token" - ], - "properties": { - "fee": { - "$ref": "#/definitions/IbcFee" - }, - "memo": { - "type": "string" - }, - "receiver": { - "type": "string" - }, - "sender": { - "type": "string" - }, - "source_channel": { - "type": "string" - }, - "source_port": { - "type": "string" - }, - "timeout_height": { - "$ref": "#/definitions/RequestPacketTimeoutHeight" - }, - "timeout_timestamp": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "token": { - "$ref": "#/definitions/Coin" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "SubmitAdminProposal sends a proposal to neutron's Admin module. This type of messages can be only executed by Neutron DAO.", - "type": "object", - "required": [ - "submit_admin_proposal" - ], - "properties": { - "submit_admin_proposal": { - "type": "object", - "required": [ - "admin_proposal" - ], - "properties": { - "admin_proposal": { - "$ref": "#/definitions/AdminProposal" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can create denoms, namespaced under the contract's address. A contract may create any number of independent sub-denoms.", - "type": "object", - "required": [ - "create_denom" - ], - "properties": { - "create_denom": { - "type": "object", - "required": [ - "subdenom" - ], - "properties": { - "subdenom": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can change the admin of a denom that they are the admin of.", - "type": "object", - "required": [ - "change_admin" - ], - "properties": { - "change_admin": { - "type": "object", - "required": [ - "denom", - "new_admin_address" - ], - "properties": { - "denom": { - "type": "string" - }, - "new_admin_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can mint native tokens for an existing factory denom that they are the admin of.", - "type": "object", - "required": [ - "mint_tokens" - ], - "properties": { - "mint_tokens": { - "type": "object", - "required": [ - "amount", - "denom", - "mint_to_address" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - }, - "mint_to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can burn native tokens for an existing factory denom that they are the admin of. Currently, the burn from address must be the admin contract.", - "type": "object", - "required": [ - "burn_tokens" - ], - "properties": { - "burn_tokens": { - "type": "object", - "required": [ - "amount", - "burn_from_address", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "burn_from_address": { - "description": "Must be set to `\"\"` for now", - "type": "string" - }, - "denom": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can set before send hooks for denoms, namespaced under the contract's address.", - "type": "object", - "required": [ - "set_before_send_hook" - ], - "properties": { - "set_before_send_hook": { - "type": "object", - "required": [ - "contract_addr", - "denom" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "denom": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactoryMessage Contracts can force specified `amount` of an existing factory denom that they are admin of to a `transfer_to_address` from a `transfer_from_address`.", - "type": "object", - "required": [ - "force_transfer" - ], - "properties": { - "force_transfer": { - "type": "object", - "required": [ - "amount", - "denom", - "transfer_from_address", - "transfer_to_address" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - }, - "transfer_from_address": { - "type": "string" - }, - "transfer_to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactoryMessage Contracts can set a metadata for of an existing factory denom that they are admin of.", - "type": "object", - "required": [ - "set_denom_metadata" - ], - "properties": { - "set_denom_metadata": { - "type": "object", - "required": [ - "base", - "denom_units", - "description", - "display", - "name", - "symbol", - "uri", - "uri_hash" - ], - "properties": { - "base": { - "description": "*base** represents the base denom (should be the DenomUnit with exponent = 0).", - "type": "string" - }, - "denom_units": { - "description": "*denom_units** represents the list of DenomUnit's for a given coin", - "type": "array", - "items": { - "$ref": "#/definitions/DenomUnit" - } - }, - "description": { - "description": "*description** description of a token", - "type": "string" - }, - "display": { - "description": "**display** indicates the suggested denom that should be displayed in clients.", - "type": "string" - }, - "name": { - "description": "*name** defines the name of the token (eg: Cosmos Atom)", - "type": "string" - }, - "symbol": { - "description": "**symbol** is the token symbol usually shown on exchanges (eg: ATOM). This can be the same as the display.", - "type": "string" - }, - "uri": { - "description": "*uri** to a document (on or off-chain) that contains additional information. Optional.", - "type": "string" - }, - "uri_hash": { - "description": "**uri_hash** is a sha256 hash of a document pointed by URI. It's used to verify that the document didn't change. Optional.", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "AddSchedule adds new schedule with a given `name`. Until schedule is removed it will execute all `msgs` every `period` blocks. First execution is at least on `current_block + period` block. [Permissioned - DAO Only]", + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", "type": "object", "required": [ - "add_schedule" + "transfer" ], "properties": { - "add_schedule": { + "transfer": { "type": "object", "required": [ - "msgs", - "name", - "period" + "amount", + "channel_id", + "timeout", + "to_address" ], "properties": { - "msgs": { - "description": "list of cosmwasm messages to be executed", - "type": "array", - "items": { - "$ref": "#/definitions/MsgExecuteContract" - } + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] }, - "name": { - "description": "Name of a new schedule. Needed to be able to `RemoveSchedule` and to log information about it", + "channel_id": { + "description": "existing channel to send the tokens over", "type": "string" }, - "period": { - "description": "period in blocks with which `msgs` will be executed", - "type": "integer", - "format": "uint64", - "minimum": 0.0 + "memo": { + "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", + "type": [ + "string", + "null" + ] + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false }, { - "description": "RemoveSchedule removes the schedule with a given `name`. [Permissioned - DAO or Security DAO only]", + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", "required": [ - "remove_schedule" + "send_packet" ], "properties": { - "remove_schedule": { + "send_packet": { "type": "object", "required": [ - "name" + "channel_id", + "data", + "timeout" ], "properties": { - "name": { + "channel_id": { "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false }, { - "description": "Contractmanager message Resubmits failed acknowledgement. Acknowledgement failure is created when contract returns error or acknowledgement is out of gas. [Permissioned - only from contract that is initial caller of IBC transaction]", + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", "type": "object", "required": [ - "resubmit_failure" + "close_channel" ], "properties": { - "resubmit_failure": { + "close_channel": { "type": "object", "required": [ - "failure_id" + "channel_id" ], "properties": { - "failure_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 + "channel_id": { + "type": "string" } - } - } - }, - "additionalProperties": false - }, - { - "description": "Dex messages", - "type": "object", - "required": [ - "dex" - ], - "properties": { - "dex": { - "$ref": "#/definitions/DexMsg" + }, + "additionalProperties": false } }, "additionalProperties": false } ] }, - "ParamChange": { - "description": "ParamChange defines the struct for parameter change request.", - "type": "object", - "required": [ - "key", - "subspace", - "value" - ], - "properties": { - "key": { - "description": "*key** is a name of parameter. Unique for subspace.", - "type": "string" - }, - "subspace": { - "description": "*subspace** is a key of module to which the parameter to change belongs. Unique for each module.", - "type": "string" - }, - "value": { - "description": "*value** is a new value for given parameter. Non unique.", - "type": "string" - } - } - }, - "ParamChangeProposal": { - "description": "ParamChangeProposal defines the struct for single parameter change proposal.", - "type": "object", - "required": [ - "description", - "param_changes", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "param_changes": { - "description": "*param_changes** is a vector of params to be changed. Non unique.", - "type": "array", - "items": { - "$ref": "#/definitions/ParamChange" - } - }, - "title": { - "description": "*title** is a text title of proposal. Non unique.", - "type": "string" - } - } - }, - "PinCodesProposal": { - "description": "Deprecated. PinCodesProposal defines the struct for pin contract codes proposal.", - "deprecated": true, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", "type": "object", - "required": [ - "code_ids", - "description", - "title" - ], "properties": { - "code_ids": { - "description": "*code_ids** is an array of codes to be pined.", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] } - } + }, + "additionalProperties": false }, - "Plan": { - "description": "Plan defines the struct for planned upgrade.", + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", "type": "object", "required": [ "height", - "info", - "name" + "revision" ], "properties": { "height": { - "description": "*height** is a height at which the upgrade must be performed", + "description": "block height after which the packet times out. the height within the given revision", "type": "integer", - "format": "int64" - }, - "info": { - "description": "*info** is any application specific upgrade info to be included on-chain", - "type": "string" - }, - "name": { - "description": "*name** is a name for the upgrade", - "type": "string" - } - } - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - } - }, - "ProposalExecuteMessage": { - "description": "ProposalExecuteMessage defines the struct for sdk47 compatible admin proposal.", - "type": "object", - "required": [ - "message" - ], - "properties": { - "message": { - "description": "*message** is a json representing an sdk message passed to admin module to execute.", - "type": "string" - } - } - }, - "ProtobufAny": { - "description": "Type for wrapping any protobuf message", - "type": "object", - "required": [ - "type_url", - "value" - ], - "properties": { - "type_url": { - "description": "*type_url** describes the type of the serialized message", - "type": "string" - }, - "value": { - "description": "*value** must be a valid serialized protocol buffer of the above specified type", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - }, - "RequestPacketTimeoutHeight": { - "type": "object", - "properties": { - "revision_height": { - "type": [ - "integer", - "null" - ], "format": "uint64", "minimum": 0.0 }, - "revision_number": { - "type": [ - "integer", - "null" - ], + "revision": { + "description": "the version that the client is currently on (e.g. after resetting the chain this could increment 1 as height drops to 0)", + "type": "integer", "format": "uint64", "minimum": 0.0 } - } - }, - "SoftwareUpgradeProposal": { - "description": "Deprecated. SoftwareUpgradeProposal defines the struct for software upgrade proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "plan", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "plan": { - "description": "*plan** is a plan of upgrade.", - "allOf": [ - { - "$ref": "#/definitions/Plan" - } - ] - }, - "title": { - "description": "*title** is a text title of proposal. Non unique.", - "type": "string" - } - } + }, + "additionalProperties": false }, "StakingMsg": { "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", @@ -2059,7 +620,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2084,7 +646,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2113,46 +676,14 @@ "src_validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false } ] }, - "SudoContractProposal": { - "description": "Deprecated. SudoContractProposal defines the struct for sudo execution proposal.", - "deprecated": true, - "type": "object", - "required": [ - "contract", - "description", - "msg", - "title" - ], - "properties": { - "contract": { - "description": "*contract** is an address of contract to be executed.", - "type": "string" - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "msg": { - "description": "**msg*** is a sudo message.", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - } - }, "Timestamp": { "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", "allOf": [ @@ -2169,101 +700,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "UnpinCodesProposal": { - "description": "Deprecated. UnpinCodesProposal defines the struct for unpin contract codes proposal.", - "deprecated": true, - "type": "object", - "required": [ - "code_ids", - "description", - "title" - ], - "properties": { - "code_ids": { - "description": "*code_ids** is an array of codes to be unpined.", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - } - }, - "UpdateAdminProposal": { - "description": "Deprecated. UpdateAdminProposal defines the struct for update admin proposal.", - "deprecated": true, - "type": "object", - "required": [ - "contract", - "description", - "new_admin", - "title" - ], - "properties": { - "contract": { - "description": "*contract** is an address of contract to update admin.", - "type": "string" - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "new_admin": { - "description": "**new_admin*** is an address of new admin", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - } - }, - "UpgradeProposal": { - "description": "UpgradeProposal defines the struct for IBC upgrade proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "plan", - "title", - "upgraded_client_state" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "plan": { - "description": "*plan** is a plan of upgrade.", - "allOf": [ - { - "$ref": "#/definitions/Plan" - } - ] - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - }, - "upgraded_client_state": { - "description": "*upgraded_client_state** is an upgraded client state.", - "allOf": [ - { - "$ref": "#/definitions/ProtobufAny" - } - ] - } - } - }, "VoteOption": { "type": "string", "enum": [ @@ -2308,7 +744,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2358,7 +795,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2412,7 +850,8 @@ "salt": { "$ref": "#/definitions/Binary" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2449,7 +888,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2474,7 +914,8 @@ "contract_addr": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2495,7 +936,8 @@ "contract_addr": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -2515,7 +957,8 @@ "weight": { "$ref": "#/definitions/Decimal" } - } + }, + "additionalProperties": false } } } diff --git a/contracts/reflect/schema/instantiate_msg.json b/contracts/reflect/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/reflect/schema/instantiate_msg.json +++ b/contracts/reflect/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/reflect/schema/query_msg.json b/contracts/reflect/schema/query_msg.json index 75f442e..bc4cdcc 100644 --- a/contracts/reflect/schema/query_msg.json +++ b/contracts/reflect/schema/query_msg.json @@ -34,7 +34,8 @@ "denom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -59,7 +60,8 @@ "denom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -80,7 +82,56 @@ "address": { "type": "string" } - } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "This calls into the native bank module for querying metadata for a specific bank token. Return value is DenomMetadataResponse", + "type": "object", + "required": [ + "denom_metadata" + ], + "properties": { + "denom_metadata": { + "type": "object", + "required": [ + "denom" + ], + "properties": { + "denom": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "This calls into the native bank module for querying metadata for all bank tokens that have a metadata entry. Return value is AllDenomMetadataResponse", + "type": "object", + "required": [ + "all_denom_metadata" + ], + "properties": { + "all_denom_metadata": { + "type": "object", + "properties": { + "pagination": { + "anyOf": [ + { + "$ref": "#/definitions/PageRequest" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -91,6 +142,125 @@ "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", "type": "string" }, + "DistributionQuery": { + "oneOf": [ + { + "description": "See ", + "type": "object", + "required": [ + "delegator_withdraw_address" + ], + "properties": { + "delegator_withdraw_address": { + "type": "object", + "required": [ + "delegator_address" + ], + "properties": { + "delegator_address": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "See ", + "type": "object", + "required": [ + "delegation_rewards" + ], + "properties": { + "delegation_rewards": { + "type": "object", + "required": [ + "delegator_address", + "validator_address" + ], + "properties": { + "delegator_address": { + "type": "string" + }, + "validator_address": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "See ", + "type": "object", + "required": [ + "delegation_total_rewards" + ], + "properties": { + "delegation_total_rewards": { + "type": "object", + "required": [ + "delegator_address" + ], + "properties": { + "delegator_address": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "See ", + "type": "object", + "required": [ + "delegator_validators" + ], + "properties": { + "delegator_validators": { + "type": "object", + "required": [ + "delegator_address" + ], + "properties": { + "delegator_address": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "GrpcQuery": { + "description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to allowlist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query. Because of this, using it with the [`query`](crate::QuerierWrapper::query) function will result in a deserialization error. Use [`raw_query`](crate::Querier::raw_query) or [`query_grpc`](crate::QuerierWrapper::query_grpc) instead.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).", + "type": "object", + "required": [ + "data", + "path" + ], + "properties": { + "data": { + "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "path": { + "description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"", + "type": "string" + } + }, + "additionalProperties": false + }, "IbcQuery": { "description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"", "oneOf": [ @@ -102,7 +272,8 @@ ], "properties": { "port_id": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -123,7 +294,8 @@ "null" ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -150,7 +322,8 @@ "null" ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -176,7 +349,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -204,7 +378,8 @@ "owner_address": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -216,7 +391,8 @@ ], "properties": { "registered_interchain_queries": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -238,7 +414,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -250,7 +427,8 @@ ], "properties": { "min_ibc_fee": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -274,7 +452,8 @@ "subdenom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -294,13 +473,43 @@ "subdenom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false } ] }, + "PageRequest": { + "description": "Simplified version of the PageRequest type for pagination from the cosmos-sdk", + "type": "object", + "required": [ + "limit", + "reverse" + ], + "properties": { + "key": { + "anyOf": [ + { + "$ref": "#/definitions/Binary" + }, + { + "type": "null" + } + ] + }, + "limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "reverse": { + "type": "boolean" + } + }, + "additionalProperties": false + }, "QueryRequest_for_InterchainQueries": { "oneOf": [ { @@ -339,6 +548,18 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionQuery" + } + }, + "additionalProperties": false + }, { "description": "A Stargate query is encoded the same way as abci_query, with path and protobuf encoded request data. The format is defined in [ADR-21](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-021-protobuf-query-encoding.md). The response is protobuf encoded data directly without a JSON response wrapper. The caller is responsible for compiling the proper protobuf definitions for both requests and responses.", "deprecated": true, @@ -366,7 +587,8 @@ "description": "this is the fully qualified service path used for routing, eg. \"/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -394,6 +616,18 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "grpc" + ], + "properties": { + "grpc": { + "$ref": "#/definitions/GrpcQuery" + } + }, + "additionalProperties": false } ] }, @@ -407,7 +641,8 @@ ], "properties": { "bonded_denom": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -428,7 +663,8 @@ "delegator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -453,7 +689,8 @@ "validator": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -466,7 +703,8 @@ ], "properties": { "all_validators": { - "type": "object" + "type": "object", + "additionalProperties": false } }, "additionalProperties": false @@ -488,7 +726,8 @@ "description": "The validator's address (e.g. (e.g. cosmosvaloper1...))", "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -522,7 +761,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -552,7 +792,8 @@ } ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -573,7 +814,8 @@ "contract_addr": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -596,7 +838,8 @@ "format": "uint64", "minimum": 0.0 } - } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index f9ebb8b..54210f5 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -5,7 +5,6 @@ use cosmwasm_std::{ Uint128, }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -34,19 +33,14 @@ pub fn instantiate( #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { Send { to: String, amount: Uint128 }, - ReflectMsg { msgs: Vec> }, + ReflectMsg { msgs: Vec }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct MigrateMsg {} #[entry_point] -pub fn execute( - deps: DepsMut, - _env: Env, - _: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, _env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -74,7 +68,14 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResul pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> StdResult { match msg.id { REFLECT_REPLY_ID => { - Ok(Response::default().set_data(msg.result.unwrap().msg_responses[0].clone().value)) + let res = Response::default(); + + let msg_responses = msg.result.unwrap().msg_responses; + if msg_responses.is_empty() { + Ok(res) + } else { + Ok(res.set_data(msg_responses[0].clone().value)) + } } _ => { unimplemented!() diff --git a/contracts/stargate_querier/.cargo/config b/contracts/stargate_querier/.cargo/config deleted file mode 100644 index 406f9aa..0000000 --- a/contracts/stargate_querier/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example stargate_querier-schema" diff --git a/contracts/stargate_querier/README.md b/contracts/stargate_querier/README.md deleted file mode 100644 index 62142d7..0000000 --- a/contracts/stargate_querier/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Description - -Simple contract for integration tests. - -Makes all kinds of stargate queries allowed for Neutron chain. diff --git a/contracts/stargate_querier/schema/instantiate_msg.json b/contracts/stargate_querier/schema/instantiate_msg.json deleted file mode 100644 index 44588cf..0000000 --- a/contracts/stargate_querier/schema/instantiate_msg.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object" -} diff --git a/contracts/stargate_querier/src/contract.rs b/contracts/stargate_querier/src/contract.rs deleted file mode 100644 index d996ad5..0000000 --- a/contracts/stargate_querier/src/contract.rs +++ /dev/null @@ -1,346 +0,0 @@ -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use cosmos_sdk_proto::{ - cosmos::{auth, bank}, - ibc, -}; -use cosmwasm_std::{ - entry_point, to_json_binary, Binary, ContractResult, Deps, DepsMut, Empty, Env, MessageInfo, - QueryRequest, Response, StdError, StdResult, SystemResult, -}; -use std::str::from_utf8; - -use crate::stargate; -use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; -use neutron_sdk::NeutronResult; -use prost::Message; -use serde_json_wasm::to_vec; - -const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - deps.api.debug("WASMDEBUG: instantiate"); - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - _: DepsMut, - _: Env, - _: MessageInfo, - _msg: ExecuteMsg, -) -> StdResult> { - Ok(Response::default()) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> NeutronResult { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - match msg { - QueryMsg::BankBalance { address, denom } => query_bank_balance(deps, address, denom), - QueryMsg::BankDenomMetadata { denom } => query_bank_denom_metadata(deps, denom), - QueryMsg::BankParams {} => query_bank_params(deps), - QueryMsg::BankSupplyOf { denom } => query_bank_supply_of(deps, denom), - QueryMsg::AuthAccount { address } => query_auth_account(deps, address), - QueryMsg::TransferDenomTrace { hash } => query_transfer_denom_trace(deps, hash), - QueryMsg::IbcClientState { client_id } => query_ibc_client_state(deps, client_id), - QueryMsg::IbcConsensusState { - client_id, - revision_number, - revision_height, - latest_height, - } => query_ibc_consensus_state( - deps, - client_id, - revision_number, - revision_height, - latest_height, - ), - QueryMsg::IbcConnection { connection_id } => query_ibc_connection(deps, connection_id), - QueryMsg::TokenfactoryParams {} => query_tokenfactory_params(deps), - QueryMsg::TokenfactoryDenomAuthorityMetadata { denom } => { - query_tokenfactory_denom_authority_metadata(deps, denom) - } - QueryMsg::TokenfactoryDenomsFromCreator { creator } => { - query_tokenfactory_denoms_from_creator(deps, creator) - } - QueryMsg::ContractmanagerAddressFailures { address } => { - query_contractmanager_query_address_failures(deps, address) - } - QueryMsg::ContractmanagerFailures { address } => { - query_contractmanager_query_failures(deps, address) - } - QueryMsg::InterchaintxParams {} => query_interchaintx_params(deps), - QueryMsg::InterchainqueriesParams {} => query_interchainqueries_params(deps), - QueryMsg::FeeburnerParams {} => query_feeburner_params(deps), - QueryMsg::FeeburnerTotalBurnedNeutronsAmount {} => { - query_feeburner_total_burned_neutrons_amount(deps) - } - } -} - -fn query_bank_balance(deps: Deps, address: String, denom: String) -> NeutronResult { - let msg = bank::v1beta1::QueryBalanceRequest { address, denom }; - let resp = make_stargate_query( - deps, - "/cosmos.bank.v1beta1.Query/Balance".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_bank_denom_metadata(deps: Deps, denom: String) -> NeutronResult { - let msg = bank::v1beta1::QueryDenomMetadataRequest { denom }; - let mut bytes = Vec::new(); - Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?; - - let resp = make_stargate_query( - deps, - "/cosmos.bank.v1beta1.Query/DenomMetadata".to_string(), - bytes, - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_bank_params(deps: Deps) -> NeutronResult { - let msg = bank::v1beta1::QueryParamsRequest {}; - let mut bytes = Vec::new(); - Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?; - - let resp = make_stargate_query(deps, "/cosmos.bank.v1beta1.Query/Params".to_string(), bytes)?; - Ok(to_json_binary(&resp)?) -} - -fn query_bank_supply_of(deps: Deps, denom: String) -> NeutronResult { - let msg = bank::v1beta1::QuerySupplyOfRequest { denom }; - let resp = make_stargate_query( - deps, - "/cosmos.bank.v1beta1.Query/SupplyOf".to_string(), - Message::encode_to_vec(&msg), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_auth_account(deps: Deps, address: String) -> NeutronResult { - let msg = auth::v1beta1::QueryAccountRequest { address }; - let resp = make_stargate_query( - deps, - "/cosmos.auth.v1beta1.Query/Account".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_transfer_denom_trace(deps: Deps, hash: String) -> NeutronResult { - let msg = ibc::applications::transfer::v1::QueryDenomTraceRequest { hash }; - let resp = make_stargate_query( - deps, - "/ibc.applications.transfer.v1.Query/DenomTrace".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_ibc_client_state(deps: Deps, client_id: String) -> NeutronResult { - let msg = ibc::core::client::v1::QueryClientStateRequest { client_id }; - let resp = make_stargate_query( - deps, - "/ibc.core.client.v1.Query/ClientState".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_ibc_consensus_state( - deps: Deps, - client_id: String, - revision_number: u64, - revision_height: u64, - latest_height: bool, -) -> NeutronResult { - let msg = ibc::core::client::v1::QueryConsensusStateRequest { - client_id, - revision_number, - revision_height, - latest_height, - }; - let resp = make_stargate_query( - deps, - "/ibc.core.client.v1.Query/ConsensusState".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_ibc_connection(deps: Deps, connection_id: String) -> NeutronResult { - let msg = ibc::core::connection::v1::QueryConnectionRequest { connection_id }; - let resp = make_stargate_query( - deps, - "/ibc.core.connection.v1.Query/Connection".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_tokenfactory_params(deps: Deps) -> NeutronResult { - let msg = osmosis_std::types::osmosis::tokenfactory::v1beta1::QueryParamsRequest {}; - let resp = make_stargate_query( - deps, - "/osmosis.tokenfactory.v1beta1.Query/Params".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_tokenfactory_denom_authority_metadata(deps: Deps, denom: String) -> NeutronResult { - let msg = - osmosis_std::types::osmosis::tokenfactory::v1beta1::QueryDenomAuthorityMetadataRequest { - denom, - }; - let resp = make_stargate_query( - deps, - "/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_tokenfactory_denoms_from_creator(deps: Deps, creator: String) -> NeutronResult { - let msg = osmosis_std::types::osmosis::tokenfactory::v1beta1::QueryDenomsFromCreatorRequest { - creator, - }; - let resp = make_stargate_query( - deps, - "/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_contractmanager_query_address_failures( - deps: Deps, - address: String, -) -> NeutronResult { - let msg = stargate::contractmanager::QueryAddressFailuresRequest { address }; - let resp = make_stargate_query( - deps, - "/neutron.contractmanager.Query/AddressFailures".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_contractmanager_query_failures(deps: Deps, address: String) -> NeutronResult { - let msg = stargate::contractmanager::QueryFailuresRequest { - address, - pagination: None, - }; - let resp = make_stargate_query( - deps, - "/neutron.contractmanager.Query/Failures".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_interchaintx_params(deps: Deps) -> NeutronResult { - let msg = stargate::interchaintx::QueryParams {}; - let resp = make_stargate_query( - deps, - "/neutron.interchaintxs.v1.Query/Params".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_interchainqueries_params(deps: Deps) -> NeutronResult { - let msg = stargate::interchainqueries::QueryParams {}; - let resp = make_stargate_query( - deps, - "/neutron.interchainqueries.Query/Params".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -fn query_feeburner_params(deps: Deps) -> NeutronResult { - let msg = stargate::feeburner::QueryParams {}; - let resp = make_stargate_query( - deps, - "/neutron.feeburner.Query/Params".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -// WARN: should not work since we did not allowlist it -// exists here only for testing purposes -fn query_feeburner_total_burned_neutrons_amount(deps: Deps) -> NeutronResult { - let msg = stargate::feeburner::QueryTotalBurnedNeutronsAmountRequest {}; - let resp = make_stargate_query( - deps, - "/neutron.feeburner.Query/TotalBurnedNeutronsAmount".to_string(), - msg.encode_to_vec(), - )?; - - Ok(to_json_binary(&resp)?) -} - -pub fn make_stargate_query( - deps: Deps, - path: String, - encoded_query_data: Vec, -) -> StdResult { - #[allow(deprecated)] - let raw = to_vec::>(&QueryRequest::Stargate { - path, - data: encoded_query_data.into(), - }) - .map_err(|serialize_err| { - StdError::generic_err(format!("Serializing QueryRequest: {}", serialize_err)) - })?; - match deps.querier.raw_query(&raw) { - SystemResult::Err(system_err) => Err(StdError::generic_err(format!( - "Querier system error: {}", - system_err - ))), - SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err(format!( - "Querier contract error: {}", - contract_err - ))), - // response(value) is base64 encoded bytes - SystemResult::Ok(ContractResult::Ok(value)) => { - let str = value.to_base64(); - deps.api - .debug(format!("WASMDEBUG: make_stargate_query: {:?}", str).as_str()); - from_utf8(value.as_slice()) - .map(|s| s.to_string()) - .map_err(|_e| StdError::generic_err("Unable to encode from utf8")) - } - } -} diff --git a/contracts/stargate_querier/src/stargate.rs b/contracts/stargate_querier/src/stargate.rs deleted file mode 100644 index 9f25dfc..0000000 --- a/contracts/stargate_querier/src/stargate.rs +++ /dev/null @@ -1,34 +0,0 @@ -pub mod interchaintx { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryParams {} -} - -pub mod interchainqueries { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryParams {} -} - -pub mod feeburner { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryParams {} - - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryTotalBurnedNeutronsAmountRequest {} -} - -pub mod contractmanager { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryAddressFailuresRequest { - #[prost(string, tag = "1")] - pub address: ::prost::alloc::string::String, - } - - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryFailuresRequest { - #[prost(string, tag = "1")] - pub address: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub pagination: - ::core::option::Option<::cosmos_sdk_proto::cosmos::base::query::v1beta1::PageRequest>, - } -} diff --git a/contracts/tokenfactory/Cargo.toml b/contracts/tokenfactory/Cargo.toml index 7fe7cd6..e709cc5 100644 --- a/contracts/tokenfactory/Cargo.toml +++ b/contracts/tokenfactory/Cargo.toml @@ -23,6 +23,7 @@ cosmwasm-std = { workspace = true } serde = { workspace = true } schemars = { workspace = true } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/tokenfactory/schema/execute_msg.json b/contracts/tokenfactory/schema/execute_msg.json index 4137274..71dfbee 100644 --- a/contracts/tokenfactory/schema/execute_msg.json +++ b/contracts/tokenfactory/schema/execute_msg.json @@ -17,7 +17,8 @@ "subdenom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -41,7 +42,8 @@ "new_admin_address": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -64,8 +66,15 @@ }, "denom": { "type": "string" + }, + "mint_to_address": { + "type": [ + "string", + "null" + ] } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -86,10 +95,17 @@ "amount": { "$ref": "#/definitions/Uint128" }, + "burn_from_address": { + "type": [ + "string", + "null" + ] + }, "denom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -117,7 +133,8 @@ "recipient": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -141,7 +158,8 @@ "denom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -173,7 +191,8 @@ "to": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -224,7 +243,8 @@ "uri_hash": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -232,7 +252,7 @@ ], "definitions": { "DenomUnit": { - "description": "Replicates the cosmos-sdk bank module DenomUnit type", + "description": "DenomUnit represents a struct that describes a given denomination unit of the basic token.", "type": "object", "required": [ "aliases", @@ -241,20 +261,24 @@ ], "properties": { "aliases": { + "description": "aliases is a list of string aliases for the given denom", "type": "array", "items": { "type": "string" } }, "denom": { + "description": "denom represents the string name of the given denom unit (e.g uatom).", "type": "string" }, "exponent": { + "description": "exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 10^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom).", "type": "integer", "format": "uint32", "minimum": 0.0 } - } + }, + "additionalProperties": false }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", diff --git a/contracts/tokenfactory/schema/instantiate_msg.json b/contracts/tokenfactory/schema/instantiate_msg.json index 44588cf..1352613 100644 --- a/contracts/tokenfactory/schema/instantiate_msg.json +++ b/contracts/tokenfactory/schema/instantiate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/tokenfactory/schema/migrate_msg.json b/contracts/tokenfactory/schema/migrate_msg.json index 87b18ea..7fbe8c5 100644 --- a/contracts/tokenfactory/schema/migrate_msg.json +++ b/contracts/tokenfactory/schema/migrate_msg.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "MigrateMsg", - "type": "object" + "type": "object", + "additionalProperties": false } diff --git a/contracts/tokenfactory/schema/query_msg.json b/contracts/tokenfactory/schema/query_msg.json index 7f89698..d86ed5d 100644 --- a/contracts/tokenfactory/schema/query_msg.json +++ b/contracts/tokenfactory/schema/query_msg.json @@ -11,17 +11,18 @@ "full_denom": { "type": "object", "required": [ - "creator_addr", + "creator", "subdenom" ], "properties": { - "creator_addr": { + "creator": { "type": "string" }, "subdenom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -35,13 +36,18 @@ "denom_admin": { "type": "object", "required": [ + "creator", "subdenom" ], "properties": { + "creator": { + "type": "string" + }, "subdenom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false @@ -55,13 +61,18 @@ "before_send_hook": { "type": "object", "required": [ - "denom" + "creator", + "subdenom" ], "properties": { - "denom": { + "creator": { + "type": "string" + }, + "subdenom": { "type": "string" } - } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index c66085b..c9960b8 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -1,13 +1,15 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_std::{ coins, entry_point, to_json_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, - MessageInfo, Response, StdResult, + MessageInfo, Response, StdError, StdResult, }; -use neutron_sdk::query::token_factory::query_before_send_hook; -use neutron_sdk::{ - bindings::{msg::NeutronMsg, query::NeutronQuery}, - query::token_factory::{query_denom_admin, query_full_denom}, - NeutronResult, +use neutron_sdk::NeutronError::Std; +use neutron_sdk::NeutronResult; +use neutron_std::types::cosmos::bank::v1beta1::Metadata; +use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::osmosis::tokenfactory::v1beta1::{ + MsgBurn, MsgChangeAdmin, MsgCreateDenom, MsgForceTransfer, MsgMint, MsgSetBeforeSendHook, + MsgSetDenomMetadata, TokenfactoryQuerier, }; #[entry_point] @@ -26,23 +28,57 @@ pub fn execute( env: Env, _info: MessageInfo, msg: ExecuteMsg, -) -> StdResult> { - let msg: CosmosMsg = match msg { - ExecuteMsg::CreateDenom { subdenom } => NeutronMsg::submit_create_denom(subdenom).into(), +) -> StdResult { + let msg: CosmosMsg = match msg { + ExecuteMsg::CreateDenom { subdenom } => MsgCreateDenom { + sender: env.contract.address.to_string(), + subdenom, + } + .into(), ExecuteMsg::ChangeAdmin { denom, new_admin_address, - } => NeutronMsg::submit_change_admin(denom, new_admin_address).into(), - ExecuteMsg::MintTokens { denom, amount } => { - NeutronMsg::submit_mint_tokens(denom, amount, env.contract.address).into() + } => MsgChangeAdmin { + sender: env.contract.address.to_string(), + denom, + new_admin: new_admin_address, + } + .into(), + ExecuteMsg::MintTokens { + denom, + amount, + mint_to_address, + } => MsgMint { + sender: env.contract.address.to_string(), + amount: Some(CosmosCoin { + denom, + amount: amount.to_string(), + }), + mint_to_address: mint_to_address.unwrap_or(env.contract.address.into()), } - ExecuteMsg::BurnTokens { denom, amount } => { - NeutronMsg::submit_burn_tokens(denom, amount).into() + .into(), + ExecuteMsg::BurnTokens { + denom, + amount, + burn_from_address, + } => MsgBurn { + sender: env.contract.address.to_string(), + amount: Some(CosmosCoin { + denom, + amount: amount.to_string(), + }), + burn_from_address: burn_from_address.unwrap_or(env.contract.address.into()), } + .into(), ExecuteMsg::SetBeforeSendHook { denom, contract_addr, - } => NeutronMsg::submit_set_before_send_hook(denom, contract_addr).into(), + } => MsgSetBeforeSendHook { + sender: env.contract.address.to_string(), + denom, + contract_addr, + } + .into(), ExecuteMsg::SendTokens { recipient, denom, @@ -57,7 +93,16 @@ pub fn execute( amount, from, to, - } => NeutronMsg::submit_force_transfer(denom, amount, from, to).into(), + } => MsgForceTransfer { + sender: env.contract.address.to_string(), + amount: Some(CosmosCoin { + denom, + amount: amount.to_string(), + }), + transfer_from_address: from, + transfer_to_address: to, + } + .into(), ExecuteMsg::SetDenomMetadata { description, denom_units, @@ -67,31 +112,42 @@ pub fn execute( symbol, uri, uri_hash, - } => NeutronMsg::submit_set_denom_metadata( - description, - denom_units, - base, - display, - name, - symbol, - uri, - uri_hash, - ) + } => MsgSetDenomMetadata { + sender: env.contract.address.to_string(), + metadata: Some(Metadata { + description, + denom_units, + base, + display, + name, + symbol, + uri, + uri_hash, + }), + } .into(), }; Ok(Response::new().add_message(msg)) } #[entry_point] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { + let querier = TokenfactoryQuerier::new(&deps.querier); Ok(match msg { - QueryMsg::FullDenom { - creator_addr, - subdenom, - } => to_json_binary(&query_full_denom(deps, creator_addr, subdenom)?)?, - QueryMsg::DenomAdmin { subdenom } => to_json_binary(&query_denom_admin(deps, subdenom)?)?, - QueryMsg::BeforeSendHook { denom } => { - to_json_binary(&query_before_send_hook(deps, denom)?)? + QueryMsg::FullDenom { creator, subdenom } => { + let res = &querier.full_denom(creator, subdenom)?; + to_json_binary(res)? + } + QueryMsg::DenomAdmin { creator, subdenom } => { + let authority = querier.denom_authority_metadata(creator, subdenom)?; + to_json_binary( + &authority + .authority_metadata + .ok_or(Std(StdError::generic_err("authority metadata not found")))?, + )? + } + QueryMsg::BeforeSendHook { creator, subdenom } => { + to_json_binary(&querier.before_send_hook_address(creator, subdenom)?)? } }) } diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index e163c28..73b68cc 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -1,4 +1,5 @@ -use cosmwasm_std::{DenomUnit, Uint128}; +use cosmwasm_std::Uint128; +use neutron_std::types::cosmos::bank::v1beta1::DenomUnit; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -18,10 +19,12 @@ pub enum ExecuteMsg { MintTokens { denom: String, amount: Uint128, + mint_to_address: Option, }, BurnTokens { denom: String, amount: Uint128, + burn_from_address: Option, }, SendTokens { recipient: String, @@ -53,16 +56,9 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - FullDenom { - creator_addr: String, - subdenom: String, - }, - DenomAdmin { - subdenom: String, - }, - BeforeSendHook { - denom: String, - }, + FullDenom { creator: String, subdenom: String }, + DenomAdmin { creator: String, subdenom: String }, + BeforeSendHook { creator: String, subdenom: String }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 8142c30..5198580 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.73.0" +channel = "1.78.0"