Handle old style ethereum transactions that do not set status
This commit is contained in:
parent
e9e6b472b6
commit
35a13e0647
@ -412,9 +412,16 @@ func GetErc20FromTx(tx *bchain.Tx) ([]Erc20Transfer, error) {
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
txStatusUnknown = iota - 2
|
||||||
|
txStatusPending
|
||||||
|
txStatusFailure
|
||||||
|
txStatusOK
|
||||||
|
)
|
||||||
|
|
||||||
// EthereumTxData contains ethereum specific transaction data
|
// EthereumTxData contains ethereum specific transaction data
|
||||||
type EthereumTxData struct {
|
type EthereumTxData struct {
|
||||||
Status int `json:"status"` // 1 OK, 0 Fail, -1 pending
|
Status int `json:"status"` // 1 OK, 0 Fail, -1 pending, -2 unknown
|
||||||
Nonce uint64 `json:"nonce"`
|
Nonce uint64 `json:"nonce"`
|
||||||
GasLimit *big.Int `json:"gaslimit"`
|
GasLimit *big.Int `json:"gaslimit"`
|
||||||
GasUsed *big.Int `json:"gasused"`
|
GasUsed *big.Int `json:"gasused"`
|
||||||
@ -423,7 +430,7 @@ type EthereumTxData struct {
|
|||||||
|
|
||||||
// GetEthereumTxData returns EthereumTxData from bchain.Tx
|
// GetEthereumTxData returns EthereumTxData from bchain.Tx
|
||||||
func GetEthereumTxData(tx *bchain.Tx) *EthereumTxData {
|
func GetEthereumTxData(tx *bchain.Tx) *EthereumTxData {
|
||||||
etd := EthereumTxData{Status: -1}
|
etd := EthereumTxData{Status: txStatusPending}
|
||||||
csd, ok := tx.CoinSpecificData.(completeTransaction)
|
csd, ok := tx.CoinSpecificData.(completeTransaction)
|
||||||
if ok {
|
if ok {
|
||||||
if csd.Tx != nil {
|
if csd.Tx != nil {
|
||||||
@ -432,10 +439,13 @@ func GetEthereumTxData(tx *bchain.Tx) *EthereumTxData {
|
|||||||
etd.GasPrice, _ = hexutil.DecodeBig(csd.Tx.GasPrice)
|
etd.GasPrice, _ = hexutil.DecodeBig(csd.Tx.GasPrice)
|
||||||
}
|
}
|
||||||
if csd.Receipt != nil {
|
if csd.Receipt != nil {
|
||||||
if csd.Receipt.Status == "0x1" {
|
switch csd.Receipt.Status {
|
||||||
etd.Status = 1
|
case "0x1":
|
||||||
} else {
|
etd.Status = txStatusOK
|
||||||
etd.Status = 0
|
case "": // old transactions did not set status
|
||||||
|
etd.Status = txStatusUnknown
|
||||||
|
default:
|
||||||
|
etd.Status = txStatusFailure
|
||||||
}
|
}
|
||||||
etd.GasUsed, _ = hexutil.DecodeBig(csd.Receipt.GasUsed)
|
etd.GasUsed, _ = hexutil.DecodeBig(csd.Receipt.GasUsed)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,10 +25,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Status</td>
|
<td>Status</td>
|
||||||
{{- if $tx.EthereumSpecific.Status -}}
|
{{- if $tx.EthereumSpecific.Status -}}
|
||||||
{{- if ne $tx.EthereumSpecific.Status 1 -}}
|
{{- if eq $tx.EthereumSpecific.Status 1 -}}
|
||||||
|
<td class="data text-success">Success</td>
|
||||||
|
{{- else -}}
|
||||||
|
{{- if eq $tx.EthereumSpecific.Status -1 -}}
|
||||||
<td class="data">Pending</td>
|
<td class="data">Pending</td>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<td class="data text-success">Success</td>
|
<td class="data">Unknown</td>
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<td class="data text-danger">Fail</td>
|
<td class="data text-danger">Fail</td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user