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

wrong serialization of bigint when using getLastLog. #6206

Closed
vekexasia opened this issue Jun 15, 2023 · 2 comments
Closed

wrong serialization of bigint when using getLastLog. #6206

vekexasia opened this issue Jun 15, 2023 · 2 comments
Assignees
Labels
4.x 4.0 related Bug Addressing a bug

Comments

@vekexasia
Copy link

Expected behavior

Typescript allows blocknumbers to be passed as bigint. but it's not properly taken into account.

Actual behavior

Do not know how to serialize a BigInt

Steps to reproduce the behavior

 const web3 = new Web3(process.env.WS_ADDRESS!);
  const logs = await web3.eth.getPastLogs({
    fromBlock: 17486201n,
    toBlock: 17486201n,

  });

  console.log(logs);

Logs

TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at WebSocketProvider._sendToSocket (/home/me/eth_tests/node_modules/web3-providers-ws/src/index.ts:134:37)
    at WebSocketProvider._sendPendingRequests (/home/me/eth_tests/node_modules/web3-providers-ws/node_modules/web3-utils/src/socket_provider.ts:446:9)
    at WebSocketProvider._onConnect (/home/me/eth_tests/node_modules/web3-providers-ws/node_modules/web3-utils/src/socket_provider.ts:441:8)
    at callListener (/home/me/eth_tests/node_modules/ws/lib/event-target.js:290:14)
    at WebSocket.onOpen (/home/me/eth_tests/node_modules/ws/lib/event-target.js:237:9)
    at WebSocket.emit (node:events:513:28)
    at WebSocket.emit (node:domain:489:12)
    at WebSocket.setSocket (/home/me/eth_tests/node_modules/ws/lib/websocket.js:237:10)
    at ClientRequest.<anonymous> (/home/me/eth_tests/node_modules/ws/lib/websocket.js:985:15)

Environment

node 18.12.0, web3 v4.0.1

@jdevcs jdevcs added the 4.x 4.0 related label Jun 19, 2023
@mconnelly8 mconnelly8 added the Bug Addressing a bug label Jun 20, 2023
@luu-alex luu-alex self-assigned this Jun 21, 2023
@luu-alex
Copy link
Contributor

Thank you for reporting this bug, i'll create a PR for this soon and have a fix

@luu-alex
Copy link
Contributor

PR has been merged to fix this, it'll be available next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

5 participants
@vekexasia @luu-alex @jdevcs @mconnelly8 and others