diff --git a/Cargo.lock b/Cargo.lock index fc544368..c9f87aa4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,12 +25,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base16ct" version = "0.2.0" @@ -134,9 +128,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6b4c3f9c4616d6413d4b5fc4c270a4cc32a374b9be08671e80e1a019f805d8f" dependencies = [ "digest 0.10.7", - "ecdsa 0.16.8", + "ecdsa", "ed25519-zebra", - "k256 0.13.1", + "k256", "rand_core 0.6.4", "thiserror", ] @@ -190,7 +184,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "serde-json-wasm 0.5.2", "sha2 0.10.8", "static_assertions", "thiserror", @@ -205,18 +199,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-bigint" version = "0.5.3" @@ -254,20 +236,21 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.16.5" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" +checksum = "cc392a5cb7e778e3f90adbf7faa43c4db7f35b6623224b08886d796718edb875" dependencies = [ "anyhow", + "bech32", "cosmwasm-std", "cw-storage-plus", "cw-utils", "derivative", - "itertools 0.10.5", - "k256 0.11.6", - "prost 0.9.0", + "itertools 0.12.1", + "prost 0.12.4", "schemars", "serde", + "sha2 0.10.8", "thiserror", ] @@ -312,16 +295,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "der" version = "0.7.8" @@ -370,30 +343,18 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der 0.6.1", - "elliptic-curve 0.12.3", - "rfc6979 0.3.1", - "signature 1.6.4", -] - [[package]] name = "ecdsa" version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ - "der 0.7.8", + "der", "digest 0.10.7", - "elliptic-curve 0.13.6", - "rfc6979 0.4.0", - "signature 2.1.0", - "spki 0.7.2", + "elliptic-curve", + "rfc6979", + "signature", + "spki", ] [[package]] @@ -417,41 +378,21 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array", - "group 0.12.1", - "pkcs8 0.9.0", - "rand_core 0.6.4", - "sec1 0.3.0", - "subtle", - "zeroize", -] - [[package]] name = "elliptic-curve" version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.3", + "base16ct", + "crypto-bigint", "digest 0.10.7", - "ff 0.13.0", + "ff", "generic-array", - "group 0.13.0", - "pkcs8 0.10.2", + "group", + "pkcs8", "rand_core 0.6.4", - "sec1 0.7.3", + "sec1", "subtle", "zeroize", ] @@ -462,16 +403,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "ff" version = "0.13.0" @@ -510,24 +441,13 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.13.0", + "ff", "rand_core 0.6.4", "subtle", ] @@ -596,18 +516,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.8", -] - [[package]] name = "k256" version = "0.13.1" @@ -615,11 +523,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.8", - "elliptic-curve 0.13.6", + "ecdsa", + "elliptic-curve", "once_cell", "sha2 0.10.8", - "signature 2.1.0", + "signature", ] [[package]] @@ -960,24 +868,14 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", -] - [[package]] name = "pkcs8" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.8", - "spki 0.7.2", + "der", + "spki", ] [[package]] @@ -1025,29 +923,29 @@ dependencies = [ [[package]] name = "prost" -version = "0.9.0" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive 0.9.0", + "prost-derive 0.11.9", ] [[package]] name = "prost" -version = "0.11.9" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", - "prost-derive 0.11.9", + "prost-derive 0.12.4", ] [[package]] name = "prost-derive" -version = "0.9.0" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools 0.10.5", @@ -1058,15 +956,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -1102,17 +1000,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac", - "zeroize", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -1153,30 +1040,16 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array", - "pkcs8 0.9.0", - "subtle", - "zeroize", -] - [[package]] name = "sec1" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "base16ct 0.2.0", - "der 0.7.8", + "base16ct", + "der", "generic-array", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -1214,6 +1087,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.199" @@ -1271,16 +1153,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - [[package]] name = "signature" version = "2.1.0" @@ -1291,16 +1163,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - [[package]] name = "spki" version = "0.7.2" @@ -1308,7 +1170,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.8", + "der", ] [[package]] @@ -1325,9 +1187,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "sylvia" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f33388920659b494dab887f3bb40ebb071c602750597575034bea7c63ab12800" +checksum = "e64c8e892525ec035e5bdbeceec19309b1534734da7ff7bc69e9f639b077c497" dependencies = [ "anyhow", "cosmwasm-schema", @@ -1338,22 +1200,23 @@ dependencies = [ "schemars", "serde", "serde-cw-value", - "serde-json-wasm", + "serde-json-wasm 1.0.1", "sylvia-derive", ] [[package]] name = "sylvia-derive" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8031f53dbfda341acd7bd321e10d0d684b673324145026e23705da4b6d5c4919" +checksum = "ae5e0f41752efba2c6895514fa4caae742f69a2a73b4790bb6e365400c563bc1" dependencies = [ "convert_case", + "itertools 0.12.1", "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9a4b76ad..b15060e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ 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.8.1" +sylvia = "0.10.1" cosmwasm-schema = "1.5.4" cosmwasm-std = { version = "1.5.4", features = ["ibc3", "cosmwasm_1_3"] } cw-storage-plus = "1.2.0" @@ -39,7 +39,7 @@ itertools = "0.12.1" # dev deps anyhow = "1" -cw-multi-test = "0.16.5" +cw-multi-test = "0.20" derivative = "2" test-case = "3.3.1" diff --git a/contracts/consumer/converter/src/contract.rs b/contracts/consumer/converter/src/contract.rs index 226bafd6..db32327a 100644 --- a/contracts/consumer/converter/src/contract.rs +++ b/contracts/consumer/converter/src/contract.rs @@ -30,8 +30,8 @@ pub struct ConverterContract<'a> { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] -#[messages(converter_api as ConverterApi)] +#[sv::error(ContractError)] +#[sv::messages(converter_api as ConverterApi)] impl ConverterContract<'_> { pub const fn new() -> Self { Self { @@ -47,7 +47,7 @@ impl ConverterContract<'_> { /// /// Discount is applied to foreign tokens after adjusting foreign/native price, /// such that 0.3 discount means foreign assets have 70% of their value - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, @@ -92,7 +92,7 @@ impl ConverterContract<'_> { Ok(Response::new().add_submessage(init_msg)) } - #[msg(reply)] + #[sv::msg(reply)] fn reply(&self, ctx: ReplyCtx, reply: Reply) -> Result { match reply.id { REPLY_ID_INSTANTIATE => self.reply_init_callback(ctx.deps, reply.result.unwrap()), @@ -114,7 +114,7 @@ impl ConverterContract<'_> { /// This is only used for tests. /// Ideally we want conditional compilation of these whole methods and the enum variants - #[msg(exec)] + #[sv::msg(exec)] fn test_stake( &self, ctx: ExecCtx, @@ -135,7 +135,7 @@ impl ConverterContract<'_> { /// This is only used for tests. /// Ideally we want conditional compilation of these whole methods and the enum variants - #[msg(exec)] + #[sv::msg(exec)] fn test_unstake( &self, ctx: ExecCtx, @@ -156,7 +156,7 @@ impl ConverterContract<'_> { /// This is only used for tests. /// Ideally we want conditional compilation of these whole methods and the enum variants - #[msg(exec)] + #[sv::msg(exec)] fn test_burn( &self, ctx: ExecCtx, @@ -175,7 +175,7 @@ impl ConverterContract<'_> { } } - #[msg(query)] + #[sv::msg(query)] fn config(&self, ctx: QueryCtx) -> Result { let config = self.config.load(ctx.deps.storage)?; let virtual_staking = self.virtual_stake.load(ctx.deps.storage)?.into_string(); @@ -200,7 +200,7 @@ impl ConverterContract<'_> { .add_attribute("validator", &validator) .add_attribute("amount", amount.amount.to_string()); - let msg = virtual_staking_api::ExecMsg::Bond { validator, amount }; + let msg = virtual_staking_api::sv::ExecMsg::Bond { validator, amount }; let msg = WasmMsg::Execute { contract_addr: self.virtual_stake.load(deps.storage)?.into(), msg: to_json_binary(&msg)?, @@ -224,7 +224,7 @@ impl ConverterContract<'_> { .add_attribute("validator", &validator) .add_attribute("amount", amount.amount.to_string()); - let msg = virtual_staking_api::ExecMsg::Unbond { validator, amount }; + let msg = virtual_staking_api::sv::ExecMsg::Unbond { validator, amount }; let msg = WasmMsg::Execute { contract_addr: self.virtual_stake.load(deps.storage)?.into(), msg: to_json_binary(&msg)?, @@ -248,7 +248,7 @@ impl ConverterContract<'_> { .add_attribute("validators", validators.join(",")) .add_attribute("amount", amount.amount.to_string()); - let msg = virtual_staking_api::ExecMsg::Burn { + let msg = virtual_staking_api::sv::ExecMsg::Burn { validators: validators.to_vec(), amount, }; @@ -272,6 +272,7 @@ impl ConverterContract<'_> { } ); + // FIXME not sure how to get this to compile with latest sylvia // get the price value (usage is a bit clunky, need to use trait and cannot chain Remote::new() with .querier()) // also see https://github.com/CosmWasm/sylvia/issues/181 to just store Remote in state use price_feed_api::Querier; @@ -349,14 +350,11 @@ impl ConverterContract<'_> { } } -#[contract] -#[messages(converter_api as ConverterApi)] impl ConverterApi for ConverterContract<'_> { type Error = ContractError; /// Rewards tokens (in native staking denom) are sent alongside the message, and should be distributed to all /// stakers who staked on this validator. This is tracked on the provider, so we send an IBC packet there. - #[msg(exec)] fn distribute_reward( &self, mut ctx: ExecCtx, @@ -382,7 +380,6 @@ impl ConverterApi for ConverterContract<'_> { /// /// info.funds sent along with the message should be the sum of all rewards for all validators, /// in the native staking denom. - #[msg(exec)] fn distribute_rewards( &self, mut ctx: ExecCtx, @@ -422,7 +419,6 @@ impl ConverterApi for ConverterContract<'_> { /// /// Send validator set additions (entering the active validator set), jailings and tombstonings /// to the external staking contract on the Consumer via IBC. - #[msg(exec)] #[allow(clippy::too_many_arguments)] fn valset_update( &self, diff --git a/contracts/consumer/converter/src/multitest/virtual_staking_mock.rs b/contracts/consumer/converter/src/multitest/virtual_staking_mock.rs index 13552e60..b1155da9 100644 --- a/contracts/consumer/converter/src/multitest/virtual_staking_mock.rs +++ b/contracts/consumer/converter/src/multitest/virtual_staking_mock.rs @@ -42,7 +42,7 @@ pub struct VirtualStakingMock<'a> { #[contract] #[error(ContractError)] -#[messages(virtual_staking_api as VirtualStakingApi)] +#[sv::messages(virtual_staking_api as VirtualStakingApi)] impl VirtualStakingMock<'_> { pub const fn new() -> Self { Self { @@ -51,7 +51,7 @@ impl VirtualStakingMock<'_> { } } - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate(&self, ctx: InstantiateCtx) -> Result { nonpayable(&ctx.info)?; let denom = ctx.deps.querier.query_bonded_denom()?; @@ -63,7 +63,7 @@ impl VirtualStakingMock<'_> { Ok(Response::new()) } - #[msg(query)] + #[sv::msg(query)] fn config(&self, ctx: QueryCtx) -> Result { let cfg = self.config.load(ctx.deps.storage)?; let denom = cfg.denom; @@ -71,7 +71,7 @@ impl VirtualStakingMock<'_> { Ok(ConfigResponse { denom, converter }) } - #[msg(query)] + #[sv::msg(query)] fn stake(&self, ctx: QueryCtx, validator: String) -> Result { let stake = self .stake @@ -80,7 +80,7 @@ impl VirtualStakingMock<'_> { Ok(StakeResponse { stake }) } - #[msg(query)] + #[sv::msg(query)] fn all_stake(&self, ctx: QueryCtx) -> Result { let stakes = self .stake @@ -107,14 +107,14 @@ pub struct ConfigResponse { } #[contract] -#[messages(virtual_staking_api as VirtualStakingApi)] +#[sv::messages(virtual_staking_api as VirtualStakingApi)] impl VirtualStakingApi for VirtualStakingMock<'_> { type Error = ContractError; /// Requests to bond tokens to a validator. This will be actually handled at the next epoch. /// If the virtual staking module is over the max cap, it will trigger a rebalance. /// If the max cap is 0, then this will immediately return an error. - #[msg(exec)] + #[sv::msg(exec)] fn bond(&self, ctx: ExecCtx, validator: String, amount: Coin) -> Result { nonpayable(&ctx.info)?; let cfg = self.config.load(ctx.deps.storage)?; @@ -137,7 +137,7 @@ impl VirtualStakingApi for VirtualStakingMock<'_> { /// Requests to unbond tokens from a validator. This will be actually handled at the next epoch. /// If the virtual staking module is over the max cap, it will trigger a rebalance in addition to unbond. /// If the virtual staking contract doesn't have at least amount tokens staked to the given validator, this will return an error. - #[msg(exec)] + #[sv::msg(exec)] fn unbond( &self, ctx: ExecCtx, @@ -165,7 +165,7 @@ impl VirtualStakingApi for VirtualStakingMock<'_> { /// Requests to unbond and burn tokens from a lists of validators (one or more). This will be actually handled at the next epoch. /// If the virtual staking module is over the max cap, it will trigger a rebalance in addition to unbond. /// If the virtual staking contract doesn't have at least amount tokens staked over the given validators, this will return an error. - #[msg(exec)] + #[sv::msg(exec)] fn burn( &self, ctx: ExecCtx, diff --git a/contracts/consumer/remote-price-feed/src/bin/schema.rs b/contracts/consumer/remote-price-feed/src/bin/schema.rs index 1acd896c..830716f4 100644 --- a/contracts/consumer/remote-price-feed/src/bin/schema.rs +++ b/contracts/consumer/remote-price-feed/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mesh_remote_price_feed::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use mesh_remote_price_feed::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/contracts/consumer/remote-price-feed/src/contract.rs b/contracts/consumer/remote-price-feed/src/contract.rs index 7671b640..06e370fc 100644 --- a/contracts/consumer/remote-price-feed/src/contract.rs +++ b/contracts/consumer/remote-price-feed/src/contract.rs @@ -2,8 +2,7 @@ use cosmwasm_std::{entry_point, Decimal, DepsMut, Env, IbcChannel, Response, Tim use cw2::set_contract_version; use cw_storage_plus::Item; use cw_utils::nonpayable; -use mesh_apis::price_feed_api::SudoMsg; -use sylvia::types::{InstantiateCtx, QueryCtx}; +use sylvia::types::{InstantiateCtx, QueryCtx, SudoCtx}; use sylvia::{contract, schemars}; use mesh_apis::price_feed_api::{self, PriceFeedApi, PriceResponse}; @@ -33,8 +32,8 @@ impl Default for RemotePriceFeedContract { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] -#[messages(price_feed_api as PriceFeedApi)] +#[sv::error(ContractError)] +#[sv::messages(price_feed_api as PriceFeedApi)] impl RemotePriceFeedContract { pub fn new() -> Self { Self { @@ -50,7 +49,7 @@ impl RemotePriceFeedContract { } } - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, mut ctx: InstantiateCtx, @@ -83,14 +82,11 @@ impl RemotePriceFeedContract { } } -#[contract] -#[messages(price_feed_api as PriceFeedApi)] impl PriceFeedApi for RemotePriceFeedContract { type Error = ContractError; /// Return the price of the foreign token. That is, how many native tokens /// are needed to buy one foreign token. - #[msg(query)] fn price(&self, ctx: QueryCtx) -> Result { Ok(self .price_keeper @@ -99,14 +95,9 @@ impl PriceFeedApi for RemotePriceFeedContract { native_per_foreign: rate, })?) } -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result { - let contract = RemotePriceFeedContract::new(); - match msg { - SudoMsg::HandleEpoch {} => contract.scheduler.trigger(deps, &env), + fn handle_epoch(&self, ctx: SudoCtx) -> Result { + Ok(self.scheduler.trigger(ctx.deps, &ctx.env)?) } } diff --git a/contracts/consumer/simple-price-feed/src/bin/schema.rs b/contracts/consumer/simple-price-feed/src/bin/schema.rs index d6814af1..aba310dd 100644 --- a/contracts/consumer/simple-price-feed/src/bin/schema.rs +++ b/contracts/consumer/simple-price-feed/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mesh_simple_price_feed::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use mesh_simple_price_feed::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/contracts/consumer/simple-price-feed/src/contract.rs b/contracts/consumer/simple-price-feed/src/contract.rs index 6c4cb6e7..59896fc4 100644 --- a/contracts/consumer/simple-price-feed/src/contract.rs +++ b/contracts/consumer/simple-price-feed/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{ensure_eq, Decimal, Response}; use cw2::set_contract_version; use cw_storage_plus::Item; use cw_utils::nonpayable; -use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx}; +use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx, SudoCtx}; use sylvia::{contract, schemars}; use mesh_apis::price_feed_api::{self, PriceFeedApi, PriceResponse}; @@ -20,8 +20,8 @@ pub struct SimplePriceFeedContract<'a> { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] -#[messages(price_feed_api as PriceFeedApi)] +#[sv::error(ContractError)] +#[sv::messages(price_feed_api as PriceFeedApi)] impl SimplePriceFeedContract<'_> { pub const fn new() -> Self { Self { @@ -31,7 +31,7 @@ impl SimplePriceFeedContract<'_> { /// Sets up the contract with an initial price. /// If the owner is not set in the message, it defaults to info.sender. - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, @@ -53,7 +53,7 @@ impl SimplePriceFeedContract<'_> { Ok(Response::new()) } - #[msg(exec)] + #[sv::msg(exec)] fn update_price( &self, ctx: ExecCtx, @@ -75,7 +75,7 @@ impl SimplePriceFeedContract<'_> { Ok(Response::new()) } - #[msg(query)] + #[sv::msg(query)] fn config(&self, ctx: QueryCtx) -> Result { let config = self.config.load(ctx.deps.storage)?; Ok(ConfigResponse { @@ -85,18 +85,20 @@ impl SimplePriceFeedContract<'_> { } } -#[contract] -#[messages(price_feed_api as PriceFeedApi)] impl PriceFeedApi for SimplePriceFeedContract<'_> { type Error = ContractError; /// Return the price of the foreign token. That is, how many native tokens /// are needed to buy one foreign token. - #[msg(query)] fn price(&self, ctx: QueryCtx) -> Result { let config = self.config.load(ctx.deps.storage)?; Ok(PriceResponse { native_per_foreign: config.native_per_foreign, }) } + + /// Nothing needs to be done on the epoch + fn handle_epoch(&self, _ctx: SudoCtx) -> Result { + Ok(Response::new()) + } } diff --git a/contracts/osmosis-price-provider/src/contract.rs b/contracts/osmosis-price-provider/src/contract.rs index 10997c33..9c2ff9d2 100644 --- a/contracts/osmosis-price-provider/src/contract.rs +++ b/contracts/osmosis-price-provider/src/contract.rs @@ -21,7 +21,7 @@ pub struct OsmosisPriceProvider { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] +#[sv::error(ContractError)] impl OsmosisPriceProvider { pub const fn new() -> Self { Self { @@ -30,7 +30,7 @@ impl OsmosisPriceProvider { } } - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, diff --git a/contracts/provider/external-staking/src/bin/schema.rs b/contracts/provider/external-staking/src/bin/schema.rs index 33178722..a8681e08 100644 --- a/contracts/provider/external-staking/src/bin/schema.rs +++ b/contracts/provider/external-staking/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mesh_external_staking::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use mesh_external_staking::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/contracts/provider/external-staking/src/contract.rs b/contracts/provider/external-staking/src/contract.rs index 50d8e7e2..b2da41e2 100644 --- a/contracts/provider/external-staking/src/contract.rs +++ b/contracts/provider/external-staking/src/contract.rs @@ -62,9 +62,9 @@ impl Default for ExternalStakingContract<'_> { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] -#[messages(cross_staking_api as CrossStakingApi)] -#[messages(crate::test_methods as TestMethods)] +#[sv::error(ContractError)] +#[sv::messages(cross_staking_api as CrossStakingApi)] +#[sv::messages(crate::test_methods as TestMethods)] impl ExternalStakingContract<'_> { pub fn new() -> Self { Self { @@ -86,7 +86,7 @@ impl ExternalStakingContract<'_> { } #[allow(clippy::too_many_arguments)] - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, @@ -245,7 +245,7 @@ impl ExternalStakingContract<'_> { /// Schedules tokens for release, adding them to the pending unbonds. After the unbonding period /// passes, funds are ready to be released through a `withdraw_unbonded` call by the user. - #[msg(exec)] + #[sv::msg(exec)] pub fn unstake( &self, ctx: ExecCtx, @@ -600,7 +600,7 @@ impl ExternalStakingContract<'_> { /// /// Tokens to be claimed have to be unbond before by calling the `unbond` message, and /// their unbonding period must have passed. - #[msg(exec)] + #[sv::msg(exec)] pub fn withdraw_unbonded(&self, ctx: ExecCtx) -> Result { nonpayable(&ctx.info)?; @@ -727,7 +727,7 @@ impl ExternalStakingContract<'_> { } /// Withdraw rewards from staking via given validator - #[msg(exec)] + #[sv::msg(exec)] pub fn withdraw_rewards( &self, ctx: ExecCtx, @@ -955,14 +955,14 @@ impl ExternalStakingContract<'_> { } /// Queries for contract configuration - #[msg(query)] + #[sv::msg(query)] pub fn config(&self, ctx: QueryCtx) -> Result { let resp = self.config.load(ctx.deps.storage)?.into(); Ok(resp) } /// Query for the endpoint that can connect - #[msg(query)] + #[sv::msg(query)] pub fn authorized_endpoint( &self, ctx: QueryCtx, @@ -972,14 +972,14 @@ impl ExternalStakingContract<'_> { } /// Query for the endpoint that can connect - #[msg(query)] + #[sv::msg(query)] pub fn ibc_channel(&self, ctx: QueryCtx) -> Result { let channel = IBC_CHANNEL.load(ctx.deps.storage)?; Ok(IbcChannelResponse { channel }) } /// Show all external validators that we know to be active (and can delegate to) - #[msg(query)] + #[sv::msg(query)] pub fn list_active_validators( &self, ctx: QueryCtx, @@ -994,7 +994,7 @@ impl ExternalStakingContract<'_> { } /// Show all external validators that we know about, along with their state. - #[msg(query)] + #[sv::msg(query)] pub fn list_validators( &self, ctx: QueryCtx, @@ -1019,7 +1019,7 @@ impl ExternalStakingContract<'_> { /// Queries for stake info /// /// If stake does not exist for (user, validator) pair, the zero-stake is returned - #[msg(query)] + #[sv::msg(query)] pub fn stake( &self, ctx: QueryCtx, @@ -1039,7 +1039,7 @@ impl ExternalStakingContract<'_> { /// Paginated list of user stakes. /// /// `start_after` is the last validator of previous page - #[msg(query)] + #[sv::msg(query)] pub fn stakes( &self, ctx: QueryCtx, @@ -1075,7 +1075,7 @@ impl ExternalStakingContract<'_> { } /// Queries a pending tx. - #[msg(query)] + #[sv::msg(query)] fn pending_tx(&self, ctx: QueryCtx, tx_id: u64) -> Result { let resp = self.pending_txs.load(ctx.deps.storage, tx_id)?; Ok(resp) @@ -1084,7 +1084,7 @@ impl ExternalStakingContract<'_> { /// Queries for all pending txs. /// Reports txs in descending order (newest first). /// `start_after` is the last tx id included in previous page - #[msg(query)] + #[sv::msg(query)] fn all_pending_txs_desc( &self, ctx: QueryCtx, @@ -1111,7 +1111,7 @@ impl ExternalStakingContract<'_> { /// Returns how much rewards are to be withdrawn by particular user, from the particular /// validator staking - #[msg(query)] + #[sv::msg(query)] pub fn pending_rewards( &self, ctx: QueryCtx, @@ -1141,7 +1141,7 @@ impl ExternalStakingContract<'_> { /// Returns how much rewards are to be withdrawn by particular user, iterating over all validators. /// This is like stakes is to stake query, but for rewards. - #[msg(query)] + #[sv::msg(query)] pub fn all_pending_rewards( &self, ctx: QueryCtx, @@ -1210,11 +1210,11 @@ pub mod cross_staking { use mesh_apis::{cross_staking_api::CrossStakingApi, local_staking_api::SlashRatioResponse}; #[contract(module=crate::contract)] - #[messages(mesh_apis::cross_staking_api as CrossStakingApi)] + #[sv::messages(mesh_apis::cross_staking_api as CrossStakingApi)] impl CrossStakingApi for ExternalStakingContract<'_> { type Error = ContractError; - #[msg(exec)] + #[sv::msg(exec)] fn receive_virtual_stake( &self, ctx: ExecCtx, @@ -1298,7 +1298,7 @@ pub mod cross_staking { Ok(resp) } - #[msg(exec)] + #[sv::msg(exec)] fn burn_virtual_stake( &self, ctx: ExecCtx, @@ -1432,7 +1432,7 @@ pub mod cross_staking { Ok(resp) } - #[msg(query)] + #[sv::msg(query)] fn max_slash(&self, ctx: QueryCtx) -> Result { let Config { slash_ratio, .. } = self.config.load(ctx.deps.storage)?; Ok(SlashRatioResponse { diff --git a/contracts/provider/external-staking/src/test_methods.rs b/contracts/provider/external-staking/src/test_methods.rs index d6b7e638..98deae7e 100644 --- a/contracts/provider/external-staking/src/test_methods.rs +++ b/contracts/provider/external-staking/src/test_methods.rs @@ -11,15 +11,15 @@ pub trait TestMethods { type Error: From; /// Commits a pending stake. - #[msg(exec)] + #[sv::msg(exec)] fn test_commit_stake(&self, ctx: ExecCtx, tx_id: u64) -> Result; /// Rollbacks a pending stake. - #[msg(exec)] + #[sv::msg(exec)] fn test_rollback_stake(&self, ctx: ExecCtx, tx_id: u64) -> Result; /// Updates the active validator set. - #[msg(exec)] + #[sv::msg(exec)] fn test_set_active_validator( &self, ctx: ExecCtx, @@ -29,7 +29,7 @@ pub trait TestMethods { ) -> Result; /// Sets validator as `unbonded`. - #[msg(exec)] + #[sv::msg(exec)] fn test_remove_validator( &self, ctx: ExecCtx, @@ -38,7 +38,7 @@ pub trait TestMethods { time: u64, ) -> Result; - #[msg(exec)] + #[sv::msg(exec)] fn test_tombstone_validator( &self, ctx: ExecCtx, @@ -48,15 +48,15 @@ pub trait TestMethods { ) -> Result; /// Commits a pending unstake. - #[msg(exec)] + #[sv::msg(exec)] fn test_commit_unstake(&self, ctx: ExecCtx, tx_id: u64) -> Result; /// Rollbacks a pending unstake. - #[msg(exec)] + #[sv::msg(exec)] fn test_rollback_unstake(&self, ctx: ExecCtx, tx_id: u64) -> Result; /// Distribute rewards. - #[msg(exec)] + #[sv::msg(exec)] fn test_distribute_rewards( &self, ctx: ExecCtx, @@ -65,7 +65,7 @@ pub trait TestMethods { ) -> Result; /// Batch distribute rewards. - #[msg(exec)] + #[sv::msg(exec)] fn test_distribute_rewards_batch( &self, ctx: ExecCtx, @@ -74,7 +74,7 @@ pub trait TestMethods { ) -> Result; /// Commits a withdraw rewards transaction. - #[msg(exec)] + #[sv::msg(exec)] fn test_commit_withdraw_rewards( &self, ctx: ExecCtx, @@ -82,7 +82,7 @@ pub trait TestMethods { ) -> Result; /// Rollbacks a withdraw rewards transaction. - #[msg(exec)] + #[sv::msg(exec)] fn test_rollback_withdraw_rewards( &self, ctx: ExecCtx, @@ -92,7 +92,7 @@ pub trait TestMethods { /// Slashes a validator. /// This will not perform any check on the validator's state in the validator set, which should /// be done before calling this function. - #[msg(exec)] + #[sv::msg(exec)] fn test_handle_slashing( &self, ctx: ExecCtx, diff --git a/contracts/provider/external-staking/src/test_methods_impl.rs b/contracts/provider/external-staking/src/test_methods_impl.rs index a9687631..c63927c1 100644 --- a/contracts/provider/external-staking/src/test_methods_impl.rs +++ b/contracts/provider/external-staking/src/test_methods_impl.rs @@ -10,12 +10,12 @@ use sylvia::types::ExecCtx; /// These methods are for test usage only #[contract(module=crate::contract)] -#[messages(crate::test_methods as TestMethods)] +#[sv::messages(crate::test_methods as TestMethods)] impl TestMethods for ExternalStakingContract<'_> { type Error = ContractError; /// Commits a pending stake. - #[msg(exec)] + #[sv::msg(exec)] fn test_commit_stake(&self, ctx: ExecCtx, tx_id: u64) -> Result { #[cfg(any(feature = "mt", test))] { @@ -30,7 +30,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Rollbacks a pending stake. - #[msg(exec)] + #[sv::msg(exec)] fn test_rollback_stake(&self, ctx: ExecCtx, tx_id: u64) -> Result { #[cfg(any(test, feature = "mt"))] { @@ -45,7 +45,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Updates the active validator set. - #[msg(exec)] + #[sv::msg(exec)] fn test_set_active_validator( &self, ctx: ExecCtx, @@ -68,7 +68,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Sets validator as `unbonded`. - #[msg(exec)] + #[sv::msg(exec)] fn test_remove_validator( &self, ctx: ExecCtx, @@ -90,7 +90,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Sets validator as `unbonded`. - #[msg(exec)] + #[sv::msg(exec)] fn test_tombstone_validator( &self, ctx: ExecCtx, @@ -112,7 +112,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Commits a pending unstake. - #[msg(exec)] + #[sv::msg(exec)] fn test_commit_unstake(&self, ctx: ExecCtx, tx_id: u64) -> Result { #[cfg(any(test, feature = "mt"))] { @@ -127,7 +127,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Rollbacks a pending unstake. - #[msg(exec)] + #[sv::msg(exec)] fn test_rollback_unstake(&self, ctx: ExecCtx, tx_id: u64) -> Result { #[cfg(any(test, feature = "mt"))] { @@ -142,7 +142,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Distribute rewards. - #[msg(exec)] + #[sv::msg(exec)] fn test_distribute_rewards( &self, ctx: ExecCtx, @@ -162,7 +162,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Batch distribute rewards. - #[msg(exec)] + #[sv::msg(exec)] fn test_distribute_rewards_batch( &self, ctx: ExecCtx, @@ -182,7 +182,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Commits a withdraw rewards transaction. - #[msg(exec)] + #[sv::msg(exec)] fn test_commit_withdraw_rewards( &self, ctx: ExecCtx, @@ -201,7 +201,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Rollbacks a withdraw rewards transaction. - #[msg(exec)] + #[sv::msg(exec)] fn test_rollback_withdraw_rewards( &self, ctx: ExecCtx, @@ -220,7 +220,7 @@ impl TestMethods for ExternalStakingContract<'_> { } /// Slashes a validator - #[msg(exec)] + #[sv::msg(exec)] fn test_handle_slashing( &self, ctx: ExecCtx, diff --git a/contracts/provider/native-staking-proxy/src/bin/schema.rs b/contracts/provider/native-staking-proxy/src/bin/schema.rs index e9246c00..c378ebbb 100644 --- a/contracts/provider/native-staking-proxy/src/bin/schema.rs +++ b/contracts/provider/native-staking-proxy/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mesh_native_staking_proxy::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use mesh_native_staking_proxy::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/contracts/provider/native-staking-proxy/src/contract.rs b/contracts/provider/native-staking-proxy/src/contract.rs index f19fa45a..89aa6240 100644 --- a/contracts/provider/native-staking-proxy/src/contract.rs +++ b/contracts/provider/native-staking-proxy/src/contract.rs @@ -25,7 +25,7 @@ pub struct NativeStakingProxyContract<'a> { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] +#[sv::error(ContractError)] impl NativeStakingProxyContract<'_> { pub const fn new() -> Self { Self { @@ -36,7 +36,7 @@ impl NativeStakingProxyContract<'_> { /// The caller of the instantiation will be the native-staking contract. /// We stake `funds.info` on the given validator - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, @@ -75,7 +75,7 @@ impl NativeStakingProxyContract<'_> { /// Stakes the tokens from `info.funds` to the given validator. /// Can only be called by the parent contract - #[msg(exec)] + #[sv::msg(exec)] fn stake(&self, ctx: ExecCtx, validator: String) -> Result { let cfg = self.config.load(ctx.deps.storage)?; ensure_eq!(cfg.parent, ctx.info.sender, ContractError::Unauthorized {}); @@ -91,7 +91,7 @@ impl NativeStakingProxyContract<'_> { /// Burn `amount` tokens from the given validator, if set. /// If `validator` is not set, undelegate evenly from all validators the user has stake. /// Can only be called by the parent contract - #[msg(exec)] + #[sv::msg(exec)] fn burn( &self, ctx: ExecCtx, @@ -179,7 +179,7 @@ impl NativeStakingProxyContract<'_> { /// Re-stakes the given amount from the one validator to another on behalf of the calling user. /// Returns an error if the user doesn't have such stake - #[msg(exec)] + #[sv::msg(exec)] fn restake( &self, ctx: ExecCtx, @@ -207,7 +207,7 @@ impl NativeStakingProxyContract<'_> { } /// Vote with the user's stake (over all delegations) - #[msg(exec)] + #[sv::msg(exec)] fn vote( &self, ctx: ExecCtx, @@ -224,7 +224,7 @@ impl NativeStakingProxyContract<'_> { } /// Vote with the user's stake (over all delegations) - #[msg(exec)] + #[sv::msg(exec)] fn vote_weighted( &self, ctx: ExecCtx, @@ -246,7 +246,7 @@ impl NativeStakingProxyContract<'_> { /// If the caller has any delegations, withdraw all rewards from those delegations and /// send the tokens to the caller. /// NOTE: must make sure not to release unbonded tokens - #[msg(exec)] + #[sv::msg(exec)] fn withdraw_rewards(&self, ctx: ExecCtx) -> Result { let cfg = self.config.load(ctx.deps.storage)?; ensure_eq!(cfg.owner, ctx.info.sender, ContractError::Unauthorized {}); @@ -270,7 +270,7 @@ impl NativeStakingProxyContract<'_> { /// Unstakes the given amount from the given validator on behalf of the calling user. /// Returns an error if the user doesn't have such stake. /// After the unbonding period, it will allow the user to claim the tokens (returning to vault) - #[msg(exec)] + #[sv::msg(exec)] fn unstake( &self, ctx: ExecCtx, @@ -295,7 +295,7 @@ impl NativeStakingProxyContract<'_> { /// Releases any tokens that have fully unbonded from a previous unstake. /// This will go back to the parent via `release_proxy_stake`. /// Errors if the proxy doesn't have any liquid tokens - #[msg(exec)] + #[sv::msg(exec)] fn release_unbonded(&self, ctx: ExecCtx) -> Result { let cfg = self.config.load(ctx.deps.storage)?; ensure_eq!(cfg.owner, ctx.info.sender, ContractError::Unauthorized {}); @@ -318,7 +318,7 @@ impl NativeStakingProxyContract<'_> { } // Send them to the parent contract via `release_proxy_stake` - let msg = to_json_binary(&native_staking_callback::ExecMsg::ReleaseProxyStake {})?; + let msg = to_json_binary(&native_staking_callback::sv::ExecMsg::ReleaseProxyStake {})?; let wasm_msg = Execute { contract_addr: cfg.parent.to_string(), @@ -328,7 +328,7 @@ impl NativeStakingProxyContract<'_> { Ok(Response::new().add_message(wasm_msg)) } - #[msg(query)] + #[sv::msg(query)] fn config(&self, ctx: QueryCtx) -> Result { Ok(self.config.load(ctx.deps.storage)?) } diff --git a/contracts/provider/native-staking-proxy/src/multitest.rs b/contracts/provider/native-staking-proxy/src/multitest.rs index a89fc034..f89a4788 100644 --- a/contracts/provider/native-staking-proxy/src/multitest.rs +++ b/contracts/provider/native-staking-proxy/src/multitest.rs @@ -7,7 +7,7 @@ use cw_multi_test::{App as MtApp, StakingInfo, StakingSudo, SudoMsg}; use sylvia::multitest::App; -use mesh_vault::contract::multitest_utils::VaultContractProxy; +use mesh_vault::contract::sv::mt::VaultContractProxy; use crate::contract; use crate::msg::ConfigResponse; @@ -57,15 +57,15 @@ fn setup<'app>( user: &str, validators: &[&str], ) -> AnyResult> { - let vault_code = mesh_vault::contract::multitest_utils::CodeId::store_code(app); - let staking_code = mesh_native_staking::contract::multitest_utils::CodeId::store_code(app); - let staking_proxy_code = contract::multitest_utils::CodeId::store_code(app); + let vault_code = mesh_vault::contract::sv::mt::CodeId::store_code(app); + let staking_code = mesh_native_staking::contract::sv::mt::CodeId::store_code(app); + let staking_proxy_code = contract::sv::mt::CodeId::store_code(app); // Instantiate vault msg let staking_init_info = mesh_vault::msg::StakingInitInfo { admin: None, code_id: staking_code.code_id(), - msg: to_json_binary(&mesh_native_staking::contract::InstantiateMsg { + msg: to_json_binary(&mesh_native_staking::contract::sv::InstantiateMsg { denom: OSMO.to_owned(), proxy_code_id: staking_proxy_code.code_id(), slash_ratio_dsign: Decimal::percent(5), @@ -120,10 +120,8 @@ fn instantiation() { setup(&app, owner, user, &[validator]).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Check config let config = staking_proxy.config().unwrap(); @@ -166,10 +164,8 @@ fn staking() { let vault = setup(&app, owner, user, &[validator]).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Stake some more vault @@ -214,10 +210,8 @@ fn restaking() { setup(&app, owner, user, &[validator]).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Restake 30% to a different validator staking_proxy @@ -255,10 +249,8 @@ fn unstaking() { setup(&app, owner, user, &[validator]).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Unstake 50% staking_proxy @@ -277,10 +269,6 @@ fn unstaking() { // And that they are now held, until the unbonding period // First, check that the contract has no funds - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); assert_eq!( app.app() .wrap() @@ -294,10 +282,6 @@ fn unstaking() { block.height += 1234; block.time = block.time.plus_seconds(UNBONDING_PERIOD); }); - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); // Check that the contract now has the funds assert_eq!( @@ -323,10 +307,8 @@ fn burning() { setup(&app, owner, user, &[validator]).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Burn 10%, from validator staking_proxy @@ -345,10 +327,6 @@ fn burning() { // And that they are now held, until the unbonding period // First, check that the contract has no funds - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); assert_eq!( app.app() .wrap() @@ -362,10 +340,6 @@ fn burning() { block.height += 1234; block.time = block.time.plus_seconds(UNBONDING_PERIOD); }); - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); // Check that the contract now has the funds assert_eq!( @@ -403,10 +377,8 @@ fn burning_multiple_delegations() { setup(&app, owner, user, &validators).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Burn 15%, no validator specified let burn_amount = 15; @@ -440,10 +412,6 @@ fn burning_multiple_delegations() { // And that they are now held, until the unbonding period // First, check that the contract has no funds - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); assert_eq!( app.app() .wrap() @@ -457,10 +425,6 @@ fn burning_multiple_delegations() { block.height += 1234; block.time = block.time.plus_seconds(UNBONDING_PERIOD); }); - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); // Check that the contract now has the funds assert_eq!( @@ -497,10 +461,8 @@ fn releasing_unbonded() { let vault = setup(&app, owner, user, &[validator]).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Unstake 100% staking_proxy @@ -521,10 +483,6 @@ fn releasing_unbonded() { block.height += 12345; block.time = block.time.plus_seconds(UNBONDING_PERIOD + 1); }); - // Manually cause queue to get processed. TODO: Handle automatically in sylvia mt or cw-mt - app.app_mut() - .sudo(SudoMsg::Staking(StakingSudo::ProcessQueue {})) - .unwrap(); // Release the unbonded funds staking_proxy.release_unbonded().call(user).unwrap(); @@ -562,10 +520,8 @@ fn withdrawing_rewards() { let original_user_funds = app.app().wrap().query_balance(user, OSMO).unwrap(); // Access staking proxy instance - let staking_proxy = contract::multitest_utils::NativeStakingProxyContractProxy::new( - Addr::unchecked(proxy_addr), - &app, - ); + let staking_proxy = + contract::sv::mt::NativeStakingProxyContractProxy::new(Addr::unchecked(proxy_addr), &app); // Advance time enough for rewards to accrue app.update_block(|block| { diff --git a/contracts/provider/native-staking-proxy/src/native_staking_callback.rs b/contracts/provider/native-staking-proxy/src/native_staking_callback.rs index 25eca15f..53dc0241 100644 --- a/contracts/provider/native-staking-proxy/src/native_staking_callback.rs +++ b/contracts/provider/native-staking-proxy/src/native_staking_callback.rs @@ -10,6 +10,6 @@ pub trait NativeStakingCallback { /// This sends tokens back from the proxy to native-staking. (See info.funds) /// The native-staking contract can determine which user it belongs to via an internal Map. /// The native-staking contract will then send those tokens back to vault and release the claim. - #[msg(exec)] + #[sv::msg(exec)] fn release_proxy_stake(&self, _ctx: ExecCtx) -> Result; } diff --git a/contracts/provider/native-staking/src/bin/schema.rs b/contracts/provider/native-staking/src/bin/schema.rs index 9418954a..4f7cbbbc 100644 --- a/contracts/provider/native-staking/src/bin/schema.rs +++ b/contracts/provider/native-staking/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mesh_native_staking::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use mesh_native_staking::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/contracts/provider/native-staking/src/contract.rs b/contracts/provider/native-staking/src/contract.rs index 3aa562a7..6a7a1041 100644 --- a/contracts/provider/native-staking/src/contract.rs +++ b/contracts/provider/native-staking/src/contract.rs @@ -3,8 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::Order::Ascending; use cosmwasm_std::{ - from_json, Addr, Decimal, DepsMut, Env, Event, Reply, Response, StdResult, SubMsgResponse, - WasmMsg, + from_json, Addr, Decimal, DepsMut, Reply, Response, StdResult, SubMsgResponse, WasmMsg, }; use cw2::set_contract_version; use cw_storage_plus::{Item, Map}; @@ -13,7 +12,6 @@ use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx, ReplyCtx}; use sylvia::{contract, schemars}; use mesh_apis::local_staking_api; -use mesh_apis::local_staking_api::SudoMsg; use mesh_apis::vault_api::{SlashInfo, VaultApiHelper}; use mesh_native_staking_proxy::msg::OwnerMsg; use mesh_native_staking_proxy::native_staking_callback; @@ -45,9 +43,9 @@ pub(crate) enum SlashingReason { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] -#[messages(local_staking_api as LocalStakingApi)] -#[messages(native_staking_callback as NativeStakingCallback)] +#[sv::error(ContractError)] +#[sv::messages(local_staking_api as LocalStakingApi)] +#[sv::messages(native_staking_callback as NativeStakingCallback)] impl NativeStakingContract<'_> { pub const fn new() -> Self { Self { @@ -59,7 +57,7 @@ impl NativeStakingContract<'_> { } /// The caller of the instantiation will be the vault contract - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, @@ -84,44 +82,7 @@ impl NativeStakingContract<'_> { Ok(Response::new()) } - /// This is called every time there's a change of the active validator set that implies slashing. - /// In test code, this is called from `test_handle_jailing`. - /// In non-test code, this is called from `sudo`. - fn handle_jailing( - &self, - mut deps: DepsMut, - jailed: &[String], - tombstoned: &[String], - ) -> Result { - let cfg = self.config.load(deps.storage)?; - let mut msgs = vec![]; - for validator in tombstoned { - // Slash the validator (if bonded) - let slash_msg = - self.handle_slashing(&mut deps, &cfg, validator, SlashingReason::DoubleSign)?; - if let Some(msg) = slash_msg { - msgs.push(msg) - } - } - for validator in jailed { - // Slash the validator (if bonded) - let slash_msg = - self.handle_slashing(&mut deps, &cfg, validator, SlashingReason::Offline)?; - if let Some(msg) = slash_msg { - msgs.push(msg) - } - } - let mut evt = Event::new("jailing"); - if !jailed.is_empty() { - evt = evt.add_attribute("jailed", jailed.join(",")); - } - if !tombstoned.is_empty() { - evt = evt.add_attribute("tombstoned", tombstoned.join(",")); - } - Ok(Response::new().add_event(evt).add_messages(msgs)) - } - - fn handle_slashing( + pub(crate) fn handle_slashing( &self, deps: &mut DepsMut, config: &Config, @@ -177,12 +138,12 @@ impl NativeStakingContract<'_> { Ok(Some(msg)) } - #[msg(query)] + #[sv::msg(query)] fn config(&self, ctx: QueryCtx) -> Result { self.config.load(ctx.deps.storage).map_err(Into::into) } - #[msg(reply)] + #[sv::msg(reply)] fn reply(&self, ctx: ReplyCtx, reply: Reply) -> Result { match reply.id { REPLY_ID_INSTANTIATE => self.reply_init_callback(ctx.deps, reply.result.unwrap()), @@ -210,7 +171,7 @@ impl NativeStakingContract<'_> { Ok(Response::new()) } - #[msg(query)] + #[sv::msg(query)] fn proxy_by_owner( &self, ctx: QueryCtx, @@ -223,7 +184,7 @@ impl NativeStakingContract<'_> { }) } - #[msg(query)] + #[sv::msg(query)] fn owner_by_proxy( &self, ctx: QueryCtx, @@ -235,35 +196,4 @@ impl NativeStakingContract<'_> { owner: owner_addr.to_string(), }) } - - /// Jails validators temporarily or permanently. - /// Method used for test only. - #[msg(exec)] - fn test_handle_jailing( - &self, - ctx: ExecCtx, - jailed: Vec, - tombstoned: Vec, - ) -> Result { - #[cfg(any(feature = "mt", test))] - { - NativeStakingContract::new().handle_jailing(ctx.deps, &jailed, &tombstoned) - } - #[cfg(not(any(feature = "mt", test)))] - { - let _ = (ctx, jailed, tombstoned); - Err(ContractError::Unauthorized {}) - } - } -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result { - match msg { - SudoMsg::Jailing { jailed, tombstoned } => NativeStakingContract::new().handle_jailing( - deps, - &jailed.unwrap_or_default(), - &tombstoned.unwrap_or_default(), - ), - } } diff --git a/contracts/provider/native-staking/src/error.rs b/contracts/provider/native-staking/src/error.rs index 198619f4..e0d2e422 100644 --- a/contracts/provider/native-staking/src/error.rs +++ b/contracts/provider/native-staking/src/error.rs @@ -2,7 +2,7 @@ use cosmwasm_std::StdError; use cw_utils::{ParseReplyError, PaymentError}; use thiserror::Error; -#[derive(Error, Debug)] +#[derive(Error, Debug, PartialEq)] pub enum ContractError { #[error("{0}")] Std(#[from] StdError), diff --git a/contracts/provider/native-staking/src/local_staking_api.rs b/contracts/provider/native-staking/src/local_staking_api.rs index 3d9d5a27..2dce85ba 100644 --- a/contracts/provider/native-staking/src/local_staking_api.rs +++ b/contracts/provider/native-staking/src/local_staking_api.rs @@ -1,28 +1,24 @@ -use cosmwasm_std::{ensure_eq, from_json, to_json_binary, Binary, Coin, Response, SubMsg, WasmMsg}; +use cosmwasm_std::{ + ensure_eq, from_json, to_json_binary, Binary, Coin, Event, Response, SubMsg, WasmMsg, +}; use cw_utils::{must_pay, nonpayable}; -use sylvia::types::QueryCtx; -use sylvia::{contract, types::ExecCtx}; +use sylvia::types::{ExecCtx, QueryCtx, SudoCtx}; #[allow(unused_imports)] use mesh_apis::local_staking_api::{self, LocalStakingApi, SlashRatioResponse}; -use crate::contract::{NativeStakingContract, REPLY_ID_INSTANTIATE}; +use crate::contract::{NativeStakingContract, SlashingReason, REPLY_ID_INSTANTIATE}; use crate::error::ContractError; use crate::msg::StakeMsg; -// FIXME: Move to sylvia contract macro -use crate::contract::BoundQuerier; use crate::state::Config; -#[contract] -#[messages(local_staking_api as LocalStakingApi)] impl LocalStakingApi for NativeStakingContract<'_> { type Error = ContractError; /// Receives stake (info.funds) from vault contract on behalf of owner and performs the action /// specified in msg with it. /// Msg is custom to each implementation of the staking contract and opaque to the vault - #[msg(exec)] fn receive_stake( &self, ctx: ExecCtx, @@ -52,11 +48,12 @@ impl LocalStakingApi for NativeStakingContract<'_> { { None => { // Instantiate proxy contract and send funds to stake, with reply handling on success - let msg = to_json_binary(&mesh_native_staking_proxy::contract::InstantiateMsg { - denom: cfg.denom, - owner: owner.clone(), - validator, - })?; + let msg = + to_json_binary(&mesh_native_staking_proxy::contract::sv::InstantiateMsg { + denom: cfg.denom, + owner: owner.clone(), + validator, + })?; let wasm_msg = WasmMsg::Instantiate { admin: Some(ctx.env.contract.address.into()), code_id: cfg.proxy_code_id, @@ -69,9 +66,10 @@ impl LocalStakingApi for NativeStakingContract<'_> { } Some(proxy_addr) => { // Send stake message with funds to the proxy contract - let msg = to_json_binary(&mesh_native_staking_proxy::contract::ExecMsg::Stake { - validator, - })?; + let msg = + to_json_binary(&mesh_native_staking_proxy::contract::sv::ExecMsg::Stake { + validator, + })?; let wasm_msg = WasmMsg::Execute { contract_addr: proxy_addr.into(), msg, @@ -86,7 +84,6 @@ impl LocalStakingApi for NativeStakingContract<'_> { /// propagation, the native staking contract needs to burn / discount the indicated slashing amount. /// If `validator` is set, undelegate preferentially from it first. /// If it is not set, undelegate evenly from all validators the user has stake in. - #[msg(exec)] fn burn_stake( &self, ctx: ExecCtx, @@ -110,10 +107,11 @@ impl LocalStakingApi for NativeStakingContract<'_> { None => Err(ContractError::NoProxy(owner)), Some(proxy_addr) => { // Send burn message to the proxy contract - let msg = to_json_binary(&mesh_native_staking_proxy::contract::ExecMsg::Burn { - validator, - amount, - })?; + let msg = + to_json_binary(&mesh_native_staking_proxy::contract::sv::ExecMsg::Burn { + validator, + amount, + })?; let wasm_msg = WasmMsg::Execute { contract_addr: proxy_addr.into(), msg, @@ -124,8 +122,47 @@ impl LocalStakingApi for NativeStakingContract<'_> { } } + /// This is called every time there's a change of the active validator set that implies slashing. + /// In test code, this is called from `test_handle_jailing`. + /// In non-test code, this is called from `sudo`. + fn jailing( + &self, + mut ctx: SudoCtx, + jailed: Option>, + tombstoned: Option>, + ) -> Result { + let jailed = &jailed.unwrap_or_default(); + let tombstoned = &tombstoned.unwrap_or_default(); + + let cfg = self.config.load(ctx.deps.storage)?; + let mut msgs = vec![]; + for validator in tombstoned { + // Slash the validator (if bonded) + let slash_msg = + self.handle_slashing(&mut ctx.deps, &cfg, validator, SlashingReason::DoubleSign)?; + if let Some(msg) = slash_msg { + msgs.push(msg) + } + } + for validator in jailed { + // Slash the validator (if bonded) + let slash_msg = + self.handle_slashing(&mut ctx.deps, &cfg, validator, SlashingReason::Offline)?; + if let Some(msg) = slash_msg { + msgs.push(msg) + } + } + let mut evt = Event::new("jailing"); + if !jailed.is_empty() { + evt = evt.add_attribute("jailed", jailed.join(",")); + } + if !tombstoned.is_empty() { + evt = evt.add_attribute("tombstoned", tombstoned.join(",")); + } + Ok(Response::new().add_event(evt).add_messages(msgs)) + } + /// Returns the maximum percentage that can be slashed - #[msg(query)] fn max_slash(&self, ctx: QueryCtx) -> Result { let Config { slash_ratio_dsign, diff --git a/contracts/provider/native-staking/src/multitest.rs b/contracts/provider/native-staking/src/multitest.rs index ff2781bb..51482ac6 100644 --- a/contracts/provider/native-staking/src/multitest.rs +++ b/contracts/provider/native-staking/src/multitest.rs @@ -5,14 +5,15 @@ use cosmwasm_std::{ use cw_multi_test::{App as MtApp, StakingInfo}; use sylvia::multitest::App; -use mesh_native_staking_proxy::contract::multitest_utils::{ +use mesh_apis::local_staking_api::sv::mt::LocalStakingApiProxy; +use mesh_native_staking_proxy::contract::sv::mt::{ CodeId as NativeStakingProxyCodeId, NativeStakingProxyContractProxy, }; use mesh_sync::ValueRange; - -use crate::local_staking_api::test_utils::LocalStakingApi; +use mesh_vault::contract::sv::mt::VaultContractProxy; use crate::contract; +use crate::contract::sv::mt::NativeStakingContractProxy; use crate::error::ContractError; use crate::msg; use crate::msg::{OwnerByProxyResponse, ProxyByOwnerResponse}; @@ -107,7 +108,7 @@ fn instantiation() { let owner = "vault"; // Owner of the staking contract (i. e. the vault contract) let staking_proxy_code = NativeStakingProxyCodeId::store_code(&app); - let staking_code = contract::multitest_utils::CodeId::store_code(&app); + let staking_code = contract::sv::mt::CodeId::store_code(&app); let staking = staking_code .instantiate( @@ -123,7 +124,7 @@ fn instantiation() { let config = staking.config().unwrap(); assert_eq!(config.denom, OSMO); - let res = staking.local_staking_api_proxy().max_slash().unwrap(); + let res = staking.max_slash().unwrap(); assert_eq!(res.slash_ratio_dsign, slashing_rate_dsign()); } @@ -141,7 +142,7 @@ fn receiving_stake() { // Contracts setup let staking_proxy_code = NativeStakingProxyCodeId::store_code(&app); - let staking_code = contract::multitest_utils::CodeId::store_code(&app); + let staking_code = contract::sv::mt::CodeId::store_code(&app); let staking = staking_code .instantiate( @@ -167,7 +168,6 @@ fn receiving_stake() { }) .unwrap(); staking - .local_staking_api_proxy() .receive_stake(user1.to_owned(), stake_msg) .with_funds(&coins(100, OSMO)) .call(owner) // called from vault @@ -191,7 +191,6 @@ fn receiving_stake() { }) .unwrap(); staking - .local_staking_api_proxy() .receive_stake(user1.to_owned(), stake_msg) .with_funds(&coins(50, OSMO)) .call(owner) // called from vault @@ -222,7 +221,6 @@ fn receiving_stake() { }) .unwrap(); staking - .local_staking_api_proxy() .receive_stake(user2.to_owned(), stake_msg) .with_funds(&coins(10, OSMO)) .call(owner) // called from vault @@ -256,15 +254,15 @@ fn releasing_proxy_stake() { let app = app(&[(user, (300, OSMO))], &[validator]); // Contracts setup - let vault_code = mesh_vault::contract::multitest_utils::CodeId::store_code(&app); - let staking_code = contract::multitest_utils::CodeId::store_code(&app); + let vault_code = mesh_vault::contract::sv::mt::CodeId::store_code(&app); + let staking_code = contract::sv::mt::CodeId::store_code(&app); let staking_proxy_code = NativeStakingProxyCodeId::store_code(&app); // Instantiate vault msg let staking_init_info = mesh_vault::msg::StakingInitInfo { admin: None, code_id: staking_code.code_id(), - msg: to_json_binary(&crate::contract::InstantiateMsg { + msg: to_json_binary(&crate::contract::sv::InstantiateMsg { denom: OSMO.to_owned(), proxy_code_id: staking_proxy_code.code_id(), slash_ratio_dsign: slashing_rate_dsign(), @@ -340,11 +338,6 @@ fn releasing_proxy_stake() { .unstake(validator.to_string(), coin(100, OSMO)) .call(user) .unwrap(); - app.app_mut() - .sudo(cw_multi_test::SudoMsg::Staking( - cw_multi_test::StakingSudo::ProcessQueue {}, - )) - .unwrap(); staking_proxy.release_unbonded().call(user).unwrap(); // Check that the vault has the funds again diff --git a/contracts/provider/native-staking/src/native_staking_callback.rs b/contracts/provider/native-staking/src/native_staking_callback.rs index c64184af..4996296f 100644 --- a/contracts/provider/native-staking/src/native_staking_callback.rs +++ b/contracts/provider/native-staking/src/native_staking_callback.rs @@ -1,6 +1,5 @@ use cosmwasm_std::Response; use cw_utils::must_pay; -use sylvia::contract; use sylvia::types::ExecCtx; #[allow(unused_imports)] @@ -9,18 +8,12 @@ use mesh_native_staking_proxy::native_staking_callback::{self, NativeStakingCall use crate::contract::NativeStakingContract; use crate::error::ContractError; -// FIXME: Move to sylvia contract macro -use crate::contract::BoundQuerier; - -#[contract] -#[messages(native_staking_callback as NativeStakingCallback)] impl NativeStakingCallback for NativeStakingContract<'_> { type Error = ContractError; /// This sends tokens back from the proxy to native-staking. (See info.funds) /// The native-staking contract can determine which user it belongs to via an internal Map. /// The native-staking contract will then send those tokens back to vault and release the claim. - #[msg(exec)] fn release_proxy_stake(&self, ctx: ExecCtx) -> Result { let cfg = self.config.load(ctx.deps.storage)?; diff --git a/contracts/provider/vault/src/bin/schema.rs b/contracts/provider/vault/src/bin/schema.rs index 580812f4..ab50e399 100644 --- a/contracts/provider/vault/src/bin/schema.rs +++ b/contracts/provider/vault/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mesh_vault::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use mesh_vault::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/contracts/provider/vault/src/contract.rs b/contracts/provider/vault/src/contract.rs index ee4009e7..4ce5003e 100644 --- a/contracts/provider/vault/src/contract.rs +++ b/contracts/provider/vault/src/contract.rs @@ -9,7 +9,7 @@ use std::cmp::min; use mesh_apis::cross_staking_api::CrossStakingApiHelper; use mesh_apis::local_staking_api::{ - LocalStakingApiHelper, LocalStakingApiQueryMsg, SlashRatioResponse, + sv::LocalStakingApiQueryMsg, LocalStakingApiHelper, SlashRatioResponse, }; use mesh_apis::vault_api::{self, SlashInfo, VaultApi}; use mesh_sync::Tx::InFlightStaking; @@ -64,8 +64,8 @@ pub struct VaultContract<'a> { #[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] -#[error(ContractError)] -#[messages(vault_api as VaultApi)] +#[sv::error(ContractError)] +#[sv::messages(vault_api as VaultApi)] impl VaultContract<'_> { pub fn new() -> Self { Self { @@ -85,7 +85,7 @@ impl VaultContract<'_> { Ok(id) } - #[msg(instantiate)] + #[sv::msg(instantiate)] pub fn instantiate( &self, ctx: InstantiateCtx, @@ -117,7 +117,7 @@ impl VaultContract<'_> { } } - #[msg(exec)] + #[sv::msg(exec)] fn bond(&self, ctx: ExecCtx) -> Result { let denom = self.config.load(ctx.deps.storage)?.denom; let amount = must_pay(&ctx.info, &denom)?; @@ -137,7 +137,7 @@ impl VaultContract<'_> { Ok(resp) } - #[msg(exec)] + #[sv::msg(exec)] fn unbond(&self, ctx: ExecCtx, amount: Coin) -> Result { nonpayable(&ctx.info)?; @@ -174,7 +174,7 @@ impl VaultContract<'_> { } /// This assigns a claim of amount tokens to the remote contract, which can take some action with it - #[msg(exec)] + #[sv::msg(exec)] fn stake_remote( &self, mut ctx: ExecCtx, @@ -223,7 +223,7 @@ impl VaultContract<'_> { } /// This sends actual tokens to the local staking contract - #[msg(exec)] + #[sv::msg(exec)] fn stake_local( &self, mut ctx: ExecCtx, @@ -263,7 +263,7 @@ impl VaultContract<'_> { } } - #[msg(query)] + #[sv::msg(query)] fn account(&self, ctx: QueryCtx, account: String) -> Result { let denom = self.config.load(ctx.deps.storage)?.denom; let account = ctx.deps.api.addr_validate(&account)?; @@ -279,7 +279,7 @@ impl VaultContract<'_> { }) } - #[msg(query)] + #[sv::msg(query)] fn account_details( &self, ctx: QueryCtx, @@ -301,7 +301,7 @@ impl VaultContract<'_> { }) } - #[msg(query)] + #[sv::msg(query)] fn config(&self, ctx: QueryCtx) -> Result { let config = self.config.load(ctx.deps.storage)?; let local_staking = self.local_staking.load(ctx.deps.storage)?; @@ -314,7 +314,7 @@ impl VaultContract<'_> { Ok(resp) } - #[msg(query)] + #[sv::msg(query)] fn active_external_staking( &self, ctx: QueryCtx, @@ -332,7 +332,7 @@ impl VaultContract<'_> { } /// Returns a single claim between the user and lienholder - #[msg(query)] + #[sv::msg(query)] fn claim( &self, ctx: QueryCtx, @@ -350,7 +350,7 @@ impl VaultContract<'_> { /// Returns paginated claims list for an user /// /// `start_after` is a last lienholder of the previous page, and it will not be included - #[msg(query)] + #[sv::msg(query)] fn account_claims( &self, ctx: QueryCtx, @@ -388,7 +388,7 @@ impl VaultContract<'_> { /// `start_after` is the last account included in previous page /// /// `with_collateral` flag filters out users with no collateral, defaulted to false - #[msg(query)] + #[sv::msg(query)] fn all_accounts( &self, ctx: QueryCtx, @@ -432,7 +432,7 @@ impl VaultContract<'_> { } /// Queries a pending tx. - #[msg(query)] + #[sv::msg(query)] fn pending_tx(&self, ctx: QueryCtx, tx_id: u64) -> Result { let resp = self.pending.txs.load(ctx.deps.storage, tx_id)?; Ok(resp) @@ -441,7 +441,7 @@ impl VaultContract<'_> { /// Queries for all pending txs. /// Reports txs in descending order (newest first). /// `start_after` is the last tx id included in previous page - #[msg(query)] + #[sv::msg(query)] fn all_pending_txs_desc( &self, ctx: QueryCtx, @@ -467,7 +467,7 @@ impl VaultContract<'_> { Ok(resp) } - #[msg(reply)] + #[sv::msg(reply)] fn reply(&self, ctx: ReplyCtx, reply: Reply) -> Result { match reply.id { REPLY_ID_INSTANTIATE => self.reply_init_callback(ctx.deps, reply.result.unwrap()), @@ -957,13 +957,10 @@ impl Default for VaultContract<'_> { } } -#[contract] -#[messages(vault_api as VaultApi)] impl VaultApi for VaultContract<'_> { type Error = ContractError; /// This must be called by the remote staking contract to release this claim - #[msg(exec)] fn release_cross_stake( &self, mut ctx: ExecCtx, @@ -987,7 +984,6 @@ impl VaultApi for VaultContract<'_> { /// This must be called by the local staking contract to release this claim /// Amount of tokens unstaked are those included in ctx.info.funds - #[msg(exec)] fn release_local_stake( &self, mut ctx: ExecCtx, @@ -1009,7 +1005,6 @@ impl VaultApi for VaultContract<'_> { } /// This must be called by the native staking contract to process a misbehaviour - #[msg(exec)] fn local_slash( &self, mut ctx: ExecCtx, @@ -1038,7 +1033,6 @@ impl VaultApi for VaultContract<'_> { } /// This must be called by the external staking contract to process a misbehaviour - #[msg(exec)] fn cross_slash( &self, mut ctx: ExecCtx, @@ -1066,7 +1060,6 @@ impl VaultApi for VaultContract<'_> { Ok(resp) } - #[msg(exec)] fn commit_tx(&self, mut ctx: ExecCtx, tx_id: u64) -> Result { self.commit_stake(&mut ctx, tx_id)?; @@ -1078,7 +1071,6 @@ impl VaultApi for VaultContract<'_> { Ok(resp) } - #[msg(exec)] fn rollback_tx(&self, mut ctx: ExecCtx, tx_id: u64) -> Result { self.rollback_stake(&mut ctx, tx_id)?; diff --git a/contracts/provider/vault/src/multitest.rs b/contracts/provider/vault/src/multitest.rs index 12a44466..cc8c73de 100644 --- a/contracts/provider/vault/src/multitest.rs +++ b/contracts/provider/vault/src/multitest.rs @@ -1,20 +1,18 @@ use cosmwasm_std::{coin, coins, to_json_binary, Addr, Decimal, Uint128, Validator}; use cw_multi_test::{App as MtApp, StakingInfo}; use mesh_apis::ibc::AddValidator; -use mesh_external_staking::contract::multitest_utils::ExternalStakingContractProxy; +use mesh_external_staking::contract::sv::mt::ExternalStakingContractProxy; use mesh_external_staking::msg::{AuthorizedEndpoint, ReceiveVirtualStake, StakeInfo}; use mesh_external_staking::state::SlashRatio; use mesh_external_staking::state::Stake; -use mesh_external_staking::test_methods_impl::test_utils::TestMethods; -use mesh_native_staking::contract::multitest_utils::NativeStakingContractProxy; -use mesh_native_staking_proxy::contract::multitest_utils::NativeStakingProxyContractProxy; +use mesh_native_staking::contract::sv::mt::NativeStakingContractProxy; +use mesh_native_staking_proxy::contract::sv::mt::NativeStakingProxyContractProxy; use mesh_sync::Tx::InFlightStaking; use mesh_sync::{Tx, ValueRange}; use sylvia::multitest::App; use crate::contract; -use crate::contract::multitest_utils::VaultContractProxy; -use crate::contract::test_utils::VaultApi; +use crate::contract::sv::mt::VaultContractProxy; use crate::error::ContractError; use crate::msg::{ AccountResponse, AllAccountsResponseItem, AllActiveExternalStakingResponse, LienResponse, @@ -31,7 +29,7 @@ const SLASHING_PERCENTAGE: u64 = 10; /// App initialization fn init_app(users: &[&str], amounts: &[u128]) -> App { - let mut app = MtApp::new(|router, _api, storage| { + let mut app = App::new(|router, _api, storage| { for (&user, amount) in std::iter::zip(users, amounts) { router .bank @@ -117,15 +115,14 @@ fn setup_inner<'app>( Option>, ExternalStakingContractProxy<'app, MtApp>, ) { - let vault_code = contract::multitest_utils::CodeId::store_code(app); + let vault_code = contract::sv::mt::CodeId::store_code(app); let staking_init_info = if local_staking { - let native_staking_code = - mesh_native_staking::contract::multitest_utils::CodeId::store_code(app); + let native_staking_code = mesh_native_staking::contract::sv::mt::CodeId::store_code(app); let native_staking_proxy_code = - mesh_native_staking_proxy::contract::multitest_utils::CodeId::store_code(app); + mesh_native_staking_proxy::contract::sv::mt::CodeId::store_code(app); - let native_staking_inst_msg = mesh_native_staking::contract::InstantiateMsg { + let native_staking_inst_msg = mesh_native_staking::contract::sv::InstantiateMsg { denom: OSMO.to_string(), slash_ratio_dsign: Decimal::percent(10), slash_ratio_offline: Decimal::percent(10), @@ -163,8 +160,7 @@ fn setup_cross_stake<'app>( unbond_period: u64, ) -> ExternalStakingContractProxy<'app, MtApp> { // FIXME: Code shouldn't be duplicated - let cross_staking_code = - mesh_external_staking::contract::multitest_utils::CodeId::store_code(app); + let cross_staking_code = mesh_external_staking::contract::sv::mt::CodeId::store_code(app); // FIXME: Connection endpoint should be unique let remote_contact = AuthorizedEndpoint::new("connection-2", "wasm-osmo1foobarbaz"); @@ -275,11 +271,6 @@ fn process_staking_unbondings(app: &App) { let mut block_info = app.block_info(); block_info.time = block_info.time.plus_seconds(61); app.set_block(block_info); - app.app_mut() - .sudo(cw_multi_test::SudoMsg::Staking( - cw_multi_test::StakingSudo::ProcessQueue {}, - )) - .unwrap(); } #[track_caller] diff --git a/packages/apis/src/converter_api.rs b/packages/apis/src/converter_api.rs index 77d0fb67..2a26474d 100644 --- a/packages/apis/src/converter_api.rs +++ b/packages/apis/src/converter_api.rs @@ -12,7 +12,7 @@ pub trait ConverterApi { /// Rewards tokens (in native staking denom) are sent alongside the message, and should be distributed to all /// stakers who staked on this validator. - #[msg(exec)] + #[sv::msg(exec)] fn distribute_reward(&self, ctx: ExecCtx, validator: String) -> Result; /// This is a batch for of distribute_reward, including the payment for multiple validators. @@ -20,7 +20,7 @@ pub trait ConverterApi { /// /// info.funds sent along with the message should be the sum of all rewards for all validators, /// in the native staking denom. - #[msg(exec)] + #[sv::msg(exec)] fn distribute_rewards( &self, ctx: ExecCtx, @@ -31,7 +31,7 @@ pub trait ConverterApi { /// /// TODO: pubkeys need to be part of the Validator struct (requires CosmWasm support). #[allow(clippy::too_many_arguments)] - #[msg(exec)] + #[sv::msg(exec)] fn valset_update( &self, ctx: ExecCtx, diff --git a/packages/apis/src/cross_staking_api.rs b/packages/apis/src/cross_staking_api.rs index c02fbbc1..f83e0dac 100644 --- a/packages/apis/src/cross_staking_api.rs +++ b/packages/apis/src/cross_staking_api.rs @@ -18,7 +18,7 @@ pub trait CrossStakingApi { /// Receives stake from vault contract on behalf of owner and performs the action /// specified in msg with it. /// Msg is custom to each implementation of the staking contract and opaque to the vault - #[msg(exec)] + #[sv::msg(exec)] fn receive_virtual_stake( &self, ctx: ExecCtx, @@ -34,7 +34,7 @@ pub trait CrossStakingApi { /// If it is not set, undelegate evenly from all validators the user has stake in. /// This should be transactional, but it's not. If the transaction fails there isn't much we can /// do, besides logging the failure. - #[msg(exec)] + #[sv::msg(exec)] fn burn_virtual_stake( &self, ctx: ExecCtx, @@ -44,7 +44,7 @@ pub trait CrossStakingApi { ) -> Result; /// Returns the maximum percentage that can be slashed - #[msg(query)] + #[sv::msg(query)] fn max_slash(&self, ctx: QueryCtx) -> Result; } @@ -64,7 +64,7 @@ impl CrossStakingApiHelper { msg: Binary, funds: Vec, ) -> Result { - let msg = CrossStakingApiExecMsg::ReceiveVirtualStake { + let msg = sv::CrossStakingApiExecMsg::ReceiveVirtualStake { owner, msg, amount, @@ -84,7 +84,7 @@ impl CrossStakingApiHelper { amount: Coin, validator: Option, ) -> Result { - let msg = CrossStakingApiExecMsg::BurnVirtualStake { + let msg = sv::CrossStakingApiExecMsg::BurnVirtualStake { owner: owner.to_string(), validator, amount, @@ -98,7 +98,7 @@ impl CrossStakingApiHelper { } pub fn max_slash(&self, deps: Deps) -> Result { - let query = CrossStakingApiQueryMsg::MaxSlash {}; + let query = sv::CrossStakingApiQueryMsg::MaxSlash {}; deps.querier.query_wasm_smart(&self.0, &query) } } diff --git a/packages/apis/src/local_staking_api.rs b/packages/apis/src/local_staking_api.rs index f2be8dd9..2212fba4 100644 --- a/packages/apis/src/local_staking_api.rs +++ b/packages/apis/src/local_staking_api.rs @@ -2,7 +2,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{ to_json_binary, Addr, Binary, Coin, Decimal, Deps, Response, StdError, WasmMsg, }; -use sylvia::types::{ExecCtx, QueryCtx}; +use sylvia::types::{ExecCtx, QueryCtx, SudoCtx}; use sylvia::{interface, schemars}; #[cw_serde] @@ -20,7 +20,7 @@ pub trait LocalStakingApi { /// Receives stake (info.funds) from vault contract on behalf of owner and performs the action /// specified in msg with it. /// Msg is custom to each implementation of the staking contract and opaque to the vault - #[msg(exec)] + #[sv::msg(exec)] fn receive_stake( &self, ctx: ExecCtx, @@ -37,7 +37,7 @@ pub trait LocalStakingApi { /// propagation, the native staking contract needs to burn / discount the indicated slashing amount. /// If `validator` is set, undelegate preferentially from it first. /// If it is not set, undelegate evenly from all validators the user has stake in. - #[msg(exec)] + #[sv::msg(exec)] fn burn_stake( &self, ctx: ExecCtx, @@ -47,8 +47,20 @@ pub trait LocalStakingApi { ) -> Result; /// Returns the maximum percentage that can be slashed - #[msg(query)] + #[sv::msg(query)] fn max_slash(&self, ctx: QueryCtx) -> Result; + + /// `SudoMsg::Jailing` should be called every time there's a validator set update that implies + /// slashing. + /// - Temporary removal of a validator from the active set due to jailing. + /// - Permanent removal (i.e. tombstoning) of a validator from the active set. + #[sv::msg(sudo)] + fn jailing( + &self, + ctx: SudoCtx, + jailed: Option>, + tombstoned: Option>, + ) -> Result; } #[cw_serde] @@ -68,7 +80,7 @@ impl LocalStakingApiHelper { // amount to stake on that contract funds: Vec, ) -> Result { - let msg = LocalStakingApiExecMsg::ReceiveStake { owner, msg }; + let msg = sv::LocalStakingApiExecMsg::ReceiveStake { owner, msg }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), msg: to_json_binary(&msg)?, @@ -83,7 +95,7 @@ impl LocalStakingApiHelper { amount: Coin, validator: Option, ) -> Result { - let msg = LocalStakingApiExecMsg::BurnStake { + let msg = sv::LocalStakingApiExecMsg::BurnStake { owner: owner.to_string(), validator, amount, @@ -97,19 +109,7 @@ impl LocalStakingApiHelper { } pub fn max_slash(&self, deps: Deps) -> Result { - let query = LocalStakingApiQueryMsg::MaxSlash {}; + let query = sv::LocalStakingApiQueryMsg::MaxSlash {}; deps.querier.query_wasm_smart(&self.0, &query) } } - -#[cw_serde] -pub enum SudoMsg { - /// `SudoMsg::Jailing` should be called every time there's a validator set update that implies - /// slashing. - /// - Temporary removal of a validator from the active set due to jailing. - /// - Permanent removal (i.e. tombstoning) of a validator from the active set. - Jailing { - jailed: Option>, - tombstoned: Option>, - }, -} diff --git a/packages/apis/src/price_feed_api.rs b/packages/apis/src/price_feed_api.rs index dbed0af1..49723bf1 100644 --- a/packages/apis/src/price_feed_api.rs +++ b/packages/apis/src/price_feed_api.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Decimal, StdError}; -use sylvia::types::QueryCtx; +use cosmwasm_std::{Decimal, Response, StdError}; +use sylvia::types::{QueryCtx, SudoCtx}; use sylvia::{interface, schemars}; /// This is a common interface to any price feed provider. @@ -15,16 +15,14 @@ pub trait PriceFeedApi { /// Return the price of the foreign token. That is, how many native tokens /// are needed to buy one foreign token. - #[msg(query)] + #[sv::msg(query)] fn price(&self, ctx: QueryCtx) -> Result; + + #[sv::msg(sudo)] + fn handle_epoch(&self, ctx: SudoCtx) -> Result; } #[cw_serde] pub struct PriceResponse { pub native_per_foreign: Decimal, } - -#[cw_serde] -pub enum SudoMsg { - HandleEpoch {}, -} diff --git a/packages/apis/src/vault_api.rs b/packages/apis/src/vault_api.rs index 56d25686..9d051627 100644 --- a/packages/apis/src/vault_api.rs +++ b/packages/apis/src/vault_api.rs @@ -10,7 +10,7 @@ pub trait VaultApi { type Error: From; /// This must be called by the remote staking contract to release this claim - #[msg(exec)] + #[sv::msg(exec)] fn release_cross_stake( &self, ctx: ExecCtx, @@ -22,7 +22,7 @@ pub trait VaultApi { /// This must be called by the local staking contract to release this claim /// Amount of tokens unstaked are those included in ctx.info.funds - #[msg(exec)] + #[sv::msg(exec)] fn release_local_stake( &self, ctx: ExecCtx, @@ -32,19 +32,19 @@ pub trait VaultApi { /// This must be called by the remote staking contract to commit the remote staking call on success. /// Transaction ID is used to identify the original (vault contract originated) transaction. - #[msg(exec)] + #[sv::msg(exec)] fn commit_tx(&self, ctx: ExecCtx, tx_id: u64) -> Result; /// This must be called by the remote staking contract to rollback the remote staking call on failure. /// Transaction ID is used to identify the original (vault contract originated) transaction. - #[msg(exec)] + #[sv::msg(exec)] fn rollback_tx(&self, ctx: ExecCtx, tx_id: u64) -> Result; /// This must be called by the native staking contract to process a slashing event /// because of a misbehaviour on the Provider chain. /// `validator` is the misbehaving validator address. Used during slashing propagation to /// preferentially burn stakes from this validator. - #[msg(exec)] + #[sv::msg(exec)] fn local_slash( &self, ctx: ExecCtx, @@ -56,7 +56,7 @@ pub trait VaultApi { /// because of a misbehaviour on the Consumer chain. /// `validator` is the misbehaving validator address. Used during slashing propagation to /// preferentially burn stakes from this validator. - #[msg(exec)] + #[sv::msg(exec)] fn cross_slash( &self, ctx: ExecCtx, @@ -87,7 +87,7 @@ impl VaultApiHelper { amount: Coin, funds: Vec, ) -> Result { - let msg = VaultApiExecMsg::ReleaseCrossStake { owner, amount }; + let msg = sv::VaultApiExecMsg::ReleaseCrossStake { owner, amount }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), msg: to_json_binary(&msg)?, @@ -103,7 +103,7 @@ impl VaultApiHelper { // tokens to send along with this funds: Vec, ) -> Result { - let msg = VaultApiExecMsg::ReleaseLocalStake { owner }; + let msg = sv::VaultApiExecMsg::ReleaseLocalStake { owner }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), msg: to_json_binary(&msg)?, @@ -117,7 +117,7 @@ impl VaultApiHelper { slashes: Vec, slashed_validator: &str, ) -> Result { - let msg = VaultApiExecMsg::LocalSlash { + let msg = sv::VaultApiExecMsg::LocalSlash { slashes, validator: slashed_validator.to_string(), }; @@ -134,7 +134,7 @@ impl VaultApiHelper { slashes: Vec, slashed_validator: &str, ) -> Result { - let msg = VaultApiExecMsg::CrossSlash { + let msg = sv::VaultApiExecMsg::CrossSlash { slashes, validator: slashed_validator.to_string(), }; @@ -147,7 +147,7 @@ impl VaultApiHelper { } pub fn commit_tx(&self, tx_id: u64) -> Result { - let msg = VaultApiExecMsg::CommitTx { tx_id }; + let msg = sv::VaultApiExecMsg::CommitTx { tx_id }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), msg: to_json_binary(&msg)?, @@ -157,7 +157,7 @@ impl VaultApiHelper { } pub fn rollback_tx(&self, tx_id: u64) -> Result { - let msg = VaultApiExecMsg::RollbackTx { tx_id }; + let msg = sv::VaultApiExecMsg::RollbackTx { tx_id }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), msg: to_json_binary(&msg)?, diff --git a/packages/apis/src/virtual_staking_api.rs b/packages/apis/src/virtual_staking_api.rs index e997b86a..8e1b6bb9 100644 --- a/packages/apis/src/virtual_staking_api.rs +++ b/packages/apis/src/virtual_staking_api.rs @@ -13,13 +13,13 @@ pub trait VirtualStakingApi { /// Requests to bond tokens to a validator. This will be actually handled at the next epoch. /// If the virtual staking module is over the max cap, it will trigger a rebalance. /// If the max cap is 0, then this will immediately return an error. - #[msg(exec)] + #[sv::msg(exec)] fn bond(&self, ctx: ExecCtx, validator: String, amount: Coin) -> Result; /// Requests to unbond tokens from a validator. This will be actually handled at the next epoch. /// If the virtual staking module is over the max cap, it will trigger a rebalance in addition to unbond. /// If the virtual staking contract doesn't have at least amount tokens staked to the given validator, this will return an error. - #[msg(exec)] + #[sv::msg(exec)] fn unbond( &self, ctx: ExecCtx, @@ -30,7 +30,7 @@ pub trait VirtualStakingApi { /// Burns stake. This is called when the user's collateral is slashed and, as part of slashing /// propagation, the virtual staking contract needs to burn / discount the indicated slashing amount. /// Undelegates evenly from all `validators`. - #[msg(exec)] + #[sv::msg(exec)] fn burn( &self, ctx: ExecCtx,