Skip to content

fix: validate checkout token amounts - #18

Open
worlldz wants to merge 1 commit into
circlefin:masterfrom
worlldz:fix/validate-checkout-amount
Open

fix: validate checkout token amounts#18
worlldz wants to merge 1 commit into
circlefin:masterfrom
worlldz:fix/validate-checkout-amount

Conversation

@worlldz

@worlldz worlldz commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • validate checkout amounts as positive plain decimals within the selected token's precision
  • return a 400 response for unsupported formats instead of letting parseUnits throw or round the value
  • add focused Node test coverage and run it in CI

Why

POST /api/checkout/intent first coerced the amount with Number() and then passed the original string to parseUnits(). Values such as 1e3 passed the numeric check but caused parseUnits() to throw, producing an unhandled server error. Values beyond the token's six-decimal precision could also be rounded instead of rejected.

The new parser accepts only positive plain-decimal values that can be represented exactly by the token.

Testing

  • npm test
  • npx tsc --noEmit
  • npm run lint
  • npm run build

@worlldz
worlldz marked this pull request as ready for review August 7, 2026 10:23
@worlldz
worlldz force-pushed the fix/validate-checkout-amount branch from af02fdd to a46bd37 Compare August 7, 2026 10:37
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