From ed088cdf21552ae18072f9f45aa985b7550e4f84 Mon Sep 17 00:00:00 2001 From: i-norden Date: Wed, 4 Jan 2023 15:48:17 -0600 Subject: [PATCH] eth_feeHistory fallthrough endpoint --- pkg/eth/api.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/eth/api.go b/pkg/eth/api.go index c00e385e..44a9763b 100644 --- a/pkg/eth/api.go +++ b/pkg/eth/api.go @@ -503,6 +503,25 @@ func (pea *PublicEthAPI) CreateAccessList(ctx context.Context, args TransactionA return nil, RequiresProxyError{method: "eth_createAccessList"} } +type feeHistoryResult struct { + OldestBlock *hexutil.Big `json:"oldestBlock"` + Reward [][]*hexutil.Big `json:"reward,omitempty"` + BaseFee []*hexutil.Big `json:"baseFeePerGas,omitempty"` + GasUsedRatio []float64 `json:"gasUsedRatio"` +} + +// FeeHistory returns the fee market history. +func (pea *PublicEthAPI) FeeHistory(ctx context.Context, blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) { + if pea.proxyOnError { + var res *feeHistoryResult + if err := pea.rpc.CallContext(ctx, &res, "eth_feeHistory", blockCount, lastBlock, rewardPercentiles); err != nil { + return nil, err + } + return res, nil + } + return nil, RequiresProxyError{method: "eth_feeHistory"} +} + /* Receipts and Logs