From e673c7097059410d4a67e1c51097d9bd5b2d357c Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Wed, 28 Jan 2026 11:08:29 -0500 Subject: [PATCH] feat: expose ethapi.NewRPCTransaction and ethapi.NewRPCPendingTransaction (#260) --- internal/ethapi/api.libevm.go | 30 ++++++++++++++++++++++++++++++ libevm/ethapi/ethapi.go | 19 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 internal/ethapi/api.libevm.go diff --git a/internal/ethapi/api.libevm.go b/internal/ethapi/api.libevm.go new file mode 100644 index 0000000000..36be0d099a --- /dev/null +++ b/internal/ethapi/api.libevm.go @@ -0,0 +1,30 @@ +// Copyright 2026 the libevm authors. +// +// The libevm additions to go-ethereum are free software: you can redistribute +// them and/or modify them under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The libevm additions are distributed in the hope that they will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see +// . + +package ethapi + +import ( + "math/big" + + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/params" +) + +// NewRPCTransaction exports the [newRPCTransaction] function. +func NewRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction { + return newRPCTransaction(tx, blockHash, blockNumber, blockTime, index, baseFee, config) +} diff --git a/libevm/ethapi/ethapi.go b/libevm/ethapi/ethapi.go index 5d1ed7aabb..99876d8ecf 100644 --- a/libevm/ethapi/ethapi.go +++ b/libevm/ethapi/ethapi.go @@ -17,7 +17,14 @@ // Package ethapi exposes the internal ethapi package. package ethapi -import "github.com/ava-labs/libevm/internal/ethapi" +import ( + "math/big" + + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/internal/ethapi" + "github.com/ava-labs/libevm/params" +) // Type aliases required by constructors. type ( @@ -69,3 +76,13 @@ func NewTxPoolAPI(b Backend) *TxPoolAPI { func NewDebugAPI(b Backend) *DebugAPI { return ethapi.NewDebugAPI(b) } + +// NewRPCPendingTransaction is identical to [ethapi.NewRPCPendingTransaction]. +func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction { + return ethapi.NewRPCPendingTransaction(tx, current, config) +} + +// NewRPCTransaction is identical to [ethapi.NewRPCTransaction]. +func NewRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction { + return ethapi.NewRPCTransaction(tx, blockHash, blockNumber, blockTime, index, baseFee, config) +}