Skip to content

Commit 668bd8b

Browse files
fix(postage): prevent nil pointer panic in TopUpBatch on transaction … (#5332)
1 parent 91b01ad commit 668bd8b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/postage/postagecontract/contract.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (c *postageContract) CreateBatch(ctx context.Context, initialBalance *big.I
390390
if err != nil {
391391
return
392392
}
393-
txHash = receipt.TxHash
393+
394394
for _, ev := range receipt.Logs {
395395
if ev.Address == c.postageStampContractAddress && len(ev.Topics) > 0 && ev.Topics[0] == c.batchCreatedTopic {
396396
var createdEvent batchCreatedEvent
@@ -415,6 +415,7 @@ func (c *postageContract) CreateBatch(ctx context.Context, initialBalance *big.I
415415
if err != nil {
416416
return
417417
}
418+
txHash = receipt.TxHash
418419
return
419420
}
420421
}
@@ -447,7 +448,6 @@ func (c *postageContract) TopUpBatch(ctx context.Context, batchID []byte, topupB
447448

448449
receipt, err := c.sendTopUpBatchTransaction(ctx, batch.ID, topupBalance)
449450
if err != nil {
450-
txHash = receipt.TxHash
451451
return
452452
}
453453

@@ -483,9 +483,10 @@ func (c *postageContract) DiluteBatch(ctx context.Context, batchID []byte, newDe
483483
if err != nil {
484484
return
485485
}
486-
txHash = receipt.TxHash
486+
487487
for _, ev := range receipt.Logs {
488488
if ev.Address == c.postageStampContractAddress && len(ev.Topics) > 0 && ev.Topics[0] == c.batchDepthIncreaseTopic {
489+
txHash = receipt.TxHash
489490
return
490491
}
491492
}

0 commit comments

Comments
 (0)