Skip to content

Conversation

@vaibhavgeek
Copy link

@vaibhavgeek vaibhavgeek commented Oct 29, 2024

Fix BigInt Serialization Issues in JSON Responses

Problem

The original implementation was encountering serialization errors when attempting to return responses containing BigInt values. This occurred because BigInt values cannot be directly serialized to JSON.

Changes Made

  1. Added explicit string conversion for BigInt fields in the response objects:

    • paymasterVerificationGasLimit
    • paymasterPostOpGasLimit
  2. Created a serializedResult object that converts BigInt values to strings before JSON serialization:

const serializedResult = {
    ...result,
    paymasterVerificationGasLimit: result.paymasterVerificationGasLimit?.toString(),
    paymasterPostOpGasLimit: result.paymasterPostOpGasLimit?.toString()
};

Testing

Verified that API responses now successfully serialize without errors
Confirmed compatibility with both EntryPoint versions
Added console.log statements to help with debugging response data

Impact

This change ensures proper handling of BigInt values in the paymaster API responses while maintaining the expected response format for clients. The modification is backward compatible and improves the reliability of the service.
Please review and merge these changes to resolve the serialization issues.

@vaibhavgeek vaibhavgeek changed the title Update app.ts - searlisation errors fixed Serialization Issues in JSON Responses Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants