viem icon indicating copy to clipboard operation
viem copied to clipboard

bug: Issues with 'publicClient.watchContractEvent()'

Open sunniebb opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Package Version

0.3.31

Current Behavior

Deployment Envi: NextJS: ^13.2.3

ABI:

{
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "uint256",
              "name": "id",
              "type": "uint256"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "buyer",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "seller",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "deposit",
              "type": "uint256"
          }
      ],
      "name": "SubscribeService",
      "type": "event"
  },

Code:

 const unwatch = publicClient.watchContractEvent({
        address: PAYMENT_ADDRESS,
        abi: paymentAbi,
        eventName: "SubscribeService",
        args: {
          id: subscription_id,
        },
        onLogs: (logs) => {
          unwatch();
          console.log("subscribe successful!");
        },
      });
      ````
      
      'id' is a bigInt, and when executing this code, i will get an error:
      
      Listen Subscribe Error: TypeError: Do not know how to serialize a BigInt
      

### Expected Behavior

It should run no problem

### Steps To Reproduce

Please see my code above

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

_No response_

### Anything else?

Nothing else

sunniebb avatar May 22 '23 04:05 sunniebb

Fixed! Should be published on 0.3.33 soon.

jxom avatar May 22 '23 07:05 jxom

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.

github-actions[bot] avatar Jun 02 '24 00:06 github-actions[bot]