Repository navigation
fix(web): reject fractional atomic-unit listing prices - #240
Merged
Merged
Conversation
This branch was successfully deployed
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
Listing prices are denominated in indivisible atomic units: USDC micro-units and SOL lamports. The two shared validators previously used
Number.isFinite, so they accepted values such as10_000.5USDC micro-units and1_000_000.5lamports once those values cleared the floor check.This PR changes both validators to require
Number.isIntegerand adds behavioral regression coverage for fractional values in the shared USDC micro-unit validator and the currency-aware USDC/SOL validator.The normal publish and listing paths already compute integral units, so valid free, floor, and above-floor prices keep their existing behavior. Invalid fractional atomic units are now rejected at the shared boundary before they can be converted to
bigintfor an on-chain call.Verification
npm test --workspace @agentvouch/web -- __tests__/lib/pricing.test.ts --maxWorkers=1 --no-fileParallelisminitially failed on the two new fractional-atomic-unit assertions.npm run format:check— passed.npm run lint:web— passed.npm run typecheck— passed with Node v24.10.0.npm test— passed: web 152 files / 1,313 tests; CLI 13 files / 77 tests.git diff --check— passed before commit.npm exec --workspace @agentvouch/web -- next build --webpack— webpack compiled successfully and TypeScript completed. It then failed only while prerendering/sitemap.xmlbecause this cron checkout lacks gitignoredweb/.env.local/DATABASE_URL; no environment configuration was changed. The pre-existingox/viemdynamic-import warning also remained.Scope and rollback
Two files only:
web/lib/pricing.tsandweb/__tests__/lib/pricing.test.ts. No chain, schema, dependency, or configuration changes.Rollback is a revert of this commit; no persisted state or deployment needs cleanup.