fix(provider): preserve 64-bit amounts in Kupo, Ogmios and Blockfrost - #533
Open
emmanuel-musau wants to merge 3 commits into
Open
emmanuel-musau wants to merge 3 commits into
emmanuel-musau wants to merge 3 commits into
Conversation
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.
Cardano lovelace and native-token quantities are uint64, but a JS number is exact only to 2^53-1, so any amount above that was silently rounded in three places: Kupo decodes unquoted JSON integers, and
JSON.parsetruncated them before the schema ran (#454), while the Ogmios and Blockfrost evaluate paths converted internal bigints back throughNumber()when serializing the additional UTxO set (#406, #455) — a corrupted amount gives wrong evaluation inputs and, for high-supply tokens, a transaction the node rejects. This adds an internal lossless JSON codec that decodes integers beyond the safe range as bigint and writes them back as bare numeric literals (the unquoted form these endpoints require, not quoted strings), and routes the affected Kupo GETs and Ogmios/Blockfrost evaluate POSTs through it, carrying amounts as bigint end to end; Ogmios protocol parameters deliberately keep their existing number schemas, since those values are bounded and the coreProtocolParameterstype declares them as numbers. Maestro needed no change — it sends additional UTxOs as CBOR and already decodes amounts as strings. Ten tests cover the codec and all three providers through their real entry points against a stubbed fetch; each fails on main and passes here, and reverting either half of the fix — the value transforms or the transport wiring — makes them fail again. No public API change; build, type-check, lint and all 1161 tests pass.Closes #454, closes #406, closes #455.