optimism-java / shisui

Ethereum Portal Network Client written in Go
https://www.ethportal.net/clients/shisui
GNU Lesser General Public License v3.0
5 stars 6 forks source link

Implementation of endpoints eth_getBlockReceipts and eth_getBlockTransactionCountByHash #169

Closed r4f4ss closed 5 days ago

r4f4ss commented 6 days ago

Implementations follows specs.

Reference file: internal/ethapi/api.go

Note that is WIP since eth_getBlockReceipts returns the error "parameter not implemented" if called with string tag (e.g. "latest") or block number. Block search by number is not implemented.

Integration test of eth_getBlockReceipts

Using curl:

curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["0xb81fcfee29cea2922aa9f553644463bee1c49895e56bc87f4417834e681ad305"],"id":1}'
curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["latest"],"id":1}'
curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["0x1234"],"id":1}'

Apparently ethers Js do not implement this method: https://github.com/ethers-io/ethers.js/issues/4768

Intregration test of eth_getBlockTransactionCountByHash

Using curl:

curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0xb81fcfee29cea2922aa9f553644463bee1c49895e56bc87f4417834e681ad305"],"id":1}'

Using web3.js:

import { Web3 } from 'web3'

const provider = new Web3("http://localhost:8545/");
const tc = await provider.eth.getBlockTransactionCount("0xb81fcfee29cea2922aa9f553644463bee1c49895e56bc87f4417834e681ad305")
console.log(tc)