diff --git a/Cargo.lock b/Cargo.lock index 584882c79..934705691 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,7 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - [[package]] name = "arrayvec" version = "0.5.2" @@ -275,8 +273,8 @@ dependencies = [ name = "cw1-subkeys" version = "0.6.2" dependencies = [ - "cosmwasm-schema 0.14.1", - "cosmwasm-std 0.14.1", + "cosmwasm-schema 0.15.0", + "cosmwasm-std 0.15.0", "cw-storage-plus", "cw0", "cw1", @@ -291,8 +289,8 @@ dependencies = [ name = "cw1-whitelist" version = "0.6.2" dependencies = [ - "cosmwasm-schema 0.14.1", - "cosmwasm-std 0.14.1", + "cosmwasm-schema 0.15.0", + "cosmwasm-std 0.15.0", "cw-storage-plus", "cw0", "cw1", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index e2ba2a39c..b05070eea 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -22,11 +22,11 @@ cw0 = { path = "../../packages/cw0", version = "0.6.2" } cw1 = { path = "../../packages/cw1", version = "0.6.2" } cw2 = { path = "../../packages/cw2", version = "0.6.2" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.6.2", features = ["library"] } -cosmwasm-std = { version = "0.14.0", features = ["iterator", "staking"] } +cosmwasm-std = { version = "0.15.0", features = ["iterator", "staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.20" } +thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "0.14.0" } +cosmwasm-schema = { version = "0.15.0" } diff --git a/contracts/cw1-subkeys/schema/all_allowances_response.json b/contracts/cw1-subkeys/schema/all_allowances_response.json index c87862f0a..df21ba91c 100644 --- a/contracts/cw1-subkeys/schema/all_allowances_response.json +++ b/contracts/cw1-subkeys/schema/all_allowances_response.json @@ -101,7 +101,7 @@ } }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", "allOf": [ { "$ref": "#/definitions/Uint64" diff --git a/contracts/cw1-subkeys/schema/allowance.json b/contracts/cw1-subkeys/schema/allowance.json index 0df591b9f..b77d82067 100644 --- a/contracts/cw1-subkeys/schema/allowance.json +++ b/contracts/cw1-subkeys/schema/allowance.json @@ -83,7 +83,7 @@ } }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", "allOf": [ { "$ref": "#/definitions/Uint64" diff --git a/contracts/cw1-subkeys/schema/execute_msg.json b/contracts/cw1-subkeys/schema/execute_msg.json index 08a7f404e..adbd5c9d7 100644 --- a/contracts/cw1-subkeys/schema/execute_msg.json +++ b/contracts/cw1-subkeys/schema/execute_msg.json @@ -18,7 +18,7 @@ "msgs": { "type": "array", "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" + "$ref": "#/definitions/SubMsg_for_Empty" } } } @@ -421,6 +421,16 @@ } } }, + "ReplyOn": { + "description": "Use this to define when the contract gets a response callback. If you only need it for errors or success you can select just those in order to save gas.", + "type": "string", + "enum": [ + "always", + "error", + "success", + "never" + ] + }, "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": [ @@ -505,8 +515,39 @@ } ] }, + "SubMsg_for_Empty": { + "description": "A submessage that will guarantee a `reply` call on success or error, depending on the `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message, but not revert any state changes in the calling contract. If this is required, it must be done manually in the `reply` entry point.", + "type": "object", + "required": [ + "id", + "msg", + "reply_on" + ], + "properties": { + "gas_limit": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "id": { + "description": "An arbitrary ID chosen by the contract. This is typically used to match `Reply`s in the `reply` entry point to the submessage.", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "msg": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + }, + "reply_on": { + "$ref": "#/definitions/ReplyOn" + } + } + }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", "allOf": [ { "$ref": "#/definitions/Uint64" @@ -535,13 +576,19 @@ "type": "object", "required": [ "contract_addr", - "msg", - "send" + "funds", + "msg" ], "properties": { "contract_addr": { "type": "string" }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -549,12 +596,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } @@ -572,9 +613,9 @@ "type": "object", "required": [ "code_id", + "funds", "label", - "msg", - "send" + "msg" ], "properties": { "admin": { @@ -588,6 +629,12 @@ "format": "uint64", "minimum": 0.0 }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -599,12 +646,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } diff --git a/contracts/cw1-subkeys/schema/query_msg.json b/contracts/cw1-subkeys/schema/query_msg.json index 816f286fd..4f1f560b9 100644 --- a/contracts/cw1-subkeys/schema/query_msg.json +++ b/contracts/cw1-subkeys/schema/query_msg.json @@ -437,13 +437,19 @@ "type": "object", "required": [ "contract_addr", - "msg", - "send" + "funds", + "msg" ], "properties": { "contract_addr": { "type": "string" }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -451,12 +457,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } @@ -474,9 +474,9 @@ "type": "object", "required": [ "code_id", + "funds", "label", - "msg", - "send" + "msg" ], "properties": { "admin": { @@ -490,6 +490,12 @@ "format": "uint64", "minimum": 0.0 }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -501,12 +507,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index 3efba4218..067b616c0 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -6,7 +6,7 @@ use std::ops::{AddAssign, Sub}; use cosmwasm_std::entry_point; use cosmwasm_std::{ attr, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, DistributionMsg, Empty, Env, - MessageInfo, Order, Response, StakingMsg, StdError, StdResult, + MessageInfo, Order, Response, StakingMsg, StdError, StdResult, SubMsg, }; use cw0::Expiration; use cw1::CanExecuteResponse; @@ -78,7 +78,7 @@ pub fn execute_execute( deps: DepsMut, _env: Env, info: MessageInfo, - msgs: Vec>, + msgs: Vec>, ) -> Result, ContractError> where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -94,7 +94,7 @@ where Ok(res) } else { for msg in &msgs { - match msg { + match &msg.msg { CosmosMsg::Staking(staking_msg) => { let perm = PERMISSIONS.may_load(deps.storage, &info.sender)?; let perm = perm.ok_or(ContractError::NotAllowed {})?; @@ -123,9 +123,9 @@ where } // Relay messages let res = Response { - submessages: vec![], messages: msgs, attributes: vec![attr("action", "execute"), attr("owner", info.sender)], + events: vec![], data: None, }; Ok(res) @@ -208,7 +208,6 @@ where })?; let res = Response { - submessages: vec![], messages: vec![], attributes: vec![ attr("action", "increase_allowance"), @@ -217,6 +216,7 @@ where attr("denomination", amount.denom), attr("amount", amount.amount), ], + events: vec![], data: None, }; Ok(res) @@ -258,7 +258,6 @@ where } let res = Response { - submessages: vec![], messages: vec![], attributes: vec![ attr("action", "decrease_allowance"), @@ -267,6 +266,7 @@ where attr("denomination", amount.denom), attr("amount", amount.amount), ], + events: vec![], data: None, }; Ok(res) @@ -294,7 +294,6 @@ where PERMISSIONS.save(deps.storage, &spender_addr, &perm)?; let res = Response { - submessages: vec![], messages: vec![], attributes: vec![ attr("action", "set_permissions"), @@ -302,6 +301,7 @@ where attr("spender", spender), attr("permissions", perm), ], + events: vec![], data: None, }; Ok(res) @@ -1164,11 +1164,10 @@ mod tests { ); // Create Send message - let msgs = vec![BankMsg::Send { + let msgs = vec![SubMsg::new(BankMsg::Send { to_address: spender2.to_string(), amount: coins(1000, "token1"), - } - .into()]; + })]; let execute_msg = ExecuteMsg::Execute { msgs: msgs.clone() }; @@ -1203,7 +1202,7 @@ mod tests { ); // For admins, even other message types are allowed - let other_msgs = vec![CosmosMsg::Custom(Empty {})]; + let other_msgs = vec![SubMsg::new(CosmosMsg::Custom(Empty {}))]; let execute_msg = ExecuteMsg::Execute { msgs: other_msgs.clone(), }; @@ -1266,26 +1265,22 @@ mod tests { // default is no permission execute(deps.as_mut(), mock_env(), info.clone(), setup_perm_msg2).unwrap(); - let msg_delegate = vec![StakingMsg::Delegate { + let msg_delegate = vec![SubMsg::new(StakingMsg::Delegate { validator: "validator1".into(), amount: coin1.clone(), - } - .into()]; - let msg_redelegate = vec![StakingMsg::Redelegate { + })]; + let msg_redelegate = vec![SubMsg::new(StakingMsg::Redelegate { src_validator: "validator1".into(), dst_validator: "validator2".into(), amount: coin1.clone(), - } - .into()]; - let msg_undelegate = vec![StakingMsg::Undelegate { + })]; + let msg_undelegate = vec![SubMsg::new(StakingMsg::Undelegate { validator: "validator1".into(), amount: coin1, - } - .into()]; - let msg_withdraw = vec![DistributionMsg::WithdrawDelegatorReward { + })]; + let msg_withdraw = vec![SubMsg::new(DistributionMsg::WithdrawDelegatorReward { validator: "validator1".into(), - } - .into()]; + })]; let msgs = vec![ msg_delegate.clone(), diff --git a/contracts/cw1-subkeys/src/msg.rs b/contracts/cw1-subkeys/src/msg.rs index 1e4bd55b0..2a9201694 100644 --- a/contracts/cw1-subkeys/src/msg.rs +++ b/contracts/cw1-subkeys/src/msg.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; -use cosmwasm_std::{Coin, CosmosMsg, Empty}; +use cosmwasm_std::{Coin, CosmosMsg, Empty, SubMsg}; use cw0::{Expiration, NativeBalance}; use crate::state::Permissions; @@ -16,7 +16,7 @@ where /// Execute requests the contract to re-dispatch all these messages with the /// contract's address as sender. Every implementation has it's own logic to /// determine in - Execute { msgs: Vec> }, + Execute { msgs: Vec> }, /// Freeze will make a mutable contract immutable, must be called by an admin Freeze {}, /// UpdateAdmins will change the admin set of the contract, must be called by an existing admin, diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 380790542..4556afcee 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.2" } cw1 = { path = "../../packages/cw1", version = "0.6.2" } cw2 = { path = "../../packages/cw2", version = "0.6.2" } -cosmwasm-std = { version = "0.14.0", features = ["iterator", "staking"] } +cosmwasm-std = { version = "0.15.0", features = ["iterator", "staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.2", features = ["iterator"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.20" } +thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "0.14.0" } +cosmwasm-schema = { version = "0.15.0" } diff --git a/contracts/cw1-whitelist/schema/execute_msg.json b/contracts/cw1-whitelist/schema/execute_msg.json index 29488cd14..216f21ebd 100644 --- a/contracts/cw1-whitelist/schema/execute_msg.json +++ b/contracts/cw1-whitelist/schema/execute_msg.json @@ -18,7 +18,7 @@ "msgs": { "type": "array", "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" + "$ref": "#/definitions/SubMsg_for_Empty" } } } @@ -258,6 +258,16 @@ "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" }, + "ReplyOn": { + "description": "Use this to define when the contract gets a response callback. If you only need it for errors or success you can select just those in order to save gas.", + "type": "string", + "enum": [ + "always", + "error", + "success", + "never" + ] + }, "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": [ @@ -342,6 +352,37 @@ } ] }, + "SubMsg_for_Empty": { + "description": "A submessage that will guarantee a `reply` call on success or error, depending on the `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message, but not revert any state changes in the calling contract. If this is required, it must be done manually in the `reply` entry point.", + "type": "object", + "required": [ + "id", + "msg", + "reply_on" + ], + "properties": { + "gas_limit": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "id": { + "description": "An arbitrary ID chosen by the contract. This is typically used to match `Reply`s in the `reply` entry point to the submessage.", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "msg": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + }, + "reply_on": { + "$ref": "#/definitions/ReplyOn" + } + } + }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" @@ -360,13 +401,19 @@ "type": "object", "required": [ "contract_addr", - "msg", - "send" + "funds", + "msg" ], "properties": { "contract_addr": { "type": "string" }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -374,12 +421,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } @@ -397,9 +438,9 @@ "type": "object", "required": [ "code_id", + "funds", "label", - "msg", - "send" + "msg" ], "properties": { "admin": { @@ -413,6 +454,12 @@ "format": "uint64", "minimum": 0.0 }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -424,12 +471,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } diff --git a/contracts/cw1-whitelist/schema/query_msg.json b/contracts/cw1-whitelist/schema/query_msg.json index 041caf514..af59d3053 100644 --- a/contracts/cw1-whitelist/schema/query_msg.json +++ b/contracts/cw1-whitelist/schema/query_msg.json @@ -337,13 +337,19 @@ "type": "object", "required": [ "contract_addr", - "msg", - "send" + "funds", + "msg" ], "properties": { "contract_addr": { "type": "string" }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -351,12 +357,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } @@ -374,9 +374,9 @@ "type": "object", "required": [ "code_id", + "funds", "label", - "msg", - "send" + "msg" ], "properties": { "admin": { @@ -390,6 +390,12 @@ "format": "uint64", "minimum": 0.0 }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -401,12 +407,6 @@ "$ref": "#/definitions/Binary" } ] - }, - "send": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } } } } diff --git a/contracts/cw1-whitelist/src/contract.rs b/contracts/cw1-whitelist/src/contract.rs index d34e6d6ea..e2f962fe6 100644 --- a/contracts/cw1-whitelist/src/contract.rs +++ b/contracts/cw1-whitelist/src/contract.rs @@ -5,7 +5,7 @@ use std::fmt; use cosmwasm_std::entry_point; use cosmwasm_std::{ attr, to_binary, Addr, Api, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, - Response, StdResult, + Response, StdResult, SubMsg, }; use cw1::CanExecuteResponse; @@ -59,7 +59,7 @@ pub fn execute_execute( deps: DepsMut, _env: Env, info: MessageInfo, - msgs: Vec>, + msgs: Vec>, ) -> Result, ContractError> where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -243,17 +243,15 @@ mod tests { let freeze: ExecuteMsg = ExecuteMsg::Freeze {}; let msgs = vec![ - BankMsg::Send { + SubMsg::new(BankMsg::Send { to_address: bob.to_string(), amount: coins(10000, "DAI"), - } - .into(), - WasmMsg::Execute { + }), + SubMsg::new(WasmMsg::Execute { contract_addr: "some contract".into(), msg: to_binary(&freeze).unwrap(), - send: vec![], - } - .into(), + funds: vec![], + }), ]; // make some nice message diff --git a/contracts/cw1-whitelist/src/msg.rs b/contracts/cw1-whitelist/src/msg.rs index 0eeed3d2c..d5c089291 100644 --- a/contracts/cw1-whitelist/src/msg.rs +++ b/contracts/cw1-whitelist/src/msg.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; -use cosmwasm_std::{CosmosMsg, Empty}; +use cosmwasm_std::{CosmosMsg, Empty, SubMsg}; #[derive(Serialize, Deserialize, JsonSchema)] pub struct InstantiateMsg { @@ -19,7 +19,7 @@ where /// Execute requests the contract to re-dispatch all these messages with the /// contract's address as sender. Every implementation has it's own logic to /// determine in - Execute { msgs: Vec> }, + Execute { msgs: Vec> }, /// Freeze will make a mutable contract immutable, must be called by an admin Freeze {}, /// UpdateAdmins will change the admin set of the contract, must be called by an existing admin,