diff --git a/Cargo.lock b/Cargo.lock index 6df3936..29af06a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,9 +33,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "ark-bls12-381" @@ -160,13 +160,13 @@ dependencies = [ [[package]] name = "astroport" -version = "5.4.0" -source = "git+https://github.com/astroport-fi/astroport-core#034ec4375ce50e34d9e9aff15d1f86d497b27b81" +version = "5.7.0" +source = "git+https://github.com/astroport-fi/astroport-core#54d65dcbe9cf652c024fc0110b531f190efafce6" dependencies = [ "astroport-circular-buffer", "cosmos-sdk-proto 0.19.0", - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-asset", "cw-storage-plus 1.2.0", "cw-utils", @@ -179,27 +179,27 @@ dependencies = [ [[package]] name = "astroport-circular-buffer" version = "0.2.0" -source = "git+https://github.com/astroport-fi/astroport-core#034ec4375ce50e34d9e9aff15d1f86d497b27b81" +source = "git+https://github.com/astroport-fi/astroport-core#54d65dcbe9cf652c024fc0110b531f190efafce6" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "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.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "cw2 1.1.2", "thiserror", @@ -245,8 +245,8 @@ checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" name = "before-send-hook-test" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "schemars", "serde", @@ -290,9 +290,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" dependencies = [ "serde", ] @@ -312,19 +312,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "client_updater" -version = "0.1.0" -dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", - "cw-storage-plus 2.0.0", - "cw2 2.0.0", - "neutron-sdk", - "schemars", - "serde", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -355,15 +342,15 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" +checksum = "5f6ceb8624260d0d3a67c4e1a1d43fc7e9406720afbcb124521501dd138f90aa" [[package]] name = "cosmwasm-crypto" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f862b355f7e47711e0acfe6af92cb3fd8fd5936b66a9eaa338b51edabd1e77d" +checksum = "58535cbcd599b3c193e3967c8292fe1dbbb5de7c2a2d87380661091dd4744044" dependencies = [ "digest 0.10.7", "ed25519-zebra 3.1.0", @@ -374,9 +361,9 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ced5a6dd2801a383d3e14e5ae5caa7fdfeff1bd9f22b30e810e0aded8a5869" +checksum = "4125381e5fd7fefe9f614640049648088015eca2b60d861465329a5d87dfa538" dependencies = [ "ark-bls12-381", "ark-ec", @@ -397,31 +384,31 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd85de6467cd1073688c86b39833679ae6db18cf4771471edd9809f15f1679f1" +checksum = "a8e07de16c800ac82fd188d055ecdb923ead0cf33960d3350089260bb982c09f" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-derive" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd1873f84d9b17edf8a90ffe10a89a649b82feacc00e36788b81d2c3cbf03c" +checksum = "1b5658b1dc64e10b56ae7a449f678f96932a96f6cfad1769d608d1d1d656480a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] name = "cosmwasm-schema" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4cd28147a66eba73720b47636a58097a979ad8c8bfdb4ed437ebcbfe362576" +checksum = "93d388adfa9cb449557a92e9318121ac1a481fc4f599213b03a5b62699b403b4" dependencies = [ - "cosmwasm-schema-derive 1.5.7", + "cosmwasm-schema-derive 1.5.8", "schemars", "serde", "serde_json", @@ -430,11 +417,11 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27984b137eb2ac561f97f6bdb02004a98eb6f2ba263062c140b8e231ee1826b7" +checksum = "f86b4d949b6041519c58993a73f4bbfba8083ba14f7001eae704865a09065845" dependencies = [ - "cosmwasm-schema-derive 2.1.0", + "cosmwasm-schema-derive 2.1.4", "schemars", "serde", "serde_json", @@ -443,9 +430,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9acd45c63d41bc9b16bc6dc7f6bd604a8c2ad29ce96c8f3c96d7fc8ef384392e" +checksum = "2411b389e56e6484f81ba955b758d02522d620c98fc960c4bd2251d48b7aa19f" dependencies = [ "proc-macro2", "quote", @@ -454,26 +441,26 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ef0d201f611bdb6c9124207032423eb956f1fc8ab3e3ee7253a9c08a5f5809" +checksum = "c8ef1b5835a65fcca3ab8b9a02b4f4dacc78e233a5c2f20b270efb9db0666d12" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] name = "cosmwasm-std" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2685c2182624b2e9e17f7596192de49a3f86b7a0c9a5f6b25c1df5e24592e836" +checksum = "c21fde95ccd20044a23c0ac6fd8c941f3e8c158169dc94b5aa6491a2d9551a8d" dependencies = [ "base64 0.21.7", "bech32 0.9.1", "bnum 0.10.0", - "cosmwasm-crypto 1.5.7", - "cosmwasm-derive 1.5.7", + "cosmwasm-crypto 1.5.8", + "cosmwasm-derive 1.5.8", "derivative", "forward_ref", "hex", @@ -487,16 +474,16 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" +checksum = "70eb7ab0c1e99dd6207496963ba2a457c4128ac9ad9c72a83f8d9808542b849b" dependencies = [ "base64 0.22.1", "bech32 0.11.0", "bnum 0.11.0", "cosmwasm-core", - "cosmwasm-crypto 2.1.0", - "cosmwasm-derive 2.1.0", + "cosmwasm-crypto 2.1.4", + "cosmwasm-derive 2.1.4", "derive_more", "hex", "rand_core 0.6.4", @@ -510,9 +497,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -521,8 +508,8 @@ dependencies = [ name = "cron" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -620,7 +607,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] @@ -629,7 +616,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" dependencies = [ - "cosmwasm-std 1.5.7", + "cosmwasm-std 1.5.8", ] [[package]] @@ -638,8 +625,8 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c999a12f8cd8736f6f86e9a4ede5905530cb23cfdef946b9da1c506ad1b70799" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-address-like", "cw-storage-plus 1.2.0", "cw20", @@ -652,7 +639,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ - "cosmwasm-std 1.5.7", + "cosmwasm-std 1.5.8", "schemars", "serde", ] @@ -663,7 +650,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ - "cosmwasm-std 2.1.0", + "cosmwasm-std 2.1.4", "schemars", "serde", ] @@ -674,8 +661,8 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw2 1.1.2", "schemars", "semver", @@ -689,8 +676,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "schemars", "semver", @@ -704,8 +691,8 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "schemars", "semver", @@ -719,8 +706,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-utils", "schemars", "serde", @@ -758,46 +745,35 @@ dependencies = [ [[package]] name = "derive_more" -version = "1.0.0-beta.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "1.0.0-beta.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", "unicode-xid", ] -[[package]] -name = "dex" -version = "0.1.0" -dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", - "cw2 2.0.0", - "neutron-sdk", - "schemars", - "serde", -] - [[package]] name = "dex_grpc" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -849,8 +825,8 @@ dependencies = [ name = "echo" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "schemars", "serde", ] @@ -896,9 +872,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -987,10 +963,11 @@ dependencies = [ name = "grpc_querier" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "schemars", "serde", @@ -1052,8 +1029,8 @@ version = "0.1.0" dependencies = [ "base64 0.21.7", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1070,8 +1047,8 @@ version = "0.1.0" dependencies = [ "base64 0.21.7", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1086,11 +1063,12 @@ dependencies = [ name = "ibc_transfer" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1122,9 +1100,9 @@ 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", @@ -1136,28 +1114,35 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "marketmap" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.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.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1169,8 +1154,8 @@ dependencies = [ name = "neutron-price-feed-mock" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "thiserror", @@ -1179,14 +1164,14 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#38197fb61ca4180ca695a5d215d31309813046d6" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#b83c182e8688f826c313cae318ff8ae908b87c81" dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", - "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-sdk?branch=main)", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "protobuf", @@ -1202,15 +1187,15 @@ dependencies = [ [[package]] name = "neutron-std" -version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e4e54dcf999dcafa1b71040c5c75d58f82c9122b" +version = "5.0.0" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#25e0d0c1e7f56d40ba62908d9e2c03b5d3779bd2" dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", - "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings)", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "neutron-std-derive", "prost 0.12.6", "prost-types 0.12.6", "protobuf", @@ -1227,19 +1212,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e4e54dcf999dcafa1b71040c5c75d58f82c9122b" -dependencies = [ - "itertools 0.10.5", - "proc-macro2", - "prost-types 0.12.6", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "neutron-std-derive" -version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#38197fb61ca4180ca695a5d215d31309813046d6" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#25e0d0c1e7f56d40ba62908d9e2c03b5d3779bd2" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -1254,11 +1227,12 @@ version = "0.1.0" dependencies = [ "base64 0.21.7", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "schemars", "serde", @@ -1270,11 +1244,12 @@ name = "neutron_interchain_txs" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -1287,11 +1262,12 @@ name = "neutron_validators_test" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1344,9 +1320,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" @@ -1358,10 +1334,11 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" name = "oracle" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", ] @@ -1402,9 +1379,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "primeorder" @@ -1417,9 +1397,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -1467,7 +1447,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] @@ -1510,9 +1490,9 @@ 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", ] @@ -1576,8 +1556,8 @@ dependencies = [ name = "reflect" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", "schemars", @@ -1596,18 +1576,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "ryu" @@ -1636,7 +1616,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] @@ -1661,9 +1641,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] @@ -1697,22 +1677,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.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] @@ -1723,16 +1703,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1816,14 +1797,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.85", ] [[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" @@ -1847,9 +1828,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -1894,22 +1875,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] @@ -1945,9 +1926,10 @@ dependencies = [ name = "tokenfactory" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "neutron-sdk", + "neutron-std", "schemars", "serde", ] @@ -1972,21 +1954,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 = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +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" @@ -2000,6 +1982,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -2011,7 +1994,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] [[package]] @@ -2031,5 +2014,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.85", ] diff --git a/Cargo.toml b/Cargo.toml index 2efae4e..284a715 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,9 +2,7 @@ members = [ "contracts/balance-tracker", "contracts/before-send-hook", - "contracts/client_updater", "contracts/cron", - "contracts/dex", "contracts/dex_grpc", "contracts/echo", "contracts/grpc_querier", @@ -34,7 +32,8 @@ 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 = "feat/clean-bindings" } +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 } 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/client_updater/.cargo/config b/contracts/client_updater/.cargo/config deleted file mode 100644 index f5c196b..0000000 --- a/contracts/client_updater/.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 client_updater-schema" diff --git a/contracts/client_updater/Cargo.toml b/contracts/client_updater/Cargo.toml deleted file mode 100644 index 52a634b..0000000 --- a/contracts/client_updater/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "client_updater" -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"] - -[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 } - -[dev-dependencies] -cosmwasm-schema = { workspace = true } 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/examples/client_updater-schema.rs b/contracts/client_updater/examples/client_updater-schema.rs deleted file mode 100644 index 112c257..0000000 --- a/contracts/client_updater/examples/client_updater-schema.rs +++ /dev/null @@ -1,29 +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 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); -} diff --git a/contracts/client_updater/schema/execute_msg.json b/contracts/client_updater/schema/execute_msg.json deleted file mode 100644 index ade18ff..0000000 --- a/contracts/client_updater/schema/execute_msg.json +++ /dev/null @@ -1,39 +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 - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/client_updater/schema/instantiate_msg.json b/contracts/client_updater/schema/instantiate_msg.json deleted file mode 100644 index 1352613..0000000 --- a/contracts/client_updater/schema/instantiate_msg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "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/.cargo/config b/contracts/cron/.cargo/config similarity index 85% rename from contracts/dex/.cargo/config rename to contracts/cron/.cargo/config index 8d4bc73..11c14fd 100644 --- a/contracts/dex/.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/cron/src/contract.rs b/contracts/cron/src/contract.rs index 538eeca..83f7451 100644 --- a/contracts/cron/src/contract.rs +++ b/contracts/cron/src/contract.rs @@ -1,5 +1,5 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{BEGIN_BLOCKER_SHEDULES, END_BLOCKER_SHEDULES}; +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, @@ -34,24 +34,24 @@ pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> Std match msg { ExecuteMsg::AddBeginBlockerSchedule { name } => { - let counter = BEGIN_BLOCKER_SHEDULES + let counter = BEGIN_BLOCKER_SCHEDULES .may_load(deps.storage, name.clone())? .unwrap_or_default() .checked_add(1) .unwrap_or_default(); - BEGIN_BLOCKER_SHEDULES.save(deps.storage, name, &counter)?; + BEGIN_BLOCKER_SCHEDULES.save(deps.storage, name, &counter)?; Ok(Response::default()) } ExecuteMsg::AddEndBlockerSchedule { name } => { - let counter = END_BLOCKER_SHEDULES + let counter = END_BLOCKER_SCHEDULES .may_load(deps.storage, name.clone())? .unwrap_or_default() .checked_add(1) .unwrap_or_default(); - END_BLOCKER_SHEDULES.save(deps.storage, name, &counter)?; + END_BLOCKER_SCHEDULES.save(deps.storage, name, &counter)?; Ok(Response::default()) } @@ -62,11 +62,11 @@ pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> Std pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::GetBeginBlockerScheduleCounter { name } => { - let res = BEGIN_BLOCKER_SHEDULES.may_load(deps.storage, name)?; + let res = BEGIN_BLOCKER_SCHEDULES.may_load(deps.storage, name)?; to_json_binary(&res) } QueryMsg::GetEndBlockerScheduleCounter { name } => { - let res = END_BLOCKER_SHEDULES.may_load(deps.storage, name)?; + let res = END_BLOCKER_SCHEDULES.may_load(deps.storage, name)?; to_json_binary(&res) } } diff --git a/contracts/cron/src/state.rs b/contracts/cron/src/state.rs index 065ebbc..848be2a 100644 --- a/contracts/cron/src/state.rs +++ b/contracts/cron/src/state.rs @@ -1,4 +1,4 @@ use cw_storage_plus::Map; -pub const BEGIN_BLOCKER_SHEDULES: Map = Map::new("begin_blocker_shedules"); -pub const END_BLOCKER_SHEDULES: Map = Map::new("end_blocker_shedules"); +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/README.md b/contracts/dex/README.md deleted file mode 100644 index 5fae2c9..0000000 --- a/contracts/dex/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Dex - -This contract is used for tests in the main neutron repository. 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 9d0c7b2..0000000 --- a/contracts/dex/schema/dex_msg.json +++ /dev/null @@ -1,414 +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/DepositOptions" - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "additionalProperties": false - } - ], - "definitions": { - "DepositOptions": { - "type": "object", - "properties": { - "disable_autoswap": { - "type": [ - "boolean", - "null" - ] - }, - "fail_tx_on_bel": { - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - }, - "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" - } - } - }, - "additionalProperties": false - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - }, - "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); ```", - "type": "string" - } - } -} diff --git a/contracts/dex/schema/dex_query.json b/contracts/dex/schema/dex_query.json deleted file mode 100644 index bc0a5c0..0000000 --- a/contracts/dex/schema/dex_query.json +++ /dev/null @@ -1,715 +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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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" - } - } - }, - "additionalProperties": false - }, - "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" - } - }, - "additionalProperties": false - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - }, - "additionalProperties": false - } - } -} diff --git a/contracts/dex/schema/instantiate_msg.json b/contracts/dex/schema/instantiate_msg.json deleted file mode 100644 index 1352613..0000000 --- a/contracts/dex/schema/instantiate_msg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "additionalProperties": false -} 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_grpc/Cargo.toml b/contracts/dex_grpc/Cargo.toml index 90fc9d6..c36eb12 100644 --- a/contracts/dex_grpc/Cargo.toml +++ b/contracts/dex_grpc/Cargo.toml @@ -32,6 +32,7 @@ library = [] [dependencies] neutron-sdk = { workspace = true } +neutron-std = { workspace = true } cosmwasm-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } diff --git a/contracts/dex_grpc/schema/query_msg.json b/contracts/dex_grpc/schema/query_msg.json index 3bc7e5e..7122ae1 100644 --- a/contracts/dex_grpc/schema/query_msg.json +++ b/contracts/dex_grpc/schema/query_msg.json @@ -842,6 +842,7 @@ "creator", "limit_sell_price", "max_amount_out", + "min_average_sell_price", "order_type", "receiver", "tick_index_in_to_out", @@ -872,6 +873,10 @@ "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" diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index 57998ee..00dba8f 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -1,11 +1,13 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_std::{ - entry_point, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, + entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; -use neutron_sdk::proto_types::neutron::dex; 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"); @@ -41,19 +43,17 @@ pub fn execute( tick_indexes_a_to_b, fees, options, - } => Ok( - Response::new().add_message(Into::::into(dex::MsgDeposit { - creator: env.contract.address.to_string(), - 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, @@ -62,17 +62,15 @@ pub fn execute( shares_to_remove, tick_indexes_a_to_b, fees, - } => Ok( - Response::new().add_message(Into::::into(dex::MsgWithdrawal { - creator: env.contract.address.to_string(), - 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, @@ -84,34 +82,31 @@ pub fn execute( order_type, expiration_time, max_amount_out, - } => Ok( - Response::new().add_message(Into::::into(dex::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, - })), - ), - ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message( - Into::::into(dex::MsgWithdrawFilledLimitOrder { + } => 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(Into::::into(dex::MsgCancelLimitOrder { - creator: env.contract.address.to_string(), - tranche_key, - })), - ) + Ok(Response::new().add_message(MsgCancelLimitOrder { + creator: env.contract.address.to_string(), + tranche_key, + })) } ExecuteMsg::MultiHopSwap { @@ -120,16 +115,14 @@ pub fn execute( amount_in, exit_limit_price, pick_best_route, - } => Ok( - Response::new().add_message(Into::::into(dex::MsgMultiHopSwap { - creator: env.contract.address.to_string(), - 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, + })), } } @@ -138,7 +131,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); - let dex_querier = dex::DexQuerier::new(&deps.querier); + let dex_querier = DexQuerier::new(&deps.querier); match msg { QueryMsg::Params {} => Ok(to_json_binary(&dex_querier.params()?)?), diff --git a/contracts/dex_grpc/src/msg.rs b/contracts/dex_grpc/src/msg.rs index d536d4f..27aafb5 100644 --- a/contracts/dex_grpc/src/msg.rs +++ b/contracts/dex_grpc/src/msg.rs @@ -1,9 +1,9 @@ -use neutron_sdk::proto_types::neutron::dex::{ +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 neutron_sdk::proto_types::{cosmos::base::query::v1beta1::PageRequest, neutron::dex}; -use neutron_sdk::shim::Timestamp; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -50,7 +50,7 @@ pub enum ExecuteMsg { }, MultiHopSwap { receiver: String, - routes: Vec, + routes: Vec, amount_in: String, exit_limit_price: String, pick_best_route: bool, diff --git a/contracts/docs/interchainqueries/howto/register_kv_icq/examples/neutron_interchain_queries-schema.rs b/contracts/docs/interchainqueries/howto/register_kv_icq/examples/neutron_interchain_queries-schema.rs index 7225f36..666c1b2 100644 --- a/contracts/docs/interchainqueries/howto/register_kv_icq/examples/neutron_interchain_queries-schema.rs +++ b/contracts/docs/interchainqueries/howto/register_kv_icq/examples/neutron_interchain_queries-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 neutron_interchain_queries::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use howto_register_kv_icq::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/grpc_querier/Cargo.toml b/contracts/grpc_querier/Cargo.toml index a0f76f1..bab6fa9 100644 --- a/contracts/grpc_querier/Cargo.toml +++ b/contracts/grpc_querier/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/grpc_querier/src/contract.rs b/contracts/grpc_querier/src/contract.rs index 5b22634..6ef3da6 100644 --- a/contracts/grpc_querier/src/contract.rs +++ b/contracts/grpc_querier/src/contract.rs @@ -3,21 +3,20 @@ 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::grpc; use cw2::set_contract_version; -use neutron_sdk::proto_types::{ - cosmos::{auth, bank}, - ibc::{ - applications::transfer, - core::{client, connection}, - }, - neutron::{feeburner, interchainqueries, interchaintxs}, - osmosis::tokenfactory, -}; +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"); @@ -44,15 +43,15 @@ pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); - let bank_querier = bank::v1beta1::BankQuerier::new(&deps.querier); - let auth_querier = auth::v1beta1::AuthQuerier::new(&deps.querier); - let transfer_querier = transfer::v1::TransferQuerier::new(&deps.querier); - let client_querier = client::v1::ClientQuerier::new(&deps.querier); - let connection_querier = connection::v1::ConnectionQuerier::new(&deps.querier); - let tokenfactory_querier = tokenfactory::v1beta1::TokenfactoryQuerier::new(&deps.querier); - let interchaintxs_querier = interchaintxs::v1::InterchaintxsQuerier::new(&deps.querier); - let interchainqueries_querier = interchainqueries::InterchainqueriesQuerier::new(&deps.querier); - let feeburner_querier = feeburner::FeeburnerQuerier::new(&deps.querier); + 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 } => { @@ -138,7 +137,10 @@ pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { // 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 = grpc::contractmanager::QueryAddressFailuresRequest { address }; + let msg = QueryFailuresRequest { + address, + pagination: None, + }; let mut bytes = Vec::new(); Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?; @@ -151,9 +153,8 @@ fn query_contractmanager_query_address_failures(deps: Deps, address: String) -> to_json_binary(&resp) } -// Can be refactored after https://hadronlabs.atlassian.net/browse/NTRN-359 is done fn query_contractmanager_query_failures(deps: Deps, address: String) -> StdResult { - let msg = grpc::contractmanager::QueryFailuresRequest { + let msg = QueryFailuresRequest { address, pagination: None, }; diff --git a/contracts/grpc_querier/src/grpc.rs b/contracts/grpc_querier/src/grpc.rs deleted file mode 100644 index 647311e..0000000 --- a/contracts/grpc_querier/src/grpc.rs +++ /dev/null @@ -1,17 +0,0 @@ -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< - ::neutron_sdk::proto_types::cosmos::base::query::v1beta1::PageRequest, - >, - } -} diff --git a/contracts/grpc_querier/src/lib.rs b/contracts/grpc_querier/src/lib.rs index 98ab7aa..c7a7772 100644 --- a/contracts/grpc_querier/src/lib.rs +++ b/contracts/grpc_querier/src/lib.rs @@ -15,5 +15,4 @@ #![warn(clippy::unwrap_used, clippy::expect_used)] pub mod contract; -mod grpc; pub mod msg; 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/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/market_map_query.json b/contracts/marketmap/schema/query_msg.json similarity index 86% rename from contracts/marketmap/schema/market_map_query.json rename to contracts/marketmap/schema/query_msg.json index 35df8e8..10bd1f0 100644 --- a/contracts/marketmap/schema/market_map_query.json +++ b/contracts/marketmap/schema/query_msg.json @@ -1,9 +1,8 @@ { "$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" @@ -66,16 +65,17 @@ ], "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" } }, 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/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 0faca5d..a8bfe55 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -375,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": { @@ -394,10 +393,7 @@ ] }, "new_update_period": { - "type": [ - "integer", - "null" - ], + "type": "integer", "format": "uint64", "minimum": 0.0 }, @@ -531,12 +527,7 @@ } ], "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", @@ -544,15 +535,16 @@ ], "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" } }, diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index ca7619a..3027540 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -24,14 +24,16 @@ 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, }; @@ -53,8 +55,10 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ 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. @@ -78,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, @@ -111,6 +133,7 @@ pub fn execute( update_period, } => register_gov_proposal_votes_query( deps, + env.contract.address, connection_id, proposals_ids, voters, @@ -120,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, @@ -142,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, recipients, update_period, min_height, - } => register_transfers_query(connection_id, recipients, 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 } => { @@ -171,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, @@ -231,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, @@ -257,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, @@ -273,22 +350,28 @@ 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, recipients: Vec, update_period: u64, min_height: Option, -) -> NeutronResult> { +) -> NeutronResult { let mut query_data: Vec = recipients .into_iter() .map(|r| TransactionFilterItem { @@ -306,7 +389,8 @@ pub fn register_transfers_query( }) } - let msg = NeutronMsg::register_interchain_query( + let msg = register_interchain_query( + contract, QueryPayload::TX(query_data), connection_id, update_period, @@ -316,49 +400,63 @@ pub fn register_transfers_query( } 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(), @@ -367,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)?)?), @@ -415,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(); @@ -423,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, @@ -431,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)? @@ -446,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, @@ -461,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, @@ -478,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 @@ -488,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 = @@ -586,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 311a181..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}; @@ -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 d0ee479..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,7 +1034,7 @@ 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, }; @@ -1097,7 +1138,7 @@ 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, }; 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 d80aedf..297efea 100644 --- a/contracts/neutron_interchain_txs/schema/execute_msg.json +++ b/contracts/neutron_interchain_txs/schema/execute_msg.json @@ -24,7 +24,7 @@ "ordering": { "anyOf": [ { - "$ref": "#/definitions/ChannelOrdering" + "$ref": "#/definitions/Order" }, { "type": "null" @@ -309,13 +309,6 @@ } ], "definitions": { - "ChannelOrdering": { - "type": "string", - "enum": [ - "ORDER_ORDERED", - "ORDER_UNORDERED" - ] - }, "IntegrationTestsSudoFailureMock": { "type": "string", "enum": [ @@ -324,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/query_interchain_account_address_response.json b/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json index d1314a5..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,13 +1,14 @@ { "$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" } }, diff --git a/contracts/neutron_interchain_txs/schema/sudo_msg.json b/contracts/neutron_interchain_txs/schema/sudo_msg.json index de8ad10..9c5fab7 100644 --- a/contracts/neutron_interchain_txs/schema/sudo_msg.json +++ b/contracts/neutron_interchain_txs/schema/sudo_msg.json @@ -167,6 +167,7 @@ "type": "string" }, "Height": { + "description": "Height is used for sudo call for `TxQueryResult` enum variant type", "type": "object", "properties": { "revision_height": { diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 5efba78..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::{ChannelOrdering, 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,20 +91,21 @@ 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 { @@ -173,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 } => { @@ -191,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, @@ -210,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 { @@ -238,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, @@ -248,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) @@ -264,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)?) } @@ -284,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)?; @@ -308,13 +313,14 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, - ordering: Option, -) -> 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); @@ -322,11 +328,7 @@ fn execute_register_ica( 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) } @@ -338,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 { @@ -356,12 +358,13 @@ fn execute_undelegate( 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], @@ -387,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 { @@ -413,12 +412,13 @@ fn do_delegate( 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], @@ -442,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(); @@ -452,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)? { @@ -473,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()); @@ -488,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)? } @@ -575,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 { @@ -603,7 +607,7 @@ fn sudo_response( env: Env, request: RequestPacket, data: Binary, -) -> StdResult> { +) -> StdResult { deps.api.debug( format!( "WASMDEBUG: sudo_response: sudo received: {:?} {:?}", @@ -715,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()); @@ -754,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 a6ed4b0..7dd4d87 100644 --- a/contracts/neutron_interchain_txs/src/msg.rs +++ b/contracts/neutron_interchain_txs/src/msg.rs @@ -1,6 +1,6 @@ use crate::storage::{AcknowledgementResult, IntegrationTestsSudoFailureMock}; use cosmwasm_std::Uint128; -use neutron_sdk::bindings::msg::ChannelOrdering; +use neutron_std::types::ibc::core::channel::v1::Order; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -39,7 +39,7 @@ pub enum ExecuteMsg { Register { connection_id: String, interchain_account_id: String, - ordering: Option, + ordering: Option, }, SetFees { denom: String, 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/query_interchain_account_address_response.json b/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json index d1314a5..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,13 +1,14 @@ { "$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" } }, diff --git a/contracts/neutron_validator_test/schema/sudo_msg.json b/contracts/neutron_validator_test/schema/sudo_msg.json index de8ad10..9c5fab7 100644 --- a/contracts/neutron_validator_test/schema/sudo_msg.json +++ b/contracts/neutron_validator_test/schema/sudo_msg.json @@ -167,6 +167,7 @@ "type": "string" }, "Height": { + "description": "Height is used for sudo call for `TxQueryResult` enum variant type", "type": "object", "properties": { "revision_height": { diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index fc1b9d8..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::{ChannelOrdering, 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,12 +284,13 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, -) -> NeutronResult> { - let register = NeutronMsg::register_interchain_account( +) -> NeutronResult { + let register = register_interchain_account( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), - None, - Some(ChannelOrdering::OrderOrdered), + vec![], + Some(Order::Ordered), ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; @@ -286,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 { @@ -306,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], @@ -343,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 { @@ -364,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], @@ -391,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(); @@ -402,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(); @@ -413,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 { @@ -471,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, @@ -497,7 +526,7 @@ fn sudo_open_ack( } pub fn sudo_tx_query_result( - deps: DepsMut, + deps: DepsMut, _env: Env, query_id: u64, _height: Height, @@ -508,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 @@ -518,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 = @@ -585,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: {:?} {:?}", @@ -639,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()); @@ -671,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/oracle_query.json b/contracts/oracle/schema/query_msg.json similarity index 72% rename from contracts/oracle/schema/oracle_query.json rename to contracts/oracle/schema/query_msg.json index c337977..38d0902 100644 --- a/contracts/oracle/schema/oracle_query.json +++ b/contracts/oracle/schema/query_msg.json @@ -1,20 +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 - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -24,11 +11,15 @@ "get_price": { "type": "object", "required": [ - "currency_pair" + "base", + "quote" ], "properties": { - "currency_pair": { - "$ref": "#/definitions/CurrencyPair" + "base": { + "type": "string" + }, + "quote": { + "type": "string" } }, "additionalProperties": false @@ -59,24 +50,19 @@ } }, "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 69c7dd8..a9c70df 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -42,7 +42,7 @@ "msgs": { "type": "array", "items": { - "$ref": "#/definitions/CosmosMsg_for_NeutronMsg" + "$ref": "#/definitions/CosmosMsg_for_Empty" } } }, @@ -53,163 +53,6 @@ } ], "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 - }, - { - "description": "Deprecated. Proposal to clear contract admin.", - "deprecated": true, - "type": "object", - "required": [ - "clear_admin_proposal" - ], - "properties": { - "clear_admin_proposal": { - "$ref": "#/definitions/ClearAdminProposal" - } - }, - "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", @@ -290,88 +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" - } - }, - "additionalProperties": false - }, - "ChannelOrdering": { - "type": "string", - "enum": [ - "ORDER_ORDERED", - "ORDER_UNORDERED" - ] - }, - "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" - } - }, - "additionalProperties": false - }, - "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" - } - }, - "additionalProperties": false - }, "Coin": { "type": "object", "required": [ @@ -388,7 +149,7 @@ }, "additionalProperties": false }, - "CosmosMsg_for_NeutronMsg": { + "CosmosMsg_for_Empty": { "oneOf": [ { "type": "object", @@ -409,7 +170,7 @@ ], "properties": { "custom": { - "$ref": "#/definitions/NeutronMsg" + "$ref": "#/definitions/Empty" } }, "additionalProperties": false @@ -520,120 +281,24 @@ "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 - } - }, - "additionalProperties": false - }, - "DepositOptions": { - "type": "object", - "properties": { - "disable_autoswap": { - "type": [ - "boolean", - "null" - ] - }, - "fail_tx_on_bel": { - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - }, - "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/DepositOptions" - } - }, - "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" } }, @@ -643,57 +308,20 @@ "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" } }, @@ -703,249 +331,16 @@ "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" - ], - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "additionalProperties": false - }, - { - "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": [ - "fund_community_pool" - ], - "properties": { - "fund_community_pool": { - "type": "object", - "required": [ - "amount" + "amount" ], "properties": { "amount": { @@ -963,6 +358,11 @@ } ] }, + "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), }, ], })) } ```", "oneOf": [ @@ -1032,39 +432,6 @@ } ] }, - "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" - } - } - }, - "additionalProperties": false - }, "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": [ @@ -1230,147 +597,28 @@ }, "additionalProperties": false }, - "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" - } - }, - "additionalProperties": false - }, - "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" - } - }, - "additionalProperties": false - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "NeutronMsg": { - "description": "A number of Custom messages that can call into the Neutron bindings.", + "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", "oneOf": [ { - "description": "RegisterInterchainAccount registers an interchain account on remote chain.", + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "register_interchain_account" + "delegate" ], "properties": { - "register_interchain_account": { + "delegate": { "type": "object", "required": [ - "connection_id", - "interchain_account_id" + "amount", + "validator" ], "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" + "amount": { + "$ref": "#/definitions/Coin" }, - "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.", + "validator": { "type": "string" - }, - "ordering": { - "description": "**ordering** is an order of channel. Can be ordered or unordered. Set to ordered if not specified.", - "anyOf": [ - { - "$ref": "#/definitions/ChannelOrdering" - }, - { - "type": "null" - } - ] - }, - "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 @@ -1379,846 +627,23 @@ "additionalProperties": false }, { - "description": "SubmitTx starts the process of executing any Cosmos-SDK *msgs* on remote chain.", + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "submit_tx" + "undelegate" ], "properties": { - "submit_tx": { + "undelegate": { "type": "object", "required": [ - "connection_id", - "fee", - "interchain_account_id", - "memo", - "msgs", - "timeout" + "amount", + "validator" ], "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" + "amount": { + "$ref": "#/definitions/Coin" }, - "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 - } - }, - "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 - } - }, - "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 retrieve.", - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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 - } - }, - "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]", - "type": "object", - "required": [ - "add_schedule" - ], - "properties": { - "add_schedule": { - "type": "object", - "required": [ - "msgs", - "name", - "period" - ], - "properties": { - "msgs": { - "description": "list of cosmwasm messages to be executed", - "type": "array", - "items": { - "$ref": "#/definitions/MsgExecuteContract" - } - }, - "name": { - "description": "Name of a new schedule. Needed to be able to `RemoveSchedule` and to log information about it", - "type": "string" - }, - "period": { - "description": "period in blocks with which `msgs` will be executed", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "RemoveSchedule removes the schedule with a given `name`. [Permissioned - DAO or Security DAO only]", - "type": "object", - "required": [ - "remove_schedule" - ], - "properties": { - "remove_schedule": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - }, - "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]", - "type": "object", - "required": [ - "resubmit_failure" - ], - "properties": { - "resubmit_failure": { - "type": "object", - "required": [ - "failure_id" - ], - "properties": { - "failure_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Dex messages", - "type": "object", - "required": [ - "dex" - ], - "properties": { - "dex": { - "$ref": "#/definitions/DexMsg" - } - }, - "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" - } - }, - "additionalProperties": false - }, - "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" - } - }, - "additionalProperties": false - }, - "PinCodesProposal": { - "description": "Deprecated. PinCodesProposal defines the struct for pin 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 pined.", - "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" - } - }, - "additionalProperties": false - }, - "Plan": { - "description": "Plan defines the struct for planned upgrade.", - "type": "object", - "required": [ - "height", - "info", - "name" - ], - "properties": { - "height": { - "description": "*height** is a height at which the upgrade must be performed", - "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" - } - }, - "additionalProperties": false - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - }, - "additionalProperties": false - }, - "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" - } - }, - "additionalProperties": false - }, - "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" - } - ] - } - }, - "additionalProperties": false - }, - "RequestPacketTimeoutHeight": { - "type": "object", - "properties": { - "revision_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "revision_number": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - "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", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { + "validator": { "type": "string" } }, @@ -2259,40 +684,6 @@ } ] }, - "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" - } - }, - "additionalProperties": false - }, "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": [ @@ -2309,104 +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" - } - }, - "additionalProperties": false - }, - "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" - } - }, - "additionalProperties": false - }, - "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" - } - ] - } - }, - "additionalProperties": false - }, "VoteOption": { "type": "string", "enum": [ diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index cf4033c..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 { 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 ce3284f..71dfbee 100644 --- a/contracts/tokenfactory/schema/execute_msg.json +++ b/contracts/tokenfactory/schema/execute_msg.json @@ -252,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", @@ -261,15 +261,18 @@ ], "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 diff --git a/contracts/tokenfactory/schema/query_msg.json b/contracts/tokenfactory/schema/query_msg.json index 117bfc9..d86ed5d 100644 --- a/contracts/tokenfactory/schema/query_msg.json +++ b/contracts/tokenfactory/schema/query_msg.json @@ -11,11 +11,11 @@ "full_denom": { "type": "object", "required": [ - "creator_addr", + "creator", "subdenom" ], "properties": { - "creator_addr": { + "creator": { "type": "string" }, "subdenom": { @@ -36,9 +36,13 @@ "denom_admin": { "type": "object", "required": [ + "creator", "subdenom" ], "properties": { + "creator": { + "type": "string" + }, "subdenom": { "type": "string" } @@ -57,10 +61,14 @@ "before_send_hook": { "type": "object", "required": [ - "denom" + "creator", + "subdenom" ], "properties": { - "denom": { + "creator": { + "type": "string" + }, + "subdenom": { "type": "string" } }, diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 69bc940..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,32 +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(), + } => MsgChangeAdmin { + sender: env.contract.address.to_string(), + denom, + new_admin: new_admin_address, + } + .into(), ExecuteMsg::MintTokens { denom, amount, mint_to_address, - } => NeutronMsg::submit_mint_tokens( - denom, - amount, - mint_to_address.unwrap_or(env.contract.address.into()), - ) + } => 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()), + } .into(), ExecuteMsg::BurnTokens { denom, amount, burn_from_address, - } => NeutronMsg::submit_burn_tokens(denom, amount, burn_from_address).into(), + } => 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, @@ -66,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, @@ -76,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 64da292..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}; @@ -55,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)]