Skip to content

Commit 0615fe5

Browse files
committed
fix(evm): tx submission validation
1 parent ad69ee8 commit 0615fe5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

chain/evm/client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,26 @@ func (client *Client) Tx(ctx context.Context, txID pack.Bytes) (account.Tx, pack
6767
Signer: types.NewEIP155Signer(chainID),
6868
}
6969
if pending {
70-
return &pendingTx, 0, nil
70+
// Transaction has not been included in a block yet.
71+
return nil, 0, fmt.Errorf("tx %v is pending", txID)
7172
}
7273

7374
receipt, err := client.EthClient.TransactionReceipt(ctx, common.BytesToHash(txID))
7475
if err != nil {
7576
return nil, pack.NewU64(0), fmt.Errorf("fetching recipt for tx %v : %v", txID, err)
7677
}
7778

78-
// if no receipt, tx has 0 confirmations
7979
if receipt == nil {
80+
// Transaction has 0 confirmations.
8081
return &pendingTx, 0, nil
8182
}
8283

83-
// reverted tx
8484
if receipt.Status == 0 {
85+
// Transaction has been reverted.
8586
return nil, pack.NewU64(0), fmt.Errorf("tx %v reverted, reciept status 0", txID)
8687
}
8788

88-
// tx confirmed
89+
// Transaction has been confirmed.
8990
confirmedTx := Tx{
9091
tx,
9192
types.LatestSignerForChainID(chainID),

0 commit comments

Comments
 (0)