From b9bbfdf37294e340d99efd0a8ec5a7349e4c8a5b Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Sat, 4 Mar 2023 10:08:47 +1000 Subject: [PATCH] ethapi: Omit isSystemTx: "false" from JSON-RPC responses (#60) --- internal/ethapi/api.go | 5 ++++- internal/ethapi/api_test.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index fca60003b..f8d3ba090 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -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) diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 0c939e619..da3fa9a3f 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -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), ¶ms.ChainConfig{}, nil) + + require.Nil(t, got.IsSystemTx, "should omit IsSystemTx when false") +} + func TestUnmarshalRpcDepositTx(t *testing.T) { tests := []struct { name string