Skip to content

Commit 6a64342

Browse files
unmarshal only when the txnReceipt is not empty (#328)
1 parent 7ae17b7 commit 6a64342

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

relayer/relayer.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/0xsequence/ethkit/go-ethereum/common"
1818
"github.com/0xsequence/ethkit/go-ethereum/common/hexutil"
1919
"github.com/0xsequence/ethkit/go-ethereum/core/types"
20+
2021
"github.com/0xsequence/go-sequence"
2122
"github.com/0xsequence/go-sequence/core"
2223
v1 "github.com/0xsequence/go-sequence/core/v1"
@@ -343,12 +344,15 @@ func (r *Client) waitMetaTxnReceipt(ctx context.Context, metaTxnID sequence.Meta
343344
if err != nil {
344345
return sequence.MetaTxnStatusUnknown, nil, err
345346
}
346-
txnReceipt := metaTxnReceipt.TxnReceipt
347+
347348
var receipt *types.Receipt
348-
err = json.Unmarshal([]byte(txnReceipt), &receipt)
349-
if err != nil {
350-
return 0, nil, fmt.Errorf("failed to decode txn receipt data: %w", err)
349+
// Only unmarshal TxnReceipt when the field is non-empty, since attempting to decode an empty JSON string would result in an error.
350+
if metaTxnReceipt.TxnReceipt != "" {
351+
if err = json.Unmarshal([]byte(metaTxnReceipt.TxnReceipt), &receipt); err != nil {
352+
return 0, nil, fmt.Errorf("decode txn receipt data: %w", err)
353+
}
351354
}
355+
352356
return MetaTxnStatusFromString(metaTxnReceipt.Status), receipt, nil
353357
}
354358
}

0 commit comments

Comments
 (0)