Skip to content

Gasless USDC/USDT0 transfers (replaces OpenGSN for transfers) - #592

Draft
sisou wants to merge 3 commits into
masterfrom
soeren/gasless-transfers
Draft

sisou wants to merge 3 commits into
masterfrom
soeren/gasless-transfers

Conversation

@sisou

@sisou sisou commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Adds gasless USDC/USDT0 transfers to signPolygonTransaction. They use the GaslessTransfer contract and Nimiq relay of NimiqToolbox/gas-abstraction (private) instead of OpenGSN. Swap-related requests (setupSwap, refundSwap, OpenGSN relay requests to signPolygonTransaction) are unchanged; they move to the new gas abstraction in a follow-up.

Part of a coordinated change

Repo PR Depends on
Keyguard nimiq/keyguard#570 –
Hub this PR nimiq/keyguard#570 (new @nimiq/keyguard-client types)
Wallet nimiq/wallet#317 this PR (new @nimiq/hub-api types)

Release order: Keyguard, then Hub, then Wallet.

Changes

  • Public API (@nimiq/hub-api):
    • New SignPolygonGaslessTransferRequest: request: { token, from, to, amount, fee, relay }, tokenNonce, optional corrects (the payment's latest signed version, to re-sign it with the same nonce), recipientLabel.
    • New SignedPolygonGaslessTransfer: { request, signature, authorization }, the relay's POST /v1/transfer body.
    • signPolygonTransaction() accepts it besides the existing SignPolygonTransactionRequest. The result type follows the request type.
  • Parsing: requests without relayData are parsed by the new SignPolygonTransactionRequestParsing.ts (shape checks only) and forwarded to the Keyguard field by field. The Keyguard validates them against its own pins. OpenGSN requests are passed through as before.
  • findWalletByPolygonAddress and the signer lookup in SignPolygonTransaction.vue compare addresses case-insensitively.

Compatibility

Additive for type consumers. At runtime, the Keyguard (nimiq/keyguard#570) no longer signs the OpenGSN transfer variant (transferWithPermit / transferWithApproval), so third-party apps that still build it get an error. SIGN_POLYGON_TRANSACTION stays on the third-party whitelist.

Before merging

Testing

  • yarn test:unit: 87 passing, including the new SignPolygonTransactionRequestParsing.spec.ts.
  • tsc, yarn lint, and yarn lint / yarn build in client/.
  • yarn build:ci fails locally with the same Ledger module parse errors on master, so .vue files weren't type-checked by the build.
  • Not tested end to end yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKgXoeSB62akioiTzYya6C

sisou and others added 2 commits September 30, 2026 17:53
SIGN_POLYGON_TRANSACTION now takes the plain fields of a gasless transfer
through the GaslessTransfer contract of NimiqToolbox/gas-abstraction
(token, from, to, amount, fee, relay), the token permit nonce and an
optional `corrects` for a new version of an earlier payment. It returns
the relay submit body (request, signature, authorization). The Keyguard
validates everything against its own pins; the Hub checks the shape and
forwards only the known fields.

- Move the request parsing into SignPolygonTransactionRequestParsing.ts,
  with unit tests.
- Look up Polygon addresses case-insensitively.
- Remove the OpenGSN RelayRequest type and USDC/USDT HTLC support from
  setupSwap and refundSwap (breaking change of @nimiq/hub-api).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKgXoeSB62akioiTzYya6C
Swaps will move to the new gas abstraction separately, so restore the
OpenGSN-based swap code in setupSwap, refundSwap and signPolygonTransaction,
and only add the gasless transfer variant:

- SIGN_POLYGON_TRANSACTION accepts either a gasless transfer
  (SignPolygonGaslessTransferRequest, parsed and forwarded field by field)
  or, as before, an OpenGSN relay request for swap related transactions.
  signPolygonTransaction's result type follows the request variant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKgXoeSB62akioiTzYya6C

This branch has not been deployed

No deployments
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