Skip to content

feat(x402): add the signer groundwork for an x402 command group - #1001

Open
gummy789j wants to merge 1 commit into
feat/v4.14.0from
feat/x402-signer-bridge
Open

feat(x402): add the signer groundwork for an x402 command group#1001
gummy789j wants to merge 1 commit into
feat/v4.14.0from
feat/x402-signer-bridge

Conversation

@gummy789j

Copy link
Copy Markdown
Collaborator

x402-cli signs its payments through @bankofai/agent-wallet. Migrating its commands into wallet-cli means re-pointing that signer at a wallet-cli account; this is the seam that makes the rest of that migration mechanical. No x402 SDK is a dependency yet, and no command is wired.

  • domain/x402/network-id — convert between wallet-cli network ids and the CAIP-2 ids x402 uses. TRON differs only in base (tron:728126428 is tron:0x2b6653dc); eip155 identifiers are identical on both sides.

  • application/contracts/x402-payer — PayerSigner and PayerPolicy. The contract carries two closures rather than the domain Signer, because an x402 scheme calls the wallet from deep inside a payment flow, where nothing can run a Ledger's precheck / prompt / abort ceremony.

  • application/services/x402/payer-signer — resolve the active account, refusing a watch-only one before any keystore decrypt, and apply that ceremony once per signature. The TRON allowance path signs an approve transaction before the payment, so each signature needs its own round.

  • adapters/outbound/x402/signer-bridge — reshape the payer for the x402 SDK, declared structurally so no x402 package is imported. It is the one place every typed-data payload passes through, so it carries all three guards: the payload's payer must be the selected account, a GasFree maxFee must stay within the caller's ceiling, and the returned signature must be for the struct that was requested. The first two refuse before any signature is requested, so a rejected payment never reaches a device prompt.

  • domain/typed-data — resolvePrimaryType, so those guards work from the payload's real signing root instead of an optional field. Without it, a payload that omitted primaryType skipped all three checks.

  • three error codes: payer_mismatch, fee_cap_exceeded and signed_payload_mismatch, with their rows in machine-interface.md.

x402-cli signs its payments through @bankofai/agent-wallet. Migrating its
commands into wallet-cli means re-pointing that signer at a wallet-cli
account; this is the seam that makes the rest of that migration mechanical.
No x402 SDK is a dependency yet, and no command is wired.

- domain/x402/network-id — convert between wallet-cli network ids and the
  CAIP-2 ids x402 uses. TRON differs only in base (tron:728126428 is
  tron:0x2b6653dc); eip155 identifiers are identical on both sides.

- application/contracts/x402-payer — PayerSigner and PayerPolicy. The
  contract carries two closures rather than the domain Signer, because an
  x402 scheme calls the wallet from deep inside a payment flow, where
  nothing can run a Ledger's precheck / prompt / abort ceremony.

- application/services/x402/payer-signer — resolve the active account,
  refusing a watch-only one before any keystore decrypt, and apply that
  ceremony once per signature. The TRON allowance path signs an approve
  transaction before the payment, so each signature needs its own round.

- adapters/outbound/x402/signer-bridge — reshape the payer for the x402
  SDK, declared structurally so no x402 package is imported. It is the one
  place every typed-data payload passes through, so it carries all three
  guards: the payload's payer must be the selected account, a GasFree
  maxFee must stay within the caller's ceiling, and the returned signature
  must be for the struct that was requested. The first two refuse before
  any signature is requested, so a rejected payment never reaches a device
  prompt.

- domain/typed-data — resolvePrimaryType, so those guards work from the
  payload's real signing root instead of an optional field. Without it, a
  payload that omitted primaryType skipped all three checks.

- three error codes: payer_mismatch, fee_cap_exceeded and
  signed_payload_mismatch, with their rows in machine-interface.md.
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