Skip to content

fix(handler): accept decimal-string rate/volume in CREATE_INTENT handler - #28

Merged
vrogojin merged 1 commit into
masterfrom
fix/command-handler-decimal-strings
Jun 13, 2026
Merged

fix(handler): accept decimal-string rate/volume in CREATE_INTENT handler#28
vrogojin merged 1 commit into
masterfrom
fix/command-handler-decimal-strings

Conversation

@vrogojin

Copy link
Copy Markdown
Owner

Summary

PR #27 changed TradingIntent.rate_min/rate_max/volume_min/volume_max from bigint to string but missed the gate in trader-command-handler.ts. The handler still ran safeParseBigint() first, which rejected '0.08' with rate_min must be a non-negative integer string before reaching validateIntentParams (which I'd updated for decimals in #27).

Fix

Drop the safeParseBigint calls for rate/volume. Assert each param is a string for the type-system, then forward to validateIntentParams for format/range checks.

The safeParseBigint helper stays for the WITHDRAW handler (line 704), where amount is a real smallest-units token quantity.

Verified

  • 698 / 698 tests pass
  • soak end-to-end: sphere trader create-intent --rate-min 0.08 --rate-max 0.12 --volume-min 50 --volume-max 50 now reaches the trader's intent engine

Related

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.
@vrogojin
vrogojin merged commit e5d9de7 into master Jun 13, 2026
1 check passed
@vrogojin
vrogojin deleted the fix/command-handler-decimal-strings branch June 13, 2026 13:29
@vrogojin
vrogojin restored the fix/command-handler-decimal-strings branch July 15, 2026 14:13
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.

1 participant