From e78d720a0bf6672fbfec4d6abe0e56920354026e Mon Sep 17 00:00:00 2001 From: P <1674920+peterbitfly@users.noreply.github.com> Date: Mon, 27 Feb 2023 11:08:56 +0100 Subject: [PATCH 1/2] include withdrawals in ethclient responses --- ethclient/ethclient.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 460035f36a6d..17bdc6ea759b 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -102,9 +102,10 @@ func (ec *Client) PeerCount(ctx context.Context) (uint64, error) { } type rpcBlock struct { - Hash common.Hash `json:"hash"` - Transactions []rpcTransaction `json:"transactions"` - UncleHashes []common.Hash `json:"uncles"` + Hash common.Hash `json:"hash"` + Transactions []rpcTransaction `json:"transactions"` + UncleHashes []common.Hash `json:"uncles"` + Withdrawals []*types.Withdrawal `json:"withdrawals"` } func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) { @@ -169,7 +170,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface } txs[i] = tx.tx } - return types.NewBlockWithHeader(head).WithBody(txs, uncles), nil + return types.NewBlockWithHeader(head).WithBody(txs, uncles).WithWithdrawals(body.Withdrawals), nil } // HeaderByHash returns the block header with the given hash. From 9fc34ee3edf48035f45d85475bd0dc9b2e3fa281 Mon Sep 17 00:00:00 2001 From: peter <1674920+peterbitfly@users.noreply.github.com> Date: Tue, 28 Feb 2023 12:32:57 +0100 Subject: [PATCH 2/2] omit empty withdrawals array in json serialization --- ethclient/ethclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 17bdc6ea759b..6f309030bab9 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -105,7 +105,7 @@ type rpcBlock struct { Hash common.Hash `json:"hash"` Transactions []rpcTransaction `json:"transactions"` UncleHashes []common.Hash `json:"uncles"` - Withdrawals []*types.Withdrawal `json:"withdrawals"` + Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` } func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) {