1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::ops::Deref;
use cosmwasm_std::{to_binary, CosmosMsg, HumanAddr, StdResult, WasmMsg};
use cw4::{Cw4Contract, Member};
use crate::msg::HandleMsg;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Cw4GroupContract(pub Cw4Contract);
impl Deref for Cw4GroupContract {
type Target = Cw4Contract;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl Cw4GroupContract {
pub fn new(addr: HumanAddr) -> Self {
Cw4GroupContract(Cw4Contract(addr))
}
fn encode_msg(&self, msg: HandleMsg) -> StdResult<CosmosMsg> {
Ok(WasmMsg::Execute {
contract_addr: self.addr(),
msg: to_binary(&msg)?,
send: vec![],
}
.into())
}
pub fn update_members(&self, remove: Vec<HumanAddr>, add: Vec<Member>) -> StdResult<CosmosMsg> {
let msg = HandleMsg::UpdateMembers { remove, add };
self.encode_msg(msg)
}
}