Skip to content

Commit

Permalink
ethapi: Omit isSystemTx: "false" from JSON-RPC responses (ethereum#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored Mar 4, 2023
1 parent 13e42b0 commit b9bbfdf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,10 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
srcHash := tx.SourceHash()
isSystemTx := tx.IsSystemTx()
result.SourceHash = &srcHash
result.IsSystemTx = &isSystemTx
if isSystemTx {
// Only include IsSystemTx when true
result.IsSystemTx = &isSystemTx
}
result.Mint = (*hexutil.Big)(tx.Mint())
if receipt != nil && receipt.DepositNonce != nil {
result.Nonce = hexutil.Uint64(*receipt.DepositNonce)
Expand Down
9 changes: 9 additions & 0 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ func TestNewRPCTransactionDepositTx(t *testing.T) {
require.Equal(t, got.Nonce, (hexutil.Uint64)(nonce), "newRPCTransaction().Mint = %v, want %v", got.Nonce, nonce)
}

func TestNewRPCTransactionOmitIsSystemTxFalse(t *testing.T) {
tx := types.NewTx(&types.DepositTx{
IsSystemTransaction: false,
})
got := newRPCTransaction(tx, common.Hash{}, uint64(12), uint64(1), big.NewInt(0), &params.ChainConfig{}, nil)

require.Nil(t, got.IsSystemTx, "should omit IsSystemTx when false")
}

func TestUnmarshalRpcDepositTx(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit b9bbfdf

Please sign in to comment.