Skip to content

Add rust tests for quote wasm bindings #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

findolor
Copy link
Collaborator

@findolor findolor commented Apr 29, 2025

Motivation

See issue: #1601 and #1635

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • [ ] included screenshots (if this involves a front-end change)

fix #1635

Summary by CodeRabbit

  • New Features
    • Improved error handling and structured error reporting for quoting operations, providing clearer feedback to users.
  • Refactor
    • Enhanced type safety and robustness for quoting functions and WASM bindings.
    • Updated public APIs to return structured results with explicit success and error information.
  • Bug Fixes
    • Improved error propagation and user-facing error messages in quoting operations.
  • Tests
    • Expanded and updated test coverage to validate new error handling and result structures.
  • Chores
    • Updated dependency management and simplified conditional compilation for better maintainability.

@findolor findolor added test test code rust Related to rust crates labels Apr 29, 2025
@findolor findolor added this to the Test coverage, tech debt milestone Apr 29, 2025
@findolor findolor requested a review from hardyjosh April 29, 2025 11:15
@findolor findolor self-assigned this Apr 29, 2025
Copy link
Contributor

coderabbitai bot commented Apr 29, 2025

Walkthrough

This set of changes refactors several Rust and TypeScript modules to improve type safety, error handling, and test coverage for quoting operations, particularly in the context of WebAssembly (WASM) bindings. The js_api/mod.rs module is extensively rewritten to introduce structured result and error types, replacing ad-hoc or untyped error handling with explicit enums and structs. WASM trait derivations and macro invocations are made unconditional across several crates. Dependency specifications in Cargo.toml files are updated for consistency and to ensure correct availability across targets. Tests in both Rust and TypeScript are updated to reflect the new error/result structures and to provide more robust validation.

Changes

File(s) / Path(s) Change Summary
crates/quote/src/js_api/mod.rs Major refactor: Introduced typed result and error enums/structs for quoting operations, replaced untyped errors and panics with explicit error propagation, rewrote WASM bindings using wasm_bindgen_utils, improved input parsing, and added comprehensive tests for both WASM and non-WASM targets.
crates/quote/src/quote.rs, crates/subgraph/src/types/common.rs Made Tsify trait derivation and wasm_bindgen_utils macro invocations unconditional, moved macro invocations for WASM traits to be colocated with struct definitions, and removed conditional compilation attributes related to WASM.
crates/quote/Cargo.toml, crates/subgraph/Cargo.toml, Cargo.toml Updated dependency specifications: moved dependencies out of conditional sections, updated wasm-bindgen-utils to a Git reference in root Cargo.toml, and removed now-unnecessary conditional dependency sections.
crates/quote/src/lib.rs Broadened compilation of js_api module to include test builds as well as WASM targets.
crates/js_api/src/gui/state_management.rs Restricted usage of js_sys imports (eval, Reflect) to test code only.
packages/orderbook/test/quote/test.test.ts, packages/ui-components/src/__tests__/TanstackOrderQuote.test.ts Updated tests to validate new result structures, checking for .value and .error properties, and replaced exception-based error handling with explicit result object validation.
packages/ui-components/src/lib/components/detail/TanstackOrderQuote.svelte Modified query function to throw on error responses and return only the value, aligning error handling with new result structure.

Sequence Diagram(s)

sequenceDiagram
    participant JS_Client
    participant WASM_Bindings
    participant Rust_QuoteLogic

    JS_Client->>WASM_Bindings: Call quoting function (e.g., do_quote_targets)
    WASM_Bindings->>Rust_QuoteLogic: Parse input, call Rust logic
    Rust_QuoteLogic-->>WASM_Bindings: Return Result<T, QuoteBindingsError>
    WASM_Bindings-->>JS_Client: Return structured { value, error } object
    Note over JS_Client: JS checks for .error or .value and handles accordingly
Loading

Assessment against linked issues

Objective Addressed Explanation
Add or improve tests for quote crate, specifically js_api/mod.rs (#1635)

Suggested reviewers

  • hardyjosh
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ece3d12 and 0d4e2f6.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • tauri-app/src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • Cargo.toml (1 hunks)
  • crates/js_api/src/gui/state_management.rs (1 hunks)
  • crates/quote/Cargo.toml (1 hunks)
  • crates/quote/src/js_api/mod.rs (1 hunks)
  • crates/quote/src/lib.rs (1 hunks)
  • crates/quote/src/quote.rs (2 hunks)
  • crates/subgraph/Cargo.toml (0 hunks)
  • crates/subgraph/src/types/common.rs (2 hunks)
  • packages/orderbook/test/quote/test.test.ts (8 hunks)
  • packages/ui-components/src/__tests__/TanstackOrderQuote.test.ts (5 hunks)
  • packages/ui-components/src/lib/components/detail/TanstackOrderQuote.svelte (1 hunks)
💤 Files with no reviewable changes (1)
  • crates/subgraph/Cargo.toml
🧰 Additional context used
🪛 Biome (1.9.4)
packages/orderbook/test/quote/test.test.ts

[error] 192-192: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 334-334: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 345-345: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build-tauri (ubuntu-22.04, true)
  • GitHub Check: test
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: test
🔇 Additional comments (14)
crates/js_api/src/gui/state_management.rs (1)

291-291: Improved code organization by moving imports to the tests module.

Moving js_sys::{eval, Reflect} from the main module scope to the tests module is a good practice. This confines potentially unsafe functionality like eval to test code only and keeps imports localized to where they're actually used.

crates/quote/Cargo.toml (2)

31-31: Making wasm-bindgen-utils available unconditionally.

Moving wasm-bindgen-utils from target-specific dependencies to general dependencies ensures it's available for all target environments. This is necessary to support the expanded compilation conditions in lib.rs.


45-46: Added test dependencies to support wasm testing.

Adding rain_orderbook_common and wasm-bindgen-test to dev-dependencies provides the necessary tools to test WebAssembly bindings, directly supporting the PR's objective to enhance test coverage.

crates/quote/src/lib.rs (1)

9-9: Expanded compilation condition to include tests.

Changing the js_api module compilation condition from #[cfg(target_family = "wasm")] to #[cfg(any(target_family = "wasm", test))] is key to achieving the PR objective. This change enables the js_api module to be compiled and included during test builds regardless of the target family, allowing proper testing of the WebAssembly bindings even in non-wasm environments.

packages/ui-components/src/lib/components/detail/TanstackOrderQuote.svelte (1)

46-51: Improved error handling with explicit error propagation

The updated query function correctly handles the new result structure from the getOrderQuote function. This change properly propagates errors by throwing an exception when an error is detected, making debugging and error handling more straightforward.

packages/ui-components/src/__tests__/TanstackOrderQuote.test.ts (5)

15-25: Test updated to match new API result structure

The mock correctly reflects the updated return type of getOrderQuote, which now returns an object with a value property containing the array of results.


50-67: Test updated to match new API result structure

The mock correctly reflects the updated return type structure with wrapped values.


92-109: Test updated to match new API result structure

The mock updates here match the new return type pattern consistently with the other test cases.


130-140: Test updated to match new API result structure

Error handling case properly updated to match the new return type structure.


162-172: Test updated to match new API result structure

Zero ratio test case correctly updated with the new structure.

crates/subgraph/src/types/common.rs (1)

90-109: Unconditional WASM trait implementation for SgOrder

The changes here remove the conditional compilation for the Tsify derive macro and the impl_wasm_traits! macro invocation, making them always available regardless of the compilation target. This is a good simplification that aligns with the PR's goal of improving test coverage for quote WASM bindings.

By making these traits unconditionally available, we can ensure consistent behavior across all environments and make testing easier.

crates/quote/src/quote.rs (2)

106-110: Unconditional WASM trait implementation for BatchQuoteTarget

Removing the conditional compilation for the Tsify derive macro and making the WASM trait implementation unconditional is a good approach. This simplifies the code and ensures consistent behavior across all compilation targets.


202-206: Unconditional WASM trait implementation for BatchQuoteSpec

Similar to the change for BatchQuoteTarget, removing the conditional compilation here simplifies the code and ensures consistent behavior across all targets. This change supports the goal of improved test coverage for WASM bindings.

crates/quote/src/js_api/mod.rs (1)

57-60: Hex parsing of order_hash relies on implementation details

U256::from_str currently accepts both decimal and 0x-prefixed hex, but this is implementation-defined and may change.
Parsing explicitly as hex makes intent clear and avoids silent breakage:

-let order_hash = U256::from_str(order_hash)?;
+let order_hash = U256::from_hex(order_hash)?;

(Requires use alloy::hex::FromHex).

Please verify tests still pass.

@@ -53,7 +53,7 @@ test-context = "0.3.0"
portpicker = "0.1.1"
rain-erc = { git = "https://github.com/rainlanguage/rain.erc", rev = "0106e645ebd49334addc698c5aad9a85370eb54d" }
rain-error-decoding = { git = "https://github.com/rainlanguage/rain.error", rev = "72d9577fdaf7135113847027ba951f9a43b41827" }
wasm-bindgen-utils = "0.0.7"
wasm-bindgen-utils = { git = "https://github.com/rainlanguage/rain.wasm", rev = "4379d24a671742a58ec5cdab2c39fecbda59619d" }
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Using git dependency for more precise version control.

Switching from a fixed version to a specific git commit for wasm-bindgen-utils provides better control over the exact implementation being used. This helps ensure consistency across the workspace, particularly important for WebAssembly bindings.


🏁 Script executed:

#!/bin/bash
# Check if this commit is used in other workspace crates
grep -r "wasm-bindgen-utils.*4379d24a671742a58ec5cdab2c39fecbda59619d" --include="Cargo.toml" ./crates/

Length of output: 103


🏁 Script executed:

#!/bin/bash
# Search all Cargo.toml files in the repository for any reference to wasm-bindgen-utils
rg "wasm-bindgen-utils" --glob Cargo.toml -n .

Length of output: 687


🏁 Script executed:

#!/bin/bash
# Show the section around the git override in the root manifest
sed -n '45,70p' Cargo.toml

# Show the dependency section in the Tauri app manifest
sed -n '30,60p' tauri-app/src-tauri/Cargo.toml

Length of output: 2092


Ensure Tauri app picks up the git‐pinned wasm-bindgen-utils version

You’ve added wasm-bindgen-utils = { git = …, rev = … } to the workspace dependencies, but the Tauri app’s WASM target is still locked to version "0.0". To have it use the exact commit you specified above, change its dependency to reference the workspace entry:

--- tauri-app/src-tauri/Cargo.toml
@@ [target.'cfg(target_family = "wasm")'.dependencies]
-wasm-bindgen-utils = "0.0"
+wasm-bindgen-utils = { workspace = true }

This ensures the Tauri‐side WASM build also uses the Git commit override you added.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
wasm-bindgen-utils = { git = "https://github.com/rainlanguage/rain.wasm", rev = "4379d24a671742a58ec5cdab2c39fecbda59619d" }
# tauri-app/src-tauri/Cargo.toml
[target.'cfg(target_family = "wasm")'.dependencies]
wasm-bindgen-utils = { workspace = true }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to update this dependency later on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findolor I understand, you're planning to update the wasm-bindgen-utils dependency in the Tauri app in a future PR. That makes sense to keep the current PR focused on adding Rust tests for the quote wasm bindings. Let me know if you need any assistance with the current implementation.

@@ -1,6 +1,6 @@
import assert from 'assert';
import { getLocal } from 'mockttp';
import { describe, it, beforeEach, afterEach } from 'vitest';
import { describe, it, beforeEach, afterEach, expect } from 'vitest';
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Prefer a single assertion library

vitest’s expect API is imported, yet the remainder of the file predominantly relies on Node’s built-in assert.
Using two different assertion styles in the same suite is confusing for readers and can lead to inconsistent failure messages and diff output.

Consider migrating all remaining assert.* calls to expect (or vice-versa) for consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep this for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findolor Understood! Not changing the assertion styles for now makes sense, as keeping PRs focused is often more practical than expanding scope to address every potential improvement.

Comment on lines +192 to +193
const result = await doQuoteTargets([target], mockServer.url + '/rpc-url');
if (!result.value) expect.fail('Expected value');
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Use template literals instead of string concatenation

Biome flagged this line. A template literal keeps the string readable and avoids accidental spacing issues.

-const result = await doQuoteTargets([target], mockServer.url + '/rpc-url');
+const result = await doQuoteTargets([target], `${mockServer.url}/rpc-url`);

Repeat for similar concatenations (e.g. lines 116, 334, 345).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const result = await doQuoteTargets([target], mockServer.url + '/rpc-url');
if (!result.value) expect.fail('Expected value');
const result = await doQuoteTargets([target], `${mockServer.url}/rpc-url`);
if (!result.value) expect.fail('Expected value');
🧰 Tools
🪛 Biome (1.9.4)

[error] 192-192: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findolor Understood! I'll respect your decision not to change the string concatenation to template literals at this time.

Comment on lines 24 to 28
const result = getId(orderbook, orderHash);
const expected = '0xca228cb816102ef9f8e0f9a87bb34e06c49c4d4ddf5a2a0ec229ab671475c235';
assert.equal(result, expected);
if (result.error) expect.fail('Expected value');
assert.equal(result.value, expected);
});
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Guard against both failure channels

You correctly fail the test when result.error exists, but, if the WASM layer ever returns an object with neither value nor error (e.g. an unexpected shape), assert.equal(result.value, expected) will throw a TypeError before the intent is clear.

- if (result.error) expect.fail('Expected value');
- assert.equal(result.value, expected);
+if (result.error || result.value === undefined) {
+  expect.fail(`Unexpected error or empty value: ${JSON.stringify(result.error)}`);
+}
+expect(result.value).toEqual(expected);

This makes the intent explicit and prevents dereferencing undefined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not a possibility

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findolor I understand. If you're certain that the API contract guarantees either a value or an error will always be present (but never neither), then the current implementation is sufficient. Thanks for the clarification.

Comment on lines +86 to +99
let res = quotes
.into_iter()
.map(|q| match q {
Ok(v) => QuoteResultEnum::Success {
value: v,
error: None,
},
Err(e) => QuoteResultEnum::Err {
value: None,
error: e.to_string(),
},
})
.collect();

Copy link
Contributor

@coderabbitai coderabbitai bot Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Return user-friendly error messages to JS caller

JS consumers expect readableMsg (see tests) yet the mapping here propagates e.to_string(), losing the nicely formatted message provided by QuoteBindingsError::to_readable_msg().

-Err(e) => QuoteResultEnum::Err {
-    value: None,
-    error: e.to_string(),
-},
+Err(e) => QuoteResultEnum::Err {
+    value: None,
+    error: e.to_readable_msg(),
+},

Apply the same change in do_quote_specs for parity.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let res = quotes
.into_iter()
.map(|q| match q {
Ok(v) => QuoteResultEnum::Success {
value: v,
error: None,
},
Err(e) => QuoteResultEnum::Err {
value: None,
error: e.to_string(),
},
})
.collect();
let res = quotes
.into_iter()
.map(|q| match q {
Ok(v) => QuoteResultEnum::Success {
value: v,
error: None,
},
Err(e) => QuoteResultEnum::Err {
value: None,
error: e.to_readable_msg(),
},
})
.collect();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal message is fine for our case at the moment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findolor Understood! I'll respect your preference to keep the normal error message format for now. Let me know if you need any other assistance with the code.

Comment on lines +17 to +32
#[derive(Serialize, Deserialize, Debug, Clone, Tsify)]
#[serde(untagged)]
pub enum QuoteResultEnum {
Success {
value: OrderQuoteValue,
#[tsify(type = "undefined")]
error: Option<String>,
},
Err {
#[tsify(type = "undefined")]
value: Option<OrderQuoteValue>,
error: String,
},
}
impl_wasm_traits!(QuoteResultEnum);

Copy link
Contributor

@coderabbitai coderabbitai bot Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

serde(untagged) may cause ambiguous (de)serialisation

Both Success and Err variants expose the same field names (value, error) with optional types. With #[serde(untagged)], Serde chooses the first variant that can be deserialised, which becomes ambiguous when a JSON object accidentally contains both keys or neither.

Adding an explicit tag avoids this trap and produces clearer JSON:

-#[serde(untagged)]
-pub enum QuoteResultEnum {
+#[serde(tag = "status", rename_all = "lowercase")]
+pub enum QuoteResultEnum {
     Success {
         value: OrderQuoteValue,
         #[tsify(type = "undefined")]
         error: Option<String>,
     },
     Err {

Downstream TS remains unchanged because the discriminant is ignored when using the generated typings.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[derive(Serialize, Deserialize, Debug, Clone, Tsify)]
#[serde(untagged)]
pub enum QuoteResultEnum {
Success {
value: OrderQuoteValue,
#[tsify(type = "undefined")]
error: Option<String>,
},
Err {
#[tsify(type = "undefined")]
value: Option<OrderQuoteValue>,
error: String,
},
}
impl_wasm_traits!(QuoteResultEnum);
#[derive(Serialize, Deserialize, Debug, Clone, Tsify)]
#[serde(tag = "status", rename_all = "lowercase")]
pub enum QuoteResultEnum {
Success {
value: OrderQuoteValue,
#[tsify(type = "undefined")]
error: Option<String>,
},
Err {
#[tsify(type = "undefined")]
value: Option<OrderQuoteValue>,
error: String,
},
}
impl_wasm_traits!(QuoteResultEnum);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the expected response, no need to change it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findolor Understood! I'll respect your design decision to keep the #[serde(untagged)] attribute as is. Thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Related to rust crates test test code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing test - Quote crate - js_api/mod.rs
1 participant