Skip to content

Commit ebabe8d

Browse files
committed
Add assertion to ibc-callbacks contract
1 parent 7cf0e6f commit ebabe8d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

contracts/ibc-callbacks/src/contract.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cosmwasm_std::{
2-
entry_point, to_json_binary, Binary, Deps, DepsMut, Empty, Env, IbcBasicResponse,
2+
ensure, entry_point, to_json_binary, Binary, Deps, DepsMut, Empty, Env, IbcBasicResponse,
33
IbcDestinationCallbackMsg, IbcDstCallback, IbcSourceCallbackMsg, IbcSrcCallback, IbcTimeout,
44
MessageInfo, Response, StdError, StdResult, TransferMsgBuilder,
55
};
@@ -127,11 +127,26 @@ pub fn ibc_source_callback(
127127
#[entry_point]
128128
pub fn ibc_destination_callback(
129129
deps: DepsMut,
130-
_env: Env,
130+
env: Env,
131131
msg: IbcDestinationCallbackMsg,
132132
) -> StdResult<IbcBasicResponse> {
133133
let mut counts = load_stats(deps.storage)?;
134134

135+
// Assert that we have the funds we expect.
136+
// This is just for testing purposes and to show that the funds are already available during
137+
// the callback.
138+
for coin in &msg.funds {
139+
let balance = deps
140+
.querier
141+
.query_balance(&env.contract.address, &coin.denom)?;
142+
ensure!(
143+
balance.amount >= coin.amount,
144+
StdError::generic_err(format!(
145+
"Didn't receive expected funds. expected: {coin}, have: {balance}"
146+
))
147+
);
148+
}
149+
135150
// save the receive
136151
counts.ibc_destination_callbacks.push(msg);
137152

0 commit comments

Comments
 (0)