perf: wasm intent layer - #98
Open
conwayconstar wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 10 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
1 issue found across 11 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="wasm/codegen/bullet_schema/emit/startup_subpaths/calls.rs">
<violation number="1" location="wasm/codegen/bullet_schema/emit/startup_subpaths/calls.rs:121">
P2: Warp amount normalization accepts any string without integer validation. Invalid amount strings bypass startup checks and fail later when converting to runtime calls.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| return String(value); | ||
| } | ||
| if (typeof value === "string") { | ||
| return value; |
Contributor
There was a problem hiding this comment.
P2: Warp amount normalization accepts any string without integer validation. Invalid amount strings bypass startup checks and fail later when converting to runtime calls.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wasm/codegen/bullet_schema/emit/startup_subpaths/calls.rs, line 121:
<comment>Warp amount normalization accepts any string without integer validation. Invalid amount strings bypass startup checks and fail later when converting to runtime calls.</comment>
<file context>
@@ -0,0 +1,186 @@
+ return String(value);
+ }
+ if (typeof value === "string") {
+ return value;
+ }
+ throw new Error(`${fieldName} must be a decimal string, bigint, or safe integer number`);
</file context>
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.
What
Adds startup-safe SDK subpaths so web startup code can import lightweight call/topic/error/primitive helpers without pulling in the full wasm-bindgen runtime:
@bulletxyz/sdk-wasm/calls@bulletxyz/sdk-wasm/topics@bulletxyz/sdk-wasm/errors@bulletxyz/sdk-wasm/primitivesThe new
/callsentrypoint emits plain runtime-call data. The full WASM runtime is only crossed when the app explicitly converts or submits that data:RuntimeCall.fromCall(call)Transaction.builder().call(RuntimeCall.fromCall(call))client.sendCall(call)Existing root APIs remain supported, including
CallMessage,User.*,.callMessage(...), andclient.sendCallMessage(...).Why
The web app was paying for the full SDK/WASM runtime during initial route startup because importing factories, enums, topics, and error helpers from the root package pulled generated wasm-bindgen glue into the startup graph.
This lets
/tradeand other startup paths define transaction callbacks, topic strings, enum values, and error guards without importing the WASM runtime. The app only pays for WASM when it initializes the client or actually builds/signs/submits a transaction.Note
Medium Risk
New public package surface and transaction submission path (
fromCall/sendCall) must stay aligned with schema serde and existing signing; mistakes could affect submitted call payloads, though existing APIs remain and tests cover the boundary.Overview
Adds startup-safe WASM SDK subpaths so route-level code can import call builders, topics, primitives, and error guards without pulling in wasm-bindgen glue or the
.wasmbinary.Codegen in
wasm/build.rsnow writeswasm/.generated/(gitignored) andjust build-wasmcopies those bundles intopkg/.package.jsonexports./calls,./topics,./errors, and./primitives. Schema-driven emitters produce plainRuntimeCallData(exchange actions from the schema, plus JSWarp.transferRemotewith safe-integer amount checks), frozen enums/structs, websocketTopichelpers, andisBulletSdkError/asBulletSdkError.Bridges intent data into the full runtime via
RuntimeCall.fromCall(call)(serde first, warp fallback through existingWarp::transfer_remote),Transaction.builder().call(...), andclient.sendCall(call). Root APIs (User.*,.callMessage,sendCallMessage) are unchanged.Docs cover the lazy-import pattern; Jest tests assert subpaths avoid WASM imports and round-trip through
RuntimeCall.fromCall.Reviewed by Cursor Bugbot for commit e452fb2. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds a startup-safe WASM intent layer for the web by exposing lightweight SDK subpaths that don’t load the wasm-bindgen runtime. Apps can build calls, topics, primitives, and error guards at route startup and only cross the WASM boundary when converting or submitting.
New Features
@bulletxyz/sdk-wasm/calls,@bulletxyz/sdk-wasm/topics,@bulletxyz/sdk-wasm/errors,@bulletxyz/sdk-wasm/primitives.isRuntimeCallDataandtoRuntimeCallJson; convert/submit viaRuntimeCall.fromCall(call),Transaction.builder().call(...), andclient.sendCall(call).Warp.transferRemote(...)with strict amount handling (string/bigint/safe integer) and relayer normalization.Topic.*,OrderbookDepth,KlineInterval, enums, and struct classes withtoJSON().isBulletSdkErrorandasBulletSdkErroravailable from@bulletxyz/sdk-wasm/errors. Docs updated; codegen emits subpath bundles and an internalstartup-shared(not exported). Tests lock that these imports don’t pull wasm/glue.Migration
User.*,CallMessage, andclient.sendCallMessage(...)still work.Written for commit e452fb2. Summary will update on new commits.