x402 icon indicating copy to clipboard operation
x402 copied to clipboard

feat(ton): add TON network support (native + jetton)

Open web3luka opened this issue 3 months ago • 2 comments

Description

This PR adds TON (The Open Network) support to x402.
It introduces a new network adapter that enables merchants and facilitators to accept payments in TON native coins as well as Jettons (TEP-74 standard).

Key changes:

  • [x] Implemented verifyTONExact for native and jetton payments
  • [x] Added address normalization across raw/bounceable / non-bounceable formats
  • [x] Added memo validation (x402: strict mode) with fallback for legacy memos
  • [x] Unified error codes for better integration with existing adapters
  • [x] Utility helpers: normalizeTonAddress, getTonExplorerUrl, validateMemo, toAtomic
  • [x] Unit tests covering native + jetton flows, decimal mismatch, forward_ton_amount edge cases, cross-format addresses
  • [x] Explorer integration via tonviewer.com (mainnet + testnet)

Tests

  • [x] Added src/ton/index.test.ts with >180 cases:
    • Native transfers with memo
    • Jetton transfers with forward payload (memo)
    • Decimal mismatch/amount mismatch
    • Cross-format address normalization
    • Invalid memo and expired invoice handling
  • [x] Verified unit tests with pnpm test inside /typescript
  • [x] Manually checked explorer URL generation for mainnet and testnet

Checklist

  • [x] I have formatted and linted my code (pnpm format && pnpm lint)
  • [x] All new and existing tests pass (pnpm test)
    image
  • [x] My commits are signed (verified via git log --show-signature)

web3luka avatar Oct 03 '25 09:10 web3luka

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

cb-heimdall avatar Oct 03 '25 09:10 cb-heimdall

@web3luka is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 03 '25 09:10 vercel[bot]