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

Merged
merged 18 commits into from
May 14, 2025
Merged

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

  • Refactor

    • Improved error handling and type safety for quoting operations, introducing structured result and error types.
    • Updated public APIs to return explicit result objects with success and error information.
    • Removed conditional compilation for TypeScript bindings and WASM traits, making them always available.
    • Simplified and consolidated trait derivations and macro invocations for WASM and TypeScript compatibility.
  • Tests

    • Enhanced test coverage for quoting functions, including success and error scenarios.
    • Updated tests to validate new result structures and error handling patterns.
    • Adjusted mocks and assertions to align with the new result object format.
  • Bug Fixes

    • Improved error propagation and user-facing error messages in quoting workflows.
    • Added explicit error handling in UI components for order quote queries.
  • Chores

    • Updated dependency configurations to ensure required packages are available across all build targets.

@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

The changes refactor WASM-related Rust modules and TypeScript bindings across several crates, improving type safety, error handling, and test coverage. Conditional compilation for WASM and test targets is simplified or removed, making WASM traits and dependencies unconditional. Result types and error handling in quoting APIs are made explicit and structured, with corresponding updates to downstream TypeScript and Svelte code and tests to match new result object shapes.

Changes

File(s) Change Summary
crates/js_api/src/gui/state_management.rs Moved eval and Reflect imports to test-only scope, restricting their use to tests.
crates/quote/Cargo.toml
crates/subgraph/Cargo.toml
Made wasm-bindgen-utils and wasm-bindgen-test unconditional dependencies; removed WASM-specific dependency section from subgraph.
crates/quote/src/js_api/mod.rs Major refactor: replaced raw/untyped WASM interfaces with explicit result and error types, improved error handling, added comprehensive tests, and introduced new serializable structs/enums for quoting results.
crates/quote/src/lib.rs Changed conditional compilation for js_api module to include both WASM and test builds.
crates/quote/src/quote.rs Made Tsify derives and WASM trait implementations unconditional for BatchQuoteTarget and BatchQuoteSpec.
crates/subgraph/src/types/common.rs Made Tsify derive and WASM trait implementation unconditional for SgOrder; moved macro invocation to struct definition.
packages/orderbook/test/quote/test.test.ts Updated tests to check for .value and .error properties on results, replacing exception-based assertions with explicit result validation.
packages/ui-components/src/tests/TanstackOrderQuote.test.ts Updated mocks for getOrderQuote to return objects with a value property wrapping the result array, matching new API.
packages/ui-components/src/lib/components/detail/TanstackOrderQuote.svelte Updated query function to throw on error responses and return only the value on success, matching new result structure.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Svelte UI
    participant TS as TypeScript Layer
    participant WASM as WASM Quote API
    participant Rust as Rust Quote Logic

    UI->>TS: orderQuoteQuery()
    TS->>WASM: getOrderQuote(...)
    WASM->>Rust: parse inputs, perform quote
    Rust-->>WASM: Result<DoOrderQuoteResult, QuoteBindingsError>
    WASM-->>TS: { value: [...], error?: string }
    alt error present
        TS-->>UI: throw Error(error)
    else success
        TS-->>UI: value
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add missing tests for quote crate's js_api/mod.rs (#1635)

Possibly related PRs

  • Add rust tests for gui state management #1682: Also modifies state_management.rs by adjusting usage of eval and Reflect for testing and adds WASM-bindgen tests, directly relating to the changes in test code and imports in this PR.

Suggested reviewers

  • findolor

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

Cargo.toml Outdated
@@ -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.

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: 1

📜 Review details

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

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • Cargo.toml (1 hunks)
🔇 Additional comments (1)
Cargo.toml (1)

56-56: Approve: Bump wasm-bindgen-utils to 0.0.8
This version bump aligns with the unconditional inclusion of WASM utilities across the crates/quote and crates/subgraph modules.

@hardyjosh
Copy link
Contributor

There seems to be lots of changes to the source as well as adding tests - can this PR be for backfilling only?

@findolor findolor requested a review from 0xgleb May 12, 2025 09:34
Copy link
Collaborator

@0xgleb 0xgleb left a comment

Choose a reason for hiding this comment

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

added one non-critical suggestion. overall looks good

Comment on lines +109 to +110
subgraph_url: String,
rpc_url: String,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: taking &str is generally preferable over String unless you need something specific to the String wrapper. Also, .do_quote method takes &str anyway, so it looks like this introduces a little bit of overhead for no reason

@hardyjosh hardyjosh enabled auto-merge May 13, 2025 21:54
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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d2fb79 and 5d7d1c8.

📒 Files selected for processing (3)
  • crates/js_api/src/gui/state_management.rs (1 hunks)
  • crates/quote/Cargo.toml (1 hunks)
  • crates/subgraph/Cargo.toml (0 hunks)
💤 Files with no reviewable changes (1)
  • crates/subgraph/Cargo.toml
🧰 Additional context used
🧠 Learnings (1)
crates/quote/Cargo.toml (1)
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1715
File: crates/js_api/src/common/mod.rs:111-118
Timestamp: 2025-04-30T09:28:36.960Z
Learning: In the rain.orderbook repository, the WASM tests are already properly configured with conditional compilation using `#[cfg(target_family = "wasm")]` and `#[cfg(not(target_family = "wasm"))]`, and don't require additional `wasm_bindgen_test_configure!(run_in_browser)` directives.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (2)
crates/js_api/src/gui/state_management.rs (1)

293-293: Good practice moving JS imports to the test module

Moving use js_sys::{eval, Reflect} from the main module scope to the test module improves code organization and safety by restricting these potentially unsafe or environment-specific imports to where they're actually used. This change aligns with the PR's goal of improving WASM bindings safety and modularity.

crates/quote/Cargo.toml (1)

44-46:

❌ Incorrect review comment

Confirm dev-dependencies for wasm tests

Moving rain_orderbook_common and wasm-bindgen-test into [dev-dependencies] makes them available across all test targets. Ensure that:

  1. Your Rust tests remain correctly gated (e.g., #[cfg(target_family = "wasm")] where needed).
  2. No redundant wasm_bindgen_test_configure! directives are introduced (per previous learnings, those aren’t necessary).
  3. rain_orderbook_common is only referenced in test code and not accidentally used in production modules.

You can verify rain_orderbook_common usage with:


🏁 Script executed:

#!/bin/bash
# Find occurrences of rain_orderbook_common in this crate
rg -n "rain_orderbook_common" -A2 crates/quote

Length of output: 821


🏁 Script executed:

#!/bin/bash
set -e
echo "Checking for module declarations in lib.rs:"
rg -n "mod quote_debug" -A2 crates/quote/src/lib.rs || echo "quote_debug not declared in lib.rs"
rg -n "mod order_quotes" -A2 crates/quote/src/lib.rs || echo "order_quotes not declared in lib.rs"

echo ""
echo "Inspecting the top of quote_debug.rs for cfg attributes:"
head -n 20 crates/quote/src/quote_debug.rs

echo ""
echo "Inspecting the top of order_quotes.rs for cfg attributes:"
head -n 20 crates/quote/src/order_quotes.rs

Length of output: 1872


rain_orderbook_common must remain a normal dependency

The rain_orderbook_common crate is imported by library modules, not just tests, so moving it to [dev-dependencies] would break your build:

  • crates/quote/src/quote_debug.rs (uses rain_orderbook_common::add_order::AddOrderArgs and dotrain_order::DotrainOrder)
  • crates/quote/src/order_quotes.rs (uses rain_orderbook_common::{add_order::AddOrderArgs, dotrain_order::DotrainOrder})

Dev-dependencies are only for test-only code. Please keep rain_orderbook_common under [dependencies]. The wasm-bindgen-test crate can live in [dev-dependencies] if you actually have #[cfg(target_family = "wasm")] test modules; otherwise consider removing it.

Likely an incorrect or invalid review comment.

@@ -27,21 +27,19 @@ anyhow = { workspace = true }
reqwest = { workspace = true }
clap = { workspace = true, features = ["env"]}
tracing-subscriber = { workspace = true, features = ['env-filter'] }
wasm-bindgen-utils = { workspace = true }
Copy link
Contributor

@coderabbitai coderabbitai bot May 13, 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

Review unconditional inclusion of wasm-bindgen-utils

You’ve moved wasm-bindgen-utils into [dependencies], making it compile for all targets. This broadening may introduce unnecessary bloat or break non-wasm builds if unguarded usages exist. Please verify that all calls to this crate are properly protected by #[cfg(target_family = "wasm")] or consider putting it behind a dedicated Cargo feature (e.g., wasm) to avoid linking it in non-wasm contexts.

To check for any unguarded imports or macro invocations:


🏁 Script executed:

#!/bin/bash
# Search for unguarded uses of wasm-bindgen-utils in source
rg -n "wasm_bindgen_utils" -A2 crates/quote/src

Length of output: 906


Guard wasm-bindgen-utils behind a cfg or Cargo feature

You’ve added wasm-bindgen-utils as an unconditional dependency, but it’s imported unguardedly in several modules:

  • crates/quote/src/quote.rs (line 19)
  • crates/quote/src/order_quotes.rs (line 13)
  • crates/quote/src/js_api/mod.rs (line 15)
  • crates/quote/src/error.rs (line 10)

This will bloat non-WASM builds and may break them if any of those imports or macros run on non-wasm targets. To fix this, either:

  1. Wrap each import (and any associated code) in:

    #[cfg(target_family = "wasm")]
    use wasm_bindgen_utils::;
  2. Or make it an optional dependency and gate it behind a new feature (e.g. wasm):

    [dependencies]
    wasm-bindgen-utils = { workspace = true, optional = true }
    
    [features]
    default = []
    wasm    = ["wasm-bindgen-utils"]

    Then wrap your modules or imports with:

    #![cfg(feature = "wasm")]

Please update the imports or Cargo.toml as needed to ensure non-WASM targets don’t pull in this crate.

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 don't need to add this as a feature as we are using this dep in our repo without any issues. As another point sometimes our non wasm targets need this so this needs to stay

Copy link
Contributor

Choose a reason for hiding this comment

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

@findolor Thanks for the clarification! I understand now that you're intentionally making wasm-bindgen-utils an unconditional dependency because:

  1. You're already using it in the repo without issues
  2. Some of your non-wasm targets (likely tests) need this dependency too

This aligns with the other changes I noticed in your PR where you're making wasm-related code available for testing purposes. Your approach makes sense - I'll approve this change.


✏️ Learnings added
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1710
File: crates/quote/Cargo.toml:30-30
Timestamp: 2025-05-14T04:49:14.581Z
Learning: In the rain.orderbook repository, wasm-bindgen-utils is intentionally used as an unconditional dependency because non-wasm targets (like tests) sometimes need to use it.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@hardyjosh hardyjosh merged commit 8d15a04 into main May 14, 2025
17 checks passed
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
3 participants