Skip to content

Commit

Permalink
Add eth_getAccountPendingTransactions rpc method (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanliqun authored Nov 8, 2024
1 parent 5d28757 commit 5f8cd09
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/mcuadros/go-defaults v1.2.0
github.com/montanaflynn/stats v0.6.6
github.com/openweb3/go-rpc-provider v0.3.3
github.com/openweb3/web3go v0.2.11
github.com/openweb3/web3go v0.2.12-0.20241027043301-adf3a873700d
github.com/pkg/errors v0.9.1
github.com/rs/cors v1.7.0
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ github.com/openweb3/go-rpc-provider v0.3.3 h1:aNelA69cJ9pk9lo7Z8ukYz/qPyZUGNU3IF
github.com/openweb3/go-rpc-provider v0.3.3/go.mod h1:jUDuGZDP5eoN3iS7ZG3qg/aRAzL9ncUMkJ/R85X4s+w=
github.com/openweb3/go-sdk-common v0.0.0-20240627072707-f78f0155ab34 h1:qLelmviLGRleOB6A8ssljatvs6K6n1BMd3PNeozNq/E=
github.com/openweb3/go-sdk-common v0.0.0-20240627072707-f78f0155ab34/go.mod h1:YMfzbYeq1G7s6nRjcFAgYSA/Uqy5+Aa1UvL0Rbnc290=
github.com/openweb3/web3go v0.2.11 h1:+AYBAgApgpQKfuiIjdckaInkHLZuhmJRw5HS6QFEvwc=
github.com/openweb3/web3go v0.2.11/go.mod h1:SHcfq7LpXx4y2IH63QrqSXSkU0DTL981lDHtMR30+aw=
github.com/openweb3/web3go v0.2.12-0.20241027043301-adf3a873700d h1:vZBvzBmJa4Lf9DIIcdW+zKGZHp9B5PndgRxgpIQewmE=
github.com/openweb3/web3go v0.2.12-0.20241027043301-adf3a873700d/go.mod h1:SHcfq7LpXx4y2IH63QrqSXSkU0DTL981lDHtMR30+aw=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
Expand Down
8 changes: 8 additions & 0 deletions rpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ func (api *ethAPI) GetTransactionReceipt(ctx context.Context, txHash common.Hash
return receipt, err
}

// Returns pending transactions for a given account.
func (api *ethAPI) GetAccountPendingTransactions(
ctx context.Context, addr common.Address, startNonce *hexutil.Big, limit *hexutil.Uint64,
) (*web3Types.AccountPendingTransactions, error) {
w3c := GetEthClientFromContext(ctx)
return w3c.Eth.AccountPendingTransactions(addr, startNonce.ToInt(), (*uint64)(limit))
}

// GetLogs returns an array of all logs matching a given filter object.
func (api *ethAPI) GetLogs(ctx context.Context, fq web3Types.FilterQuery) ([]web3Types.Log, error) {
w3c := GetEthClientFromContext(ctx)
Expand Down
2 changes: 1 addition & 1 deletion rpc/handler/cfx_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (handler *CfxLogsApiHandler) getLogsReorgGuard(
logrus.WithFields(logrus.Fields{
"logFilter": filter,
"databaseFilters": dbFilters,
"functionFilter": fnFilter,
"fullnodeFilter": fnFilter,
"boundCheckEnabled": useBoundCheck,
"resultSetCount": len(logs),
"responseSizeBytes": uint64(accumulator),
Expand Down
2 changes: 1 addition & 1 deletion rpc/handler/eth_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (handler *EthLogsApiHandler) getLogsReorgGuard(
logrus.WithFields(logrus.Fields{
"logFilter": filter,
"databaseFilter": dbFilter,
"functionFilter": fnFilter,
"fullnodeFilter": fnFilter,
"boundCheckEnabled": useBoundCheck,
"resultSetCount": len(logs),
"responseSizeBytes": uint64(accumulator),
Expand Down

0 comments on commit 5f8cd09

Please sign in to comment.