wevm / viem

TypeScript Interface for Ethereum
https://viem.sh
Other
2.54k stars 835 forks source link

bug: `getLogs` from beta version didn't translate `blockNumber` from hex string to bigint #1611

Closed runjuu closed 10 months ago

runjuu commented 10 months ago

Is there an existing issue for this?

Package Version

2.0.0-beta.16

Current Behavior

blockNumber, transactionIndex and logIndex are hex strings.

Expected Behavior

blockNumber, transactionIndex and logIndex should be bigint or number types

Steps To Reproduce

import { createPublicClient, http } from 'viem';
import { crossbell } from 'viem/chains';

const client = createPublicClient({ chain: crossbell, transport: http() });

client
  .getLogs({
    event: {
      inputs: [
        { indexed: true, name: 'characterId', type: 'uint256' },
        { indexed: true, name: 'creator', type: 'address' },
        { indexed: true, name: 'to', type: 'address' },
        { indexed: false, name: 'handle', type: 'string' },
        { indexed: false, name: 'timestamp', type: 'uint256' },
      ],
      name: 'CharacterCreated',
      type: 'event',
    },
    fromBlock: 51419487n,
    toBlock: 52820341n,
  })
  .then(console.log);
image

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

https://stackblitz.com/edit/nestjs-typescript-starter-xyivpk?file=src%2Fmain.ts&terminal=start

Anything else?

It seems like the bug is introduced by 468a4ae3160c738046de115cec2a7e5ab7286a01, as formatLog was only applied to the logs without events.

jxom commented 10 months ago

Fixed in 2.0.0-rc.1. Many thanks.

github-actions[bot] commented 5 months ago

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.