Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_newBlockFilter #207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/methodsStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,21 +656,21 @@ Tests:

**Why (if not finished) :** Dynamic network. Tests needs improvement.

## eth_newFilter
## eth_newBlockFilter

**Status :**

RPC-convert:

- [ ] Finished
- [x] Not Finished
- [x] Finished
- [ ] Not Finished
Comment on lines +665 to +666

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change


Tests:

- [ ] Finished
- [x] Finished
- [ ] Not Finished

**Why (if not finished) :**
**Why (if not finished) :** Not supported in Starknet. Returning error with message 'the method eth_newBlockFilter does not exist/is not available'

## eth_newPendingTransactionFilter

Expand Down
6 changes: 6 additions & 0 deletions src/rpc/calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { getUncleByBlockNumberAndIndexHandler } from './calls/getUncleByBlockNum
import { getUncleCountByBlockNumberHandler } from './calls/getUncleCountByBlockNumber'
import { getUncleCountByBlockHashHandler } from './calls/getUncleCountByBlockHash'
import { unsubscribeHandler } from './calls/unsubscribe'
import { newBlockFilterHandler } from './calls/newBlockFilter'

const router: Router = Router()

Expand Down Expand Up @@ -216,6 +217,11 @@ Methods.set('eth_unsubscribe', {
handler: unsubscribeHandler,
})

Methods.set('eth_newBlockFilter', {
method: 'eth_newBlockFilter',
handler: newBlockFilterHandler,
})

router.post('/', async function (req: ParsedRequest, res: Response) {
const request = req.rpcRequest
if (request?.method) {
Expand Down
14 changes: 14 additions & 0 deletions src/rpc/calls/newBlockFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { RPCError, RPCRequest, RPCResponse } from '../../types/types'

export async function newBlockFilterHandler(
request: RPCRequest,
): Promise<RPCResponse | RPCError> {
return {
jsonrpc: request.jsonrpc,
id: request.id,
error: {
code: -32000,
message: 'the method eth_newBlockFilter does not exist/is not available', // Infura's answer
},
}
}
19 changes: 19 additions & 0 deletions tests/rpc/calls/newBlockFilter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { newBlockFilterHandler } from '../../../src/rpc/calls/newBlockFilter'
import { RPCError, RPCResponse } from '../../../src/types/types'

describe('Test newBlockFilterHandler', () => {
it('Returns not available', async () => {
const request = {
jsonrpc: '2.0',
method: 'eth_newBlockFilter',
params: [],
id: 1,
}
const result: RPCResponse | RPCError = <RPCResponse>(
await newBlockFilterHandler(request)
)
expect(result.error?.message).toBe(
'the method eth_newBlockFilter does not exist/is not available',
)
})
})
Loading