Skip to content

SDK drift: Escrow.approveTx serializes amountWei as a JSON string; Escrow.approve_tx sends it as a JSON integer #1049

Closed as duplicate

Description

@realfishsam

Drift

When a caller passes amountWei to Escrow.approveTx in TypeScript, it is serialized into the request body as a JSON string via .toString(). Python Escrow.approve_tx sends amount_wei as a JSON integer. The server receives different JSON types for the same field depending on which SDK is used.

Note: issue #1025 already tracks the SDK-level type mismatch (bigint vs int). This issue is specifically about the wire serialization — the JSON type that actually reaches the server.

TypeScript SDK

sdks/typescript/pmxt/escrow.ts:34

body: {
    token,
    amount_wei: amountWei === undefined ? null : amountWei.toString(),
},

amountWei.toString() produces a JSON string, e.g. "1000000000000000000".

Python SDK

sdks/python/pmxt/escrow.py:114–123

body: dict[str, Any] = {"token": token}
if amount_wei is not None:
    body["amount_wei"] = amount_wei   # int → JSON number, e.g. 1000000000000000000

amount_wei is an int and is serialized as a JSON number.

Expected

Both SDKs should serialize amount_wei in the same JSON type (either both as string or both as integer) so the upstream /v0/escrow/approveTx endpoint receives a consistent payload regardless of which SDK is used.

Impact

If the server expects a JSON number, TypeScript callers will cause a type error or silent misparse. If the server expects a JSON string (common for amounts exceeding 64-bit float precision), Python callers may cause a parse error. The inconsistency makes the correct server expectation ambiguous and can produce intermittent, hard-to-diagnose failures.

Activity

  1. realfishsam commented on Jul 3, 2026

    @realfishsam
    ContributorAuthor

    Closing as duplicate of #1025. #1025's own body already fully describes and diagnoses the identical JSON string-vs-integer wire-format mismatch for amountWei on approve_tx/approveTx and recommends the same fix. Relevant context has been copied over.


    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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions