Skip to content

refactor(server): route write-path scale/UUID helpers through @tap/units #263

Description

@ThatAlexPalmer

The app write path already uses @tap/units (scaleShares / scaleAmount / uuidToBytes16 / validateShareCaps) — BigInt 1e10 math that matches the poller unscale.

The server still has a second implementation:

  • server/utils/convertToFixedPointDecimals.jstoScaledBigNumber does Math.round(price * 1e10) (IEEE float). There is a leftover TODO: might not be refactored correctly from ethers v5 to v6 on toDecimal.
  • server/utils/convertUUID.js — same UUID↔bytes16 job as @tap/units.

Controllers (issuanceController, transferController, stockClassController, seed, etc.) import the local helpers. That is a real drift risk (float rounding vs BigInt) and it fights the agent rule: do not reintroduce local scaleAmount copies.

What to do

Do not change onchain behavior in a drive-by. Make the server utils thin wrappers around @tap/units, then delete the local math once call sites compile and a couple of issuance/transfer seed paths are checked.

Keep convertTimeStampToUint40 (not in @tap/units). USDC 1e6 branch in getScale — confirm it is still used before dropping it.

Out of scope

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions