diff --git a/examples/ethereum/client/client.go b/examples/ethereum/client/client.go index a17abca..39c8f84 100644 --- a/examples/ethereum/client/client.go +++ b/examples/ethereum/client/client.go @@ -46,10 +46,10 @@ func (c *EthereumClient) ParseOps( var ops []*RosettaTypes.Operation // Compute fee operations - feeOps := services.FeeOps(tx) + feeOps := services.FeeOps(tx, sdkTypes.Currency) ops = append(ops, feeOps...) - traceOps := services.TraceOps(tx.Trace, len(ops)) + traceOps := services.TraceOps(tx.Trace, len(ops), sdkTypes.Currency) ops = append(ops, traceOps...) return ops, nil diff --git a/mocks/client/graph_ql.go b/mocks/client/graph_ql.go index 40596db..897986a 100644 --- a/mocks/client/graph_ql.go +++ b/mocks/client/graph_ql.go @@ -1,4 +1,4 @@ -// Code generated by mockery v0.0.0-dev. DO NOT EDIT. +// Code generated by mockery v2.33.3. DO NOT EDIT. package client @@ -18,13 +18,16 @@ func (_m *GraphQL) Query(ctx context.Context, input string) (string, error) { ret := _m.Called(ctx, input) var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (string, error)); ok { + return rf(ctx, input) + } if rf, ok := ret.Get(0).(func(context.Context, string) string); ok { r0 = rf(ctx, input) } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(ctx, input) } else { @@ -33,3 +36,17 @@ func (_m *GraphQL) Query(ctx context.Context, input string) (string, error) { return r0, r1 } + +// NewGraphQL creates a new instance of GraphQL. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewGraphQL(t interface { + mock.TestingT + Cleanup(func()) +}) *GraphQL { + mock := &GraphQL{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/client/jsonrpc.go b/mocks/client/jsonrpc.go index dcb314b..9519783 100644 --- a/mocks/client/jsonrpc.go +++ b/mocks/client/jsonrpc.go @@ -1,4 +1,4 @@ -// Code generated by mockery v0.0.0-dev. DO NOT EDIT. +// Code generated by mockery v2.33.3. DO NOT EDIT. package client @@ -49,3 +49,17 @@ func (_m *JSONRPC) CallContext(ctx context.Context, result interface{}, method s func (_m *JSONRPC) Close() { _m.Called() } + +// NewJSONRPC creates a new instance of JSONRPC. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewJSONRPC(t interface { + mock.TestingT + Cleanup(func()) +}) *JSONRPC { + mock := &JSONRPC{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/services/client.go b/mocks/services/client.go index 0b9dd63..28c9a1d 100644 --- a/mocks/services/client.go +++ b/mocks/services/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v0.0.0-dev. DO NOT EDIT. +// Code generated by mockery v2.33.3. DO NOT EDIT. package services @@ -14,6 +14,8 @@ import ( coretypes "github.com/ethereum/go-ethereum/core/types" + ethereum "github.com/ethereum/go-ethereum" + json "encoding/json" mock "github.com/stretchr/testify/mock" @@ -33,6 +35,10 @@ func (_m *Client) Balance(_a0 context.Context, _a1 *types.AccountIdentifier, _a2 ret := _m.Called(_a0, _a1, _a2, _a3) var r0 *types.AccountBalanceResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AccountIdentifier, *types.PartialBlockIdentifier, []*types.Currency) (*types.AccountBalanceResponse, error)); ok { + return rf(_a0, _a1, _a2, _a3) + } if rf, ok := ret.Get(0).(func(context.Context, *types.AccountIdentifier, *types.PartialBlockIdentifier, []*types.Currency) *types.AccountBalanceResponse); ok { r0 = rf(_a0, _a1, _a2, _a3) } else { @@ -41,7 +47,6 @@ func (_m *Client) Balance(_a0 context.Context, _a1 *types.AccountIdentifier, _a2 } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *types.AccountIdentifier, *types.PartialBlockIdentifier, []*types.Currency) error); ok { r1 = rf(_a0, _a1, _a2, _a3) } else { @@ -70,13 +75,16 @@ func (_m *Client) BlockAuthor(ctx context.Context, blockIndex int64) (string, er ret := _m.Called(ctx, blockIndex) var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (string, error)); ok { + return rf(ctx, blockIndex) + } if rf, ok := ret.Get(0).(func(context.Context, int64) string); ok { r0 = rf(ctx, blockIndex) } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { r1 = rf(ctx, blockIndex) } else { @@ -119,11 +127,39 @@ func (_m *Client) CallContext(ctx context.Context, result interface{}, method st return r0 } +// EstimateGas provides a mock function with given fields: ctx, msg +func (_m *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error) { + ret := _m.Called(ctx, msg) + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, ethereum.CallMsg) (uint64, error)); ok { + return rf(ctx, msg) + } + if rf, ok := ret.Get(0).(func(context.Context, ethereum.CallMsg) uint64); ok { + r0 = rf(ctx, msg) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(context.Context, ethereum.CallMsg) error); ok { + r1 = rf(ctx, msg) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetBlockReceipts provides a mock function with given fields: ctx, blockHash, txs, baseFee func (_m *Client) GetBlockReceipts(ctx context.Context, blockHash common.Hash, txs []client.RPCTransaction, baseFee *big.Int) ([]*client.RosettaTxReceipt, error) { ret := _m.Called(ctx, blockHash, txs, baseFee) var r0 []*client.RosettaTxReceipt + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash, []client.RPCTransaction, *big.Int) ([]*client.RosettaTxReceipt, error)); ok { + return rf(ctx, blockHash, txs, baseFee) + } if rf, ok := ret.Get(0).(func(context.Context, common.Hash, []client.RPCTransaction, *big.Int) []*client.RosettaTxReceipt); ok { r0 = rf(ctx, blockHash, txs, baseFee) } else { @@ -132,7 +168,6 @@ func (_m *Client) GetBlockReceipts(ctx context.Context, blockHash common.Hash, t } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, common.Hash, []client.RPCTransaction, *big.Int) error); ok { r1 = rf(ctx, blockHash, txs, baseFee) } else { @@ -147,13 +182,16 @@ func (_m *Client) GetContractCallGasLimit(ctx context.Context, toAddress string, ret := _m.Called(ctx, toAddress, fromAddress, data) var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, []byte) (uint64, error)); ok { + return rf(ctx, toAddress, fromAddress, data) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, []byte) uint64); ok { r0 = rf(ctx, toAddress, fromAddress, data) } else { r0 = ret.Get(0).(uint64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string, []byte) error); ok { r1 = rf(ctx, toAddress, fromAddress, data) } else { @@ -168,6 +206,10 @@ func (_m *Client) GetContractCurrency(addr common.Address, erc20 bool) (*client. ret := _m.Called(addr, erc20) var r0 *client.ContractCurrency + var r1 error + if rf, ok := ret.Get(0).(func(common.Address, bool) (*client.ContractCurrency, error)); ok { + return rf(addr, erc20) + } if rf, ok := ret.Get(0).(func(common.Address, bool) *client.ContractCurrency); ok { r0 = rf(addr, erc20) } else { @@ -176,7 +218,6 @@ func (_m *Client) GetContractCurrency(addr common.Address, erc20 bool) (*client. } } - var r1 error if rf, ok := ret.Get(1).(func(common.Address, bool) error); ok { r1 = rf(addr, erc20) } else { @@ -191,13 +232,16 @@ func (_m *Client) GetErc20TransferGasLimit(ctx context.Context, toAddress string ret := _m.Called(ctx, toAddress, fromAddress, value, currency) var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *big.Int, *types.Currency) (uint64, error)); ok { + return rf(ctx, toAddress, fromAddress, value, currency) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, *big.Int, *types.Currency) uint64); ok { r0 = rf(ctx, toAddress, fromAddress, value, currency) } else { r0 = ret.Get(0).(uint64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string, *big.Int, *types.Currency) error); ok { r1 = rf(ctx, toAddress, fromAddress, value, currency) } else { @@ -212,6 +256,10 @@ func (_m *Client) GetGasPrice(_a0 context.Context, _a1 client.Options) (*big.Int ret := _m.Called(_a0, _a1) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, client.Options) (*big.Int, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, client.Options) *big.Int); ok { r0 = rf(_a0, _a1) } else { @@ -220,7 +268,6 @@ func (_m *Client) GetGasPrice(_a0 context.Context, _a1 client.Options) (*big.Int } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, client.Options) error); ok { r1 = rf(_a0, _a1) } else { @@ -235,6 +282,10 @@ func (_m *Client) GetLoadedTransaction(ctx context.Context, request *types.Block ret := _m.Called(ctx, request) var r0 *client.LoadedTransaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.BlockTransactionRequest) (*client.LoadedTransaction, error)); ok { + return rf(ctx, request) + } if rf, ok := ret.Get(0).(func(context.Context, *types.BlockTransactionRequest) *client.LoadedTransaction); ok { r0 = rf(ctx, request) } else { @@ -243,7 +294,6 @@ func (_m *Client) GetLoadedTransaction(ctx context.Context, request *types.Block } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *types.BlockTransactionRequest) error); ok { r1 = rf(ctx, request) } else { @@ -258,13 +308,16 @@ func (_m *Client) GetNativeTransferGasLimit(ctx context.Context, toAddress strin ret := _m.Called(ctx, toAddress, fromAddress, value) var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *big.Int) (uint64, error)); ok { + return rf(ctx, toAddress, fromAddress, value) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, *big.Int) uint64); ok { r0 = rf(ctx, toAddress, fromAddress, value) } else { r0 = ret.Get(0).(uint64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string, *big.Int) error); ok { r1 = rf(ctx, toAddress, fromAddress, value) } else { @@ -279,13 +332,16 @@ func (_m *Client) GetNonce(_a0 context.Context, _a1 client.Options) (uint64, err ret := _m.Called(_a0, _a1) var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, client.Options) (uint64, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(context.Context, client.Options) uint64); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Get(0).(uint64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, client.Options) error); ok { r1 = rf(_a0, _a1) } else { @@ -314,6 +370,10 @@ func (_m *Client) GetTransactionReceipt(ctx context.Context, tx *client.LoadedTr ret := _m.Called(ctx, tx) var r0 *client.RosettaTxReceipt + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *client.LoadedTransaction) (*client.RosettaTxReceipt, error)); ok { + return rf(ctx, tx) + } if rf, ok := ret.Get(0).(func(context.Context, *client.LoadedTransaction) *client.RosettaTxReceipt); ok { r0 = rf(ctx, tx) } else { @@ -322,7 +382,6 @@ func (_m *Client) GetTransactionReceipt(ctx context.Context, tx *client.LoadedTr } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *client.LoadedTransaction) error); ok { r1 = rf(ctx, tx) } else { @@ -337,6 +396,10 @@ func (_m *Client) GetUncles(ctx context.Context, head *coretypes.Header, body *c ret := _m.Called(ctx, head, body) var r0 []*coretypes.Header + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *coretypes.Header, *client.RPCBlock) ([]*coretypes.Header, error)); ok { + return rf(ctx, head, body) + } if rf, ok := ret.Get(0).(func(context.Context, *coretypes.Header, *client.RPCBlock) []*coretypes.Header); ok { r0 = rf(ctx, head, body) } else { @@ -345,7 +408,6 @@ func (_m *Client) GetUncles(ctx context.Context, head *coretypes.Header, body *c } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *coretypes.Header, *client.RPCBlock) error); ok { r1 = rf(ctx, head, body) } else { @@ -360,6 +422,10 @@ func (_m *Client) ParseOps(tx *client.LoadedTransaction) ([]*types.Operation, er ret := _m.Called(tx) var r0 []*types.Operation + var r1 error + if rf, ok := ret.Get(0).(func(*client.LoadedTransaction) ([]*types.Operation, error)); ok { + return rf(tx) + } if rf, ok := ret.Get(0).(func(*client.LoadedTransaction) []*types.Operation); ok { r0 = rf(tx) } else { @@ -368,7 +434,6 @@ func (_m *Client) ParseOps(tx *client.LoadedTransaction) ([]*types.Operation, er } } - var r1 error if rf, ok := ret.Get(1).(func(*client.LoadedTransaction) error); ok { r1 = rf(tx) } else { @@ -383,6 +448,10 @@ func (_m *Client) PopulateCrossChainTransactions(_a0 *coretypes.Block, _a1 []*cl ret := _m.Called(_a0, _a1) var r0 []*types.Transaction + var r1 error + if rf, ok := ret.Get(0).(func(*coretypes.Block, []*client.LoadedTransaction) ([]*types.Transaction, error)); ok { + return rf(_a0, _a1) + } if rf, ok := ret.Get(0).(func(*coretypes.Block, []*client.LoadedTransaction) []*types.Transaction); ok { r0 = rf(_a0, _a1) } else { @@ -391,7 +460,6 @@ func (_m *Client) PopulateCrossChainTransactions(_a0 *coretypes.Block, _a1 []*cl } } - var r1 error if rf, ok := ret.Get(1).(func(*coretypes.Block, []*client.LoadedTransaction) error); ok { r1 = rf(_a0, _a1) } else { @@ -406,6 +474,13 @@ func (_m *Client) Status(_a0 context.Context) (*types.BlockIdentifier, int64, *t ret := _m.Called(_a0) var r0 *types.BlockIdentifier + var r1 int64 + var r2 *types.SyncStatus + var r3 []*types.Peer + var r4 error + if rf, ok := ret.Get(0).(func(context.Context) (*types.BlockIdentifier, int64, *types.SyncStatus, []*types.Peer, error)); ok { + return rf(_a0) + } if rf, ok := ret.Get(0).(func(context.Context) *types.BlockIdentifier); ok { r0 = rf(_a0) } else { @@ -414,14 +489,12 @@ func (_m *Client) Status(_a0 context.Context) (*types.BlockIdentifier, int64, *t } } - var r1 int64 if rf, ok := ret.Get(1).(func(context.Context) int64); ok { r1 = rf(_a0) } else { r1 = ret.Get(1).(int64) } - var r2 *types.SyncStatus if rf, ok := ret.Get(2).(func(context.Context) *types.SyncStatus); ok { r2 = rf(_a0) } else { @@ -430,7 +503,6 @@ func (_m *Client) Status(_a0 context.Context) (*types.BlockIdentifier, int64, *t } } - var r3 []*types.Peer if rf, ok := ret.Get(3).(func(context.Context) []*types.Peer); ok { r3 = rf(_a0) } else { @@ -439,7 +511,6 @@ func (_m *Client) Status(_a0 context.Context) (*types.BlockIdentifier, int64, *t } } - var r4 error if rf, ok := ret.Get(4).(func(context.Context) error); ok { r4 = rf(_a0) } else { @@ -468,6 +539,10 @@ func (_m *Client) TraceBlockByHash(_a0 context.Context, _a1 common.Hash, _a2 []c ret := _m.Called(_a0, _a1, _a2) var r0 map[string][]*client.FlatCall + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash, []client.RPCTransaction) (map[string][]*client.FlatCall, error)); ok { + return rf(_a0, _a1, _a2) + } if rf, ok := ret.Get(0).(func(context.Context, common.Hash, []client.RPCTransaction) map[string][]*client.FlatCall); ok { r0 = rf(_a0, _a1, _a2) } else { @@ -476,7 +551,6 @@ func (_m *Client) TraceBlockByHash(_a0 context.Context, _a1 common.Hash, _a2 []c } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, common.Hash, []client.RPCTransaction) error); ok { r1 = rf(_a0, _a1, _a2) } else { @@ -491,6 +565,10 @@ func (_m *Client) TraceReplayBlockTransactions(ctx context.Context, hsh string) ret := _m.Called(ctx, hsh) var r0 map[string][]*client.FlatCall + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (map[string][]*client.FlatCall, error)); ok { + return rf(ctx, hsh) + } if rf, ok := ret.Get(0).(func(context.Context, string) map[string][]*client.FlatCall); ok { r0 = rf(ctx, hsh) } else { @@ -499,7 +577,6 @@ func (_m *Client) TraceReplayBlockTransactions(ctx context.Context, hsh string) } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(ctx, hsh) } else { @@ -514,6 +591,11 @@ func (_m *Client) TraceReplayTransaction(ctx context.Context, hsh string) (json. ret := _m.Called(ctx, hsh) var r0 json.RawMessage + var r1 []*client.FlatCall + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (json.RawMessage, []*client.FlatCall, error)); ok { + return rf(ctx, hsh) + } if rf, ok := ret.Get(0).(func(context.Context, string) json.RawMessage); ok { r0 = rf(ctx, hsh) } else { @@ -522,7 +604,6 @@ func (_m *Client) TraceReplayTransaction(ctx context.Context, hsh string) (json. } } - var r1 []*client.FlatCall if rf, ok := ret.Get(1).(func(context.Context, string) []*client.FlatCall); ok { r1 = rf(ctx, hsh) } else { @@ -531,7 +612,6 @@ func (_m *Client) TraceReplayTransaction(ctx context.Context, hsh string) (json. } } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { r2 = rf(ctx, hsh) } else { @@ -546,6 +626,11 @@ func (_m *Client) TraceTransaction(ctx context.Context, hash common.Hash) (json. ret := _m.Called(ctx, hash) var r0 json.RawMessage + var r1 []*client.FlatCall + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash) (json.RawMessage, []*client.FlatCall, error)); ok { + return rf(ctx, hash) + } if rf, ok := ret.Get(0).(func(context.Context, common.Hash) json.RawMessage); ok { r0 = rf(ctx, hash) } else { @@ -554,7 +639,6 @@ func (_m *Client) TraceTransaction(ctx context.Context, hash common.Hash) (json. } } - var r1 []*client.FlatCall if rf, ok := ret.Get(1).(func(context.Context, common.Hash) []*client.FlatCall); ok { r1 = rf(ctx, hash) } else { @@ -563,7 +647,6 @@ func (_m *Client) TraceTransaction(ctx context.Context, hash common.Hash) (json. } } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, common.Hash) error); ok { r2 = rf(ctx, hash) } else { @@ -572,3 +655,17 @@ func (_m *Client) TraceTransaction(ctx context.Context, hash common.Hash) (json. return r0, r1, r2 } + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClient(t interface { + mock.TestingT + Cleanup(func()) +}) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/services/construction/types.go b/services/construction/types.go index 17c3e96..2e4662b 100644 --- a/services/construction/types.go +++ b/services/construction/types.go @@ -22,6 +22,7 @@ import ( evmClient "github.com/coinbase/rosetta-geth-sdk/client" "github.com/coinbase/rosetta-geth-sdk/configuration" RosettaTypes "github.com/coinbase/rosetta-sdk-go/types" + Eth "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" EthTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" @@ -181,4 +182,10 @@ type Client interface { ParseOps( tx *evmClient.LoadedTransaction, ) ([]*RosettaTypes.Operation, error) + + // EstimateGas tries to estimate the gas needed to execute a specific transaction based on + // the current pending state of the backend blockchain. There is no guarantee that this is + // the true gas limit requirement as other transactions may be added or removed by miners, + // but it should provide a basis for setting a reasonable default. + EstimateGas(ctx context.Context, msg Eth.CallMsg) (uint64, error) } diff --git a/services/mapper.go b/services/mapper.go index ede8e9f..fcd14c6 100644 --- a/services/mapper.go +++ b/services/mapper.go @@ -130,7 +130,7 @@ func TransferOps(tx *evmClient.LoadedTransaction, startIndex int) []*RosettaType return ops } -func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation { +func FeeOps(tx *evmClient.LoadedTransaction, native_currency *RosettaTypes.Currency) []*RosettaTypes.Operation { var minerEarnedAmount *big.Int if tx.FeeBurned == nil { minerEarnedAmount = tx.FeeAmount @@ -157,7 +157,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation { Account: &RosettaTypes.AccountIdentifier{ Address: evmClient.MustChecksum(tx.From.String()), }, - Amount: evmClient.Amount(new(big.Int).Neg(minerEarnedAmount), sdkTypes.Currency), + Amount: evmClient.Amount(new(big.Int).Neg(minerEarnedAmount), native_currency), }, { @@ -174,7 +174,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation { Account: &RosettaTypes.AccountIdentifier{ Address: evmClient.MustChecksum(feeRewarder), }, - Amount: evmClient.Amount(minerEarnedAmount, sdkTypes.Currency), + Amount: evmClient.Amount(minerEarnedAmount, native_currency), }, } @@ -184,12 +184,12 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation { burntOp := &RosettaTypes.Operation{ OperationIdentifier: &RosettaTypes.OperationIdentifier{ - Index: 0, // nolint:gomnd + Index: 2, // nolint:gomnd }, Type: sdkTypes.FeeOpType, Status: RosettaTypes.String(sdkTypes.SuccessStatus), Account: evmClient.Account(tx.From), - Amount: evmClient.Amount(new(big.Int).Neg(tx.FeeBurned), sdkTypes.Currency), + Amount: evmClient.Amount(new(big.Int).Neg(tx.FeeBurned), native_currency), } ops = append(ops, burntOp) @@ -203,6 +203,7 @@ func FeeOps(tx *evmClient.LoadedTransaction) []*RosettaTypes.Operation { func TraceOps( calls []*evmClient.FlatCall, startIndex int, + native_currency *RosettaTypes.Currency, ) []*RosettaTypes.Operation { // nolint: gocognit var ops []*RosettaTypes.Operation if len(calls) == 0 { @@ -250,7 +251,7 @@ func TraceOps( }, Amount: &RosettaTypes.Amount{ Value: new(big.Int).Neg(trace.Value).String(), - Currency: sdkTypes.Currency, + Currency: native_currency, }, Metadata: metadata, } @@ -311,7 +312,7 @@ func TraceOps( }, Amount: &RosettaTypes.Amount{ Value: trace.Value.String(), - Currency: sdkTypes.Currency, + Currency: native_currency, }, Metadata: metadata, } @@ -355,7 +356,7 @@ func TraceOps( }, Amount: &RosettaTypes.Amount{ Value: new(big.Int).Neg(val).String(), - Currency: sdkTypes.Currency, + Currency: native_currency, }, }) }