Skip to content

fix(wasm): accept order index as a string or number in SignCancelOrder and SignModifyOrder#78

Open
lowenhere wants to merge 2 commits into
elliottech:mainfrom
lowenhere:main
Open

fix(wasm): accept order index as a string or number in SignCancelOrder and SignModifyOrder#78
lowenhere wants to merge 2 commits into
elliottech:mainfrom
lowenhere:main

Conversation

@lowenhere

Copy link
Copy Markdown

Problem

  • WASM SignCancelOrder and SignModifyOrder read the order index via int64(args[1].Int())
  • Any order index above Number.MAX_SAFE_INTEGER (2^53 - 1) is not guaranteed to be represented exactly as a JS number, so .Int() can carry a different value into the tx, which then gets signed with no error.
  • This is reachable in normal use - server order indices span [2^48, 2^60-1] based on:
    MinOrderIndex int64 = MaxClientOrderIndex + 1
    MaxOrderIndex int64 = (1 << 60) - 1

Fix

  • Accept the index as a string or number in both functions: parse strings with strconv.ParseInt (full int64), fall back to .Int() for numbers

Validation

  • GOOS=js GOARCH=wasm go build ./wasm/ and go vet pass

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