Skip to content

feat: authorize() takes protocols[] array — accounts decides protocol via flag#146

Open
badjer wants to merge 2 commits intomainfrom
feat/authorize-protocols-array
Open

feat: authorize() takes protocols[] array — accounts decides protocol via flag#146
badjer wants to merge 2 commits intomainfrom
feat/authorize-protocols-array

Conversation

@badjer
Copy link
Copy Markdown
Contributor

@badjer badjer commented Apr 1, 2026

Summary

Changes authorize() from taking a single protocol to a protocols[] array. Each account picks the first protocol it supports. ATXPAccount calls /authorize/auto on accounts, which resolves the protocol via Redis feature flag server-side.

Breaking change to AuthorizeParams: protocol: PaymentProtocolprotocols: PaymentProtocol[]

Key changes:

  • ATXPAccount calls /authorize/auto instead of /authorize/{protocol}
  • PaymentClient simplified: removed protocolFlag, accountsServer, fetchFn, userId
  • Local accounts (Base, Solana, etc.) pick first supported protocol from array
  • Protocol handlers pass single-element arrays since they know the server's protocol
  • Net -627 lines

Depends on: accounts PR #644 (/authorize/auto endpoint)

Test plan

  • 198 client tests pass
  • 98 common tests pass
  • Local integration with LLM + accounts + auth

🤖 Generated with Claude Code

badjer and others added 2 commits April 1, 2026 11:37
Each account implementation picks the first protocol it supports from
the array. ATXPAccount calls /authorize/auto — accounts resolves the
protocol via feature flag server-side. Local accounts (Base, Solana,
etc.) filter to their supported protocols.

PaymentClient simplified — no more protocolFlag, accountsServer, or
fetchFn. Just passes protocols[] through to account.authorize().

Protocol handlers pass single-element arrays (['x402'], ['mpp']) since
they know what the server requires.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove PaymentClient class (was pure passthrough to account.authorize)
- Keep buildPaymentHeaders in new paymentHeaders.ts
- Fix amount.toString() crash: conditionally include fields in body
- Make amount/destination optional in AuthorizeParams
- Add response validation for /authorize/auto (protocol + credential)
- Type supported arrays as PaymentProtocol[] (not string[])
- Remove deprecated accountsServer from handler configs
- Guard against empty protocols array in all account implementations
- Add 4 new error-path tests for malformed responses
- Fix missing trailing newlines

Co-Authored-By: Claude Opus 4.6 (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