Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade cw3 contracts and cw4-group #315

Merged
merged 3 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update cw4-group to cosmwasm 0.15
  • Loading branch information
uint committed Jun 29, 2021
commit 761921cbb6a3a75f5d000d9d5953a431d26ffb6d
6 changes: 3 additions & 3 deletions contracts/cw4-group/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ cw2 = { path = "../../packages/cw2", version = "0.6.2" }
cw4 = { path = "../../packages/cw4", version = "0.6.2" }
cw-controllers = { path = "../../packages/controllers", version = "0.6.2" }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.2", features = ["iterator"] }
cosmwasm-std = { version = "0.14.0" }
cosmwasm-std = { version = "0.15.0" }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.21" }
thiserror = { version = "1.0.23" }

[dev-dependencies]
cosmwasm-schema = { version = "0.14.0" }
cosmwasm-schema = { version = "0.15.0" }
11 changes: 7 additions & 4 deletions contracts/cw4-group/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Order, Response, StdResult,
SubMsg,
};
use cw0::maybe_addr;
use cw2::set_contract_version;
Expand Down Expand Up @@ -101,11 +102,13 @@ pub fn execute_update_members(
// make the local update
let diff = update_members(deps.branch(), env.block.height, info.sender, add, remove)?;
// call all registered hooks
let messages = HOOKS.prepare_hooks(deps.storage, |h| diff.clone().into_cosmos_msg(h))?;
let messages = HOOKS.prepare_hooks(deps.storage, |h| {
diff.clone().into_cosmos_msg(h).map(SubMsg::new)
})?;
Ok(Response {
submessages: vec![],
messages,
attributes,
events: vec![],
data: None,
})
}
Expand Down Expand Up @@ -529,8 +532,8 @@ mod tests {
MemberDiff::new(USER2, Some(6), None),
];
let hook_msg = MemberChangedHookMsg { diffs };
let msg1 = hook_msg.clone().into_cosmos_msg(contract1).unwrap();
let msg2 = hook_msg.into_cosmos_msg(contract2).unwrap();
let msg1 = SubMsg::new(hook_msg.clone().into_cosmos_msg(contract1).unwrap());
let msg2 = SubMsg::new(hook_msg.into_cosmos_msg(contract2).unwrap());
assert_eq!(res.messages, vec![msg1, msg2]);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/cw4-group/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Cw4GroupContract {
Ok(WasmMsg::Execute {
contract_addr: self.addr().into(),
msg: to_binary(&msg)?,
send: vec![],
funds: vec![],
}
.into())
}
Expand Down
6 changes: 3 additions & 3 deletions packages/controllers/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;

use cosmwasm_std::{
attr, Addr, CosmosMsg, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, Storage,
attr, Addr, SubMsg, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, Storage,
};
use cw_storage_plus::Item;

Expand Down Expand Up @@ -59,11 +59,11 @@ impl<'a> Hooks<'a> {
Ok(self.0.save(storage, &hooks)?)
}

pub fn prepare_hooks<F: Fn(Addr) -> StdResult<CosmosMsg>>(
pub fn prepare_hooks<F: Fn(Addr) -> StdResult<SubMsg>>(
&self,
storage: &dyn Storage,
prep: F,
) -> StdResult<Vec<CosmosMsg>> {
) -> StdResult<Vec<SubMsg>> {
self.0
.may_load(storage)?
.unwrap_or_default()
Expand Down