Skip to content

Commit

Permalink
Update contracts for renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Oct 26, 2020
1 parent d0eed39 commit 5e24955
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 43 deletions.
8 changes: 4 additions & 4 deletions contracts/burner/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use cosmwasm_std::{
attr, BankMsg, Binary, DepsMut, DepsRef, Env, HandleResponse, InitResponse, MessageInfo,
attr, BankMsg, Binary, Deps, DepsRef, Env, HandleResponse, InitResponse, MessageInfo,
MigrateResponse, Order, StdError, StdResult,
};

use crate::msg::{HandleMsg, InitMsg, MigrateMsg, QueryMsg};

pub fn init(
_deps: DepsMut,
_deps: Deps,
_env: Env,
_info: MessageInfo,
_msg: InitMsg,
Expand All @@ -17,7 +17,7 @@ pub fn init(
}

pub fn handle(
_deps: DepsMut,
_deps: Deps,
_env: Env,
_info: MessageInfo,
_msg: HandleMsg,
Expand All @@ -28,7 +28,7 @@ pub fn handle(
}

pub fn migrate(
deps: DepsMut,
deps: Deps,
env: Env,
_info: MessageInfo,
msg: MigrateMsg,
Expand Down
12 changes: 6 additions & 6 deletions contracts/hackatom/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::convert::TryInto;

use cosmwasm_std::{
from_slice, to_binary, to_vec, AllBalanceResponse, Api, BankMsg, Binary, CanonicalAddr,
Context, DepsMut, DepsRef, Env, HandleResponse, HumanAddr, InitResponse, MessageInfo,
Context, Deps, DepsRef, Env, HandleResponse, HumanAddr, InitResponse, MessageInfo,
MigrateResponse, QueryRequest, QueryResponse, StdError, StdResult, WasmQuery,
};

Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct RecurseResponse {
pub const CONFIG_KEY: &[u8] = b"config";

pub fn init(
deps: DepsMut,
deps: Deps,
_env: Env,
info: MessageInfo,
msg: InitMsg,
Expand All @@ -110,7 +110,7 @@ pub fn init(
}

pub fn migrate(
deps: DepsMut,
deps: Deps,
_env: Env,
_info: MessageInfo,
msg: MigrateMsg,
Expand All @@ -127,7 +127,7 @@ pub fn migrate(
}

pub fn handle(
deps: DepsMut,
deps: Deps,
env: Env,
info: MessageInfo,
msg: HandleMsg,
Expand All @@ -143,7 +143,7 @@ pub fn handle(
}
}

fn do_release(deps: DepsMut, env: Env, info: MessageInfo) -> Result<HandleResponse, HackError> {
fn do_release(deps: Deps, env: Env, info: MessageInfo) -> Result<HandleResponse, HackError> {
let data = deps
.storage
.get(CONFIG_KEY)
Expand Down Expand Up @@ -179,7 +179,7 @@ fn do_cpu_loop() -> Result<HandleResponse, HackError> {
}
}

fn do_storage_loop(deps: DepsMut) -> Result<HandleResponse, HackError> {
fn do_storage_loop(deps: Deps) -> Result<HandleResponse, HackError> {
let mut test_case = 0u64;
loop {
deps.storage
Expand Down
19 changes: 7 additions & 12 deletions contracts/queue/src/contract.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 cosmwasm_std::{
from_slice, to_binary, to_vec, Binary, DepsMut, DepsRef, Env, HandleResponse, InitResponse,
from_slice, to_binary, to_vec, Binary, Deps, DepsRef, Env, HandleResponse, InitResponse,
MessageInfo, Order, QueryResponse, StdResult,
};

Expand Down Expand Up @@ -64,17 +64,12 @@ pub struct ListResponse {
}

// init is a no-op, just empty data
pub fn init(
_deps: DepsMut,
_env: Env,
_info: MessageInfo,
_msg: InitMsg,
) -> StdResult<InitResponse> {
pub fn init(_deps: Deps, _env: Env, _info: MessageInfo, _msg: InitMsg) -> StdResult<InitResponse> {
Ok(InitResponse::default())
}

pub fn handle(
deps: DepsMut,
deps: Deps,
_env: Env,
_info: MessageInfo,
msg: HandleMsg,
Expand All @@ -87,7 +82,7 @@ pub fn handle(

const FIRST_KEY: u8 = 0;

fn enqueue(deps: DepsMut, value: i32) -> StdResult<HandleResponse> {
fn enqueue(deps: Deps, value: i32) -> StdResult<HandleResponse> {
// find the last element in the queue and extract key
let last_item = deps.storage.range(None, None, Order::Descending).next();

Expand All @@ -103,7 +98,7 @@ fn enqueue(deps: DepsMut, value: i32) -> StdResult<HandleResponse> {
Ok(HandleResponse::default())
}

fn dequeue(deps: DepsMut) -> StdResult<HandleResponse> {
fn dequeue(deps: Deps) -> StdResult<HandleResponse> {
// find the first element in the queue and extract value
let first = deps.storage.range(None, None, Order::Ascending).next();

Expand Down Expand Up @@ -196,9 +191,9 @@ mod tests {
use cosmwasm_std::testing::{
mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
};
use cosmwasm_std::{coins, from_binary, Deps};
use cosmwasm_std::{coins, from_binary, OwnedDeps};

fn create_contract() -> (Deps<MockStorage, MockApi, MockQuerier>, MessageInfo) {
fn create_contract() -> (OwnedDeps<MockStorage, MockApi, MockQuerier>, MessageInfo) {
let mut deps = mock_dependencies(&coins(1000, "earth"));
let info = mock_info("creator", &coins(1000, "earth"));
let res = init(deps.as_mut(), mock_env(), info.clone(), InitMsg {}).unwrap();
Expand Down
13 changes: 6 additions & 7 deletions contracts/reflect/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use cosmwasm_std::{
attr, to_binary, to_vec, Binary, ContractResult, CosmosMsg, DepsMut, DepsRef, Env,
HandleResponse, HumanAddr, InitResponse, MessageInfo, QueryRequest, StdError, StdResult,
SystemResult,
attr, to_binary, to_vec, Binary, ContractResult, CosmosMsg, Deps, DepsRef, Env, HandleResponse,
HumanAddr, InitResponse, MessageInfo, QueryRequest, StdError, StdResult, SystemResult,
};

use crate::errors::ReflectError;
Expand All @@ -12,7 +11,7 @@ use crate::msg::{
use crate::state::{config, config_read, State};

pub fn init(
deps: DepsMut,
deps: Deps,
_env: Env,
info: MessageInfo,
_msg: InitMsg,
Expand All @@ -26,7 +25,7 @@ pub fn init(
}

pub fn handle(
deps: DepsMut,
deps: Deps,
env: Env,
info: MessageInfo,
msg: HandleMsg,
Expand All @@ -38,7 +37,7 @@ pub fn handle(
}

pub fn try_reflect(
deps: DepsMut,
deps: Deps,
_env: Env,
info: MessageInfo,
msgs: Vec<CosmosMsg<CustomMsg>>,
Expand All @@ -65,7 +64,7 @@ pub fn try_reflect(
}

pub fn try_change_owner(
deps: DepsMut,
deps: Deps,
_env: Env,
info: MessageInfo,
owner: HumanAddr,
Expand Down
6 changes: 3 additions & 3 deletions contracts/reflect/src/testing.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use crate::msg::{SpecialQuery, SpecialResponse};

use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{to_binary, Binary, Coin, ContractResult, Deps, HumanAddr, SystemResult};
use cosmwasm_std::{to_binary, Binary, Coin, ContractResult, HumanAddr, OwnedDeps, SystemResult};

/// A drop-in replacement for cosmwasm_std::testing::mock_dependencies
/// this uses our CustomQuerier.
pub fn mock_dependencies_with_custom_querier(
contract_balance: &[Coin],
) -> Deps<MockStorage, MockApi, MockQuerier<SpecialQuery>> {
) -> OwnedDeps<MockStorage, MockApi, MockQuerier<SpecialQuery>> {
let contract_addr = HumanAddr::from(MOCK_CONTRACT_ADDR);
let custom_querier: MockQuerier<SpecialQuery> =
MockQuerier::new(&[(&contract_addr, contract_balance)])
.with_custom_handler(|query| SystemResult::Ok(custom_query_execute(&query)));
Deps {
OwnedDeps {
storage: MockStorage::default(),
api: MockApi::default(),
querier: custom_querier,
Expand Down
21 changes: 10 additions & 11 deletions contracts/staking/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use cosmwasm_std::{
attr, coin, to_binary, BankMsg, Binary, Decimal, DepsMut, DepsRef, Env, HandleResponse,
HumanAddr, InitResponse, MessageInfo, QuerierWrapper, StakingMsg, StdError, StdResult, Uint128,
WasmMsg,
attr, coin, to_binary, BankMsg, Binary, Decimal, Deps, DepsRef, Env, HandleResponse, HumanAddr,
InitResponse, MessageInfo, QuerierWrapper, StakingMsg, StdError, StdResult, Uint128, WasmMsg,
};

use crate::errors::{StakingError, Unauthorized};
Expand All @@ -16,7 +15,7 @@ use crate::state::{

const FALLBACK_RATIO: Decimal = Decimal::one();

pub fn init(deps: DepsMut, _env: Env, info: MessageInfo, msg: InitMsg) -> StdResult<InitResponse> {
pub fn init(deps: Deps, _env: Env, info: MessageInfo, msg: InitMsg) -> StdResult<InitResponse> {
// ensure the validator is registered
let vals = deps.querier.query_validators()?;
if !vals.iter().any(|v| v.address == msg.validator) {
Expand Down Expand Up @@ -51,7 +50,7 @@ pub fn init(deps: DepsMut, _env: Env, info: MessageInfo, msg: InitMsg) -> StdRes
}

pub fn handle(
deps: DepsMut,
deps: Deps,
env: Env,
info: MessageInfo,
msg: HandleMsg,
Expand All @@ -69,7 +68,7 @@ pub fn handle(
}

pub fn transfer(
deps: DepsMut,
deps: Deps,
_env: Env,
info: MessageInfo,
recipient: HumanAddr,
Expand Down Expand Up @@ -131,7 +130,7 @@ fn assert_bonds(supply: &Supply, bonded: Uint128) -> StdResult<()> {
}
}

pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult<HandleResponse> {
pub fn bond(deps: Deps, env: Env, info: MessageInfo) -> StdResult<HandleResponse> {
let sender_raw = deps.api.canonical_address(&info.sender)?;

// ensure we have the proper denom
Expand Down Expand Up @@ -184,7 +183,7 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult<HandleRespo
}

pub fn unbond(
deps: DepsMut,
deps: Deps,
env: Env,
info: MessageInfo,
amount: Uint128,
Expand Down Expand Up @@ -253,7 +252,7 @@ pub fn unbond(
Ok(res)
}

pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult<HandleResponse> {
pub fn claim(deps: Deps, env: Env, info: MessageInfo) -> StdResult<HandleResponse> {
// find how many tokens the contract has
let invest = invest_info_read(deps.storage.as_readonly()).load()?;
let mut balance = deps
Expand Down Expand Up @@ -302,7 +301,7 @@ pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult<HandleResp
/// reinvest will withdraw all pending rewards,
/// then issue a callback to itself via _bond_all_tokens
/// to reinvest the new earnings (and anything else that accumulated)
pub fn reinvest(deps: DepsMut, env: Env, _info: MessageInfo) -> StdResult<HandleResponse> {
pub fn reinvest(deps: Deps, env: Env, _info: MessageInfo) -> StdResult<HandleResponse> {
let contract_addr = env.contract.address;
let invest = invest_info_read(deps.storage.as_readonly()).load()?;
let msg = to_binary(&HandleMsg::_BondAllTokens {})?;
Expand All @@ -329,7 +328,7 @@ pub fn reinvest(deps: DepsMut, env: Env, _info: MessageInfo) -> StdResult<Handle
}

pub fn _bond_all_tokens(
deps: DepsMut,
deps: Deps,
env: Env,
info: MessageInfo,
) -> Result<HandleResponse, StakingError> {
Expand Down

0 comments on commit 5e24955

Please sign in to comment.