fix(d402): @example amount uses 10^18 (ETH) but Demos OS_PER_DEM is 10^9#92
fix(d402): @example amount uses 10^18 (ETH) but Demos OS_PER_DEM is 10^9#92cX3po wants to merge 2 commits into
Conversation
Review Summary by QodoFix d402 middleware @example amount denomination from 10^18 to 10^9
WalkthroughsDescription• Corrects @example amount from 10^18 to 10^9 decimals • Aligns with Demos OS_PER_DEM = 10^9 denomination standard • Adds clarification comment about OS unit denomination • Prevents builder over-charging by 10^9× factor Diagramflowchart LR
A["@example amount<br/>5×10^18 ETH-style"] -->|"Fix to Demos<br/>9-decimal standard"| B["amount: 5×10^9<br/>OS_PER_DEM = 10^9"]
File Changes1. src/d402/server/middleware.ts
|
|
Warning Review limit reached
More reviews will be available in 42 minutes and 41 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Warning Walkthrough skippedFile diffs could not be summarized. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review by Qodo
1.
|
Greptile SummaryThis PR corrects a denomination error in the
Confidence Score: 5/5Safe to merge — the change is a one-line JSDoc correction with no runtime logic touched. The only modification is the @example amount value and its inline comment. The string '5000000000' correctly routes through parseOsString in _normalizeD402AmountToOsBigint, producing exactly 5_000_000_000n OS (5 DEM). No application logic, types, or behavior are altered. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["d402Required({ amount })"] --> B{typeof amount}
B -->|"number (e.g. 5)"| C["demToOs(value)\n× 10^9\n→ 5_000_000_000n OS"]
B -->|"string (e.g. '5000000000')"| D["parseOsString(value)\n→ 5_000_000_000n OS"]
B -->|bigint| E["passthrough\n(must be ≥ 0)"]
C --> F["_normalizeD402AmountToOsBigint result (OS bigint)"]
D --> F
E --> F
style D fill:#90ee90
style A fill:#f0f0f0
Reviews (2): Last reviewed commit: "fix: @example amount must be a string (O..." | Re-trigger Greptile |
Addresses Greptile/Qodo review: a bare number is normalized via demToOs (DEM), so 5000000000 as a number = 5e18 OS — the same overcharge. String routes through parseOsString (OS).
|
Good catch by the review bots — fixed. The |
|



Problem.
src/d402/server/middleware.ts@examplesetsamount: 5000000000000000000 // 5 DEM in smallest unit— that's 5×10^18, an 18-decimal (ETH-style) assumption. Per the 3.0.0-rc.1osDenominationmigration Demos uses 9 decimals:OS_PER_DEM = 10^9(denomination.demToOs(1) === 1_000_000_000n). So 5 DEM in the smallest unit (OS) is5_000_000_000, not5×10^18. A builder copying thisd402Requiredexample would over-charge by 10^9×.Section & path.
src/d402/server/middleware.ts(thed402RequiredJSDoc@example).Fix.
amount: 5000000000, // 5 DEM in smallest unit (OS); OS_PER_DEM = 10^9.One implementer's read from the PATH-OS Labs DACS reference-impl pass — happy to adjust the wording.