File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
package wasm
2
2
3
3
import (
4
+ "encoding/json"
4
5
"math"
5
6
"slices"
6
7
@@ -416,21 +417,26 @@ func (i IBCHandler) IBCReceivePacketCallback(
416
417
}
417
418
418
419
var funds wasmvmtypes.Array [wasmvmtypes.Coin ]
419
- // detect successful transfer
420
- successAck := []byte (`{"result":"AQ=="}` ) // TODO: hardcoded check is not nice
420
+
421
+ var parsedAck channeltypes.Acknowledgement_Result
422
+ err = json .Unmarshal (ack .Acknowledgement (), & parsedAck )
423
+
424
+ // detect successful IBC transfer, meaning:
425
+ // 1. it was sent to the transfer module
426
+ // 2. the acknowledgement was successful
421
427
if packet .GetDestPort () == i .transferKeeper .GetPort (cachedCtx ) &&
422
- ack .Success () && slices .Equal (ack . Acknowledgement (), successAck ) {
423
- // decode packet
428
+ ack .Success () && err == nil && slices .Equal (parsedAck . Result , [] byte { 1 } ) {
429
+
424
430
transferData , err := transfertypes .UnmarshalPacketData (packet .GetData (), version , "" )
425
431
if err != nil {
426
432
return errorsmod .Wrap (err , "unmarshal transfer packet data" )
427
433
}
428
434
429
- // validate receiver address
430
435
receiverAddr , err := sdk .AccAddressFromBech32 (transferData .Receiver )
431
436
if err != nil {
432
437
return err
433
438
}
439
+ // we only want to tell the contract about the funds if the transfer was sent to the contract
434
440
if receiverAddr .Equals (contractAddr ) {
435
441
// fill funds with the transfer amount
436
442
You can’t perform that action at this time.
0 commit comments