Skip to content

Commit 51b32cc

Browse files
internal/ethapi: merge CallArgs and SendTxArgs (ethereum#22718)
There are two transaction parameter structures defined in the codebase, although for different purposes. But most of the parameters are shared. So it's nice to reduce the code duplication by merging them together. Co-authored-by: Martin Holst Swende <martin@swende.se>
1 parent 836c647 commit 51b32cc

File tree

5 files changed

+236
-223
lines changed

5 files changed

+236
-223
lines changed

eth/tracers/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
730730
// created during the execution of EVM if the given transaction was added on
731731
// top of the provided block and returns them as a JSON object.
732732
// You can provide -2 as a block number to trace on top of the pending block.
733-
func (api *API) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
733+
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
734734
// Try to retrieve the specified block
735735
var (
736736
err error

eth/tracers/api_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ func TestTraceCall(t *testing.T) {
198198

199199
var testSuite = []struct {
200200
blockNumber rpc.BlockNumber
201-
call ethapi.CallArgs
201+
call ethapi.TransactionArgs
202202
config *TraceCallConfig
203203
expectErr error
204204
expect interface{}
205205
}{
206206
// Standard JSON trace upon the genesis, plain transfer.
207207
{
208208
blockNumber: rpc.BlockNumber(0),
209-
call: ethapi.CallArgs{
209+
call: ethapi.TransactionArgs{
210210
From: &accounts[0].addr,
211211
To: &accounts[1].addr,
212212
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -223,7 +223,7 @@ func TestTraceCall(t *testing.T) {
223223
// Standard JSON trace upon the head, plain transfer.
224224
{
225225
blockNumber: rpc.BlockNumber(genBlocks),
226-
call: ethapi.CallArgs{
226+
call: ethapi.TransactionArgs{
227227
From: &accounts[0].addr,
228228
To: &accounts[1].addr,
229229
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -240,7 +240,7 @@ func TestTraceCall(t *testing.T) {
240240
// Standard JSON trace upon the non-existent block, error expects
241241
{
242242
blockNumber: rpc.BlockNumber(genBlocks + 1),
243-
call: ethapi.CallArgs{
243+
call: ethapi.TransactionArgs{
244244
From: &accounts[0].addr,
245245
To: &accounts[1].addr,
246246
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -252,7 +252,7 @@ func TestTraceCall(t *testing.T) {
252252
// Standard JSON trace upon the latest block
253253
{
254254
blockNumber: rpc.LatestBlockNumber,
255-
call: ethapi.CallArgs{
255+
call: ethapi.TransactionArgs{
256256
From: &accounts[0].addr,
257257
To: &accounts[1].addr,
258258
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -269,7 +269,7 @@ func TestTraceCall(t *testing.T) {
269269
// Standard JSON trace upon the pending block
270270
{
271271
blockNumber: rpc.PendingBlockNumber,
272-
call: ethapi.CallArgs{
272+
call: ethapi.TransactionArgs{
273273
From: &accounts[0].addr,
274274
To: &accounts[1].addr,
275275
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -329,15 +329,15 @@ func TestOverridenTraceCall(t *testing.T) {
329329

330330
var testSuite = []struct {
331331
blockNumber rpc.BlockNumber
332-
call ethapi.CallArgs
332+
call ethapi.TransactionArgs
333333
config *TraceCallConfig
334334
expectErr error
335335
expect *callTrace
336336
}{
337337
// Succcessful call with state overriding
338338
{
339339
blockNumber: rpc.PendingBlockNumber,
340-
call: ethapi.CallArgs{
340+
call: ethapi.TransactionArgs{
341341
From: &randomAccounts[0].addr,
342342
To: &randomAccounts[1].addr,
343343
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -361,7 +361,7 @@ func TestOverridenTraceCall(t *testing.T) {
361361
// Invalid call without state overriding
362362
{
363363
blockNumber: rpc.PendingBlockNumber,
364-
call: ethapi.CallArgs{
364+
call: ethapi.TransactionArgs{
365365
From: &randomAccounts[0].addr,
366366
To: &randomAccounts[1].addr,
367367
Value: (*hexutil.Big)(big.NewInt(1000)),
@@ -390,7 +390,7 @@ func TestOverridenTraceCall(t *testing.T) {
390390
// }
391391
{
392392
blockNumber: rpc.PendingBlockNumber,
393-
call: ethapi.CallArgs{
393+
call: ethapi.TransactionArgs{
394394
From: &randomAccounts[0].addr,
395395
To: &randomAccounts[2].addr,
396396
Data: newRPCBytes(common.Hex2Bytes("8381f58a")), // call number()

graphql/graphql.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func (c *CallResult) Status() Long {
862862
}
863863

864864
func (b *Block) Call(ctx context.Context, args struct {
865-
Data ethapi.CallArgs
865+
Data ethapi.TransactionArgs
866866
}) (*CallResult, error) {
867867
if b.numberOrHash == nil {
868868
_, err := b.resolve(ctx)
@@ -887,7 +887,7 @@ func (b *Block) Call(ctx context.Context, args struct {
887887
}
888888

889889
func (b *Block) EstimateGas(ctx context.Context, args struct {
890-
Data ethapi.CallArgs
890+
Data ethapi.TransactionArgs
891891
}) (Long, error) {
892892
if b.numberOrHash == nil {
893893
_, err := b.resolveHeader(ctx)
@@ -937,7 +937,7 @@ func (p *Pending) Account(ctx context.Context, args struct {
937937
}
938938

939939
func (p *Pending) Call(ctx context.Context, args struct {
940-
Data ethapi.CallArgs
940+
Data ethapi.TransactionArgs
941941
}) (*CallResult, error) {
942942
pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
943943
result, err := ethapi.DoCall(ctx, p.backend, args.Data, pendingBlockNr, nil, vm.Config{}, 5*time.Second, p.backend.RPCGasCap())
@@ -957,7 +957,7 @@ func (p *Pending) Call(ctx context.Context, args struct {
957957
}
958958

959959
func (p *Pending) EstimateGas(ctx context.Context, args struct {
960-
Data ethapi.CallArgs
960+
Data ethapi.TransactionArgs
961961
}) (Long, error) {
962962
pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
963963
gas, err := ethapi.DoEstimateGas(ctx, p.backend, args.Data, pendingBlockNr, p.backend.RPCGasCap())

0 commit comments

Comments
 (0)