Skip to content

SDK drift: Escrow.approveTx amountWei is typed bigint in TypeScript but int in Python #1025

Description

@realfishsam

Drift

The amountWei / amount_wei parameter of the escrow approval method uses incompatible numeric types: TypeScript uses JavaScript's native bigint while Python uses int. Although both are arbitrary-precision integers semantically, the TypeScript side also serializes the value as a string (amountWei.toString()) before sending to the server, while Python sends it as a JSON number. This creates a wire-format mismatch.

TypeScript SDK

sdks/typescript/pmxt/escrow.ts:27

async approveTx(token: string, amountWei?: bigint): Promise<unknown>

The value is serialized at line 34 as:

amount_wei: amountWei === undefined ? null : amountWei.toString(),

Wire format: string (e.g. "1000000000000000000").

Python SDK

sdks/python/pmxt/escrow.py:46,114

def _amount_wei(value: int | None) -> int | None: ...

def approve_tx(self, token: str, amount_wei: int | None = None) -> dict[str, Any]:

Wire format: JSON number (e.g. 1000000000000000000).

Expected

Both SDKs should accept the same input type and produce the same wire format. Large Wei values (e.g. 2^96 - 1 for unlimited approval) exceed JavaScript's safe integer range, so string serialization is correct. Python should also serialize amount_wei as a string, or the server must be documented to accept both.

Impact

The server receives amount_wei as a string from TypeScript callers and as a JSON number from Python callers. If the server strictly validates the type, one of the two SDKs will fail. For large ERC-20 unlimited approvals, Python's integer JSON encoding may overflow the server's JSON parser if it uses a 64-bit integer type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions