Skip to content

feat: use bigint for stroops billing#233

Open
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-41-bigint-stroops
Open

feat: use bigint for stroops billing#233
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-41-bigint-stroops

Conversation

@pq198363-ops

Copy link
Copy Markdown

Closes #41

Summary

  • adds a BigInt-backed stroops helper for exact billing multiplication and summation
  • returns billedStroops, totalStroops, and disabledStroops as decimal strings so JSON responses do not lose precision above 2^53
  • applies the same exact arithmetic to pair billing, settlement, and protocol-wide billing totals
  • documents the breaking response-type change in README and billing docs
  • adds OpenAPI metadata for the string-typed billing response fields

TDD evidence

  • RED helper contract: npm run build failed because src/util/stroops.ts did not exist.
  • RED API contract: $env:NODE_ENV='test'; node --test dist/billing-stroops.test.js failed because billing endpoints returned numbers/scientific notation instead of exact decimal strings.
  • GREEN: focused helper and API billing tests passed after routing billing math through BigInt helpers.

Validation

  • npx prettier --check README.md docs/billing-units.md src/routes/usage.ts src/routes/meta.ts src/routes/operational.test.ts src/billing-stroops.test.ts src/billing-total-breakdown.test.ts src/routes/usage.test.ts src/health.test.ts src/util/stroops.ts src/util/stroops.test.ts
  • npm run lint
  • clean dist/, then npm run build
  • $env:NODE_ENV='test'; node --test dist/*.test.js dist/**/*.test.js
  • git diff --check

Full clean test summary: 96 tests, 12 suites, 96 pass, 0 fail.

Note: the package npm test script uses POSIX-style NODE_ENV=test, so on Windows PowerShell I ran the equivalent build plus node --test command above.

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.

Add an integer-overflow-safe stroops billing type to prevent float precision loss

1 participant