Skip to content

Commit dc5df80

Browse files
committed
Update contracts to cosmwasm 0.16.0-rc5
1 parent 87455e4 commit dc5df80

File tree

50 files changed

+520
-812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+520
-812
lines changed

contracts/cw1-subkeys/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ cw0 = { path = "../../packages/cw0", version = "0.7.0" }
2323
cw1 = { path = "../../packages/cw1", version = "0.7.0" }
2424
cw2 = { path = "../../packages/cw2", version = "0.7.0" }
2525
cw1-whitelist = { path = "../cw1-whitelist", version = "0.7.0", features = ["library"] }
26-
cosmwasm-std = { version = "0.16.0-rc4", features = ["iterator", "staking"] }
26+
cosmwasm-std = { version = "0.16.0-rc5", features = ["iterator", "staking"] }
2727
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.7.0" }
2828
schemars = "0.8.1"
2929
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
3030
thiserror = { version = "1.0.23" }
3131

3232
[dev-dependencies]
33-
cosmwasm-schema = { version = "0.16.0-rc4" }
33+
cosmwasm-schema = { version = "0.16.0-rc5" }
3434
cw1-whitelist = { path = "../cw1-whitelist", version = "0.7.0", features = ["library", "test-utils"] }

contracts/cw1-subkeys/src/contract.rs

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::ops::{AddAssign, Sub};
66
use cosmwasm_std::entry_point;
77
use cosmwasm_std::{
88
attr, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, DistributionMsg, Empty, Env,
9-
MessageInfo, Order, Response, StakingMsg, StdError, StdResult, SubMsg,
9+
MessageInfo, Order, Response, StakingMsg, StdError, StdResult,
1010
};
1111
use cw0::Expiration;
1212
use cw1::CanExecuteResponse;
@@ -83,14 +83,12 @@ pub fn execute_execute<T>(
8383
where
8484
T: Clone + fmt::Debug + PartialEq + JsonSchema,
8585
{
86-
// Wrap `msgs` in SubMsg.
87-
let msgs: Vec<_> = msgs.into_iter().map(SubMsg::new).collect();
8886
let cfg = ADMIN_LIST.load(deps.storage)?;
8987

9088
// Not an admin - need to check for permissions
9189
if !cfg.is_admin(info.sender.as_ref()) {
9290
for msg in &msgs {
93-
match &msg.msg {
91+
match msg {
9492
CosmosMsg::Staking(staking_msg) => {
9593
let perm = PERMISSIONS.may_load(deps.storage, &info.sender)?;
9694
let perm = perm.ok_or(ContractError::NotAllowed {})?;
@@ -119,11 +117,9 @@ where
119117
}
120118
}
121119
// Relay messages
122-
let res = Response {
123-
messages: msgs,
124-
attributes: vec![attr("action", "execute"), attr("owner", info.sender)],
125-
..Response::default()
126-
};
120+
let res = Response::new()
121+
.add_messages(msgs)
122+
.add_attributes(vec![attr("action", "execute"), attr("owner", info.sender)]);
127123
Ok(res)
128124
}
129125

@@ -202,16 +198,13 @@ where
202198
Ok(allowance)
203199
})?;
204200

205-
let res = Response {
206-
attributes: vec![
207-
attr("action", "increase_allowance"),
208-
attr("owner", info.sender),
209-
attr("spender", spender),
210-
attr("denomination", amount.denom),
211-
attr("amount", amount.amount),
212-
],
213-
..Response::default()
214-
};
201+
let res = Response::new().add_attributes(vec![
202+
attr("action", "increase_allowance"),
203+
attr("owner", info.sender),
204+
attr("spender", spender),
205+
attr("denomination", amount.denom),
206+
attr("amount", amount.amount),
207+
]);
215208
Ok(res)
216209
}
217210

@@ -250,16 +243,13 @@ where
250243
ALLOWANCES.remove(deps.storage, &spender_addr);
251244
}
252245

253-
let res = Response {
254-
attributes: vec![
255-
attr("action", "decrease_allowance"),
256-
attr("owner", info.sender),
257-
attr("spender", spender),
258-
attr("denomination", amount.denom),
259-
attr("amount", amount.amount),
260-
],
261-
..Response::default()
262-
};
246+
let res = Response::new().add_attributes(vec![
247+
attr("action", "decrease_allowance"),
248+
attr("owner", info.sender),
249+
attr("spender", spender),
250+
attr("denomination", amount.denom),
251+
attr("amount", amount.amount),
252+
]);
263253
Ok(res)
264254
}
265255

@@ -284,15 +274,12 @@ where
284274
}
285275
PERMISSIONS.save(deps.storage, &spender_addr, &perm)?;
286276

287-
let res = Response {
288-
attributes: vec![
289-
attr("action", "set_permissions"),
290-
attr("owner", info.sender),
291-
attr("spender", spender),
292-
attr("permissions", perm.to_string()),
293-
],
294-
..Response::default()
295-
};
277+
let res = Response::new().add_attributes(vec![
278+
attr("action", "set_permissions"),
279+
attr("owner", info.sender),
280+
attr("spender", spender),
281+
attr("permissions", perm.to_string()),
282+
]);
296283
Ok(res)
297284
}
298285

@@ -437,7 +424,7 @@ mod tests {
437424
use cosmwasm_std::testing::{
438425
mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
439426
};
440-
use cosmwasm_std::{coin, coins, OwnedDeps, StakingMsg, Timestamp};
427+
use cosmwasm_std::{coin, coins, OwnedDeps, StakingMsg, SubMsg, Timestamp};
441428

442429
use cw0::NativeBalance;
443430
use cw1_whitelist::msg::AdminListResponse;

contracts/cw1-whitelist/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ test-utils = []
2222
cw0 = { path = "../../packages/cw0", version = "0.7.0" }
2323
cw1 = { path = "../../packages/cw1", version = "0.7.0" }
2424
cw2 = { path = "../../packages/cw2", version = "0.7.0" }
25-
cosmwasm-std = { version = "0.16.0-rc4", features = ["iterator", "staking"] }
25+
cosmwasm-std = { version = "0.16.0-rc5", features = ["iterator", "staking"] }
2626
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.7.0" }
2727
schemars = "0.8.1"
2828
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
2929
thiserror = { version = "1.0.23" }
3030

3131
[dev-dependencies]
32-
cosmwasm-schema = { version = "0.16.0-rc4" }
32+
cosmwasm-schema = { version = "0.16.0-rc5" }

contracts/cw1-whitelist/src/contract.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::fmt;
44
#[cfg(not(feature = "library"))]
55
use cosmwasm_std::entry_point;
66
use cosmwasm_std::{
7-
attr, to_binary, Addr, Api, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo,
8-
Response, StdResult, SubMsg,
7+
to_binary, Addr, Api, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response,
8+
StdResult,
99
};
1010

1111
use cw1::CanExecuteResponse;
@@ -64,16 +64,12 @@ pub fn execute_execute<T>(
6464
where
6565
T: Clone + fmt::Debug + PartialEq + JsonSchema,
6666
{
67-
// Wrap `msgs` in SubMsg.
68-
let msgs = msgs.into_iter().map(SubMsg::new).collect();
6967
if !can_execute(deps.as_ref(), info.sender.as_ref())? {
7068
Err(ContractError::Unauthorized {})
7169
} else {
72-
let res = Response {
73-
messages: msgs,
74-
attributes: vec![attr("action", "execute")],
75-
..Response::default()
76-
};
70+
let res = Response::new()
71+
.add_messages(msgs)
72+
.add_attribute("action", "execute");
7773
Ok(res)
7874
}
7975
}
@@ -90,10 +86,7 @@ pub fn execute_freeze(
9086
cfg.mutable = false;
9187
ADMIN_LIST.save(deps.storage, &cfg)?;
9288

93-
let res = Response {
94-
attributes: vec![attr("action", "freeze")],
95-
..Response::default()
96-
};
89+
let res = Response::new().add_attribute("action", "freeze");
9790
Ok(res)
9891
}
9992
}
@@ -111,10 +104,7 @@ pub fn execute_update_admins(
111104
cfg.admins = map_validate(deps.api, &admins)?;
112105
ADMIN_LIST.save(deps.storage, &cfg)?;
113106

114-
let res = Response {
115-
attributes: vec![attr("action", "update_admins")],
116-
..Response::default()
117-
};
107+
let res = Response::new().add_attribute("action", "update_admins");
118108
Ok(res)
119109
}
120110
}
@@ -155,7 +145,7 @@ pub fn query_can_execute(
155145
mod tests {
156146
use super::*;
157147
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
158-
use cosmwasm_std::{coin, coins, BankMsg, StakingMsg, WasmMsg};
148+
use cosmwasm_std::{coin, coins, BankMsg, StakingMsg, SubMsg, WasmMsg};
159149

160150
#[test]
161151
fn instantiate_and_modify_config() {
@@ -273,7 +263,7 @@ mod tests {
273263
res.messages,
274264
msgs.into_iter().map(SubMsg::new).collect::<Vec<_>>()
275265
);
276-
assert_eq!(res.attributes, vec![attr("action", "execute")]);
266+
assert_eq!(res.attributes, [("action", "execute")]);
277267
}
278268

279269
#[test]

contracts/cw1155-base/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ cw0 = { path = "../../packages/cw0", version = "0.7.0" }
2222
cw2 = { path = "../../packages/cw2", version = "0.7.0" }
2323
cw1155 = { path = "../../packages/cw1155", version = "0.7.0" }
2424
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.7.0" }
25-
cosmwasm-std = { version = "0.16.0-rc4" }
25+
cosmwasm-std = { version = "0.16.0-rc5" }
2626
schemars = "0.8.1"
2727
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
2828
thiserror = { version = "1.0.20" }
2929

3030
[dev-dependencies]
31-
cosmwasm-schema = { version = "0.16.0-rc4" }
31+
cosmwasm-schema = { version = "0.16.0-rc5" }

0 commit comments

Comments
 (0)