diff --git a/Cargo.lock b/Cargo.lock index 10679e66f..a97c42c0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,9 +69,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cfg-if" @@ -87,9 +87,9 @@ checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" -version = "0.14.0-beta3" +version = "0.14.0-beta4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c6c908b7bb3905edd6e0b8ad58b18d26b4a125b06727a137cd32150aab59079" +checksum = "c1c01da6cef92b4cfeff1f0f9c25faea38933336c8f518923d3fa2d3802e999e" dependencies = [ "digest 0.9.0", "ed25519-zebra", @@ -100,18 +100,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "0.14.0-beta3" +version = "0.14.0-beta4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "499f5385e2019ec3c85d0d1aaa0b8fa4ee679fff6bd66f318f8d7511e09b9cfb" +checksum = "1a13cbe25d3df0636d4a1bad0880ea2dfd507740d0b851ed0bb39feee0352f4c" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "0.14.0-beta3" +version = "0.14.0-beta4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab1e8141c815e5847be08088090183a6a23bb29e0435054aa25cc9e36fbbfbde" +checksum = "6f077fb99158d345d76b309058573d4b0ce3e1609b2affb3da2405a6af572da8" dependencies = [ "schemars", "serde_json", @@ -119,9 +119,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "0.14.0-beta3" +version = "0.14.0-beta4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f576ab664cea370c4850d2b1a9eec78dd217fcb9ed1746f089faf294a0d9b9f" +checksum = "bcab389a0d8ea2a1399ad5416c1ca25cc860336ff7004a58128e487dcee8f109" dependencies = [ "base64", "cosmwasm-crypto", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.0.2" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" +checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" dependencies = [ "byteorder", "digest 0.9.0", @@ -695,20 +695,21 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "k256" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf02ecc966e1b7e8db1c81ac8f321ba24d1cfab5b634961fab10111f015858e1" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "sha2 0.9.3", ] [[package]] name = "libc" -version = "0.2.88" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" +checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" [[package]] name = "num-traits" @@ -742,9 +743,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -775,9 +776,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.10.3" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc7f5b8840fb1f83869a3e1dfd06d93db79ea05311ac5b42b8337d3371caa4f1" +checksum = "4ca515aafa02c92f4d3c69b2f4c408f839b51b1aa938d00b15e8c0966bd22d73" dependencies = [ "arrayvec", "num-traits", @@ -792,9 +793,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a24475737c47c5a97cd0858d09db5b0c01ade85d671ee569cd1a5a2c0c80a44" +checksum = "bc6ab463ae35acccb5cba66c0084c985257b797d288b6050cc2f6ac1b266cb78" dependencies = [ "dyn-clone", "schemars_derive", @@ -804,9 +805,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f0ccbfe5a97322d90f8b19604fa5b99dd8223540eb6e36c99a9125303e4c00" +checksum = "902fdfbcf871ae8f653bddf4b2c05905ddaabc08f69d32a915787e3be0d31356" dependencies = [ "proc-macro2", "quote", @@ -816,9 +817,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] @@ -834,9 +835,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -908,9 +909,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.62" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "123a78a3596b24fee53a6464ce52d8ecbf62241e6294c7e7fe12086cd161f512" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" dependencies = [ "proc-macro2", "quote", @@ -939,9 +940,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "unicode-xid" @@ -951,9 +952,9 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wasi" @@ -969,6 +970,6 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] name = "zeroize" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 28c0a8a27..5b4d818e9 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -22,11 +22,11 @@ cw0 = { path = "../../packages/cw0", version = "0.6.0-beta2" } cw1 = { path = "../../packages/cw1", version = "0.6.0-beta2" } cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.6.0-beta2", features = ["library"] } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["iterator", "staking"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["iterator", "staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } diff --git a/contracts/cw1-subkeys/schema/execute_msg.json b/contracts/cw1-subkeys/schema/execute_msg.json index 4107082bc..eafc1fba3 100644 --- a/contracts/cw1-subkeys/schema/execute_msg.json +++ b/contracts/cw1-subkeys/schema/execute_msg.json @@ -273,6 +273,18 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -287,6 +299,55 @@ } ] }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "anyOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, "Empty": { "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", "type": "object" @@ -415,34 +476,6 @@ }, "additionalProperties": false }, - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw" - ], - "properties": { - "withdraw": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "recipient": { - "description": "this is the \"withdraw address\", the one that should receive the rewards if None, then use delegator address", - "type": [ - "string", - "null" - ] - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, { "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", "type": "object", @@ -518,7 +551,7 @@ "additionalProperties": false }, { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", "type": "object", "required": [ "instantiate" @@ -533,6 +566,12 @@ "send" ], "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, "code_id": { "type": "integer", "format": "uint64", diff --git a/contracts/cw1-subkeys/schema/query_msg.json b/contracts/cw1-subkeys/schema/query_msg.json index db56c1767..11c40e7f2 100644 --- a/contracts/cw1-subkeys/schema/query_msg.json +++ b/contracts/cw1-subkeys/schema/query_msg.json @@ -256,6 +256,18 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -270,46 +282,70 @@ } ] }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", "anyOf": [ { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "delegate" + "set_withdraw_address" ], "properties": { - "delegate": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { "type": "object", "required": [ - "amount", "validator" ], "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, "validator": { + "description": "The `validator_address`", "type": "string" } } } }, "additionalProperties": false - }, + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "anyOf": [ { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "undelegate" + "delegate" ], "properties": { - "undelegate": { + "delegate": { "type": "object", "required": [ "amount", @@ -328,24 +364,21 @@ "additionalProperties": false }, { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "withdraw" + "undelegate" ], "properties": { - "withdraw": { + "undelegate": { "type": "object", "required": [ + "amount", "validator" ], "properties": { - "recipient": { - "description": "this is the \"withdraw address\", the one that should receive the rewards if None, then use delegator address", - "type": [ - "string", - "null" - ] + "amount": { + "$ref": "#/definitions/Coin" }, "validator": { "type": "string" @@ -430,7 +463,7 @@ "additionalProperties": false }, { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", "type": "object", "required": [ "instantiate" @@ -445,6 +478,12 @@ "send" ], "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, "code_id": { "type": "integer", "format": "uint64", diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index 2cff00219..412c7054b 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -5,8 +5,8 @@ use std::ops::{AddAssign, Sub}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, - Order, Response, StakingMsg, StdError, StdResult, + attr, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, DistributionMsg, Empty, Env, + MessageInfo, Order, Response, StakingMsg, StdError, StdResult, }; use cw0::Expiration; use cw1::CanExecuteResponse; @@ -100,6 +100,11 @@ where let perm = perm.ok_or(ContractError::NotAllowed {})?; check_staking_permissions(staking_msg, perm)?; } + CosmosMsg::Distribution(distribution_msg) => { + let perm = PERMISSIONS.may_load(deps.storage, &info.sender)?; + let perm = perm.ok_or(ContractError::NotAllowed {})?; + check_distribution_permissions(distribution_msg, perm)?; + } CosmosMsg::Bank(BankMsg::Send { to_address: _, amount, @@ -147,12 +152,27 @@ pub fn check_staking_permissions( return Err(ContractError::ReDelegatePerm {}); } } - StakingMsg::Withdraw { .. } => { + s => panic!("Unsupported staking message: {:?}", s), + } + Ok(true) +} + +pub fn check_distribution_permissions( + distribution_msg: &DistributionMsg, + permissions: Permissions, +) -> Result { + match distribution_msg { + DistributionMsg::SetWithdrawAddress { .. } => { + if !permissions.withdraw { + return Err(ContractError::WithdrawAddrPerm {}); + } + } + DistributionMsg::WithdrawDelegatorReward { .. } => { if !permissions.withdraw { return Err(ContractError::WithdrawPerm {}); } } - s => panic!("Unsupported staking message: {:?}", s), + s => panic!("Unsupported distribution message: {:?}", s), } Ok(true) } @@ -1262,9 +1282,8 @@ mod tests { amount: coin1, } .into()]; - let msg_withdraw = vec![StakingMsg::Withdraw { + let msg_withdraw = vec![DistributionMsg::WithdrawDelegatorReward { validator: "validator1".into(), - recipient: None, } .into()]; @@ -1462,10 +1481,10 @@ mod tests { validator: anyone.to_string(), amount: coin(70000, "ureef"), }); - let staking_withdraw_msg = CosmosMsg::Staking(StakingMsg::Withdraw { - validator: anyone.to_string(), - recipient: None, - }); + let staking_withdraw_msg = + CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { + validator: anyone.to_string(), + }); // owner can send big or small let res = query_can_execute(deps.as_ref(), owner.to_string(), send_msg.clone()).unwrap(); diff --git a/contracts/cw1-subkeys/src/error.rs b/contracts/cw1-subkeys/src/error.rs index 5ca741732..7fc23ccac 100644 --- a/contracts/cw1-subkeys/src/error.rs +++ b/contracts/cw1-subkeys/src/error.rs @@ -32,6 +32,9 @@ pub enum ContractError { #[error("Withdraw is not allowed")] WithdrawPerm {}, + + #[error("Set withdraw address is not allowed")] + WithdrawAddrPerm {}, } impl From for ContractError { diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index b169c8739..aa146246b 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -21,11 +21,11 @@ library = [] cw0 = { path = "../../packages/cw0", version = "0.6.0-beta2" } cw1 = { path = "../../packages/cw1", version = "0.6.0-beta2" } cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["iterator"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["iterator", "staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } diff --git a/contracts/cw1-whitelist/schema/execute_msg.json b/contracts/cw1-whitelist/schema/execute_msg.json index 5abe94f00..8571bc134 100644 --- a/contracts/cw1-whitelist/schema/execute_msg.json +++ b/contracts/cw1-whitelist/schema/execute_msg.json @@ -179,6 +179,18 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -193,46 +205,70 @@ } ] }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", "anyOf": [ { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "delegate" + "set_withdraw_address" ], "properties": { - "delegate": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { "type": "object", "required": [ - "amount", "validator" ], "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, "validator": { + "description": "The `validator_address`", "type": "string" } } } }, "additionalProperties": false - }, + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "anyOf": [ { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "undelegate" + "delegate" ], "properties": { - "undelegate": { + "delegate": { "type": "object", "required": [ "amount", @@ -251,24 +287,21 @@ "additionalProperties": false }, { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "withdraw" + "undelegate" ], "properties": { - "withdraw": { + "undelegate": { "type": "object", "required": [ + "amount", "validator" ], "properties": { - "recipient": { - "description": "this is the \"withdraw address\", the one that should receive the rewards if None, then use delegator address", - "type": [ - "string", - "null" - ] + "amount": { + "$ref": "#/definitions/Coin" }, "validator": { "type": "string" @@ -353,7 +386,7 @@ "additionalProperties": false }, { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", "type": "object", "required": [ "instantiate" @@ -368,6 +401,12 @@ "send" ], "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, "code_id": { "type": "integer", "format": "uint64", diff --git a/contracts/cw1-whitelist/schema/query_msg.json b/contracts/cw1-whitelist/schema/query_msg.json index 881e45bf5..1887e787c 100644 --- a/contracts/cw1-whitelist/schema/query_msg.json +++ b/contracts/cw1-whitelist/schema/query_msg.json @@ -156,6 +156,18 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -170,46 +182,70 @@ } ] }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", "anyOf": [ { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "delegate" + "set_withdraw_address" ], "properties": { - "delegate": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { "type": "object", "required": [ - "amount", "validator" ], "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, "validator": { + "description": "The `validator_address`", "type": "string" } } } }, "additionalProperties": false - }, + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "anyOf": [ { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "undelegate" + "delegate" ], "properties": { - "undelegate": { + "delegate": { "type": "object", "required": [ "amount", @@ -228,24 +264,21 @@ "additionalProperties": false }, { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "withdraw" + "undelegate" ], "properties": { - "withdraw": { + "undelegate": { "type": "object", "required": [ + "amount", "validator" ], "properties": { - "recipient": { - "description": "this is the \"withdraw address\", the one that should receive the rewards if None, then use delegator address", - "type": [ - "string", - "null" - ] + "amount": { + "$ref": "#/definitions/Coin" }, "validator": { "type": "string" @@ -330,7 +363,7 @@ "additionalProperties": false }, { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", "type": "object", "required": [ "instantiate" @@ -345,6 +378,12 @@ "send" ], "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, "code_id": { "type": "integer", "format": "uint64", diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 593ef046f..2787cbc73 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -22,7 +22,7 @@ cw0 = { path = "../../packages/cw0", version = "0.6.0-beta2" } cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw1155 = { path = "../../packages/cw1155", version = "0.6.0-beta2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2" , features = ["iterator"]} -cosmwasm-std = { version = "=0.14.0-beta3", features = ["iterator"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } diff --git a/contracts/cw20-atomic-swap/Cargo.toml b/contracts/cw20-atomic-swap/Cargo.toml index 4e50c6ef6..284ae8dfb 100644 --- a/contracts/cw20-atomic-swap/Cargo.toml +++ b/contracts/cw20-atomic-swap/Cargo.toml @@ -18,7 +18,7 @@ library = [] cw0 = { path = "../../packages/cw0", version = "0.6.0-beta2" } cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw20 = { path = "../../packages/cw20", version = "0.6.0-beta2" } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["iterator"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["iterator"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -27,4 +27,4 @@ hex = "0.3.1" sha2 = "0.8.0" [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index e6962d521..cd16febcd 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -22,10 +22,10 @@ cw0 = { path = "../../packages/cw0", version = "0.6.0-beta2" } cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw20 = { path = "../../packages/cw20", version = "0.6.0-beta2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2", features = ["iterator"] } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["iterator"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } diff --git a/contracts/cw20-bonding/Cargo.toml b/contracts/cw20-bonding/Cargo.toml index a58834e30..27a4381f0 100644 --- a/contracts/cw20-bonding/Cargo.toml +++ b/contracts/cw20-bonding/Cargo.toml @@ -25,7 +25,7 @@ cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw20 = { path = "../../packages/cw20", version = "0.6.0-beta2" } cw20-base = { path = "../../contracts/cw20-base", version = "0.6.0-beta2", features = ["library"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2" } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["staking"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["staking"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } @@ -34,4 +34,4 @@ integer-sqrt = { version = "0.1.5" } integer-cbrt = { version = "0.1" } [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } diff --git a/contracts/cw20-escrow/Cargo.toml b/contracts/cw20-escrow/Cargo.toml index 2fd7c39e2..c23001a4e 100644 --- a/contracts/cw20-escrow/Cargo.toml +++ b/contracts/cw20-escrow/Cargo.toml @@ -21,13 +21,13 @@ library = [] cw0 = { path = "../../packages/cw0", version = "0.6.0-beta2" } cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw20 = { path = "../../packages/cw20", version = "0.6.0-beta2" } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["iterator"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["iterator"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } cw-multi-test = { path = "../../packages/multi-test", version = "0.6.0-beta2" } cw20-base = { path = "../cw20-base", version = "0.6.0-beta2", features = ["library"] } diff --git a/contracts/cw20-staking/Cargo.toml b/contracts/cw20-staking/Cargo.toml index 3dd8bbdba..e100a5349 100644 --- a/contracts/cw20-staking/Cargo.toml +++ b/contracts/cw20-staking/Cargo.toml @@ -25,11 +25,11 @@ cw2 = { path = "../../packages/cw2", version = "0.6.0-beta2" } cw20 = { path = "../../packages/cw20", version = "0.6.0-beta2" } cw-controllers = { path = "../../packages/controllers", version = "0.6.0-beta2" } cw20-base = { path = "../../contracts/cw20-base", version = "0.6.0-beta2", features = ["library"] } -cosmwasm-std = { version = "=0.14.0-beta3", features = ["staking"] } +cosmwasm-std = { version = "0.14.0-beta4", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-beta2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "=0.14.0-beta3" } +cosmwasm-schema = { version = "0.14.0-beta4" } diff --git a/contracts/cw20-staking/src/contract.rs b/contracts/cw20-staking/src/contract.rs index 4eb8475c9..22743f669 100644 --- a/contracts/cw20-staking/src/contract.rs +++ b/contracts/cw20-staking/src/contract.rs @@ -1,8 +1,8 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, coin, to_binary, Addr, BankMsg, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, - QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, + attr, coin, to_binary, Addr, BankMsg, Binary, Decimal, Deps, DepsMut, DistributionMsg, Env, + MessageInfo, QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, }; use cw2::set_contract_version; @@ -35,7 +35,7 @@ pub fn instantiate( set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; // ensure the validator is registered - let vals = deps.querier.query_validators()?; + let vals = deps.querier.query_all_validators()?; if !vals.iter().any(|v| v.address == msg.validator) { return Err(ContractError::NotInValidatorSet { validator: msg.validator, @@ -356,9 +356,8 @@ pub fn reinvest(deps: DepsMut, env: Env, _info: MessageInfo) -> Result = WasmMsg::Instantiate { + admin: None, code_id, msg: init_msg, send: send_funds.to_vec(), @@ -373,6 +374,7 @@ where Ok((contract_addr, res.into())) } WasmMsg::Instantiate { + admin: _, code_id, msg, send, diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index f1c7314aa..b3ceb9d8c 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -13,6 +13,6 @@ documentation = "https://docs.cosmwasm.com" iterator = ["cosmwasm-std/iterator"] [dependencies] -cosmwasm-std = { version = "0.14.0-beta3" } +cosmwasm-std = { version = "0.14.0-beta4" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] }