diff --git a/client/client.go b/client/client.go index 70f5f33..c8ded0c 100644 --- a/client/client.go +++ b/client/client.go @@ -837,14 +837,16 @@ func (ec *SDKClient) GetContractCallGasLimit( ctx context.Context, toAddress string, fromAddress string, + value *big.Int, data []byte, ) (uint64, error) { // ToAddress for contract address is the contract address contractAddress := common.HexToAddress(toAddress) gasLimit, err := ec.EstimateGas(ctx, goEthereum.CallMsg{ - From: common.HexToAddress(fromAddress), - To: &contractAddress, - Data: data, + From: common.HexToAddress(fromAddress), + To: &contractAddress, + Value: value, + Data: data, }) if err != nil { return 0, err diff --git a/mocks/client/graph_ql.go b/mocks/client/graph_ql.go index a5c630f..40596db 100644 --- a/mocks/client/graph_ql.go +++ b/mocks/client/graph_ql.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.31.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package client @@ -18,16 +18,13 @@ 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 { @@ -36,17 +33,3 @@ 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 d1bd3c2..dcb314b 100644 --- a/mocks/client/jsonrpc.go +++ b/mocks/client/jsonrpc.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.31.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package client @@ -49,17 +49,3 @@ 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 b69980c..a0c313d 100644 --- a/mocks/services/client.go +++ b/mocks/services/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.31.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package services @@ -33,10 +33,6 @@ 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 { @@ -45,6 +41,7 @@ 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 { @@ -73,16 +70,13 @@ 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 { @@ -130,10 +124,6 @@ func (_m *Client) GetBaseFee(ctx context.Context) (*big.Int, error) { ret := _m.Called(ctx) var r0 *big.Int - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*big.Int, error)); ok { - return rf(ctx) - } if rf, ok := ret.Get(0).(func(context.Context) *big.Int); ok { r0 = rf(ctx) } else { @@ -142,6 +132,7 @@ func (_m *Client) GetBaseFee(ctx context.Context) (*big.Int, error) { } } + var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -156,10 +147,6 @@ func (_m *Client) GetBlockReceipts(ctx context.Context, blockHash common.Hash, t 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 { @@ -168,6 +155,7 @@ 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 { @@ -177,23 +165,20 @@ func (_m *Client) GetBlockReceipts(ctx context.Context, blockHash common.Hash, t return r0, r1 } -// GetContractCallGasLimit provides a mock function with given fields: ctx, toAddress, fromAddress, data -func (_m *Client) GetContractCallGasLimit(ctx context.Context, toAddress string, fromAddress string, data []byte) (uint64, error) { - ret := _m.Called(ctx, toAddress, fromAddress, data) +// GetContractCallGasLimit provides a mock function with given fields: ctx, toAddress, fromAddress, value, data +func (_m *Client) GetContractCallGasLimit(ctx context.Context, toAddress string, fromAddress string, value *big.Int, data []byte) (uint64, error) { + ret := _m.Called(ctx, toAddress, fromAddress, value, 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) + if rf, ok := ret.Get(0).(func(context.Context, string, string, *big.Int, []byte) uint64); ok { + r0 = rf(ctx, toAddress, fromAddress, value, data) } else { r0 = ret.Get(0).(uint64) } - if rf, ok := ret.Get(1).(func(context.Context, string, string, []byte) error); ok { - r1 = rf(ctx, toAddress, fromAddress, data) + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, string, *big.Int, []byte) error); ok { + r1 = rf(ctx, toAddress, fromAddress, value, data) } else { r1 = ret.Error(1) } @@ -206,10 +191,6 @@ 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 { @@ -218,6 +199,7 @@ 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 { @@ -232,16 +214,13 @@ 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 { @@ -256,10 +235,6 @@ func (_m *Client) GetGasFeeCap(_a0 context.Context, _a1 client.Options, _a2 *big ret := _m.Called(_a0, _a1, _a2) var r0 *big.Int - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, client.Options, *big.Int) (*big.Int, error)); ok { - return rf(_a0, _a1, _a2) - } if rf, ok := ret.Get(0).(func(context.Context, client.Options, *big.Int) *big.Int); ok { r0 = rf(_a0, _a1, _a2) } else { @@ -268,6 +243,7 @@ func (_m *Client) GetGasFeeCap(_a0 context.Context, _a1 client.Options, _a2 *big } } + var r1 error if rf, ok := ret.Get(1).(func(context.Context, client.Options, *big.Int) error); ok { r1 = rf(_a0, _a1, _a2) } else { @@ -282,10 +258,6 @@ 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 { @@ -294,6 +266,7 @@ 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 { @@ -308,10 +281,6 @@ func (_m *Client) GetGasTipCap(_a0 context.Context, _a1 client.Options) (*big.In 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 { @@ -320,6 +289,7 @@ func (_m *Client) GetGasTipCap(_a0 context.Context, _a1 client.Options) (*big.In } } + var r1 error if rf, ok := ret.Get(1).(func(context.Context, client.Options) error); ok { r1 = rf(_a0, _a1) } else { @@ -334,10 +304,6 @@ func (_m *Client) GetL1DataFee(ctx context.Context, ethTxBytes []byte) (*big.Int ret := _m.Called(ctx, ethTxBytes) var r0 *big.Int - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []byte) (*big.Int, error)); ok { - return rf(ctx, ethTxBytes) - } if rf, ok := ret.Get(0).(func(context.Context, []byte) *big.Int); ok { r0 = rf(ctx, ethTxBytes) } else { @@ -346,6 +312,7 @@ func (_m *Client) GetL1DataFee(ctx context.Context, ethTxBytes []byte) (*big.Int } } + var r1 error if rf, ok := ret.Get(1).(func(context.Context, []byte) error); ok { r1 = rf(ctx, ethTxBytes) } else { @@ -360,10 +327,6 @@ 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 { @@ -372,6 +335,7 @@ 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 { @@ -386,16 +350,13 @@ 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 { @@ -410,16 +371,13 @@ 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 { @@ -448,10 +406,6 @@ 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 { @@ -460,6 +414,7 @@ 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 { @@ -474,10 +429,6 @@ 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 { @@ -486,6 +437,7 @@ 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 { @@ -500,10 +452,6 @@ 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 { @@ -512,6 +460,7 @@ 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 { @@ -526,10 +475,6 @@ 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 { @@ -538,6 +483,7 @@ 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 { @@ -552,13 +498,6 @@ 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 { @@ -567,12 +506,14 @@ 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 { @@ -581,6 +522,7 @@ 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 { @@ -589,6 +531,7 @@ 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 { @@ -617,10 +560,6 @@ 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 { @@ -629,6 +568,7 @@ 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 { @@ -643,10 +583,6 @@ 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 { @@ -655,6 +591,7 @@ 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 { @@ -669,11 +606,6 @@ 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 { @@ -682,6 +614,7 @@ 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 { @@ -690,6 +623,7 @@ 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 { @@ -704,11 +638,6 @@ 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 { @@ -717,6 +646,7 @@ 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 { @@ -725,6 +655,7 @@ 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 { @@ -733,17 +664,3 @@ 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/metadata.go b/services/construction/metadata.go index 567fb59..0e1349c 100644 --- a/services/construction/metadata.go +++ b/services/construction/metadata.go @@ -95,8 +95,11 @@ func (s APIService) ConstructionMetadata( //nolint return nil, sdkTypes.WrapErr(sdkTypes.ErrInvalidInput, err) } + value := new(big.Int) + value.SetString(input.Value, 10) // nolint:gomnd + // Override the destination address to be the contract address - gasLimit, err = s.client.GetContractCallGasLimit(ctx, contractAddress, input.From, contractData) + gasLimit, err = s.client.GetContractCallGasLimit(ctx, contractAddress, input.From, value, contractData) if err != nil { return nil, sdkTypes.WrapErr(sdkTypes.ErrERC20GasLimitError, err) } diff --git a/services/construction/metadata_test.go b/services/construction/metadata_test.go index ac897a3..fa55871 100644 --- a/services/construction/metadata_test.go +++ b/services/construction/metadata_test.go @@ -33,7 +33,7 @@ import ( var ( transferValue = "1" - transferContractValue = "0" + transferContractValue = "2" transferGasPrice = uint64(5000000000) transferGasLimit = uint64(21000) transferGasTipCap = uint64(100000000) @@ -83,7 +83,9 @@ func TestMetadata(t *testing.T) { Return(big.NewInt(int64(transferGasPrice)), nil) contractData, _ := hexutil.Decode(metadataGenericData) - client.On("GetContractCallGasLimit", ctx, tokenContractAddress, testingFromAddress, contractData). + testValue := new(big.Int) + testValue.SetString(transferContractValue, 10) + client.On("GetContractCallGasLimit", ctx, tokenContractAddress, testingFromAddress, testValue, contractData). Return(transferGasLimitContract, nil) client.On("GetGasTipCap", ctx, mock.Anything). diff --git a/services/construction/types.go b/services/construction/types.go index d079a97..7395970 100644 --- a/services/construction/types.go +++ b/services/construction/types.go @@ -186,6 +186,7 @@ type Client interface { ctx context.Context, toAddress string, fromAddress string, + value *big.Int, data []byte, ) (uint64, error)