-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Summary
crates/js_api/src/gui/ (~7,850 lines across 7 files) contains the order-building state machine, validation, and transaction generation logic. ~90% is platform-agnostic business logic trapped in the WASM-only crate. Rename from gui to raindex_order_builder to reflect its actual purpose.
What needs to move
| Current file | New module | Lines | Core % | Description |
|---|---|---|---|---|
gui/mod.rs |
raindex_order_builder |
2,120 | ~85% | RaindexOrderBuilder state machine, config, deployment management |
gui/order_operations.rs |
raindex_order_builder::calldata |
1,215 | ~95% | Transaction calldata (approvals, deposits, addOrder, multicall) |
gui/field_values.rs |
raindex_order_builder::fields |
1,008 | ~90% | Field value parsing, presets, get/set/unset |
gui/select_tokens.rs |
raindex_order_builder::tokens |
1,036 | ~85% | Token selection, RPC metadata fetching |
gui/state_management.rs |
raindex_order_builder::state |
950 | ~100% | Serialize/restore state (gzip+base64+SHA256) |
gui/deposits.rs |
raindex_order_builder::deposits |
710 | ~95% | Deposit state tracking, preset detection |
gui/validation.rs |
raindex_order_builder::validation |
703 | ~100% | Number/string/boolean constraint checking |
Key renames
DotrainOrderGui→RaindexOrderBuilderGuiError→RaindexOrderBuilderErrorgui/→raindex_order_builder/
What stays in js_api
Thin WASM wrappers for each module:
#[wasm_bindgen]on a WASM-facing struct#[wasm_export]on all public methodsjs_sys::Functionstate update callback binding- Error-to-JsValue conversions
Proposed approach
- Create
common::raindex_order_buildermodule with coreRaindexOrderBuilderstruct - Replace
js_sys::Functioncallback with generic Rust callback trait/closure - Keep
js_api::gui(or rename tojs_api::order_builder) as thin WASM wrappers - Ensure
RaindexOrderBuilderis usable from CLI and tests without WASM
Benefits
- CLI can use the same order-building/validation logic
- Tests can verify state machine without WASM target
- Server-side tooling can reuse field validation and calldata generation
- Clear separation: core logic vs platform bindings
- Name reflects actual purpose (builder, not GUI)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels