-
Notifications
You must be signed in to change notification settings - Fork 369
Update cosmwasm-std #260
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
Update cosmwasm-std #260
Changes from 1 commit
af22dfa
c9e8d34
420dfec
470c2ba
e654cef
a3dde73
01d4e95
be013e0
57d574d
18df393
0c08564
2cf5432
5e8e8ba
5de3e18
401a2a7
55f97f5
49e2be0
e3bfa99
1335006
7140497
a82070c
c4ea90c
c8a8468
d213c97
bee6474
a332725
924240e
b6f055e
385600c
fbb6c17
0ed8772
e23f7cf
92eca49
40f2c7e
656964f
e0a3a94
38c40ea
a3a086a
5ef5bba
319de31
d04994a
ba8f272
42f76a2
f27698e
2710be7
a8c3b4e
f8edebd
83d0f6f
9b927c5
f8b07cd
11f1b34
72f1650
37ffc87
c6d50f5
e4f0c0c
1ac1818
6cf17a7
0a1de48
9d93a30
b88d6b0
6e20287
878950d
f90599b
da499bb
010f5ab
90c1858
5b8f926
d45e56f
1f9818e
87b4013
f427977
08c6388
cddeafd
e618606
c2a2fa3
4e105a4
07ad611
779b4fe
6cb71b9
d8894e3
e8f3eb5
81f571f
f7c0e43
f35a0ab
e529858
91c59cc
f6c8ae0
d68af14
c0ce30e
7583b2e
289d26a
120857d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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![], | ||
} | ||
|
@@ -42,7 +42,7 @@ pub struct Cw1CanonicalContract(pub CanonicalAddr); | |
impl Cw1CanonicalContract { | ||
|
||
/// 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)) | ||
} | ||
} |
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"); | ||
|
@@ -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>>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
querier: &Q, | ||
contract_addr: T, | ||
) -> StdResult<ContractVersion> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 }, | ||
|
||
/// 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>, | ||
}, | ||
} | ||
|
@@ -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, | ||
|
||
pub vote: Vote, | ||
pub weight: u64, | ||
} | ||
|
@@ -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, | ||
} |
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. | ||
|
@@ -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, | ||
|
||
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 { | ||
|
||
MemberDiff { | ||
key: addr.into(), | ||
old: old_weight, | ||
|
@@ -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> { | ||
|
||
let msg = self.into_binary()?; | ||
let execute = WasmMsg::Execute { | ||
contract_addr, | ||
contract_addr: contract_addr.into(), | ||
msg, | ||
send: vec![], | ||
}; | ||
|
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 }, | ||
} |
There was a problem hiding this comment.
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.