fix(handler): accept decimal-string rate/volume in CREATE_INTENT handler - #28
Merged
Merged
Conversation
PR #27 changed TradingIntent.rate_min/rate_max/volume_min/volume_max from bigint to string but missed the trader-command-handler.ts gate at the wire boundary. The handler still ran safeParseBigint() first, which rejected '0.08' with "rate_min must be a non-negative integer string". The shape downstream is decimal string everywhere (validateIntentParams, TradingIntent record, encodeDescription) — the handler just needs to assert the input IS a string and pass it through. Detailed validation remains in validateIntentParams (called immediately below). Verified end-to-end in unicity-sphere/sphere-sdk#475 trader-roundtrip soak: alice's `sphere trader create-intent --rate-min 0.08 ...` now succeeds at the trader gate (previously failed before reaching the intent engine). 698 / 698 tests pass.
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
PR #27 changed
TradingIntent.rate_min/rate_max/volume_min/volume_maxfrombiginttostringbut missed the gate intrader-command-handler.ts. The handler still ransafeParseBigint()first, which rejected'0.08'withrate_min must be a non-negative integer stringbefore reachingvalidateIntentParams(which I'd updated for decimals in #27).Fix
Drop the
safeParseBigintcalls for rate/volume. Assert each param is a string for the type-system, then forward tovalidateIntentParamsfor format/range checks.The
safeParseBiginthelper stays for the WITHDRAW handler (line 704), where amount is a real smallest-units token quantity.Verified
sphere trader create-intent --rate-min 0.08 --rate-max 0.12 --volume-min 50 --volume-max 50now reaches the trader's intent engineRelated