Skip to content

SDK drift: Escrow.approveTx/approve_tx serializes amount_wei as a JSON string in TypeScript but a native JSON number in Python #1705

Closed as duplicate

Description

@realfishsam

Drift

TypeScript's normalizeAmountWei deliberately converts the bigint amountWei to a decimal string (.toString()) before putting it in the request body, avoiding IEEE-754 double precision loss for large values. Python's _amount_wei returns the raw int unchanged, which then serializes as a native JSON number literal via json.dumps(body, default=str).

TypeScript SDK

sdks/typescript/pmxt/escrow.ts:51-62, used in the request body at line 130:

function normalizeAmountWei(amountWei: bigint | undefined): string | undefined {
    ...
    return amountWei.toString();   // returns a decimal STRING
}

Python SDK

sdks/python/pmxt/escrow.py:46-56, used in the request body at line 121:

def _amount_wei(value: int | None) -> int | None:
    ...
    return value   # returns the raw int, unchanged

Expected

Both SDKs should serialize amount_wei on the wire the same way — Python should stringify large integer values before including them in the request body, matching TypeScript.

Impact

This is different from existing issue #1025, which only concerns the SDK-facing parameter type (bigint vs int), not the wire serialization. amount_wei values for ERC-20 approvals are frequently very large (e.g. near uint256 max for "unlimited" approvals). Sending them as a bare JSON number risks precision loss/misinterpretation by any downstream JSON consumer that treats numbers as IEEE-754 doubles (e.g. a JS-based service) — exactly the failure mode TypeScript's pre-stringification is designed to avoid.


Found by automated SDK cross-language drift audit

Activity

  1. realfishsam commented on Jul 18, 2026

    @realfishsam
    ContributorAuthor

    Closing as duplicate of #1025. Both issues report the identical underlying finding for Escrow.approveTx/approve_tx: TypeScript serializes amount_wei as a JSON string (via .toString()/normalizeAmountWei) while Python sends it as a native JSON number (via _amount_wei), producing a wire-format mismatch. #1025 already documents this wire-format divergence (not just the bigint/int type difference) and proposes the same fix (Python should serialize as a string to match TypeScript). Extra detail from this issue has been copied into a comment on #1025.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions