Skip to content

feat(registry): update USDD to use permit2 on TRON networks#13

Merged
Hades-Ye merged 1 commit intodev/v2from
feat/update-usdd-asset-registry
Mar 12, 2026
Merged

feat(registry): update USDD to use permit2 on TRON networks#13
Hades-Ye merged 1 commit intodev/v2from
feat/update-usdd-asset-registry

Conversation

@Hades-Ye
Copy link
Copy Markdown
Contributor

Summary

  • Updated USDD configuration in AssetRegistry for TRON networks (Mainnet and Nile).
  • Set assetTransferMethod to permit2 for USDD to ensure it doesn't default to EIP-3009/TIP-712.
  • Maintained USDD's support for EIP-2612.
  • Updated corresponding unit tests in both Python and TypeScript SDKs.

@Hades-Ye Hades-Ye merged commit 3f02dae into dev/v2 Mar 12, 2026
7 checks passed
@Hades-Ye Hades-Ye deleted the feat/update-usdd-asset-registry branch March 12, 2026 15:41
boboliu-1010 pushed a commit that referenced this pull request Apr 28, 2026
…ANGELOG + docs

User requirement: "默认用 exact_permit 和 exact" — the CLI should pick
the cheapest user-fee scheme by default rather than always defaulting
to exact_gasfree's 0.1 USDT relayer cut.

Headline behavior change:
- Profile.scheme is now optional. When unset, transfer/pay auto-pick
  per (network, token) via the new src/schemes.ts table:
    eip155:97 DHLU       → exact          (ERC-3009)
    eip155:97/56 USDT/USDC → exact_permit (EIP-2612)
    tron:* USDT          → exact_permit  (TIP-712), with allowance-
                                          failure auto-fallback to
                                          exact_gasfree
- Default `nile` profile pinned to exact_permit (was exact_gasfree).
  Both BSC and TRON exact_permit settle through the BankofAI root
  facilitator with feeAmount=0 — verified live on BSC Testnet, tx
  0xe6458fcbf1da1da9a0c638cf68b357982781ae932b6742a02331d2371bfeaf30.

Implementation:
- src/schemes.ts (+10 unit tests): recommendedSchemes / pickScheme /
  isKnownScheme. Single source of truth for per-token scheme support.
- src/commands/transfer.ts: split into settleViaFacilitator (exact /
  exact_permit via FacilitatorHttpClient /fee/quote /verify /settle)
  and settleViaGasFree (in-process GasFreeAPIClient.submit). 9 unit
  tests covering both paths, dry-run, fallback, and error envelopes.
- src/commands/pay.ts: registers exact + exact_permit on EVM and
  exact_permit + exact_gasfree on TRON. Selector filters server
  accepts[] by scheme/maxAmount.
- src/commands/request.ts (+5 unit tests): offline transfer-request URI
  generator. Falls back to built-in defaults when ~/.x402/config.json
  is absent.
- src/wallet.ts: createTronClientSignerFromEnv /
  createEvmClientSignerFromEnv. Pure env-key path, no agent-wallet
  dependency at signing time. EVM derivation supported (was post-MVP).
- src/facilitator.ts: getFacilitatorBaseUrl(eip155:*) now returns the
  root URL (was a non-existent /bsc-testnet 404). Per solutions.md
  #14 the BankofAI proxy serves EVM schemes from root, only TRON
  GasFree uses network-scoped paths.
- src/commands/doctor.ts: readiness probe falls back to /supported
  when /api/v1/config/provider/all 404s, so EVM doctors don't
  misreport facilitator=fail.

Documentation:
- typescript/packages/cli/CHANGELOG.md: new file. 0.1.0 entry covering
  every shipped command + known limitations (TRON USDT transferFrom
  revert, single Nile GasFree provider, scheme registry coverage).
- typescript/packages/cli/README.md: rewritten "Schemes & fees"
  section with the cost-comparison table; first-run flow now
  recommends BSC testnet for fee-free demo; live tx hash linked.
- docs/solutions.md #13: TRON USDT (TRC-20) transferFrom returns no
  data — breaks exact_permit settle. Workaround: pin --scheme
  exact_gasfree on TRON USDT until SDK ships a TRC-20-aware adapter.
- docs/solutions.md #14: BankofAI facilitator URL semantics — root
  for everything except the TRON GasFree balance proxy.
- specs/002-bankofai-cli/notes/decisions.md D4 updated: EVM facilitator
  is root, not per-chain slug.

Tests: 15 files, 114 unit tests. Build clean. Real-chain BSC
exact_permit verified end-to-end with feeAmount=0; TRON exact_permit
dry-run works (live fee_quote returns 0); TRON exact_gasfree path
intact (prior session txs).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
boboliu-1010 pushed a commit that referenced this pull request Apr 28, 2026
Yesterday's solutions.md #13 + CHANGELOG entry blamed TRC-20 USDT's
`transferFrom` for not returning a `bool` and thus reverting in the
PaymentPermit settler. That diagnosis is wrong — proven by a static
`triggerconstantcontract` call against Nile USDT that returns
`0x...0001` (true), the standard ERC-20 success value.

The actual failure happens in the facilitator BEFORE broadcast:
`_exact_permit_base/facilitator.py:204` returns `None` from
`_settle_payment_only`, which the facilitator wraps as
`error_reason="transaction_failed"`. The doc-comment lists the four
real causes — insufficient bandwidth/energy on the facilitator
account, insufficient TRX balance, network connectivity, or
contract-call ABI mismatch.

In our case the BankofAI-hosted facilitator's TRON signer wallet
isn't keeping enough TRX/energy to broadcast `permitTransferFrom`.
BSC `exact_permit` works against the same hosted facilitator because
its EVM signer wallet is funded separately.

Updates:
- docs/solutions.md #13: rewritten end-to-end. Notes the original
  misdiagnosis prominently so future readers don't accept the wrong
  story. Lists three real fix paths (ops top-up; facilitator surface
  sub-reason; CLI workaround pin --scheme exact_gasfree).
- CHANGELOG.md "Known limitations": same correction; replace the
  TRC-20 transferFrom claim with the facilitator funding claim.
- README.md "Schemes & fees": same correction; clarify TRC-20 USDT
  is ERC-20-compliant on Nile.

No code changes; tests still 114/15 green. The CHANGELOG note that
the CLI's allowance-failure auto-fallback to gasfree does NOT cover
this case (because allowance is already maxed) stays — users hit by
this need to pin --scheme exact_gasfree manually.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant