From 9d085ef65eff9cccf8b3eb655bbef86c270243aa Mon Sep 17 00:00:00 2001 From: Arpit Temani Date: Wed, 11 Aug 2021 14:00:52 +0530 Subject: [PATCH] 2 function calls --- ethclient/ethclient.go | 12 ++++++++++-- internal/jsre/deps/web3.js | 13 +++++++++---- internal/web3ext/web3ext.go | 6 ++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index cab25f88c8..73c00de86e 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -70,8 +70,7 @@ func (ec *Client) ChainID(ctx context.Context) (*big.Int, error) { return (*big.Int)(&result), err } -// TransactionInBlock returns a single transaction at index in the given block. -func (ec *Client) TransactionRecipientsInBlock(ctx context.Context, number *big.Int) ([]*types.Receipt, error) { +func (ec *Client) TransactionReceiptsInBlockByBlockNumber(ctx context.Context, number *big.Int) ([]*types.Receipt, error) { var rs []*types.Receipt err := ec.c.CallContext(ctx, &rs, "eth_getTransactionReceiptsByBlockNumber", toBlockNumArg(number)) if err != nil { @@ -80,6 +79,15 @@ func (ec *Client) TransactionRecipientsInBlock(ctx context.Context, number *big. return rs, err } +func (ec *Client) TransactionReceiptsInBlockByBlockHash(ctx context.Context, hash common.Hash) ([]*types.Receipt, error) { + var rs []*types.Receipt + err := ec.c.CallContext(ctx, &rs, "eth_getTransactionReceiptsByBlockHash", hash) + if err != nil { + return nil, err + } + return rs, err +} + // BlockByHash returns the given full block. // // Note that loading full blocks requires two requests. Use HeaderByHash diff --git a/internal/jsre/deps/web3.js b/internal/jsre/deps/web3.js index bd3e54067c..ed1d16f608 100644 --- a/internal/jsre/deps/web3.js +++ b/internal/jsre/deps/web3.js @@ -5214,6 +5214,10 @@ var transactionFromBlockCall = function (args) { return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex'; }; +var transactionReceiptsFromBlockCall = function (args) { + return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionReceiptsByBlockHash' : 'eth_getTransactionReceiptsByBlockNumber'; +}; + var uncleCall = function (args) { return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex'; }; @@ -5393,9 +5397,9 @@ var methods = function () { inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter] }); - var getTransactionReceiptsByBlockNumber = new Method({ - name: 'getTransactionReceiptsByBlockNumber', - call: 'eth_getTransactionReceiptsByBlockNumber', + var transactionReceiptsByBlock = new Method({ + name: 'getTransactionReceiptsByBlock', + call: transactionReceiptsFromBlockCall, params: 1, outputFormatter: formatters.outputTransactionReceiptFormatter }); @@ -5461,7 +5465,8 @@ var methods = function () { compileLLL, compileSerpent, submitWork, - getWork + getWork, + transactionReceiptsByBlock ]; }; diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 7776c20b9d..10ee49c81e 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -495,8 +495,10 @@ web3._extend({ property: 'eth', methods: [ new web3._extend.Method({ - name: 'getTransactionReceiptsByBlockNumber', - call: 'eth_getTransactionReceiptsByBlockNumber', + name: 'getTransactionReceiptsByBlock', + call: function(args) { + return (web3._extend.utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionReceiptsByBlockHash' : 'eth_getTransactionReceiptsByBlockNumber'; + }, params: 1, }), new web3._extend.Method({