Skip to content

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Jul 24, 2025

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a collapsible "Advanced SDK Configuration" section in the UI, allowing users to specify SDK initialization parameters such as platform version and request settings.
    • Introduced an "Apply Configuration" button to reinitialize the SDK with user-defined options.
    • Displayed the latest platform version next to the input field for user reference.
    • Measured and displayed execution time for queries, state transitions, and data loading operations.
  • Documentation

    • Added comprehensive documentation detailing caching strategies, cache invalidation, service worker behavior, and troubleshooting tips for the WASM SDK.
  • Enhancements

    • Extended the SDK builder with new methods for configuring platform version and request settings, providing greater flexibility during SDK initialization.

Copy link
Contributor

coderabbitai bot commented Jul 24, 2025

Walkthrough

A new caching documentation file was added to the WASM SDK package, outlining caching strategies and troubleshooting. The SDK's HTML frontend was updated to allow user-configurable initialization parameters, display execution timing, and enhance UI feedback. The Rust WASM SDK builder gained new methods for platform version and request settings configuration, exposed to JavaScript.

Changes

File(s) Change Summary
packages/wasm-sdk/CACHING.md Added documentation detailing caching strategies, cache invalidation, service worker usage, and troubleshooting.
packages/wasm-sdk/index.html Added UI for advanced SDK configuration, timing feedback on operations, helper for status updates, and CSS.
packages/wasm-sdk/src/sdk.rs Added public methods to WasmSdkBuilder for platform version, request settings, and latest version retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (index.html)
    participant WasmSdkBuilder (Rust)
    participant SDK Instance

    User->>UI (index.html): Open Advanced SDK Configuration
    User->>UI (index.html): Enter config (version, timeouts, etc.) and click "Apply Configuration"
    UI (index.html)->>WasmSdkBuilder (Rust): with_version(), with_settings()
    WasmSdkBuilder (Rust)->>WasmSdkBuilder (Rust): Apply settings
    WasmSdkBuilder (Rust)-->>UI (index.html): Return configured builder
    UI (index.html)->>SDK Instance: Build SDK with user config
    User->>UI (index.html): Run query or state transition
    UI (index.html)->>SDK Instance: Execute operation
    SDK Instance-->>UI (index.html): Return result
    UI (index.html)->>User: Display result and execution time
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–25 minutes

Suggested labels

js-sdk

Suggested reviewers

  • lklimek

Poem

A rabbit hopped by the WASM SDK,
With caching tips and configs on display.
Now users can tweak, and see how fast,
Each query and contract is running at last!
With builder patterns and timing delight,
This code’s a carrot—crisp and bright! 🥕

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a0ca243 and 5ac616f.

📒 Files selected for processing (1)
  • packages/wasm-sdk/index.html (29 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/wasm-sdk/index.html
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: build-wasm-sdk
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/WasmSDKRequestSettings

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 generate unit tests to generate unit tests for 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: 2

🧹 Nitpick comments (1)
packages/wasm-sdk/index.html (1)

4809-4815: Consider debouncing the “Apply Configuration” button

Rapid repeated clicks will spawn overlapping initializeSdk calls.
Although you guard with initRequestCounter, disabling the button until the promise settles will prevent unnecessary work and bandwidth.

 document.getElementById('applyConfig').addEventListener('click', async () => {
+  const btn = document.getElementById('applyConfig');
+  btn.disabled = true;
   const network = document.querySelector('input[name="network"]:checked')?.value || 'mainnet';
   clearResults();
   updateStatus('Applying new SDK configuration...', 'loading');
   await initializeSdk(network);
+  btn.disabled = false;
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 84338d2 and c6fab80.

📒 Files selected for processing (3)
  • packages/wasm-sdk/CACHING.md (1 hunks)
  • packages/wasm-sdk/index.html (29 hunks)
  • packages/wasm-sdk/src/sdk.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/wasm-sdk/src/**/*.rs

📄 CodeRabbit Inference Engine (packages/wasm-sdk/CLAUDE.md)

packages/wasm-sdk/src/**/*.rs: When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Files:

  • packages/wasm-sdk/src/sdk.rs
packages/wasm-sdk/index.html

📄 CodeRabbit Inference Engine (CLAUDE.md)

Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'

Files:

  • packages/wasm-sdk/index.html
packages/wasm-sdk/**/index.html

📄 CodeRabbit Inference Engine (packages/wasm-sdk/CLAUDE.md)

packages/wasm-sdk/**/index.html: When adding new queries or state transitions, update the definitions in index.html.
The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Files:

  • packages/wasm-sdk/index.html
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
Learnt from: lklimek
PR: dashpay/platform#2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: QuantumExplorer
PR: dashpay/platform#2257
File: packages/rs-drive-abci/src/mimic/test_quorum.rs:159-164
Timestamp: 2024-11-20T16:16:01.830Z
Learning: QuantumExplorer prefers not to receive auto-generated messages asking to post on social media.
Learnt from: QuantumExplorer
PR: dashpay/platform#2439
File: packages/rs-dpp/src/errors/consensus/state/token/mod.rs:4-22
Timestamp: 2025-01-23T02:10:08.979Z
Learning: The user QuantumExplorer prefers to handle documentation of breaking changes separately from the code changes, particularly for token-related error types and validation rules.
Learnt from: QuantumExplorer
PR: dashpay/platform#2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.
packages/wasm-sdk/CACHING.md (11)

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.

packages/wasm-sdk/src/sdk.rs (14)

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: lklimek
PR: #2254
File: packages/rs-sdk/src/sdk.rs:585-585
Timestamp: 2024-10-18T15:39:51.172Z
Learning: The 'platform' project uses Rust version 1.80, so code in 'packages/rs-sdk' can use features available in Rust 1.80, such as the abs_diff() method.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'

Learnt from: lklimek
PR: #2232
File: packages/rs-sdk/src/mock/sdk.rs:90-95
Timestamp: 2024-10-10T10:30:19.883Z
Learning: In packages/rs-sdk/src/mock/sdk.rs, the load_expectations method in MockDashPlatformSdk remains asynchronous (async) for backward compatibility, even though it now delegates to the synchronous load_expectations_sync method.

Learnt from: shumkov
PR: #2206
File: packages/rs-drive-abci/tests/strategy_tests/main.rs:1162-1162
Timestamp: 2024-10-04T09:08:47.901Z
Learning: In the Rust test file packages/rs-drive-abci/tests/strategy_tests/main.rs, specific protocol versions like PROTOCOL_VERSION_1 are intentionally used in tests instead of PROTOCOL_VERSION_LATEST.

Learnt from: shumkov
PR: #2489
File: packages/rs-dpp/Cargo.toml:32-32
Timestamp: 2025-03-11T09:39:23.071Z
Learning: In the Dash Platform project, dependencies are currently managed using Git repository references with tags (repo+tag format in Cargo.toml) rather than published crates, as the team is not currently publishing crates to crates.io.

Learnt from: QuantumExplorer
PR: #2690
File: packages/wasm-sdk/src/queries/document.rs:383-384
Timestamp: 2025-07-10T00:37:09.586Z
Learning: In the Dash platform, DPNS (Dash Platform Name Service) contracts have the same ID across all networks (mainnet, testnet, etc.), so hardcoding the DPNS contract ID is appropriate and doesn't need to be configurable.

Learnt from: lklimek
PR: #1924
File: packages/rs-dapi-client/src/request_settings.rs:74-74
Timestamp: 2024-12-05T12:59:22.044Z
Learning: The AppliedRequestSettings struct in packages/rs-dapi-client/src/request_settings.rs is intended for internal use within the monorepo and is not part of the public API.

Learnt from: shumkov
PR: #2259
File: packages/rs-dapi-client/src/executor.rs:49-56
Timestamp: 2024-10-28T10:38:49.538Z
Learning: In packages/rs-dapi-client/src/executor.rs, the ExecutionResponse struct always has a non-optional address field of type Address because an address is always present when there's a successful response.

packages/wasm-sdk/index.html (18)

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Documents and data contracts should use state transitions for updates

Learnt from: lklimek
PR: #2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's rs-sdk/tests integration tests (e.g., in packages/rs-sdk/tests/fetch/config.rs), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.

Learnt from: lklimek
PR: #2232
File: packages/rs-sdk/src/mock/sdk.rs:90-95
Timestamp: 2024-10-10T10:30:19.883Z
Learning: In packages/rs-sdk/src/mock/sdk.rs, the load_expectations method in MockDashPlatformSdk remains asynchronous (async) for backward compatibility, even though it now delegates to the synchronous load_expectations_sync method.

Learnt from: lklimek
PR: #2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.

Learnt from: shumkov
PR: #2314
File: packages/wallet-contract/test/bootstrap.js:14-16
Timestamp: 2024-11-06T07:27:01.722Z
Learning: In packages/wallet-contract/test/bootstrap.js, for Mocha tests in Node.js, async functions like loadWasmDpp can be assigned directly to beforeAll without wrapping them in another async function.

Learnt from: shumkov
PR: #2270
File: packages/dapi/lib/grpcServer/handlers/platform/broadcastStateTransitionHandlerFactory.js:90-96
Timestamp: 2024-10-24T05:01:51.097Z
Learning: In broadcastStateTransitionHandlerFactory.js, error handling when querying transaction status is handled in the API script.

Learnt from: shumkov
PR: #2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the IdentityTransitionVersions structure within packages/rs-platform-version/src/version/v2.rs, the field credit_withdrawal does not need the identity_ prefix since it is already encompassed within identity state transitions.

Learnt from: shumkov
PR: #2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the IdentityTransitionVersions structure within packages/rs-platform-version/src/version/v2.rs, the field credit_withdrawal does not need the identity_ prefix since it is already encompassed within identity state transitions.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: build-wasm-sdk
🔇 Additional comments (6)
packages/wasm-sdk/src/sdk.rs (4)

16-19: LGTM: New imports properly support the added functionality.

The new imports are appropriately added to support platform versioning (PlatformVersion, PlatformVersionCurrentVersion), request settings (RequestSettings), and time handling (Duration). The VersionedGrpcResponse import aligns with the WASM SDK's GRPC integration patterns.

Also applies to: 24-24


136-140: LGTM: Clean and straightforward version retrieval.

The method correctly retrieves the latest platform protocol version and exposes it with appropriate JavaScript naming. The implementation is simple and reliable.


667-680: LGTM: Robust version configuration with proper error handling.

The method correctly validates the platform version using PlatformVersion::get() and provides clear error messages when invalid versions are provided. The documentation is helpful and the error handling follows WASM SDK patterns.


682-715: LGTM: Well-designed request settings configuration.

The method provides flexible configuration of request settings with proper type conversions:

  • Milliseconds to Duration conversion is correct
  • Optional parameters allow selective configuration
  • Type casts are safe in the WASM context
  • Comprehensive documentation explains each parameter clearly

The implementation follows the builder pattern appropriately and handles all the common request configuration scenarios.

packages/wasm-sdk/CACHING.md (1)

1-146: Excellent comprehensive caching documentation.

This documentation effectively explains the multi-layered caching strategy implemented for the WASM SDK:

  • Clear technical explanations: ETag mechanism and service worker caching are well explained
  • Practical guidance: Includes concrete examples for developers (build workflow, cache control)
  • Comprehensive troubleshooting: Covers common issues with actionable solutions
  • Browser compatibility: Provides browser-specific instructions for cache management

The documentation complements the new SDK configuration features by ensuring users understand how caching works with platform version updates and request settings changes. This will help prevent confusion when SDK updates are deployed.

packages/wasm-sdk/index.html (1)

2898-2903: Nice utility addition

updateStatusWithTime is a clean wrapper that standardises timing feedback and keeps the call-sites tidy.

@QuantumExplorer QuantumExplorer added this to the v2.1 milestone Jul 24, 2025
@QuantumExplorer QuantumExplorer changed the title feat: request settings in wasm sdk feat(sdk): request settings in wasm sdk Jul 24, 2025
@QuantumExplorer
Copy link
Member Author

Self Reviewed.

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

🔭 Outside diff range comments (1)
packages/wasm-sdk/index.html (1)

2051-2053: Event-listener leak on repeated schema loads

populateIndexFields attaches a change handler to indexSelector every call.
When the user loads multiple contracts, the callbacks stack up and execute n times.

Quick containment:

- indexSelector.addEventListener('change', handler);
+ indexSelector.onchange = handler; // replaces any previous listener

or keep a weak reference and remove it via removeEventListener before adding a new one.

🧹 Nitpick comments (2)
packages/wasm-sdk/index.html (2)

2898-2903: Minor: consider folding timing into updateStatusWithTime

updateStatusWithTime already computes the delta; every caller still needs the boiler-plate const startTime = performance.now().
A thin wrapper:

function timed(label, fn) {
  const start = performance.now();
  return fn().finally(() =>
    updateStatusWithTime(label, 'success', start)
  );
}

would DRY up the now numerous timing sites.
Not critical, just readability.


4809-4815: UI polish: disable “Apply Configuration” while re-initialising

During the async re-initialisation the button stays active – rapid clicks spawn parallel initializeSdk calls and race on initRequestCounter.
Guard with a disabled state or wrap the handler in a debounce.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c6fab80 and a0ca243.

📒 Files selected for processing (1)
  • packages/wasm-sdk/index.html (29 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/wasm-sdk/index.html

📄 CodeRabbit Inference Engine (CLAUDE.md)

Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'

Files:

  • packages/wasm-sdk/index.html
packages/wasm-sdk/**/index.html

📄 CodeRabbit Inference Engine (packages/wasm-sdk/CLAUDE.md)

packages/wasm-sdk/**/index.html: When adding new queries or state transitions, update the definitions in index.html.
The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Files:

  • packages/wasm-sdk/index.html
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Use WASM bindings to connect Rust and JavaScript code for cross-language integration
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
Learnt from: lklimek
PR: dashpay/platform#2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: QuantumExplorer
PR: dashpay/platform#2257
File: packages/rs-drive-abci/src/mimic/test_quorum.rs:159-164
Timestamp: 2024-11-20T16:16:01.830Z
Learning: QuantumExplorer prefers not to receive auto-generated messages asking to post on social media.
Learnt from: QuantumExplorer
PR: dashpay/platform#2439
File: packages/rs-dpp/src/errors/consensus/state/token/mod.rs:4-22
Timestamp: 2025-01-23T02:10:08.979Z
Learning: The user QuantumExplorer prefers to handle documentation of breaking changes separately from the code changes, particularly for token-related error types and validation rules.
Learnt from: QuantumExplorer
PR: dashpay/platform#2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.
packages/wasm-sdk/index.html (23)

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/index.html : Test the WASM SDK using the web interface at 'index.html' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : For WASM builds, fix 'time not implemented on this platform' errors by using js_sys::Date::now().

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/build.sh : Build the WASM SDK by running './build.sh' in 'packages/wasm-sdk'

Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'

Learnt from: lklimek
PR: #2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.

Learnt from: QuantumExplorer
PR: #2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Learnt from: shumkov
PR: #2365
File: packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js:206-213
Timestamp: 2024-12-03T05:47:30.524Z
Learning: In obtainZeroSSLCertificateTaskFactory.js, when handling ZeroSSL API errors during domain verification, the error detail structure is consistent when an error occurs, so additional null checks on e.details[ctx.externalIp] may not be necessary.

Learnt from: lklimek
PR: #2381
File: packages/rs-sdk/scripts/connect_to_remote.sh:0-0
Timestamp: 2024-12-10T12:39:38.182Z
Learning: When reviewing scripts in packages/rs-sdk/scripts/, avoid suggesting additional error handling and timeout management that complicate the script without adding significant value.

Learnt from: shumkov
PR: #2162
File: packages/dashmate/src/status/providers.js:121-127
Timestamp: 2024-09-26T14:28:54.892Z
Learning: In the mnowatch.checkPortStatus function, failures should resolve with PortStateEnum.ERROR instead of rejecting the promise.

Learnt from: shumkov
PR: #2162
File: packages/dashmate/src/status/providers.js:121-127
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the mnowatch.checkPortStatus function, failures should resolve with PortStateEnum.ERROR instead of rejecting the promise.

Learnt from: shumkov
PR: #2314
File: packages/wallet-contract/test/bootstrap.js:14-16
Timestamp: 2024-11-06T07:27:01.722Z
Learning: In packages/wallet-contract/test/bootstrap.js, for Mocha tests in Node.js, async functions like loadWasmDpp can be assigned directly to beforeAll without wrapping them in another async function.

Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Documents and data contracts should use state transitions for updates

Learnt from: lklimek
PR: #2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's rs-sdk/tests integration tests (e.g., in packages/rs-sdk/tests/fetch/config.rs), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.

Learnt from: lklimek
PR: #2232
File: packages/rs-sdk/src/mock/sdk.rs:90-95
Timestamp: 2024-10-10T10:30:19.883Z
Learning: In packages/rs-sdk/src/mock/sdk.rs, the load_expectations method in MockDashPlatformSdk remains asynchronous (async) for backward compatibility, even though it now delegates to the synchronous load_expectations_sync method.

Learnt from: shumkov
PR: #2270
File: packages/dapi/lib/grpcServer/handlers/platform/broadcastStateTransitionHandlerFactory.js:90-96
Timestamp: 2024-10-24T05:01:51.097Z
Learning: In broadcastStateTransitionHandlerFactory.js, error handling when querying transaction status is handled in the API script.

Learnt from: shumkov
PR: #2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the IdentityTransitionVersions structure within packages/rs-platform-version/src/version/v2.rs, the field credit_withdrawal does not need the identity_ prefix since it is already encompassed within identity state transitions.

Learnt from: shumkov
PR: #2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the IdentityTransitionVersions structure within packages/rs-platform-version/src/version/v2.rs, the field credit_withdrawal does not need the identity_ prefix since it is already encompassed within identity state transitions.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: build-wasm-sdk
🔇 Additional comments (1)
packages/wasm-sdk/index.html (1)

2940-2945: Great – replaced null with undefined for Option<T> bindings

The earlier runtime TypeError at the JS → WASM boundary is gone thanks to the undefined fallback and the boolean short-circuit for banFailedAddress. ✅

Also applies to: 2970-2974

@QuantumExplorer
Copy link
Member Author

Self reviewed

@QuantumExplorer QuantumExplorer merged commit 5296ca6 into v2.1-dev Jul 24, 2025
21 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/WasmSDKRequestSettings branch July 24, 2025 14:16
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.

1 participant