Skip to content

Commit

Permalink
Merge pull request #186 from CosmWasm/fix-minor-errors
Browse files Browse the repository at this point in the history
Fix minor errors
  • Loading branch information
ethanfrey authored Dec 16, 2020
2 parents a3e414e + 6b59f21 commit 2a3912d
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 63 deletions.
16 changes: 3 additions & 13 deletions contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,11 @@ pub fn init(
info: MessageInfo,
msg: InitMsg,
) -> StdResult<InitResponse> {
let result = whitelist_init(dup(&mut deps), env, info, msg)?;
let result = whitelist_init(deps.branch(), env, info, msg)?;
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
Ok(result)
}

// TODO: replace this with deps.dup()
// after https://github.com/CosmWasm/cosmwasm/pull/620 is merged
fn dup<'a>(deps: &'a mut DepsMut<'_>) -> DepsMut<'a> {
DepsMut {
storage: deps.storage,
api: deps.api,
querier: deps.querier,
}
}

pub fn handle(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -447,7 +437,7 @@ mod tests {
admins: admins.to_vec(),
mutable: true,
};
init(dup(&mut deps), mock_env(), info.clone(), init_msg).unwrap();
init(deps.branch(), mock_env(), info.clone(), init_msg).unwrap();

// Add subkeys with initial allowances
for (spender, expiration) in spenders.iter().zip(expirations) {
Expand All @@ -457,7 +447,7 @@ mod tests {
amount: amount.clone(),
expires: Some(expiration.clone()),
};
handle(dup(&mut deps), mock_env(), info.clone(), msg).unwrap();
handle(deps.branch(), mock_env(), info.clone(), msg).unwrap();
}
}
}
Expand Down
12 changes: 1 addition & 11 deletions contracts/cw20-base/src/allowances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,10 @@ mod tests {
};
let info = mock_info(&HumanAddr("creator".to_string()), &[]);
let env = mock_env();
init(dup(&mut deps), env, info, init_msg).unwrap();
init(deps.branch(), env, info, init_msg).unwrap();
query_token_info(deps.as_ref()).unwrap()
}

// TODO: replace this with deps.dup()
// after https://github.com/CosmWasm/cosmwasm/pull/620 is merged
fn dup<'a>(deps: &'a mut DepsMut<'_>) -> DepsMut<'a> {
DepsMut {
storage: deps.storage,
api: deps.api,
querier: deps.querier,
}
}

#[test]
fn increase_decrease_allowances() {
let mut deps = mock_dependencies(&coins(2, "token"));
Expand Down
12 changes: 1 addition & 11 deletions contracts/cw20-base/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ mod tests {
};
let info = mock_info(&HumanAddr("creator".to_string()), &[]);
let env = mock_env();
let res = init(dup(&mut deps), env, info, init_msg).unwrap();
let res = init(deps.branch(), env, info, init_msg).unwrap();
assert_eq!(0, res.messages.len());

let meta = query_token_info(deps.as_ref()).unwrap();
Expand All @@ -436,16 +436,6 @@ mod tests {
meta
}

// TODO: replace this with deps.dup()
// after https://github.com/CosmWasm/cosmwasm/pull/620 is merged
fn dup<'a>(deps: &'a mut DepsMut<'_>) -> DepsMut<'a> {
DepsMut {
storage: deps.storage,
api: deps.api,
querier: deps.querier,
}
}

#[test]
fn proper_initialization() {
let mut deps = mock_dependencies(&[]);
Expand Down
12 changes: 1 addition & 11 deletions contracts/cw20-base/src/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,10 @@ mod tests {
};
let info = mock_info(&HumanAddr("creator".to_string()), &[]);
let env = mock_env();
init(dup(&mut deps), env, info, init_msg).unwrap();
init(deps.branch(), env, info, init_msg).unwrap();
query_token_info(deps.as_ref()).unwrap()
}

// TODO: replace this with deps.dup()
// after https://github.com/CosmWasm/cosmwasm/pull/620 is merged
fn dup<'a>(deps: &'a mut DepsMut<'_>) -> DepsMut<'a> {
DepsMut {
storage: deps.storage,
api: deps.api,
querier: deps.querier,
}
}

#[test]
fn query_all_allowances_works() {
let mut deps = mock_dependencies(&coins(2, "token"));
Expand Down
14 changes: 2 additions & 12 deletions contracts/cw20-staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,6 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> Result<HandleResponse
Ok(res)
}

// TODO: replace this with deps.dup()
// after https://github.com/CosmWasm/cosmwasm/pull/620 is merged
fn dup<'a>(deps: &'a mut DepsMut<'_>) -> DepsMut<'a> {
DepsMut {
storage: deps.storage,
api: deps.api,
querier: deps.querier,
}
}

pub fn unbond(
mut deps: DepsMut,
env: Env,
Expand All @@ -250,15 +240,15 @@ pub fn unbond(
let tax = amount * invest.exit_tax;

// burn from the original caller
handle_burn(dup(&mut deps), env.clone(), info.clone(), amount)?;
handle_burn(deps.branch(), env.clone(), info.clone(), amount)?;
if tax > Uint128(0) {
let sub_info = MessageInfo {
sender: env.contract.address.clone(),
sent_funds: vec![],
};
// call into cw20-base to mint tokens to owner, call as self as no one else is allowed
let human_owner = deps.api.human_address(&invest.owner)?;
handle_mint(dup(&mut deps), env.clone(), sub_info, human_owner, tax)?;
handle_mint(deps.branch(), env.clone(), sub_info, human_owner, tax)?;
}

// re-calculate bonded to ensure we have real values
Expand Down
1 change: 0 additions & 1 deletion contracts/cw3-fixed-multisig/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub enum HandleMsg {
},
}

// TODO: add a custom query to return the voter list (all potential voters)
// We can also add this as a cw3 extension
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
Expand Down
1 change: 0 additions & 1 deletion contracts/cw3-fixed-multisig/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub struct Proposal {
}

impl Proposal {
/// TODO: we should get the current BlockInfo and then we can determine this a bit better
pub fn current_status(&self, block: &BlockInfo) -> Status {
let mut status = self.status;

Expand Down
1 change: 0 additions & 1 deletion contracts/cw3-flex-multisig/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ pub enum HandleMsg {
MemberChangedHook(MemberChangedHookMsg),
}

// TODO: add a custom query to return the voter list (all potential voters)
// We can also add this as a cw3 extension
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
Expand Down
2 changes: 1 addition & 1 deletion contracts/cw4-stake/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use cw0::claim::{claim_tokens, create_claim, CLAIMS};
use cw0::hooks::prepare_hooks;

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:cw4-group";
const CONTRACT_NAME: &str = "crates.io:cw4-stake";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

// Note, you can use StdResult in some functions where you do not
Expand Down
1 change: 0 additions & 1 deletion packages/cw0/src/expiration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ impl Mul<u64> for Duration {
mod test {
use super::*;

// TODO: add tests for the logic
#[test]
fn compare_expiration() {
// matching pairs
Expand Down

0 comments on commit 2a3912d

Please sign in to comment.