Skip to content

feat: add support for wasm#36

Open
HerringtonDarkholme wants to merge 1 commit intoelliottech:mainfrom
HerringtonDarkholme:main
Open

feat: add support for wasm#36
HerringtonDarkholme wants to merge 1 commit intoelliottech:mainfrom
HerringtonDarkholme:main

Conversation

@HerringtonDarkholme
Copy link

Hi lighter team, this pull request enables wasm build for host like JavaScript to use.

The change is mainly

  • type cast change
  • argument addition, matching the sharelib implementation

Other than that, the wasm build also introduces a new global variable chainId that reflects the same architecture of sharelib version.

That means the wasm user will have to use the lib in a single-threaded way, which is quite common in JS world

@alexvelea
Copy link
Collaborator

@Bvvvp009 could you take a look at this please?
also @HerringtonDarkholme , feel free to ping on Discord in the api-trading-chat as well if you have not.

@alexvelea
Copy link
Collaborator

I think your changes make sense @HerringtonDarkholme
I'd reffer to @Bvvvp009 if he has anything else to add to make the wasm spot-ready
The memo change, to support hex encoded which I've added recently would be an example
Unsure if other things have changed TBH

@Bvvvp009
Copy link
Contributor

Bvvvp009 commented Dec 5, 2025

I will look into these changes from @HerringtonDarkholme and add if any new changes are required.

Bvvvp009 added a commit to Bvvvp009/lighter-go that referenced this pull request Dec 5, 2025
- Add global chainId variable and use it in messageToSign for L2TransferTxInfo
- Add encoding/hex import for memo hex decoding
- Update SignTransfer: add argument validation, complete memo hex encoding support
- Fix SignCancelOrder: use safeInt16 for MarketIndex type safety
- Ensure all MarketIndex uses int16 (not uint8) to support spot markets (2048+)
- Match sharedlib implementation exactly for full WASM parity

This completes PR elliottech#36 by adding the remaining changes needed for full WASM support
that matches the CGO/sharedlib implementation.
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.

3 participants