You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// response contains either a result or an error and must be non-empty
318
+
oneof response {
319
+
bytes result = 21;
320
+
string error = 22;
321
+
}
322
+
}
323
+
```
324
+
325
+
Although it suggests this is a Protobuf object, the ICS spec doesn't define
326
+
whether to encode it as JSON or Protobuf. In the ICS20 implementation, this is
327
+
JSON encoded when returned from a contract. Given that, we will consider this
328
+
structure, JSON-encoded, to be the "standard" acknowledgement format.
329
+
330
+
You can find a
331
+
[CosmWasm-compatible definition of this format](https://github.com/CosmWasm/cosmwasm-plus/blob/v0.6.0-beta1/contracts/cw20-ics20/src/ibc.rs#L52-L72)
332
+
as part of the `cw20-ics20` contract.
333
+
293
334
#### Receiving an Acknowledgement
294
335
295
336
If chain B successfully received the packet (even if the contract returned an
On success, you will want to commit the pending state. For some contracts like
367
+
`cw20-ics20`, you accept the tokens before sending the packet, so no need to
368
+
commit any more state. On other contracts, you may want to store the data
369
+
returned as part of the acknowledgement (like
370
+
[storing the remote address after calling "WhoAmI"](https://github.com/CosmWasm/cosmwasm/blob/v0.14.0-beta4/contracts/ibc-reflect-send/src/ibc.rs#L157-L192)
371
+
in our simple `ibc-reflect` example.
372
+
373
+
On error, you will want to revert any state that was pending based on the
374
+
packet. For example, in ics20, if the
375
+
[remote chain rejects the packet](https://github.com/CosmWasm/cosmwasm-plus/blob/v0.6.0-beta1/contracts/cw20-ics20/src/ibc.rs#L246),
376
+
we must
377
+
[return the funds to the original sender](https://github.com/CosmWasm/cosmwasm-plus/blob/v0.6.0-beta1/contracts/cw20-ics20/src/ibc.rs#L291-L317).
324
378
325
379
#### Handling Timeouts
326
380
@@ -346,8 +400,11 @@ pub fn ibc_packet_timeout(
346
400
347
401
It is generally handled just like the error case in `ibc_packet_ack`, reverting
348
402
the state change from sending the packet (eg. if we send tokens over ICS20, both
349
-
an ack failure as well as a timeout will return those tokens to the original
0 commit comments