|
1 | 1 | 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, |
3 | 3 | IbcDestinationCallbackMsg, IbcDstCallback, IbcSourceCallbackMsg, IbcSrcCallback, IbcTimeout,
|
4 | 4 | MessageInfo, Response, StdError, StdResult, TransferMsgBuilder,
|
5 | 5 | };
|
@@ -127,11 +127,26 @@ pub fn ibc_source_callback(
|
127 | 127 | #[entry_point]
|
128 | 128 | pub fn ibc_destination_callback(
|
129 | 129 | deps: DepsMut,
|
130 |
| - _env: Env, |
| 130 | + env: Env, |
131 | 131 | msg: IbcDestinationCallbackMsg,
|
132 | 132 | ) -> StdResult<IbcBasicResponse> {
|
133 | 133 | let mut counts = load_stats(deps.storage)?;
|
134 | 134 |
|
| 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 | + |
135 | 150 | // save the receive
|
136 | 151 | counts.ibc_destination_callbacks.push(msg);
|
137 | 152 |
|
|
0 commit comments