Skip to content

Commit

Permalink
Adapt code to ContractResult -> SubMsgResult change
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Mar 1, 2022
1 parent 0640f6b commit 41274a3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions contracts/cw20-ics20/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{
attr, entry_point, from_binary, to_binary, BankMsg, Binary, ContractResult, CosmosMsg, Deps,
DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg,
IbcChannelOpenMsg, IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg,
IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, SubMsg, Uint128, WasmMsg,
attr, entry_point, from_binary, to_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env,
IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg,
IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg,
IbcReceiveResponse, Reply, Response, SubMsg, SubMsgResult, Uint128, WasmMsg,
};

use crate::amount::Amount;
Expand Down Expand Up @@ -87,8 +87,8 @@ const ACK_FAILURE_ID: u64 = 0xfa17;
pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result<Response, ContractError> {
match reply.id {
RECEIVE_ID => match reply.result {
ContractResult::Ok(_) => Ok(Response::new()),
ContractResult::Err(err) => {
SubMsgResult::Ok(_) => Ok(Response::new()),
SubMsgResult::Err(err) => {
// Important design note: with ibcv2 and wasmd 0.22 we can implement this all much easier.
// No reply needed... the receive function and submessage should return error on failure and all
// state gets reverted with a proper app-level message auto-generated
Expand All @@ -113,8 +113,8 @@ pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result<Response, Contrac
}
},
ACK_FAILURE_ID => match reply.result {
ContractResult::Ok(_) => Ok(Response::new()),
ContractResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))),
SubMsgResult::Ok(_) => Ok(Response::new()),
SubMsgResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))),
},
_ => Err(ContractError::UnknownReplyId { id: reply.id }),
}
Expand Down
6 changes: 3 additions & 3 deletions packages/multi-test/src/test_helpers/contracts/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//! Additionally it bypass all events and attributes send to it
use cosmwasm_std::{
to_binary, Attribute, Binary, ContractResult, Deps, DepsMut, Empty, Env, Event, MessageInfo,
Reply, Response, StdError, SubMsg, SubMsgExecutionResponse,
to_binary, Attribute, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply, Response,
StdError, SubMsg, SubMsgExecutionResponse, SubMsgResult,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};

Expand Down Expand Up @@ -98,7 +98,7 @@ where
if let Reply {
id,
result:
ContractResult::Ok(SubMsgExecutionResponse {
SubMsgResult::Ok(SubMsgExecutionResponse {
data: Some(data), ..
}),
} = msg
Expand Down
10 changes: 5 additions & 5 deletions packages/multi-test/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::ops::Deref;

use cosmwasm_std::{
to_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo,
ContractInfoResponse, ContractResult, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo,
Order, Querier, QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg,
SubMsgExecutionResponse, TransactionInfo, WasmMsg, WasmQuery,
ContractInfoResponse, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, Order, Querier,
QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgExecutionResponse,
SubMsgResult, TransactionInfo, WasmMsg, WasmQuery,
};
use cosmwasm_storage::{prefixed, prefixed_read, PrefixedStorage, ReadonlyPrefixedStorage};
use prost::Message;
Expand Down Expand Up @@ -436,7 +436,7 @@ where
if matches!(reply_on, ReplyOn::Always | ReplyOn::Success) {
let reply = Reply {
id,
result: ContractResult::Ok(SubMsgExecutionResponse {
result: SubMsgResult::Ok(SubMsgExecutionResponse {
events: r.events.clone(),
data: r.data,
}),
Expand All @@ -457,7 +457,7 @@ where
if matches!(reply_on, ReplyOn::Always | ReplyOn::Error) {
let reply = Reply {
id,
result: ContractResult::Err(e.to_string()),
result: SubMsgResult::Err(e.to_string()),
};
self._reply(api, router, storage, block, contract, reply)
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/parse_reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub enum ParseReplyError {
mod test {
use super::*;
use crate::parse_reply::ParseReplyError::{BrokenUtf8, ParseFailure};
use cosmwasm_std::{ContractResult, SubMsgExecutionResponse};
use cosmwasm_std::{SubMsgExecutionResponse, SubMsgResult};
use prost::Message;
use std::str::from_utf8;

Expand Down Expand Up @@ -466,7 +466,7 @@ mod test {
// Build reply message
let msg = Reply {
id: 1,
result: ContractResult::Ok(SubMsgExecutionResponse {
result: SubMsgResult::Ok(SubMsgExecutionResponse {
events: vec![],
data: Some(encoded_instantiate_reply.into()),
}),
Expand Down Expand Up @@ -514,7 +514,7 @@ mod test {
// Build reply message
let msg = Reply {
id: 1,
result: ContractResult::Ok(SubMsgExecutionResponse {
result: SubMsgResult::Ok(SubMsgExecutionResponse {
events: vec![],
data: Some(encoded_execute_reply.into()),
}),
Expand Down

0 comments on commit 41274a3

Please sign in to comment.