Commit 2064c6c
feat(x402): advertise upto scheme + send settlementOverrides (#182)
* feat(x402): advertise upto + send settlementOverrides for metered settle
- omniChallenge buildX402Requirements advertises scheme=upto for EVM (Base) x402
options (SVM stays exact; Solana upto not implemented). The deployed SDK version
thus selects exact vs upto.
- ProtocolSettlement.buildRequestBody adds settlementOverrides.amount (atomic
micro-USDC from the metered actualAmount) for x402, so settle charges the actual
(<= the Permit2 cap). settlePaymentSession passes session.spent as actualAmount.
- x402Wrapper / baseAccount select UptoEvmScheme vs ExactEvmScheme from the chosen
accept's scheme (self-custody client paths).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(x402): advertise both schemes with facilitatorAddress; scheme-gate overrides
Review fixes for x402 up-to:
- buildX402Requirements advertises BOTH 'exact' and 'upto' per EVM chain (upto only
when a facilitatorAddress is available), so non-accounts clients keep an exact
fallback and accounts picks the scheme. upto accepts carry extra.facilitatorAddress,
fetched once from auth's GET /x402/supported (cached). Dedupe accepts by
(scheme, network) so a chain surfaced twice isn't advertised twice.
- buildRequestBody adds settlementOverrides ONLY for the upto scheme (exact/EIP-3009
commits the signature to a fixed value; overriding it mismatches the signature and
the facilitator rejects it). Clamp the override to the cap.
- Revert the self-custody paths (x402Wrapper, baseAccount) to exact-only — they
can't complete upto (no facilitator approval); the accounts-mediated path is the
only upto path.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(x402): TTL on facilitator-address cache; match accept by scheme in settle
Re-review:
- Bound the facilitator-address cache with a 10-minute TTL (was process-lifetime).
The CDP settle address rotates; a long-lived process would advertise a stale
witness and silently revert every upto settle until restart.
- buildRequestBody's full-accepts branch matched by network only; the challenge now
carries both exact and upto per network, so match by scheme too (else a network
match returns exact-first and drops the override). Added a same-network test.
- Dropped the stale "EVM payloads don't embed accepted" comment (createPaymentPayload
does embed accepted for v2).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 868f331 commit 2064c6c
10 files changed
Lines changed: 580 additions & 47 deletions
File tree
- packages
- atxp-base/src
- atxp-server/src
- atxp-x402/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | | - | |
| 31 | + | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| 39 | + | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
| |||
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
45 | 109 | | |
46 | 110 | | |
47 | 111 | | |
| |||
55 | 119 | | |
56 | 120 | | |
57 | 121 | | |
58 | | - | |
59 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
60 | 127 | | |
61 | | - | |
62 | | - | |
| 128 | + | |
| 129 | + | |
63 | 130 | | |
64 | 131 | | |
65 | 132 | | |
| |||
609 | 676 | | |
610 | 677 | | |
611 | 678 | | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
612 | 746 | | |
613 | 747 | | |
0 commit comments