[rpc] Always display transaction status in the receipt (#3393)

pull/3397/head
Janet Liang 4 years ago committed by GitHub
parent b088d6dc77
commit 1deda36b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      rpc/v1/types.go
  2. 19
      rpc/v2/types.go

@ -179,8 +179,8 @@ type TxReceipt struct {
ShardID uint32 `json:"shardID"` ShardID uint32 `json:"shardID"`
From string `json:"from"` From string `json:"from"`
To string `json:"to"` To string `json:"to"`
Root hexutil.Bytes `json:"root,omitempty"` Root hexutil.Bytes `json:"root"`
Status hexutil.Uint `json:"status,omitempty"` Status hexutil.Uint `json:"status"`
} }
// StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation. // StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation.
@ -196,8 +196,8 @@ type StakingTxReceipt struct {
LogsBloom ethtypes.Bloom `json:"logsBloom"` LogsBloom ethtypes.Bloom `json:"logsBloom"`
Sender string `json:"sender"` Sender string `json:"sender"`
Type staking.Directive `json:"type"` Type staking.Directive `json:"type"`
Root hexutil.Bytes `json:"root,omitempty"` Root hexutil.Bytes `json:"root"`
Status hexutil.Uint `json:"status,omitempty"` Status hexutil.Uint `json:"status"`
} }
// CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt // CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt
@ -349,13 +349,8 @@ func NewTxReceipt(
ShardID: tx.ShardID(), ShardID: tx.ShardID(),
From: sender, From: sender,
To: receiver, To: receiver,
} Root: receipt.PostState,
Status: hexutil.Uint(receipt.Status),
// Set optionals
if len(receipt.PostState) > 0 {
txReceipt.Root = receipt.PostState
} else {
txReceipt.Status = hexutil.Uint(receipt.Status)
} }
// Set empty array for empty logs // Set empty array for empty logs
@ -396,13 +391,8 @@ func NewStakingTxReceipt(
LogsBloom: receipt.Bloom, LogsBloom: receipt.Bloom,
Sender: sender, Sender: sender,
Type: tx.StakingType(), Type: tx.StakingType(),
} Root: receipt.PostState,
Status: hexutil.Uint(receipt.Status),
// Set optionals
if len(receipt.PostState) > 0 {
txReceipt.Root = receipt.PostState
} else {
txReceipt.Status = hexutil.Uint(receipt.Status)
} }
// Set empty array for empty logs // Set empty array for empty logs

@ -178,8 +178,8 @@ type TxReceipt struct {
ShardID uint32 `json:"shardID"` ShardID uint32 `json:"shardID"`
From string `json:"from"` From string `json:"from"`
To string `json:"to"` To string `json:"to"`
Root hexutil.Bytes `json:"root,omitempty"` Root hexutil.Bytes `json:"root"`
Status uint `json:"status,omitempty"` Status uint `json:"status"`
} }
// StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation. // StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation.
@ -195,8 +195,8 @@ type StakingTxReceipt struct {
LogsBloom ethtypes.Bloom `json:"logsBloom"` LogsBloom ethtypes.Bloom `json:"logsBloom"`
Sender string `json:"sender"` Sender string `json:"sender"`
Type staking.Directive `json:"type"` Type staking.Directive `json:"type"`
Root hexutil.Bytes `json:"root,omitempty"` Root hexutil.Bytes `json:"root"`
Status uint `json:"status,omitempty"` Status uint `json:"status"`
} }
// CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt // CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt
@ -347,6 +347,8 @@ func NewTxReceipt(
ShardID: tx.ShardID(), ShardID: tx.ShardID(),
From: sender, From: sender,
To: receiver, To: receiver,
Root: receipt.PostState,
Status: uint(receipt.Status),
} }
// Set optionals // Set optionals
@ -394,13 +396,8 @@ func NewStakingTxReceipt(
LogsBloom: receipt.Bloom, LogsBloom: receipt.Bloom,
Sender: sender, Sender: sender,
Type: tx.StakingType(), Type: tx.StakingType(),
} Root: receipt.PostState,
Status: uint(receipt.Status),
// Set optionals
if len(receipt.PostState) > 0 {
txReceipt.Root = receipt.PostState
} else {
txReceipt.Status = uint(receipt.Status)
} }
// Set empty array for empty logs // Set empty array for empty logs

Loading…
Cancel
Save