From a0d8d4641dc5767d4e55ee735969565716c2fe81 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 30 May 2024 12:06:16 +0200 Subject: [PATCH 1/3] Enabled cw-orch derives, everything compiles --- Cargo.lock | 447 +++++++++++++++++- Cargo.toml | 8 +- contracts/consumer/converter/Cargo.toml | 2 + .../consumer/remote-price-feed/Cargo.toml | 2 + .../consumer/simple-price-feed/Cargo.toml | 2 + contracts/consumer/virtual-staking/Cargo.toml | 1 + contracts/osmosis-price-provider/Cargo.toml | 2 + .../provider/external-staking/Cargo.toml | 2 + .../provider/native-staking-proxy/Cargo.toml | 2 + contracts/provider/native-staking/Cargo.toml | 2 + contracts/provider/vault/Cargo.toml | 2 + packages/apis/Cargo.toml | 2 + 12 files changed, 465 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0df67f14..4d940b72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,31 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "abstract-cw-multi-test" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c77f8d4bac08f74fbc4fce8943cb2d35e742682b6cae8cb65555d6cd3830feb" +dependencies = [ + "anyhow", + "bech32 0.11.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "cw20-ics20", + "derivative", + "hex", + "itertools 0.12.1", + "log", + "prost 0.12.4", + "schemars", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "ahash" version = "0.7.6" @@ -49,6 +74,18 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "block-buffer" version = "0.9.0" @@ -84,6 +121,9 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] [[package]] name = "cfg-if" @@ -121,6 +161,17 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "cosmos-sdk-proto" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e23f6ab56d5f031cde05b8b82a5fefd3a1a223595c79e32317a97189e612bc" +dependencies = [ + "prost 0.12.4", + "prost-types 0.12.4", + "tendermint-proto", +] + [[package]] name = "cosmwasm-crypto" version = "1.5.4" @@ -175,7 +226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712fe58f39d55c812f7b2c84e097cdede3a39d520f89b6dc3153837e31741927" dependencies = [ "base64", - "bech32", + "bech32 0.9.1", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -234,6 +285,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cw-controllers" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57de8d3761e46be863e3ac1eba8c8a976362a48c6abf240df1e26c3e421ee9e8" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw-multi-test" version = "0.20.1" @@ -241,7 +307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc392a5cb7e778e3f90adbf7faa43c4db7f35b6623224b08886d796718edb875" dependencies = [ "anyhow", - "bech32", + "bech32 0.9.1", "cosmwasm-std", "cw-storage-plus", "cw-utils", @@ -254,6 +320,89 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-orch" +version = "0.22.2" +source = "git+https://github.com/abstractsdk/cw-orchestrator?branch=update/relax-bound-on-derive#19e06a6849a0b0b091c29ddbd16f1366be5d65f3" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cw-orch-contract-derive", + "cw-orch-core", + "cw-orch-fns-derive", + "cw-orch-mock", + "cw-orch-traits", + "cw-utils", + "hex", + "log", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw-orch-contract-derive" +version = "0.21.0" +source = "git+https://github.com/abstractsdk/cw-orchestrator?branch=update/relax-bound-on-derive#19e06a6849a0b0b091c29ddbd16f1366be5d65f3" +dependencies = [ + "convert_case", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "cw-orch-core" +version = "1.0.0" +source = "git+https://github.com/abstractsdk/cw-orchestrator?branch=update/relax-bound-on-derive#19e06a6849a0b0b091c29ddbd16f1366be5d65f3" +dependencies = [ + "abstract-cw-multi-test", + "anyhow", + "cosmos-sdk-proto", + "cosmwasm-std", + "cw-utils", + "dirs", + "log", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "cw-orch-fns-derive" +version = "0.19.1" +source = "git+https://github.com/abstractsdk/cw-orchestrator?branch=update/relax-bound-on-derive#19e06a6849a0b0b091c29ddbd16f1366be5d65f3" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cw-orch-mock" +version = "0.22.2" +source = "git+https://github.com/abstractsdk/cw-orchestrator?branch=update/relax-bound-on-derive#19e06a6849a0b0b091c29ddbd16f1366be5d65f3" +dependencies = [ + "abstract-cw-multi-test", + "cosmwasm-std", + "cw-orch-core", + "cw-utils", + "log", + "serde", + "sha2 0.10.8", +] + +[[package]] +name = "cw-orch-traits" +version = "0.22.0" +source = "git+https://github.com/abstractsdk/cw-orchestrator?branch=update/relax-bound-on-derive#19e06a6849a0b0b091c29ddbd16f1366be5d65f3" +dependencies = [ + "cw-orch-core", + "prost 0.12.4", + "prost-types 0.12.4", +] + [[package]] name = "cw-storage-plus" version = "1.2.0" @@ -295,6 +444,38 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw20" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-utils", + "schemars", + "serde", +] + +[[package]] +name = "cw20-ics20" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76221201da08fed611c857ea3aa21c031a4a7dc771a8b1750559ca987335dc02" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-controllers", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw20", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "der" version = "0.7.8" @@ -305,6 +486,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derivative" version = "2.2.0" @@ -337,6 +527,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + [[package]] name = "dyn-clone" version = "1.0.13" @@ -413,6 +624,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "flex-error" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" +dependencies = [ + "paste", +] + [[package]] name = "forward_ref" version = "1.0.0" @@ -563,6 +783,22 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + [[package]] name = "memchr" version = "2.6.0" @@ -575,6 +811,7 @@ version = "0.10.0-alpha.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", + "cw-orch", "schemars", "semver", "serde", @@ -602,6 +839,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -625,6 +863,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -648,6 +887,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -671,6 +911,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -692,6 +933,7 @@ version = "0.10.0-alpha.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -712,6 +954,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -732,6 +975,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -766,6 +1010,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -790,6 +1035,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "cw-storage-plus", "cw-utils", "cw2", @@ -820,6 +1066,23 @@ dependencies = [ "serde", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -841,6 +1104,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "osmosis-std" version = "0.20.1" @@ -851,7 +1120,7 @@ dependencies = [ "cosmwasm-std", "osmosis-std-derive", "prost 0.11.9", - "prost-types", + "prost-types 0.11.9", "schemars", "serde", "serde-cw-value", @@ -865,11 +1134,17 @@ checksum = "c5ebdfd1bc8ed04db596e110c6baa9b174b04f6ed1ec22c666ddc5cb3fa91bd7" dependencies = [ "itertools 0.10.5", "proc-macro2", - "prost-types", + "prost-types 0.11.9", "quote", "syn 1.0.109", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pkcs8" version = "0.10.2" @@ -880,6 +1155,12 @@ dependencies = [ "spki", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -978,6 +1259,15 @@ dependencies = [ "prost 0.11.9", ] +[[package]] +name = "prost-types" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +dependencies = [ + "prost 0.12.4", +] + [[package]] name = "quote" version = "1.0.36" @@ -1002,6 +1292,17 @@ dependencies = [ "getrandom", ] +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -1098,6 +1399,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_bytes" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.199" @@ -1187,16 +1497,25 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "subtle-encoding" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" +dependencies = [ + "zeroize", +] + [[package]] name = "sylvia" version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64c8e892525ec035e5bdbeceec19309b1534734da7ff7bc69e9f639b077c497" +source = "git+https://github.com/AbstractSDK/sylvia.git?rev=a4168a242d444cc97d6a6363304d99d630dcbef3#a4168a242d444cc97d6a6363304d99d630dcbef3" dependencies = [ "anyhow", "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-orch", "derivative", "konst", "schemars", @@ -1209,8 +1528,7 @@ dependencies = [ [[package]] name = "sylvia-derive" version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae5e0f41752efba2c6895514fa4caae742f69a2a73b4790bb6e365400c563bc1" +source = "git+https://github.com/AbstractSDK/sylvia.git?rev=a4168a242d444cc97d6a6363304d99d630dcbef3#a4168a242d444cc97d6a6363304d99d630dcbef3" dependencies = [ "convert_case", "itertools 0.12.1", @@ -1243,6 +1561,24 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tendermint-proto" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff525d5540a9fc535c38dc0d92a98da3ee36fcdfbda99cecb9f3cce5cd4d41d7" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.12.4", + "prost-types 0.12.4", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + [[package]] name = "test-case" version = "3.3.1" @@ -1296,6 +1632,35 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "toml_datetime" version = "0.6.3" @@ -1349,6 +1714,72 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "winnow" version = "0.5.15" diff --git a/Cargo.toml b/Cargo.toml index 3937a620..db297939 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,12 @@ mesh-converter = { path = "./contracts/consumer/converter" } mesh-simple-price-feed = { path = "./contracts/consumer/simple-price-feed" } mesh-virtual-staking = { path = "./contracts/consumer/virtual-staking" } -sylvia = "0.10.1" +# sylvia = "0.10.1" +# from branch update/clean-add-cw-orch +sylvia = { git = "https://github.com/AbstractSDK/sylvia.git", rev = "a4168a242d444cc97d6a6363304d99d630dcbef3", features = ["orch"] } +# need this fork of cw-orch as well... +cw-orch = { git = "https://github.com/abstractsdk/cw-orchestrator", branch = "update/relax-bound-on-derive" } +# cw-orch = "0.22.1" cosmwasm-schema = "1.5.4" cosmwasm-std = { version = "1.5.4", features = ["ibc3", "cosmwasm_1_3"] } @@ -43,6 +48,7 @@ thiserror = "1.0.59" semver = "1.0.22" itertools = "0.12.1" + # dev deps anyhow = "1" cw-multi-test = "0.20" diff --git a/contracts/consumer/converter/Cargo.toml b/contracts/consumer/converter/Cargo.toml index a152fbeb..771aea06 100644 --- a/contracts/consumer/converter/Cargo.toml +++ b/contracts/consumer/converter/Cargo.toml @@ -35,6 +35,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] mesh-burn = { workspace = true } mesh-simple-price-feed = { workspace = true, features = ["mt"] } diff --git a/contracts/consumer/remote-price-feed/Cargo.toml b/contracts/consumer/remote-price-feed/Cargo.toml index 412217df..6f577f41 100644 --- a/contracts/consumer/remote-price-feed/Cargo.toml +++ b/contracts/consumer/remote-price-feed/Cargo.toml @@ -31,6 +31,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] cw-multi-test = { workspace = true } test-case = { workspace = true } diff --git a/contracts/consumer/simple-price-feed/Cargo.toml b/contracts/consumer/simple-price-feed/Cargo.toml index b32fe2e4..6efbefcc 100644 --- a/contracts/consumer/simple-price-feed/Cargo.toml +++ b/contracts/consumer/simple-price-feed/Cargo.toml @@ -35,6 +35,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] cw-multi-test = { workspace = true } test-case = { workspace = true } diff --git a/contracts/consumer/virtual-staking/Cargo.toml b/contracts/consumer/virtual-staking/Cargo.toml index 2952a33b..cc022a3a 100644 --- a/contracts/consumer/virtual-staking/Cargo.toml +++ b/contracts/consumer/virtual-staking/Cargo.toml @@ -33,6 +33,7 @@ cw-utils = { workspace = true } schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} [dev-dependencies] mesh-simple-price-feed = { workspace = true, features = ["mt", "fake-custom"] } diff --git a/contracts/osmosis-price-provider/Cargo.toml b/contracts/osmosis-price-provider/Cargo.toml index d407fe89..bc3d7043 100644 --- a/contracts/osmosis-price-provider/Cargo.toml +++ b/contracts/osmosis-price-provider/Cargo.toml @@ -29,3 +29,5 @@ serde = { workspace = true } sylvia = { workspace = true } thiserror = { workspace = true } osmosis-std = { workspace = true } + +cw-orch = { workspace = true} diff --git a/contracts/provider/external-staking/Cargo.toml b/contracts/provider/external-staking/Cargo.toml index 1056ac3c..3f314ca6 100644 --- a/contracts/provider/external-staking/Cargo.toml +++ b/contracts/provider/external-staking/Cargo.toml @@ -33,6 +33,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] sylvia = { workspace = true, features = ["mt"] } cw-multi-test = { workspace = true } diff --git a/contracts/provider/native-staking-proxy/Cargo.toml b/contracts/provider/native-staking-proxy/Cargo.toml index a8210310..94ce6f1b 100644 --- a/contracts/provider/native-staking-proxy/Cargo.toml +++ b/contracts/provider/native-staking-proxy/Cargo.toml @@ -33,6 +33,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] sylvia = { workspace = true, features = ["mt"] } cw-multi-test = { workspace = true } diff --git a/contracts/provider/native-staking/Cargo.toml b/contracts/provider/native-staking/Cargo.toml index 1b508ffd..492492cb 100644 --- a/contracts/provider/native-staking/Cargo.toml +++ b/contracts/provider/native-staking/Cargo.toml @@ -34,6 +34,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] sylvia = { workspace = true, features = ["mt"] } cw-multi-test = { workspace = true } diff --git a/contracts/provider/vault/Cargo.toml b/contracts/provider/vault/Cargo.toml index e5fafea8..810cae6b 100644 --- a/contracts/provider/vault/Cargo.toml +++ b/contracts/provider/vault/Cargo.toml @@ -33,6 +33,8 @@ schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } +cw-orch = { workspace = true} + [dev-dependencies] sylvia = { workspace = true, features = ["mt"] } cw-multi-test = { workspace = true } diff --git a/packages/apis/Cargo.toml b/packages/apis/Cargo.toml index 1eb63b19..4111155b 100644 --- a/packages/apis/Cargo.toml +++ b/packages/apis/Cargo.toml @@ -15,3 +15,5 @@ semver = { workspace = true } serde = { workspace = true } sylvia = { workspace = true } thiserror = { workspace = true } + +cw-orch = { workspace = true } From 4e724a4ad8bc01b45c5293ca4e2b26f5f7c5199d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 30 May 2024 12:56:15 +0200 Subject: [PATCH 2/3] Update sylvia so all execute messages payable --- Cargo.lock | 4 +- Cargo.toml | 2 +- .../remote-price-feed/src/price_keeper.rs | 6 +++ .../provider/external-staking/src/crdt.rs | 6 +++ contracts/provider/vault/src/lib.rs | 3 ++ contracts/provider/vault/src/orch.rs | 54 +++++++++++++++++++ contracts/provider/vault/src/test.rs | 38 +++++++++++++ 7 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 contracts/provider/vault/src/orch.rs create mode 100644 contracts/provider/vault/src/test.rs diff --git a/Cargo.lock b/Cargo.lock index 4d940b72..992efb58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1509,7 +1509,7 @@ dependencies = [ [[package]] name = "sylvia" version = "0.10.1" -source = "git+https://github.com/AbstractSDK/sylvia.git?rev=a4168a242d444cc97d6a6363304d99d630dcbef3#a4168a242d444cc97d6a6363304d99d630dcbef3" +source = "git+https://github.com/AbstractSDK/sylvia.git?rev=76ed9ace11ce79f541d94e5d03eb9d0b9deed509#76ed9ace11ce79f541d94e5d03eb9d0b9deed509" dependencies = [ "anyhow", "cosmwasm-schema", @@ -1528,7 +1528,7 @@ dependencies = [ [[package]] name = "sylvia-derive" version = "0.10.1" -source = "git+https://github.com/AbstractSDK/sylvia.git?rev=a4168a242d444cc97d6a6363304d99d630dcbef3#a4168a242d444cc97d6a6363304d99d630dcbef3" +source = "git+https://github.com/AbstractSDK/sylvia.git?rev=76ed9ace11ce79f541d94e5d03eb9d0b9deed509#76ed9ace11ce79f541d94e5d03eb9d0b9deed509" dependencies = [ "convert_case", "itertools 0.12.1", diff --git a/Cargo.toml b/Cargo.toml index db297939..e96251c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ mesh-virtual-staking = { path = "./contracts/consumer/virtual-staking" } # sylvia = "0.10.1" # from branch update/clean-add-cw-orch -sylvia = { git = "https://github.com/AbstractSDK/sylvia.git", rev = "a4168a242d444cc97d6a6363304d99d630dcbef3", features = ["orch"] } +sylvia = { git = "https://github.com/AbstractSDK/sylvia.git", rev = "76ed9ace11ce79f541d94e5d03eb9d0b9deed509", features = ["orch"] } # need this fork of cw-orch as well... cw-orch = { git = "https://github.com/abstractsdk/cw-orchestrator", branch = "update/relax-bound-on-derive" } # cw-orch = "0.22.1" diff --git a/contracts/consumer/remote-price-feed/src/price_keeper.rs b/contracts/consumer/remote-price-feed/src/price_keeper.rs index 50b5d2de..f88d9d24 100644 --- a/contracts/consumer/remote-price-feed/src/price_keeper.rs +++ b/contracts/consumer/remote-price-feed/src/price_keeper.rs @@ -9,6 +9,12 @@ pub struct PriceKeeper { pub price_info_ttl_in_secs: Item<'static, u64>, } +impl Default for PriceKeeper { + fn default() -> Self { + Self::new() + } +} + impl PriceKeeper { pub const fn new() -> Self { Self { diff --git a/contracts/provider/external-staking/src/crdt.rs b/contracts/provider/external-staking/src/crdt.rs index 838ded4a..26dc551f 100644 --- a/contracts/provider/external-staking/src/crdt.rs +++ b/contracts/provider/external-staking/src/crdt.rs @@ -96,6 +96,12 @@ pub struct CrdtState<'a> { validators: Map<'a, &'a str, ValidatorState>, } +impl<'a> Default for CrdtState<'a> { + fn default() -> Self { + Self::new() + } +} + impl<'a> CrdtState<'a> { pub const fn new() -> Self { CrdtState { diff --git a/contracts/provider/vault/src/lib.rs b/contracts/provider/vault/src/lib.rs index 77d7a460..829c4b95 100644 --- a/contracts/provider/vault/src/lib.rs +++ b/contracts/provider/vault/src/lib.rs @@ -3,5 +3,8 @@ pub mod error; pub mod msg; #[cfg(test)] mod multitest; +pub mod orch; mod state; +#[cfg(test)] +mod test; pub mod txs; diff --git a/contracts/provider/vault/src/orch.rs b/contracts/provider/vault/src/orch.rs new file mode 100644 index 00000000..b0f1faec --- /dev/null +++ b/contracts/provider/vault/src/orch.rs @@ -0,0 +1,54 @@ +// This contains all code we needed to manually add to make it work well with cw-orch +// In the future, hopefully some of this can me auto-generated. But let's get it to work now. +use crate::contract::entry_points::{execute, instantiate, query}; +use crate::contract::sv::{ContractExecMsg, ContractQueryMsg, ContractSudoMsg, InstantiateMsg}; +use cw_orch::prelude::*; + +// Maybe uploadable can be autogenerated? +// But this is fine to include in the client code + +#[cw_orch::interface(InstantiateMsg, ContractExecMsg, ContractQueryMsg, Empty)] +pub struct MeshVault; + +impl Uploadable for MeshVault { + /// Return the path to the wasm file corresponding to the contract + fn wasm(_chain: &ChainInfoOwned) -> WasmPath { + artifacts_dir_from_workspace!() + .find_wasm_path("mesh_vault") + .unwrap() + } + /// Returns a CosmWasm contract wrapper + fn wrapper() -> Box> { + Box::new(ContractWrapper::new_with_empty(execute, instantiate, query)) + } +} + +// Autogenerating these Froms caused all kinds of rust compiler issues. +// For now, I will just manually implement them to show what could work. +// The following is done in Sylvia, ideally the other (interface) variants could be added there too: +// impl From for ContractExecMsg + +// Since we know the regular structure here, this may be easy enough to +// generate inside the `sv::messages` macro rather than the `contract` macro, eg. +// #[sv::messages(cw20_marketing as Marketing)] +// #[sv::messages(cw20_minting as Minting)] + +use mesh_apis::vault_api::sv::{VaultApiExecMsg, VaultApiQueryMsg, VaultApiSudoMsg}; + +impl From for ContractExecMsg { + fn from(msg: VaultApiExecMsg) -> Self { + ContractExecMsg::VaultApi(msg) + } +} + +impl From for ContractQueryMsg { + fn from(msg: VaultApiQueryMsg) -> Self { + ContractQueryMsg::VaultApi(msg) + } +} + +impl From for ContractSudoMsg { + fn from(msg: VaultApiSudoMsg) -> Self { + ContractSudoMsg::VaultApi(msg) + } +} diff --git a/contracts/provider/vault/src/test.rs b/contracts/provider/vault/src/test.rs new file mode 100644 index 00000000..452a062f --- /dev/null +++ b/contracts/provider/vault/src/test.rs @@ -0,0 +1,38 @@ +use cosmwasm_std::coin; +// use cw_orch::environment::IndexResponse; +use cw_orch::prelude::*; + +use crate::orch::MeshVault; + +use crate::contract::sv::{ExecMsgFns, InstantiateMsg, QueryMsgFns}; + +// TODO: shared variable +const BECH_PREFIX: &str = "osmo"; + +#[test] +fn happy_path_works() { + let denom = "uosmo"; + let chain = MockBech32::new(BECH_PREFIX); + chain + .add_balance(&chain.sender(), vec![coin(1_000_000, denom)]) + .unwrap(); + + let contract = MeshVault::new("vault", chain.clone()); + contract.upload().unwrap(); + let msg = InstantiateMsg { + denom: denom.to_string(), + local_staking: None, + }; + contract.instantiate(&msg, None, None).unwrap(); + + let cfg = contract.config().unwrap(); + println!("{:?}", cfg); + + let account = contract.account(chain.sender().into()).unwrap(); + assert_eq!(account.bonded.u128(), 0u128); + + contract.bond(&[coin(400_000, denom)]).unwrap(); + + let account = contract.account(chain.sender().into()).unwrap(); + assert_eq!(account.bonded.u128(), 400_000u128); +} From a7875156fcc1d0847626d4cc084321eda5b36828 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 30 May 2024 13:33:00 +0200 Subject: [PATCH 3/3] Build vault interface multitest properly --- contracts/provider/vault/Cargo.toml | 1 + contracts/provider/vault/src/contract.rs | 1 + contracts/provider/vault/src/orch.rs | 74 +++++++++++++++++++++++- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/contracts/provider/vault/Cargo.toml b/contracts/provider/vault/Cargo.toml index 810cae6b..b51e6a46 100644 --- a/contracts/provider/vault/Cargo.toml +++ b/contracts/provider/vault/Cargo.toml @@ -34,6 +34,7 @@ serde = { workspace = true } thiserror = { workspace = true } cw-orch = { workspace = true} +anyhow = { workspace = true } [dev-dependencies] sylvia = { workspace = true, features = ["mt"] } diff --git a/contracts/provider/vault/src/contract.rs b/contracts/provider/vault/src/contract.rs index 04a0d0e6..cd7517fa 100644 --- a/contracts/provider/vault/src/contract.rs +++ b/contracts/provider/vault/src/contract.rs @@ -63,6 +63,7 @@ pub struct VaultContract<'a> { } #[cfg_attr(not(feature = "library"), sylvia::entry_points)] +// #[sylvia::entry_points] #[contract] #[sv::error(ContractError)] #[sv::messages(vault_api as VaultApi)] diff --git a/contracts/provider/vault/src/orch.rs b/contracts/provider/vault/src/orch.rs index b0f1faec..12635dc5 100644 --- a/contracts/provider/vault/src/orch.rs +++ b/contracts/provider/vault/src/orch.rs @@ -1,12 +1,74 @@ // This contains all code we needed to manually add to make it work well with cw-orch // In the future, hopefully some of this can me auto-generated. But let's get it to work now. -use crate::contract::entry_points::{execute, instantiate, query}; + +// use crate::contract::entry_points::{execute, instantiate, query}; +// use crate::contract::sv::mt; + use crate::contract::sv::{ContractExecMsg, ContractQueryMsg, ContractSudoMsg, InstantiateMsg}; use cw_orch::prelude::*; // Maybe uploadable can be autogenerated? // But this is fine to include in the client code +#[cfg(any(feature = "mt", test))] +impl<'a> MockContract for crate::contract::VaultContract<'a> { + fn execute( + &self, + deps: cosmwasm_std::DepsMut, + env: cosmwasm_std::Env, + info: cosmwasm_std::MessageInfo, + msg: Vec, + ) -> anyhow::Result> { + sylvia::cw_multi_test::Contract::execute(self, deps, env, info, msg) + } + + fn instantiate( + &self, + deps: cosmwasm_std::DepsMut, + env: cosmwasm_std::Env, + info: cosmwasm_std::MessageInfo, + msg: Vec, + ) -> anyhow::Result> { + sylvia::cw_multi_test::Contract::instantiate(self, deps, env, info, msg) + } + + fn query( + &self, + deps: cosmwasm_std::Deps, + env: cosmwasm_std::Env, + msg: Vec, + ) -> anyhow::Result { + sylvia::cw_multi_test::Contract::query(self, deps, env, msg) + } + + fn sudo( + &self, + deps: cosmwasm_std::DepsMut, + env: cosmwasm_std::Env, + msg: Vec, + ) -> anyhow::Result> { + sylvia::cw_multi_test::Contract::sudo(self, deps, env, msg) + } + + fn reply( + &self, + deps: cosmwasm_std::DepsMut, + env: cosmwasm_std::Env, + msg: cosmwasm_std::Reply, + ) -> anyhow::Result> { + sylvia::cw_multi_test::Contract::reply(self, deps, env, msg) + } + + fn migrate( + &self, + deps: cosmwasm_std::DepsMut, + env: cosmwasm_std::Env, + msg: Vec, + ) -> anyhow::Result> { + sylvia::cw_multi_test::Contract::migrate(self, deps, env, msg) + } +} + #[cw_orch::interface(InstantiateMsg, ContractExecMsg, ContractQueryMsg, Empty)] pub struct MeshVault; @@ -17,9 +79,17 @@ impl Uploadable for MeshVault { .find_wasm_path("mesh_vault") .unwrap() } + /// Returns a CosmWasm contract wrapper + #[cfg(any(feature = "mt", test))] + fn wrapper() -> Box> { + let c = crate::contract::VaultContract::new(); + Box::new(c) + } + + #[cfg(not(any(feature = "mt", test)))] fn wrapper() -> Box> { - Box::new(ContractWrapper::new_with_empty(execute, instantiate, query)) + panic!("Multitest only implemented in tests or with 'mt' feature"); } }