Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
af22dfa
update cosmwasm-std, change math api
yihuang Mar 26, 2021
c9e8d34
rename KV -> Pair
yihuang Apr 2, 2021
420dfec
address change: cw0,cw1,cw2,cw3,cw4
yihuang Apr 8, 2021
470c2ba
address change: cw20,cw721,cw1155
yihuang Apr 8, 2021
e654cef
address change: cw-controllers
yihuang Apr 8, 2021
a3dde73
address change: multi-test
yihuang Apr 8, 2021
01d4e95
address change: cw20-base,cw721-base,cw1155-base
yihuang Apr 8, 2021
be013e0
Adjust Addr/String in cw1,3,4
ethanfrey Apr 8, 2021
57d574d
Add cw1155 package+contract to CI
ethanfrey Apr 8, 2021
18df393
Add cw1155 to deploy scripts
ethanfrey Apr 8, 2021
0c08564
Update cw1-whitelist
ethanfrey Apr 8, 2021
2cf5432
cw1-subkey compiles, only Addr, no CanonicalAddr
ethanfrey Apr 8, 2021
5e8e8ba
Fix all tests for cw1-subkeys
ethanfrey Apr 8, 2021
5de3e18
Update schemas
ethanfrey Apr 8, 2021
401a2a7
Add AddrRef for better lifetimes
ethanfrey Apr 8, 2021
55f97f5
Use AddrRef in cw1-subkeys
ethanfrey Apr 8, 2021
49e2be0
Update package cw20
ethanfrey Apr 8, 2021
e3bfa99
Update cw721 spec
ethanfrey Apr 8, 2021
1335006
Update cw1155
ethanfrey Apr 8, 2021
7140497
Remove Canonical helpers
ethanfrey Apr 8, 2021
a82070c
Update controllers to store Addr, not CanonicalAddr
ethanfrey Apr 8, 2021
c4ea90c
cw3-fixed-multisig fixed, temporarily remove integration tests
ethanfrey Apr 8, 2021
c8a8468
Add maybe_addr() helper
maurolacy Apr 8, 2021
d213c97
cargo fmt
maurolacy Apr 8, 2021
bee6474
cw4-group compiles
maurolacy Apr 8, 2021
a332725
Migrate cw4-group unit tests
maurolacy Apr 8, 2021
924240e
cw20-base compiles, tests broken
ethanfrey Apr 8, 2021
b6f055e
Update cw4-group schema
ethanfrey Apr 8, 2021
385600c
cw4-stake compiles
maurolacy Apr 8, 2021
fbb6c17
Update cw4-stake schemas
maurolacy Apr 8, 2021
0ed8772
Remove commented code
maurolacy Apr 9, 2021
e23f7cf
Update cw4-group unit tests
maurolacy Apr 9, 2021
92eca49
Update/fix fw20-base tests
maurolacy Apr 9, 2021
40f2c7e
Use Cw20CoinVerified for Balance
maurolacy Apr 10, 2021
656964f
Use Addr / Cw20CoinVerified for state
maurolacy Apr 10, 2021
e0a3a94
Use String / Cw20Coin for msg
maurolacy Apr 10, 2021
38c40ea
cw20-escrow compiles
maurolacy Apr 10, 2021
a3a086a
Update cw20-escrow unit tests
maurolacy Apr 10, 2021
5ef5bba
Update cw20-escrow integration test
maurolacy Apr 10, 2021
319de31
Use Addr for state
maurolacy Apr 10, 2021
d04994a
Use String 7 Cw20Coin for msg
maurolacy Apr 10, 2021
ba8f272
Update cw20-atomic-swap
maurolacy Apr 10, 2021
42f76a2
Update cw20-escrow schemas
maurolacy Apr 10, 2021
f27698e
Update cw20-atomic-swap schemas
maurolacy Apr 10, 2021
2710be7
Use String for msg
maurolacy Apr 10, 2021
a8c3b4e
Update cw20-bonding
maurolacy Apr 10, 2021
f8edebd
Update cw20-bonding schemas
maurolacy Apr 10, 2021
83d0f6f
Update cw20-ics20
maurolacy Apr 10, 2021
9b927c5
Update cw20-ics20 schema
maurolacy Apr 10, 2021
f8b07cd
Add address validation
maurolacy Apr 10, 2021
11f1b34
Remove closure
maurolacy Apr 10, 2021
72f1650
cw20-staking compiles
maurolacy Apr 10, 2021
37ffc87
Update cw20-staking unit tests
maurolacy Apr 10, 2021
c6d50f5
Update cw20-staking schema
maurolacy Apr 10, 2021
e4f0c0c
Use Addr, member_key str key
maurolacy Apr 10, 2021
1ac1818
Use str key for ballots
maurolacy Apr 10, 2021
6cf17a7
Use String for msg and error
maurolacy Apr 10, 2021
0a1de48
cw3-flex-multisig compiles
maurolacy Apr 10, 2021
9d93a30
group_addr validation using map_err
maurolacy Apr 10, 2021
b88d6b0
Update cw3-flex-multisig schema
maurolacy Apr 10, 2021
6e20287
Remove redundant clone
maurolacy Apr 10, 2021
878950d
Update cw3-flex-multisig unit tests
maurolacy Apr 10, 2021
f90599b
Use Addr, &str key for state
maurolacy Apr 10, 2021
da499bb
Use String for msg
maurolacy Apr 10, 2021
010f5ab
cw721-base compiles
maurolacy Apr 10, 2021
90c1858
Add Approval is_expired() helper
maurolacy Apr 10, 2021
5b8f926
Update cw721-base schema
maurolacy Apr 11, 2021
d45e56f
Update cw721-base unit tests
maurolacy Apr 11, 2021
1f9818e
Use Vec::from
maurolacy Apr 11, 2021
87b4013
Add start_after addr validation to all paginated queries
maurolacy Apr 11, 2021
f427977
Remove redundant clones
maurolacy Apr 11, 2021
08c6388
Use Addr, &str keys for state
maurolacy Apr 11, 2021
cddeafd
Use String form msg
maurolacy Apr 11, 2021
e618606
cw1155-base compiles
maurolacy Apr 11, 2021
c2a2fa3
Add cw1155-base cargo config
maurolacy Apr 11, 2021
4e105a4
Update cw1155-base unit tests
maurolacy Apr 11, 2021
07ad611
Remove redundant calls
maurolacy Apr 11, 2021
779b4fe
cargo fmt
maurolacy Apr 11, 2021
6cb71b9
cargo clippy
maurolacy Apr 11, 2021
d8894e3
Update version of wasm checker
ethanfrey Apr 12, 2021
e8f3eb5
Add schema to cw1155-base
ethanfrey Apr 12, 2021
81f571f
Merge branch 'master' into update-cosmwas-std
ethanfrey Apr 12, 2021
f7c0e43
Implement PrimaryKey for &Addr
webmaster128 Apr 11, 2021
f35a0ab
Use &Addr in cw3-fixed-multisig
webmaster128 Apr 12, 2021
e529858
Use &Addr not AddrRef in cw1-subkeys
ethanfrey Apr 13, 2021
91c59cc
Remove AddrRef from storage-plus
ethanfrey Apr 13, 2021
f6c8ae0
Use &Addr not AddrRef in cw20-base
ethanfrey Apr 13, 2021
d68af14
Fix cw4-stake and cw4-group
ethanfrey Apr 13, 2021
c0ce30e
Update cw20-staking
ethanfrey Apr 13, 2021
7583b2e
Update cw3-flex-multisig
ethanfrey Apr 13, 2021
289d26a
Cleanup
ethanfrey Apr 13, 2021
120857d
Use Addr in cw1155 state keys
ethanfrey Apr 13, 2021
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
20 changes: 7 additions & 13 deletions packages/cw0/src/pagination.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use cosmwasm_std::{Api, CanonicalAddr, HumanAddr, StdResult};
use cosmwasm_std::{Addr, Api, CanonicalAddr, StdResult};

// this is used for pagination. Maybe we move it into the std lib one day?
pub fn maybe_canonical(
api: &dyn Api,
human: Option<HumanAddr>,
) -> StdResult<Option<CanonicalAddr>> {
human.map(|x| api.canonical_address(&x)).transpose()
pub fn maybe_canonical(api: &dyn Api, human: Option<Addr>) -> StdResult<Option<CanonicalAddr>> {
human.map(|x| api.addr_canonicalize(x.as_ref())).transpose()
}

// this will set the first key after the provided key, by appending a 0 byte
pub fn calc_range_start_human(
api: &dyn Api,
start_after: Option<HumanAddr>,
start_after: Option<Addr>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is used anywhere anymore. It can be removed.

) -> StdResult<Option<Vec<u8>>> {
match start_after {
Some(human) => {
let mut v: Vec<u8> = api.canonical_address(&human)?.0.into();
let mut v: Vec<u8> = api.addr_canonicalize(human.as_ref())?.0.into();
v.push(0);
Ok(Some(v))
}
Expand All @@ -24,13 +21,10 @@ pub fn calc_range_start_human(
}

// set the end to the canonicalized format (used for Order::Descending)
pub fn calc_range_end_human(
api: &dyn Api,
end_before: Option<HumanAddr>,
) -> StdResult<Option<Vec<u8>>> {
pub fn calc_range_end_human(api: &dyn Api, end_before: Option<Addr>) -> StdResult<Option<Vec<u8>>> {
match end_before {
Some(human) => {
let v: Vec<u8> = api.canonical_address(&human)?.0.into();
let v: Vec<u8> = api.addr_canonicalize(human.as_ref())?.into();
Ok(Some(v))
}
None => Ok(None),
Expand Down
14 changes: 7 additions & 7 deletions packages/cw1/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{to_binary, Api, CanonicalAddr, CosmosMsg, HumanAddr, StdResult, WasmMsg};
use cosmwasm_std::{to_binary, Addr, Api, CanonicalAddr, CosmosMsg, StdResult, WasmMsg};

use crate::msg::Cw1ExecuteMsg;

/// Cw1Contract is a wrapper around HumanAddr that provides a lot of helpers
/// Cw1Contract is a wrapper around Addr that provides a lot of helpers
/// for working with this.
///
/// If you wish to persist this, convert to Cw1CanonicalContract via .canonical()
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Cw1Contract(pub HumanAddr);
pub struct Cw1Contract(pub Addr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


impl Cw1Contract {
pub fn addr(&self) -> HumanAddr {
pub fn addr(&self) -> Addr {
self.0.clone()
}

/// Convert this address to a form fit for storage
pub fn canonical<A: Api>(&self, api: &A) -> StdResult<Cw1CanonicalContract> {
let canon = api.canonical_address(&self.0)?;
let canon = api.addr_canonicalize(self.0.as_ref())?;
Ok(Cw1CanonicalContract(canon))
}

pub fn execute<T: Into<Vec<CosmosMsg>>>(&self, msgs: T) -> StdResult<CosmosMsg> {
let msg = Cw1ExecuteMsg::Execute { msgs: msgs.into() };
Ok(WasmMsg::Execute {
contract_addr: self.addr(),
contract_addr: self.addr().into(),
msg: to_binary(&msg)?,
send: vec![],
}
Expand All @@ -42,7 +42,7 @@ pub struct Cw1CanonicalContract(pub CanonicalAddr);
impl Cw1CanonicalContract {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this entirely, as I we are moving away from CanonicalContracts.

Fine if you leave this for now to make the PR smaller, and I can take a second PR for that one.

/// Convert this address to a form fit for usage in messages and queries
pub fn human<A: Api>(&self, api: &A) -> StdResult<Cw1Contract> {
let human = api.human_address(&self.0)?;
let human = api.addr_humanize(&self.0)?;
Ok(Cw1Contract(human))
}
}
4 changes: 2 additions & 2 deletions packages/cw1/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt;

use cosmwasm_std::{CosmosMsg, Empty, HumanAddr};
use cosmwasm_std::{CosmosMsg, Empty, Addr};

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
Expand All @@ -14,7 +14,7 @@ where
/// If CanExecute returns true then a call to `Execute` with the same message,
/// from the given sender, before any further state changes, should also succeed.
CanExecute {
sender: HumanAddr,
sender: Addr,
msg: CosmosMsg<T>,
},
}
Expand Down
6 changes: 2 additions & 4 deletions packages/cw2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{
HumanAddr, Querier, QuerierWrapper, QueryRequest, StdResult, Storage, WasmQuery,
};
use cosmwasm_std::{Querier, QuerierWrapper, QueryRequest, StdResult, Storage, WasmQuery};
use cw_storage_plus::Item;

pub const CONTRACT: Item<ContractVersion> = Item::new("contract_info");
Expand Down Expand Up @@ -44,7 +42,7 @@ pub fn set_contract_version<T: Into<String>, U: Into<String>>(
/// if the other contract exists and claims to be a cw20-base contract for example.
/// (Note: you usually want to require *interfaces* not *implementations* of the
/// contracts you compose with, so be careful of overuse)
pub fn query_contract_info<Q: Querier, T: Into<HumanAddr>>(
pub fn query_contract_info<Q: Querier, T: Into<String>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Into<String> 👍

querier: &Q,
contract_addr: T,
) -> StdResult<ContractVersion> {
Expand Down
10 changes: 5 additions & 5 deletions packages/cw3/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{to_binary, CosmosMsg, HumanAddr, StdResult, WasmMsg};
use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg};

use crate::msg::{Cw3ExecuteMsg, Vote};
use cw0::Expiration;

/// Cw3Contract is a wrapper around HumanAddr that provides a lot of helpers
/// Cw3Contract is a wrapper around Addr that provides a lot of helpers
/// for working with this.
///
/// If you wish to persist this, convert to Cw3CanonicalContract via .canonical()
///
/// FIXME: Cw3Contract currently only supports CosmosMsg<Empty>. When we actually
/// use this in some consuming code, we should make it generic over CosmosMsg<T>.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Cw3Contract(pub HumanAddr);
pub struct Cw3Contract(pub Addr);

impl Cw3Contract {
pub fn addr(&self) -> HumanAddr {
pub fn addr(&self) -> Addr {
self.0.clone()
}

pub fn encode_msg(&self, msg: Cw3ExecuteMsg) -> StdResult<CosmosMsg> {
Ok(WasmMsg::Execute {
contract_addr: self.addr(),
contract_addr: self.addr().into(),
msg: to_binary(&msg)?,
send: vec![],
}
Expand Down
16 changes: 8 additions & 8 deletions packages/cw3/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt;

use cosmwasm_std::{CosmosMsg, Decimal, Empty, HumanAddr};
use cosmwasm_std::{CosmosMsg, Decimal, Empty, Addr};
use cw0::Expiration;

use crate::msg::Vote;
Expand Down Expand Up @@ -31,20 +31,20 @@ pub enum Cw3QueryMsg {
/// Query the vote made by the given voter on `proposal_id`. This should
/// return an error if there is no such proposal. It will return a None value
/// if the proposal exists but the voter did not vote. Returns VoteResponse
Vote { proposal_id: u64, voter: HumanAddr },
Vote { proposal_id: u64, voter: Addr },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All *Msg types should use String (this is unverified input from users)
All state should use Addr.

By doing so, the compiler should enforce we validate input before saving it

/// Iterate (with pagination) over all votes for this proposal. The ordering is arbitrary,
/// unlikely to be sorted by HumanAddr. But ordering is consistent and pagination from the end
/// unlikely to be sorted by Addr. But ordering is consistent and pagination from the end
/// of each page will cover all votes for the proposal. Returns VoteListResponse
ListVotes {
proposal_id: u64,
start_after: Option<HumanAddr>,
start_after: Option<Addr>,
limit: Option<u32>,
},
/// Voter extension: Returns VoterResponse
Voter { address: HumanAddr },
Voter { address: Addr },
/// ListVoters extension: Returns VoterListResponse
ListVoters {
start_after: Option<HumanAddr>,
start_after: Option<Addr>,
limit: Option<u32>,
},
}
Expand Down Expand Up @@ -168,7 +168,7 @@ pub struct VoteListResponse {
/// the address of the voter who submitted it
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct VoteInfo {
pub voter: HumanAddr,
pub voter: Addr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again String here

pub vote: Vote,
pub weight: u64,
}
Expand All @@ -190,6 +190,6 @@ pub struct VoterListResponse {

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct VoterDetail {
pub addr: HumanAddr,
pub addr: Addr,
pub weight: u64,
}
35 changes: 16 additions & 19 deletions packages/cw4/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{
from_slice, to_binary, to_vec, Binary, CanonicalAddr, ContractResult, CosmosMsg, Empty,
HumanAddr, QuerierWrapper, QueryRequest, StdError, StdResult, SystemResult, WasmMsg, WasmQuery,
from_slice, to_binary, to_vec, Addr, Binary, CanonicalAddr, ContractResult, CosmosMsg, Empty,
QuerierWrapper, QueryRequest, StdError, StdResult, SystemResult, WasmMsg, WasmQuery,
};

use crate::msg::Cw4ExecuteMsg;
Expand All @@ -12,67 +12,64 @@ use crate::{
member_key, AdminResponse, Cw4QueryMsg, Member, MemberListResponse, MemberResponse, TOTAL_KEY,
};

/// Cw4Contract is a wrapper around HumanAddr that provides a lot of helpers
/// Cw4Contract is a wrapper around Addr that provides a lot of helpers
/// for working with cw4 contracts
///
/// If you wish to persist this, convert to Cw4CanonicalContract via .canonical()
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Cw4Contract(pub HumanAddr);
pub struct Cw4Contract(pub Addr);

impl Cw4Contract {
pub fn new(addr: HumanAddr) -> Self {
pub fn new(addr: Addr) -> Self {
Cw4Contract(addr)
}

pub fn addr(&self) -> HumanAddr {
pub fn addr(&self) -> Addr {
self.0.clone()
}

fn encode_msg(&self, msg: Cw4ExecuteMsg) -> StdResult<CosmosMsg> {
Ok(WasmMsg::Execute {
contract_addr: self.addr(),
contract_addr: self.addr().into(),
msg: to_binary(&msg)?,
send: vec![],
}
.into())
}

pub fn add_hook(&self, addr: HumanAddr) -> StdResult<CosmosMsg> {
pub fn add_hook(&self, addr: Addr) -> StdResult<CosmosMsg> {
let msg = Cw4ExecuteMsg::AddHook { addr };
self.encode_msg(msg)
}

pub fn remove_hook(&self, addr: HumanAddr) -> StdResult<CosmosMsg> {
pub fn remove_hook(&self, addr: Addr) -> StdResult<CosmosMsg> {
let msg = Cw4ExecuteMsg::AddHook { addr };
self.encode_msg(msg)
}

pub fn update_admin<T: Into<HumanAddr>>(
&self,
admin: Option<HumanAddr>,
) -> StdResult<CosmosMsg> {
pub fn update_admin<T: Into<Addr>>(&self, admin: Option<Addr>) -> StdResult<CosmosMsg> {
let msg = Cw4ExecuteMsg::UpdateAdmin { admin };
self.encode_msg(msg)
}

fn encode_smart_query(&self, msg: Cw4QueryMsg) -> StdResult<QueryRequest<Empty>> {
Ok(WasmQuery::Smart {
contract_addr: self.addr(),
contract_addr: self.addr().into(),
msg: to_binary(&msg)?,
}
.into())
}

fn encode_raw_query<T: Into<Binary>>(&self, key: T) -> QueryRequest<Empty> {
WasmQuery::Raw {
contract_addr: self.addr(),
contract_addr: self.addr().into(),
key: key.into(),
}
.into()
}

/// Show the hooks
pub fn hooks(&self, querier: &QuerierWrapper) -> StdResult<Vec<HumanAddr>> {
pub fn hooks(&self, querier: &QuerierWrapper) -> StdResult<Vec<Addr>> {
let query = self.encode_smart_query(Cw4QueryMsg::Hooks {})?;
let res: HooksResponse = querier.query(&query)?;
Ok(res.hooks)
Expand Down Expand Up @@ -120,7 +117,7 @@ impl Cw4Contract {
pub fn member_at_height(
&self,
querier: &QuerierWrapper,
member: HumanAddr,
member: Addr,
height: u64,
) -> StdResult<Option<u64>> {
let query = self.encode_smart_query(Cw4QueryMsg::Member {
Expand All @@ -134,7 +131,7 @@ impl Cw4Contract {
pub fn list_members(
&self,
querier: &QuerierWrapper,
start_after: Option<HumanAddr>,
start_after: Option<Addr>,
limit: Option<u32>,
) -> StdResult<Vec<Member>> {
let query = self.encode_smart_query(Cw4QueryMsg::ListMembers { start_after, limit })?;
Expand All @@ -143,7 +140,7 @@ impl Cw4Contract {
}

/// Read the admin
pub fn admin(&self, querier: &QuerierWrapper) -> StdResult<Option<HumanAddr>> {
pub fn admin(&self, querier: &QuerierWrapper) -> StdResult<Option<Addr>> {
let query = self.encode_smart_query(Cw4QueryMsg::Admin {})?;
let res: AdminResponse = querier.query(&query)?;
Ok(res.admin)
Expand Down
14 changes: 5 additions & 9 deletions packages/cw4/src/hook.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{to_binary, Binary, CosmosMsg, HumanAddr, StdResult, WasmMsg};
use cosmwasm_std::{to_binary, Addr, Binary, CosmosMsg, StdResult, WasmMsg};

/// MemberDiff shows the old and new states for a given cw4 member
/// They cannot both be None.
Expand All @@ -10,17 +10,13 @@ use cosmwasm_std::{to_binary, Binary, CosmosMsg, HumanAddr, StdResult, WasmMsg};
/// old = Some, new = None -> Delete
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct MemberDiff {
pub key: HumanAddr,
pub key: Addr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, this is a message, not state.
Again, use String.
Addr only in state and env/info from the runtime (already trusted)

pub old: Option<u64>,
pub new: Option<u64>,
}

impl MemberDiff {
pub fn new<T: Into<HumanAddr>>(
addr: T,
old_weight: Option<u64>,
new_weight: Option<u64>,
) -> Self {
pub fn new<T: Into<Addr>>(addr: T, old_weight: Option<u64>, new_weight: Option<u64>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything that really implements Into<Addr>? I think we can just use Addr here (or does this allow &addr as well as addr as args?)

MemberDiff {
key: addr.into(),
old: old_weight,
Expand Down Expand Up @@ -53,10 +49,10 @@ impl MemberChangedHookMsg {
}

/// creates a cosmos_msg sending this struct to the named contract
pub fn into_cosmos_msg(self, contract_addr: HumanAddr) -> StdResult<CosmosMsg> {
pub fn into_cosmos_msg(self, contract_addr: Addr) -> StdResult<CosmosMsg> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Into<String> here? So we can use Addr, String, or &str?

let msg = self.into_binary()?;
let execute = WasmMsg::Execute {
contract_addr,
contract_addr: contract_addr.into(),
msg,
send: vec![],
};
Expand Down
8 changes: 4 additions & 4 deletions packages/cw4/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::HumanAddr;
use cosmwasm_std::Addr;

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Cw4ExecuteMsg {
/// Change the admin
UpdateAdmin { admin: Option<HumanAddr> },
UpdateAdmin { admin: Option<Addr> },
/// Add a new hook to be informed of all membership changes. Must be called by Admin
AddHook { addr: HumanAddr },
AddHook { addr: Addr },
/// Remove a hook. Must be called by Admin
RemoveHook { addr: HumanAddr },
RemoveHook { addr: Addr },
}
Loading