forked from coinbase/x402
-
Notifications
You must be signed in to change notification settings - Fork 4
feat(extensions): Add Facilitator Fee Disclosures for Fee-Aware Routing - facilitatorFeeQuote, facilitatorFeeBid, facilitatorFeePaid (draft, addresses #) #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Kbhat1
wants to merge
13
commits into
main
Choose a base branch
from
feat/facilitator-fees-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This extension standardizes facilitator fee disclosure to enable fee-aware multi-facilitator routing: - FacilitatorFeeQuote: facilitator-signed fee disclosure at PaymentRequired - FacilitatorFeeBid: client fee constraints in PaymentPayload - FacilitatorFeePaid: actual fee charged in SettlementResponse Also adds extensions field to SettleResponse in core types. Closes #XXX
vite-tsconfig-paths v5.x is ESM-only, causing ERR_REQUIRE_ESM when loading vitest.config.ts in CommonJS context. Using .mts extension forces Node to treat configs as ES modules. Also added .pnpm-store to .gitignore.
fd20444 to
9434f77
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds an opt-in
facilitatorFeesextension to standardize facilitator fee disclosure, enabling fee-aware multi-facilitator routing.This extension introduces three components:
facilitatorFeeQuote: Facilitator-signed fee disclosure surfaced inPaymentRequiredfacilitatorFeeBid: Client fee constraints/preferences surfaced inPaymentPayloadfacilitatorFeePaid: Actual fee charged surfaced inSettlementResponseMotivation
Facilitators are beginning to charge explicit fees:
Without standardization, clients cannot compare total cost across facilitators, and multi-facilitator routing cannot become a real market.
Changes
Spec:
specs/extensions/facilitator_fees.md— Full extension specificationTypeScript (
@x402/extensions):src/facilitator-fees/types.ts— Type definitionssrc/facilitator-fees/schema.ts— Zod validation schemassrc/facilitator-fees/index.ts— Helper functions and exportstest/facilitator-fees.test.ts— Unit testspackage.json,tsup.config.ts,src/index.tsfor exportsCore Types (
@x402/core):extensions?: Record<string, unknown>toSettleResponseDesign Decisions
extensions, notextra: Facilitator fees are orthogonal to payment schemes and belong in the top-levelextensionsfield (likebazaar)selectedQuoteIdenables client agency while keeping simple cases simpleeip191for EVM,ed25519for SolanaTests
Build:
✅ Build successful
Lint:
cd typescript && pnpm --filter @x402/extensions lint:check✅ No errors
Code validation (all schemas and helpers verified):
Note: Unit tests are written in test/facilitator-fees.test.ts. The repo's vitest config has a pre-existing ESM/CJS compatibility issue (vite-tsconfig-paths module loading error) that affects all tests in @x402/extensions. The test file is correctly structured and will pass once resolved.