fix: price MPP challenges in the currency's own minor unit; deps - #109
Merged
Conversation
challengeToRail divided every challenge amount by 10^6, which is right for a USDC rail and wrong for stripe/charge, whose amount is in cents: a $5.20 card charge rendered as $0.000520 in `check` output. Decimals now come from methodDetails.decimals when declared, from the ISO code for a fiat quote (2, or 0 for Stripe's zero-decimal currencies), and default to 6 for token rails. A non-USD fiat quote leaves price_usd unset rather than showing a number in the wrong currency. Display only: the pay command resolves its own decimals for the max-spend check and the signed amount, and never selects the Stripe rail. Bumps to 0.5.5. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every exact pin (viem, mppx, incur, @x402/*, @solana/mpp, @agent-score/sdk) is already at its registry latest, so the coupled set does not move. eslint and typescript majors stay held. @solana/kit 8.3.0 and knip 6.35.1 sit inside the release-age soak and follow on the next install after it. Corrects the dependabot note that still described @solana/kit as ^7. OSV over bun.lock: 682 packages, no issues. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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
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.
Summary
challengeToRaildivided everyWWW-Authenticate: Paymentamount by 10^6. That is right for the USDC rails and wrong forstripe/charge, whose amount is in cents, soagentscore-pay checkrendered a $5.20 card charge on agents.scaledown.ai as $0.000520. Decimals now come frommethodDetails.decimalswhen the challenge declares it, from the ISO code for a fiat quote (2, or 0 for Stripe's zero-decimal currencies), and default to 6 for token rails. A non-USD fiat quote leavesprice_usdunset rather than carrying a number in the wrong currency under a field named usd.This is display and quoting only. The pay command resolves its own decimals for the max-spend check and for the amount it signs, and it never selects the Stripe rail, so no spend path changes. Token rails produce byte-identical output to before; the existing Tempo and Solana assertions pass unchanged.
Dependencies on the same branch:
@clack/prompts1.8.0,typescript-eslint8.70.0,knip6.35.0. Every exact pin (viem, mppx, incur, the three@x402/*,@solana/mpp,@agent-score/sdk) is already at registry latest, so the coupled settle set does not move and no live all-rails settle is owed.@solana/kit8.3.0 andknip6.35.1 are inside the release-age soak and follow on the next install. The eslint and typescript majors stay held. The dependabot note describing@solana/kitas^7now says^8. OSV overbun.lock: 682 packages, no issues. Actions pins (cosign-installer 4.1.2, osv-scanner 2.5.1) are at upstream latest.Bumps the version to 0.5.5.
Worked with Varun, who found the wrong figure while checking the ScaleDown storefront's purchase flow.
Deliberately not done: the store's JSON body lists
stripe/chargeunderaccepted_methodswith the body-levelamount_usd, socheckstill shows that row at the crypto price beside the header row at the card price. That is the MPP body shape carrying one amount for every method, not a parser bug, and the header row is the accurate one.Type of change
Public API
None.
ChallengeRail.price_usdkeeps its type; the value changes only for fiat challenges, where it was wrong.Test plan
Three tests added in
tests/www-authenticate.test.ts: the real Stripe challenge captured from agents.scaledown.ai today (520 cents reads as 5.20), the real Solana challenge from the same response (declared decimals 6 read as 5.000000), and a JPY quote leavingprice_usdundefined. Run locally:bun run test(577 passed, 2 skipped),bun run typecheck,bun run lint,bun run knip,bun run build, all exit 0.bun run dev -- check -X POST https://agents.scaledown.ai/creditsagainst the live store shows the Stripe rail at 5.20 with raw 520.Checklist
🤖 Generated with Claude Code