Skip to content

Conversation

thephez
Copy link
Collaborator

@thephez thephez commented Aug 14, 2025

Issue being fixed or feature implemented

Refactored WASM SDK documentation system to improve maintainability, organization, and development workflow. The previous documentation setup had scattered definitions and manual maintenance processes that made it difficult to keep documentation in sync with code changes. Includes some changes to index.html also since it is somewhat coupled with the documentation.

What was done?

  • Consolidated API definitions: Migrated from fixed_definitions.json to a unified api-definitions.json file containing all query and state transition definitions
  • Streamlined documentation scripts: Updated generate_docs.py and check_documentation.py to use the new consolidated definition file
  • Extracted CSS styles: Moved all CSS styling from docs.html and index.html to separate css files for better maintainability
  • Cleaned up codebase: Removed obsolete files including extract_definitions.py, extract_inputs.py, save_fixed_definitions.py, update_inputs.py, and update_state_transitions.py
  • Enhanced documentation workflow: Improved automation for keeping documentation synchronized with API changes
  • Simplified index.html: Reduced complexity by extracting definitions to the external JSON file

How Has This Been Tested?

  • WASM SDK functionality verified through existing test suite
  • Ran UI tests
  • Documentation generation scripts tested to ensure proper API reference creation
  • Manual verification of docs.html and index.html rendering and styling with extracted CSS

Breaking Changes

None. This is a refactoring that maintains all existing functionality while improving the internal documentation system.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • DPNS name search by prefix with optional limit and examples.
  • Refactor

    • Identity keys filter changed to multi-select "Key Purposes" (Authentication, Encryption, Decryption, Transfer, Voting).
    • Several public query parameters renamed or made optional (ids, dataContractId, startAfter, startAtMs, limit/offset, ms-suffixed time fields).
    • Evonodes query now uses numeric epoch with optional limit, startAfter and order ordering.
    • Runtime-driven API definitions and new initialization flow.
  • Documentation

    • Updated docs, examples, TOC and UTC manifest timestamps.
  • Style

    • Inline styles moved to external CSS for docs and UI.
  • Chores

    • Removed legacy extraction/population scripts; added JSON-driven doc generation and metadata.

Includes generated docs (minus a few inconsistencies in STs)
Done to
- Reduce the size of docs.html several hundred lines
- Make the CSS reusable and easier to maintain
- Allow for better caching of styles
- Keep the documentation generation process clean and modular
@thephez thephez added this to the v2.1 milestone Aug 14, 2025
Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Walkthrough

Replaces HTML-based extraction with JSON-driven API definitions, externalizes CSS, updates docs generation and validation to use api-definitions.json, changes several public query signatures (purposes multiselect, identityIds→ids, contractId→dataContractId, evonodes epoch-based params), adds dpnsSearch, and removes legacy extraction/update scripts.

Changes

Cohort / File(s) Summary
Public API & docs updates
packages/wasm-sdk/AI_REFERENCE.md, packages/wasm-sdk/docs.html, packages/wasm-sdk/docs_manifest.json
Update documentation and examples: replace keyRequestTypepurposes (multiselect with options 0/1/2/3/5), rename identityIdsids, rename contractIddataContractId, add dpnsSearch(prefix, limit), change evonodes range signature to epoch with optional limit, startAfter, orderAscending, add startAtMs to data contract history, and adjust examples and manifest entries.
Canonical API schema (JSON)
packages/wasm-sdk/api-definitions.json
Add top-level metadata (version, generated_at, source); convert key purposes input to purposes (multiselect) with new options; add/rename inputs across many endpoints (ids, startAfter, limit/offset, startAtMs, dataContractId, epoch, orderAscending); add dpnsSearch endpoint and inputs.
Docs generation & tooling
packages/wasm-sdk/generate_docs.py, packages/wasm-sdk/check_documentation.py
Move from HTML extraction to JSON-driven workflow: add load_api_definitions() and generate_docs_css(), read api-definitions.json, write external docs.css, use UTC timestamps, improve error handling, and remove extraction flow.
Runtime UI & client
packages/wasm-sdk/index.html
Load API definitions at runtime from api-definitions.json, initialize UI after load, use optional chaining for safe lookups, change WASM import pattern to include namespace import, add API error banner and progress steps, and link external index.css.
Docs styling
packages/wasm-sdk/docs.css, packages/wasm-sdk/index.css
Add comprehensive external stylesheets for docs UI and app UI; remove large inline style blocks from HTML and move styling to CSS files.
Removal of legacy scripts
packages/wasm-sdk/extract_definitions.py, packages/wasm-sdk/extract_inputs.py, packages/wasm-sdk/save_fixed_definitions.py, packages/wasm-sdk/update_inputs.py, packages/wasm-sdk/update_state_transitions.py
Delete legacy Python scripts that parsed index.html and maintained fixed definitions/inputs/state-transitions; extraction and auto-population flows removed.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant App (index.html)
  participant API JSON (api-definitions.json)
  participant WASM SDK

  Browser->>App (index.html): Load page
  App (index.html)->>API JSON (api-definitions.json): Fetch definitions
  API JSON (api-definitions.json)-->>App (index.html): Return queries/transitions
  App (index.html)->>App (index.html): initializeUI(definitions)
  App (index.html)->>WASM SDK: Initialize module/imports
  Browser->>App (index.html): User executes query
  App (index.html)->>WASM SDK: Call selected function with inputs
  WASM SDK-->>App (index.html): Results
  App (index.html)-->>Browser: Render output
Loading
sequenceDiagram
  participant Dev
  participant generate_docs.py
  participant api-definitions.json
  participant docs.html
  participant docs.css
  participant AI_REFERENCE.md
  participant docs_manifest.json

  Dev->>generate_docs.py: Run main
  generate_docs.py->>api-definitions.json: load_api_definitions()
  api-definitions.json-->>generate_docs.py: Query/Transition defs
  generate_docs.py->>docs.html: Write HTML (link docs.css)
  generate_docs.py->>docs.css: Write CSS (generate_docs_css)
  generate_docs.py->>AI_REFERENCE.md: Write reference
  generate_docs.py->>docs_manifest.json: Write/Update manifest
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • lklimek
  • pshenmic
  • ktechmidas

Poem

I nibble at JSON by moonlight's gleam,
Hopping through keys like a curious dream.
Purposes picked, epochs set to run,
DPNS whispers, new searches begun.
Old scripts tucked under leaves — joy, carrot-done! 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wasm-sdk-docs-refactor

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@thephez
Copy link
Collaborator Author

thephez commented Aug 14, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🔭 Outside diff range comments (8)
packages/wasm-sdk/check_documentation.py (1)

55-57: Harden manifest loading and timestamp parsing

If the manifest JSON is malformed, the script will crash. Also, generated_at may be invalid. Add error handling to fail gracefully.

-    # Load documentation manifest
-    with open(manifest_file, 'r') as f:
-        manifest = json.load(f)
+    # Load documentation manifest
+    try:
+        with open(manifest_file, 'r') as f:
+            manifest = json.load(f)
+    except (FileNotFoundError, json.JSONDecodeError) as e:
+        errors.append(f"ERROR: Failed to load docs_manifest.json: {e}")
+        return errors, warnings

Also guard timestamp parsing:

-    if 'generated_at' in manifest:
-        generated_time = datetime.fromisoformat(manifest['generated_at'])
-        age_hours = (datetime.now() - generated_time).total_seconds() / 3600
-        if age_hours > 24:
-            warnings.append(f"WARNING: Documentation was generated {age_hours:.1f} hours ago. Consider regenerating.")
+    if 'generated_at' in manifest:
+        try:
+            generated_time = datetime.fromisoformat(manifest['generated_at'])
+            age_hours = (datetime.now() - generated_time).total_seconds() / 3600
+            if age_hours > 24:
+                warnings.append(f"WARNING: Documentation was generated {age_hours:.1f} hours ago. Consider regenerating.")
+        except ValueError:
+            warnings.append("WARNING: docs_manifest.json has an invalid 'generated_at' timestamp")
packages/wasm-sdk/index.html (7)

3031-3073: Fix: missing awaits when deriving keys (identityCreate) causes undefined keys

derive_key_from_seed_with_path returns a Promise elsewhere in this file; here it’s used synchronously. This will pass undefined key material to the SDK and break identity creation.

Apply this diff to await the derivations:

-            const masterKey = derive_key_from_seed_with_path(seedPhrase, undefined, masterKeyPath, currentNetwork);
+            const masterKey = await derive_key_from_seed_with_path(seedPhrase, undefined, masterKeyPath, currentNetwork);
@@
-            const authKey = derive_key_from_seed_with_path(seedPhrase, undefined, authKeyPath, currentNetwork);
+            const authKey = await derive_key_from_seed_with_path(seedPhrase, undefined, authKeyPath, currentNetwork);
@@
-            const transferKey = derive_key_from_seed_with_path(seedPhrase, undefined, transferKeyPath, currentNetwork);
+            const transferKey = await derive_key_from_seed_with_path(seedPhrase, undefined, transferKeyPath, currentNetwork);

4205-4276: Fix: key preview uses async derivation synchronously

Same issue in the identity key preview: async derivation functions are used without awaiting, so the preview will show incorrect values (e.g., [object Promise] or empty).

Apply this diff to make the preview function async and await the derivations:

-          const updateKeyPreview = () => {
+          const updateKeyPreview = async () => {
@@
-                const masterKey = derive_key_from_seed_with_path(seedPhrase, undefined, masterKeyPath, currentNetwork);
+                const masterKey = await derive_key_from_seed_with_path(seedPhrase, undefined, masterKeyPath, currentNetwork);
@@
-                const authKey = derive_key_from_seed_with_path(seedPhrase, undefined, authKeyPath, currentNetwork);
+                const authKey = await derive_key_from_seed_with_path(seedPhrase, undefined, authKeyPath, currentNetwork);
@@
-                const transferKey = derive_key_from_seed_with_path(seedPhrase, undefined, transferKeyPath, currentNetwork);
+                const transferKey = await derive_key_from_seed_with_path(seedPhrase, undefined, transferKeyPath, currentNetwork);

2441-2455: Fix: DPNS search hardcodes testnet contract ID (breaks on mainnet)

dpnsSearch uses a fixed testnet DPNS contract, ignoring the active network. This will fail or return wrong data on mainnet.

Prefer sourcing the DPNS contract ID from the loaded API definitions, falling back to a per-network map. Apply:

-          // DPNS contract ID on testnet
-          const DPNS_CONTRACT_ID = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec";
+          // DPNS contract ID by network (prefer api-definitions.json if provided)
+          const DPNS_CONTRACT_ID =
+            (queryDefinitions?.dpns?.contractId && queryDefinitions.dpns.contractId[currentNetwork])
+            || (currentNetwork === 'testnet'
+                ? "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec"
+                : "REPLACE_WITH_MAINNET_DPNS_CONTRACT_ID");
+          if (DPNS_CONTRACT_ID === "REPLACE_WITH_MAINNET_DPNS_CONTRACT_ID") {
+            console.warn("DPNS mainnet contract ID not configured; please set via api-definitions.json (dpns.contractId.mainnet).");
+          }

If you already put the contract ID in api-definitions.json, the code will pick it up automatically.

I can update the api-definitions.json schema to carry per-network system contract IDs and wire them through consistently if you want.


3450-3473: Fix: DPNS username vote also hardcodes testnet DPNS ID

Same network-coupling issue in the DPNS voting flow.

Apply this diff:

-          const dpnsContractId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
+          const dpnsContractId =
+            (queryDefinitions?.dpns?.contractId && queryDefinitions.dpns.contractId[currentNetwork])
+            || (currentNetwork === 'testnet'
+                ? 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec'
+                : 'REPLACE_WITH_MAINNET_DPNS_CONTRACT_ID');
+          if (dpnsContractId === 'REPLACE_WITH_MAINNET_DPNS_CONTRACT_ID') {
+            console.warn("DPNS mainnet contract ID not configured; please set via api-definitions.json (dpns.contractId.mainnet).");
+          }

177-205: Deduplicate clear/copy helpers (two conflicting implementations)

There are two sets of global helpers. Keep one to avoid drift. The later window.* versions provide richer behavior; remove the earlier block.

Apply this diff to remove the first set:

-    // Global functions for button actions
-    function clearResults() {
-      document.getElementById('identityInfo').textContent = '';
-      document.getElementById('identityInfo').classList.add('empty');
-      document.getElementById('identityInfo').classList.remove('error');
-      if (typeof currentResult !== 'undefined') {
-        currentResult = null;
-      }
-    }
-    
-    function copyResults() {
-      const content = document.getElementById('identityInfo').textContent;
-      navigator.clipboard.writeText(content).then(() => {
-        const button = document.getElementById('copyButton');
-        const originalText = button.textContent;
-        button.textContent = 'Copied!';
-        setTimeout(() => {
-          button.textContent = originalText;
-        }, 2000);
-      }).catch(err => {
-        console.error('Failed to copy:', err);
-      });
-    }

No changes needed for the onclick handlers; they will resolve to window.clearResults / window.copyResults.

Also applies to: 631-657


21-23: Security: add rel="noopener noreferrer" to external link with target=_blank

Prevents the opened page from having access to the opener window.

-      <a href="https://github.com/dashpay/platform" target="_blank">GitHub</a>
+      <a href="https://github.com/dashpay/platform" target="_blank" rel="noopener noreferrer">GitHub</a>

3364-3375: Bug: DOM notification targets a non-existent element id

The DPNS preorder notification looks for #results, which doesn’t exist. Use an existing container so users see the message.

-              const resultsSection = document.getElementById('results');
-              if (resultsSection) {
-                resultsSection.insertBefore(notification, resultsSection.firstChild);
+              const resultsSection = document.getElementById('resultSplitContainer');
+              if (resultsSection) {
+                resultsSection.insertBefore(notification, resultsSection.firstChild);
🧹 Nitpick comments (8)
packages/wasm-sdk/docs.css (1)

1-9: Body-level flex is unnecessary and can cause layout issues

Since the sidebar is position: fixed and .main-content uses margins, body { display: flex; } is redundant and may introduce unwanted behavior on narrow viewports. Consider removing it.

 body {
     font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
     line-height: 1.6;
     color: #333;
     margin: 0;
     padding: 0;
     background-color: #f5f5f5;
-    display: flex;
 }
packages/wasm-sdk/index.css (1)

234-269: Duplicate selector blocks for .input-group and .input-group label — ensure intended cascade

You define .input-group and .input-group label twice in quick succession with overlapping properties (color/spacing). If the intention is to override earlier styles, consolidate for clarity to avoid future regressions.

Option 1 (consolidate into one block; keep final values):

-.input-group {
-  margin-bottom: 15px;
-}
-.
-.input-group label {
-  display: block;
-  margin-bottom: 5px;
-  font-weight: 500;
-  color: #333;
-}
+/* Consolidated definitions */
+.input-group {
+  margin-bottom: 15px;
+}
+.input-group label {
+  display: block;
+  margin-bottom: 5px;
+  font-weight: 500;
+  color: #555;
+  font-size: 0.9em;
+}

If different sections truly require different styling, scope them with parent containers to avoid global redefinitions.

packages/wasm-sdk/AI_REFERENCE.md (2)

331-344: dpnsSearch docs are clear; consider including the optional limit in the example

The section is correct. A tiny improvement: show the optional limit usage to make the signature obvious.

-const result = await sdk.dpnsSearch("prefix");
+// With explicit limit
+const result = await sdk.dpnsSearch("prefix", 10);

390-390: Fix parameter description: “Contract ID” → “Data Contract ID”

The parameter is named dataContractId but the description says “Contract ID”. Align the description to avoid confusion.

-- `dataContractId` (text, required) - Contract ID
+- `dataContractId` (text, required) - Data Contract ID
packages/wasm-sdk/api-definitions.json (1)

2-4: Add automation for timestamp updates.

The generated_at field shows a static timestamp from August 2025. Consider automating this field update in the generation scripts to maintain accurate metadata.

You could update the generate_docs.py script to write the current timestamp when generating this file.

packages/wasm-sdk/generate_docs.py (1)

13-26: Error handling in load_api_definitions could be more specific.

While the function handles both FileNotFoundError and JSONDecodeError, returning empty dictionaries silently might hide issues. Consider raising exceptions or returning error states that calling code can handle explicitly.

def load_api_definitions(api_definitions_file):
    """Load query and state transition definitions from api-definitions.json"""
    try:
        with open(api_definitions_file, 'r', encoding='utf-8') as f:
            api_data = json.load(f)
        
        query_definitions = api_data.get('queries', {})
        transition_definitions = api_data.get('transitions', {})
        
        return query_definitions, transition_definitions
        
    except (FileNotFoundError, json.JSONDecodeError) as e:
        print(f"Error loading API definitions: {e}")
-        return {}, {}
+        raise  # Let the caller handle the error appropriately
packages/wasm-sdk/index.html (2)

270-275: Nit: avoid deprecated reload(true) and be consistent

location.reload(true) is deprecated/no-op. Use location.reload().

-                  refreshBtn.onclick = () => window.location.reload(true);
+                  refreshBtn.onclick = () => window.location.reload();
-          window.location.reload(true);
+          window.location.reload();

Also applies to: 233-235


55-94: Optional: migrate remaining inline styles into index.css

Refactor the larger inline styles (details, buttons, preview/validation blocks) into CSS classes to improve maintainability and keep HTML lean. This will align index.html with the docs.html/css extraction done in this PR.

Also applies to: 146-156, 170-176, 188-206, 631-689, 1909-1944

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ab80785 and 0f82d45.

📒 Files selected for processing (14)
  • packages/wasm-sdk/AI_REFERENCE.md (6 hunks)
  • packages/wasm-sdk/api-definitions.json (6 hunks)
  • packages/wasm-sdk/check_documentation.py (6 hunks)
  • packages/wasm-sdk/docs.css (1 hunks)
  • packages/wasm-sdk/docs.html (5 hunks)
  • packages/wasm-sdk/docs_manifest.json (2 hunks)
  • packages/wasm-sdk/extract_definitions.py (0 hunks)
  • packages/wasm-sdk/extract_inputs.py (0 hunks)
  • packages/wasm-sdk/generate_docs.py (9 hunks)
  • packages/wasm-sdk/index.css (1 hunks)
  • packages/wasm-sdk/index.html (5 hunks)
  • packages/wasm-sdk/save_fixed_definitions.py (0 hunks)
  • packages/wasm-sdk/update_inputs.py (0 hunks)
  • packages/wasm-sdk/update_state_transitions.py (0 hunks)
💤 Files with no reviewable changes (5)
  • packages/wasm-sdk/update_inputs.py
  • packages/wasm-sdk/extract_inputs.py
  • packages/wasm-sdk/update_state_transitions.py
  • packages/wasm-sdk/extract_definitions.py
  • packages/wasm-sdk/save_fixed_definitions.py
🧰 Additional context used
🧠 Learnings (10)
📓 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/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/index.css
  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/docs.css
  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/index.css
  • packages/wasm-sdk/docs.css
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/index.css
  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/docs.css
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/wasm-sdk/docs.html
🪛 Biome (2.1.2)
packages/wasm-sdk/docs.css

[error] 428-428: Duplicate properties can lead to unexpected behavior and may override previous declarations unintentionally.

display is already defined here.

Remove or rename the duplicate property to ensure consistent styling.

(lint/suspicious/noDuplicateProperties)

🪛 Ruff (0.12.2)
packages/wasm-sdk/check_documentation.py

73-73: Loop control variable cat_key not used within loop body

Rename unused cat_key to _cat_key

(B007)


74-74: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

⏰ 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). (1)
  • GitHub Check: build-and-test-wasm-sdk
🔇 Additional comments (22)
packages/wasm-sdk/docs_manifest.json (2)

2-2: Manifest timestamp refreshed — OK

generated_at updated appropriately; aligns with regenerated docs.


92-95: dpnsSearch added to manifest — confirmed

dpnsSearch is present and documented; note that it's defined under the dpns group in the API definitions (so a top-level .queries check returns false).

Files checked:

  • packages/wasm-sdk/docs_manifest.json — dpnsSearch entry present (category: dpns, documented: true)
  • packages/wasm-sdk/api-definitions.json — present as .queries.dpns.dpnsSearch (inputs: prefix, limit)
  • packages/wasm-sdk/AI_REFERENCE.md — documents dpnsSearch with example
  • packages/wasm-sdk/generate_docs.py — maps dpnsSearch to get_documents (DPNS-specific handling)
  • packages/wasm-sdk/docs.html, packages/wasm-sdk/index.html — docs/examples present
  • packages/wasm-sdk/test/ui-automation/** — fixtures and tests reference dpnsSearch

No changes required.

packages/wasm-sdk/AI_REFERENCE.md (3)

74-75: Key purposes multiselect — OK

New purposes multiselect with explicit options is clear and consistent with the PR objectives.


120-120: Parameter rename to ids — OK

Renaming “identityIds” to ids is reflected correctly here.


514-519: Epoch-based range parameters — OK

The reworked inputs for getEvonodesProposedEpochBlocksByRange are correctly reflected (epoch, optional limit/startAfter/orderAscending).

packages/wasm-sdk/check_documentation.py (2)

41-50: Good: direct load from api-definitions.json with JSON error handling

Switch to JSON-driven source of truth and early error handling looks right.


110-121: Staleness warnings wired to api-definitions mtime — OK

Timestamp comparisons against docs.html and AI_REFERENCE.md are sensible and help keep docs synchronized.

packages/wasm-sdk/docs.html (5)

9-9: LGTM! External CSS approach improves maintainability.

Moving CSS to an external file is a good refactoring decision that improves code organization and maintainability.


605-609: Multiselect implementation for key purposes is well done.

The change from select to multiselect with specific key purposes (Authentication, Encryption, Decryption, Transfer, Voting) provides better flexibility for users selecting multiple key purposes in a single operation.


1070-1095: DPNS Search feature implementation looks good.

The new DPNS Search functionality is properly integrated into the UI with appropriate parameter handling for prefix-based searches.


1491-1511: Parameter updates for epoch-based queries are correct.

The migration from ProTx hash to epoch-based parameters with the addition of limit, startAfter, and orderAscending provides better query control and aligns with the API changes.


614-614: Incorrect — get_identities_contract_keys still has the fifth parameter (no breaking removal found)

Short summary: I verified the repository — the wasm export still defines both document_type_name and purposes parameters; the docs example omits the optional purposes argument but that is not evidence of a removed parameter.

Files/locations to check:

  • packages/wasm-sdk/src/queries/identity.rs — function signature at ~lines 691–696 (contains document_type_name: Option<String>, purposes: Option<Vec<u32>>)
  • packages/wasm-sdk/test/identity-queries.test.mjs — test calling wasmSdk.get_identities_contract_keys(...) (uses the function)
  • packages/wasm-sdk/docs.html — example at line ~614 shows a 4-arg example (omits optional purposes)
  • packages/wasm-sdk/index.html — example/usage around lines ~2195–2204

Updated example snippet (include optional purposes if desired):

return await window.wasmFunctions.get_identities_contract_keys(sdk, ['5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk'], 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', 'domain', [1,2]);

Action: Ignore the original critical flag — the review comment is incorrect.

Likely an incorrect or invalid review comment.

packages/wasm-sdk/api-definitions.json (4)

90-116: Well-structured multiselect implementation for key purposes.

The change from select to multiselect with enumerated key purposes (0-5) is properly implemented with clear labels for each purpose type.


166-166: Input name standardization is consistent.

The rename from identityIds to ids follows a consistent naming pattern used throughout the API.


455-474: DPNS Search feature properly defined.

The new dpnsSearch query is well-structured with appropriate input parameters for prefix-based name searching.


823-846: Epoch-based parameters improve query flexibility.

The transition from ProTx hash to epoch-based parameters with pagination support (limit, startAfter, orderAscending) provides better control over the query results.

packages/wasm-sdk/generate_docs.py (4)

68-69: New test data fields properly support the refactored features.

The addition of prefix, startAfter fields and retention of epoch in the test data aligns well with the new dpnsSearch and epoch-based query features.

Also applies to: 107-107


121-129: DPNS Search implementation correctly maps to get_documents.

The dpnsSearch special case properly constructs the where clause with startsWith operator for prefix matching and includes the parent domain constraint.


381-853: CSS generation function is comprehensive and well-organized.

The generate_docs_css function provides a complete stylesheet with good organization, responsive design considerations, and modern UI patterns. This successfully externalizes the CSS from the HTML template.


1816-1823: CSS file generation properly integrated into the workflow.

The CSS generation and file writing is correctly placed in the main workflow, ensuring docs.css is created alongside docs.html.

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

250-252: Service worker path should be relative to app; consider setting scope

Absolute “/” breaks when served from a subpath (e.g., GitHub Pages, local dev). Use a relative URL and scope.

-        navigator.serviceWorker.register('/service-worker-simple.js')
+        navigator.serviceWorker.register('./service-worker-simple.js', { scope: './' })

Please verify packages/wasm-sdk/service-worker-simple.js exists and is served relative to index.html.


913-1312: Confirmed — WASM accepts the "Between" operator variants

The repo parsing and bindings accept the exact operator strings emitted by the UI; emitting "Between", "BetweenExcludeBounds", "BetweenExcludeLeft", "BetweenExcludeRight" is correct.

Evidence (selected locations):

  • packages/wasm-sdk/src/queries/document.rs — maps operator_str -> WhereOperator including "Between" / "BetweenExclude*" (parsing for WASM bindings).
  • packages/wasm-drive-verify/src/document/verify_proof*.rs — verification bindings parse the same "Between" / "BetweenExclude*" literals.
  • packages/rs-drive/src/query/conditions.rs — WhereOperator enum and from_string() include the Between variants (and Display uses the same string names).
  • packages/wasm-sdk/index.html — combineRangeClauses() generates those operator strings and pushes them into the submitted whereClause.

Action: no change required — keep emitting the single Between* operator from the UI and preview.

thephez and others added 3 commits August 14, 2025 11:32
- Remove duplicate display: flex from #preloader CSS rule
- Add .preloader--visible modifier class with flex layout
- Update JavaScript to use classList instead of direct style manipulation
- Fixes preloader overlay being permanently visible due to CSS conflicts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ding

- Add try/except wrapper around load_api_definitions call
- Validate that loaded definitions are not empty
- Check that actual queries/transitions exist before proceeding
- Return non-zero exit code immediately on any loading failures
- Prevent generating docs with incomplete/empty data

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move CSS preloader fix from docs.css to generate_docs.py to ensure
persistence across documentation regeneration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thephez
Copy link
Collaborator Author

thephez commented Aug 14, 2025

@coderabbitai re-review

Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

@thephez I'll conduct a complete re-review of all the changes in this PR.


🧠 Learnings used
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'
✅ Actions performed

Full review triggered.

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

🔭 Outside diff range comments (8)
packages/wasm-sdk/generate_docs.py (3)

286-291: Invalid JSON string in “Search Keys by Purpose” example

Double braces produce an invalid JSON string and will fail at runtime. Use a proper JSON string.

-                <div class="example-code" id="code-getIdentityKeys3">return await window.wasmFunctions.get_identity_keys(sdk, \'5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk\', \'search\', undefined, \'{{"0": {{"0": "current"}}, "1": {{"0": "current"}}}}\');</div>
+                <div class="example-code" id="code-getIdentityKeys3">return await window.wasmFunctions.get_identity_keys(sdk, \'5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk\', \'search\', undefined, \'{"0": {"0": "current"}, "1": {"0": "current"}}\');</div>

If the expected structure differs (e.g., purpose maps or arrays), update the JSON accordingly, but keep it valid.


992-1004: Cache matching uses absolute paths; may fail under subpaths

Using /pkg/... breaks when hosted under a subpath. Build URLs relative to the current page.

-        async function checkWasmCached() {
+        async function checkWasmCached() {
             if ('caches' in window) {
                 try {
-                    const cache = await caches.open('wasm-sdk-cache-v7');
-                    const wasmResponse = await cache.match('/pkg/wasm_sdk_bg.wasm');
-                    const jsResponse = await cache.match('/pkg/wasm_sdk.js');
+                    const cache = await caches.open('wasm-sdk-cache-v7');
+                    const base = new URL('.', window.location.href);
+                    const wasmPath = new URL('pkg/wasm_sdk_bg.wasm', base).pathname;
+                    const jsPath = new URL('pkg/wasm_sdk.js', base).pathname;
+                    const wasmResponse = await cache.match(wasmPath);
+                    const jsResponse = await cache.match(jsPath);
                     return wasmResponse && jsResponse;
                 } catch (e) {
                     return false;
                 }
             }
             return false;
         }

1605-1617: AI reference example for getIdentity uses a contract ID

The example passes a data contract ID, not an identity ID. Replace with the known testnet identity ID.

-            if query_key == 'getIdentity':
-                md_content += 'const identity = await sdk.getIdentity("GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec");'
+            if query_key == 'getIdentity':
+                md_content += 'const identity = await sdk.getIdentity("5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk");'
packages/wasm-sdk/docs.html (1)

3049-3056: Potential XSS due to innerHTML of JSONified result

Even JSON-stringified values can contain HTML sequences that will be interpreted when inserted via innerHTML. Use textContent (or explicitly escape) to prevent injection.

Apply this fix:

- resultDiv.className = 'example-result success';
- resultDiv.innerHTML = '<pre>' + JSON.stringify(result, null, 2) + '</pre>';
- resultDiv.style.display = 'block';
+ resultDiv.className = 'example-result success';
+ const pre = document.createElement('pre');
+ pre.textContent = JSON.stringify(result, null, 2);
+ resultDiv.replaceChildren(pre);
+ resultDiv.style.display = 'block';
packages/wasm-sdk/api-definitions.json (1)

1878-1883: Token Transfer: replace tokenId (text) with tokenPosition (number) in API definitions

tokenTransfer currently uses "tokenId" (type: text) but is labeled "Token Contract Position" while all other token transition inputs use "tokenPosition" (type: number). This is inconsistent and should be fixed.

Locations to update:

  • packages/wasm-sdk/api-definitions.json — tokenTransfer.inputs (around line ~1878): currently "name": "tokenId" but should match other transitions.
  • packages/wasm-sdk/AI_REFERENCE.md — several entries list tokenId described as "Token Contract Position" (e.g., ~lines 1112, 1133, 1146, 1159) — update docs if you switch names.
  • Verify UI/tests that use tokenPosition (e.g., packages/wasm-sdk/index.html uses Number(values.tokenPosition) and test files) to avoid breaking changes.

Suggested change:

-              "name": "tokenId",
-              "type": "text",
-              "label": "Token Contract Position",
+              "name": "tokenPosition",
+              "type": "number",
+              "label": "Token Contract Position",

If the API is meant to accept a tokenId (string) here instead, change the label to "Token ID" and keep type "text" instead of the diff above.

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

4224-4235: Same async issue in key preview: awaiting derivation is required

The preview code dereferences .private_key_wif without awaiting. If derivation is async, this will show “undefined” or “[object Promise]”.

Convert updateKeyPreview into an async function and await the derivations.

-const updateKeyPreview = () => {
+const updateKeyPreview = async () => {
...
-const masterKey = derive_key_from_seed_with_path(seedPhrase, undefined, masterKeyPath, currentNetwork);
-const authKey = derive_key_from_seed_with_path(seedPhrase, undefined, authKeyPath, currentNetwork);
-const transferKey = derive_key_from_seed_with_path(seedPhrase, undefined, transferKeyPath, currentNetwork);
+const masterKey = await derive_key_from_seed_with_path(seedPhrase, undefined, masterKeyPath, currentNetwork);
+const authKey = await derive_key_from_seed_with_path(seedPhrase, undefined, authKeyPath, currentNetwork);
+const transferKey = await derive_key_from_seed_with_path(seedPhrase, undefined, transferKeyPath, currentNetwork);

2438-2455: Hardcoded DPNS testnet contract ID will break on mainnet

dpnsSearch and the DPNS username vote flow use a fixed testnet DPNS contract ID. This will fail on mainnet. Use per-network IDs (or query via SDK) keyed off currentNetwork.

-const DPNS_CONTRACT_ID = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec";
+const DPNS_CONTRACT_IDS = {
+  mainnet: "MAINNET_CONTRACT_ID_HERE",
+  testnet: "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec",
+};
+const DPNS_CONTRACT_ID = DPNS_CONTRACT_IDS[currentNetwork] || DPNS_CONTRACT_IDS.testnet;

Apply the same pattern at DPNS vote (Line 3450).

If you provide the correct mainnet DPNS contract ID, I can prepare a follow-up patch across both places.

Also applies to: 3450-3455


2526-2593: Duplicate branches for epoch-related queries

You have two separate else-if clusters handling:

  • getFinalizedEpochInfos
  • getEvonodesProposedEpochBlocksByIds
  • getEvonodesProposedEpochBlocksByRange

The later block is redundant and dead code. This duplication increases maintenance burden and risks drift.

-        // Epoch/Block queries
-        else if (queryType === 'getFinalizedEpochInfos') {
-          result = await get_finalized_epoch_infos(
-            sdk,
-            values.startEpoch,
-            values.count,
-            values.ascending
-          );
-          // Result is already a JS object from serde_wasm_bindgen
-        } else if (queryType === 'getEvonodesProposedEpochBlocksByIds') {
-          result = await get_evonodes_proposed_epoch_blocks_by_ids(
-            sdk,
-            values.epoch,
-            values.ids
-          );
-          // Result is already a JS object from serde_wasm_bindgen
-        } else if (queryType === 'getEvonodesProposedEpochBlocksByRange') {
-          result = await get_evonodes_proposed_epoch_blocks_by_range(
-            sdk,
-            values.epoch,
-            values.limit,
-            values.startAfter,
-            values.orderAscending
-          );
-          // Result is already a JS object from serde_wasm_bindgen
-        }

Also applies to: 2854-2879

🧹 Nitpick comments (24)
packages/wasm-sdk/docs.css (3)

430-434: Scope the visibility class to the preloader element

Use a scoped selector to avoid accidentally turning unrelated elements into flex containers if .preloader--visible is applied elsewhere.

Apply:

-.preloader--visible {
+#preloader.preloader--visible {
   display: flex;
   justify-content: center;
   align-items: center;
 }

38-46: Add visible focus states for keyboard accessibility

Interactive elements should show a clear focus outline for keyboard users.

Consider:

 .sidebar a:hover {
   background-color: #ecf0f1;
   color: #2c3e50;
 }
+
+.sidebar a:focus {
+  outline: 2px solid #3498db;
+  outline-offset: 2px;
+}

 .nav a:hover {
   text-decoration: underline;
 }
+
+.nav a:focus {
+  outline: 2px solid #3498db;
+  outline-offset: 2px;
+}

 .run-button:hover {
   background-color: #2980b9;
 }
+
+.run-button:focus {
+  outline: 2px solid #fff;
+  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.6);
+}

 .back-to-top:hover {
   background-color: #2980b9;
 }
+
+.back-to-top:focus {
+  outline: 2px solid #fff;
+  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.6);
+}

Also applies to: 178-186, 275-285, 330-340


326-328: Respect prefers-reduced-motion for spinner animation

Provide a reduced-motion fallback to improve accessibility.

Add:

 @keyframes spin {
     to { transform: rotate(360deg); }
 }
+
+@media (prefers-reduced-motion: reduce) {
+  .loading {
+    animation: none;
+  }
+}
packages/wasm-sdk/check_documentation.py (2)

69-76: Simplify dict key iteration and remove unused loop var

Avoid .keys() and unused cat_key bindings. This also aligns with Ruff hints.

-    for cat_key, category in current_defs.get('queries', {}).items():
-        for query_key in category.get('queries', {}).keys():
-            current_queries.add(query_key)
+    for category in current_defs.get('queries', {}).values():
+        for query_key in category.get('queries', {}):
+            current_queries.add(query_key)
 
-    for cat_key, category in current_defs.get('transitions', {}).items():
-        for trans_key in category.get('transitions', {}).keys():
-            current_transitions.add(trans_key)
+    for category in current_defs.get('transitions', {}).values():
+        for trans_key in category.get('transitions', {}):
+            current_transitions.add(trans_key)

161-163: Write report to the script directory for consistency

Currently writes to CWD; prefer the script directory to avoid scattering reports when invoked from different working dirs.

-    with open('documentation-check-report.txt', 'w') as f:
-        f.write(report)
+    report_path = Path(__file__).parent / 'documentation-check-report.txt'
+    with open(report_path, 'w') as f:
+        f.write(report)
packages/wasm-sdk/generate_docs.py (3)

812-816: Keep CSS selector scoping consistent with docs.css

Match the scoped selector to prevent class leakage.

-.preloader--visible {
+#preloader.preloader--visible {
     display: flex;
     justify-content: center;
     align-items: center;
 }

1883-1884: Use sys.exit for script termination

exit() comes from site and isn’t recommended for scripts; use sys.exit.

-if __name__ == "__main__":
-    exit(main())
+if __name__ == "__main__":
+    import sys
+    sys.exit(main())

381-856: Avoid duplicating CSS in code; read from the CSS file instead

Maintaining the full CSS blob in Python and also committing docs.css risks drift. Prefer reading docs.css at runtime.

You can delete generate_docs_css() and, in main(), read packages/wasm-sdk/docs.css and write it unchanged (or skip writing altogether if you intend to hand-edit the CSS). I can provide a concrete patch if you want to proceed with this refactor.

packages/wasm-sdk/index.css (2)

184-190: Scope toggle checked selector to the widget

Limit the checked selector to .toggle-switch to avoid unintended matches elsewhere.

-input:checked + .toggle-slider {
+.toggle-switch input:checked + .toggle-slider {
   background-color: #4CAF50;
 }
 
-input:checked + .toggle-slider:before {
+.toggle-switch input:checked + .toggle-slider:before {
   transform: translateX(26px);
 }

39-52: Align preloader visibility mechanism with docs page (optional)

If index.html toggles a class (rather than inline styles) to show the preloader, mirror the docs approach.

 #preloader {
   display: none;
   position: fixed;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   background: rgba(0, 0, 0, 0.9);
   color: white;
   padding: 30px;
   border-radius: 8px;
   z-index: 1000;
   min-width: 300px;
   box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
 }
+
+#preloader.preloader--visible {
+  display: block; /* or display: flex if you want centering via flex */
+}

Please confirm how index.html toggles the preloader. I can adjust the CSS accordingly if it already uses a class.

packages/wasm-sdk/docs.html (5)

154-155: Preloader toggling via class: verify CSS + add null-guard

Switching to a CSS class is cleaner than inline styles. Two asks:

  • Ensure docs.css defines the default hidden state and a .preloader--visible modifier that shows the preloader; otherwise the preloader could remain visible or hidden unexpectedly.
  • Minor hardening: guard against a missing preloader element to avoid potential runtime errors.

Apply this defensive tweak:

- if (!isCached || window.location.search.includes('force-reload')) {
-     preloader.classList.add('preloader--visible');
- }
+ if (preloader && (!isCached || window.location.search.includes('force-reload'))) {
+     preloader.classList.add('preloader--visible');
+ }
...
- setTimeout(() => {
-     preloader.classList.remove('preloader--visible');
- }, isCached ? 200 : 500);
+ setTimeout(() => {
+     if (preloader) preloader.classList.remove('preloader--visible');
+ }, isCached ? 200 : 500);
...
- preloader.classList.remove('preloader--visible');
+ if (preloader) preloader.classList.remove('preloader--visible');

Also applies to: 190-191, 196-197


403-403: DPNS Search docs look good; consider cross-linking to DPNS contract ID

The new DPNS Search entry and example are clear and consistent with the get_documents API. Consider adding a brief note or link that clarifies/points to the DPNS dataContractId used in examples to reduce guesswork for users.

Also applies to: 1070-1095


605-609: “Key Purposes” multiselect is documented, but example omits it

Purposes are optional, so the example is valid. To improve discoverability, add a second example that demonstrates passing non-empty purposes so users understand the expected values and mapping.

Add an additional example:

 <div class="example-container">
   <h5>Example</h5>
   <div class="example-code" id="code-getIdentitiesContractKeys">return await window.wasmFunctions.get_identities_contract_keys(sdk, ['5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk'], 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', 'domain');</div>
   <button class="run-button" id="run-getIdentitiesContractKeys" onclick="runExample('getIdentitiesContractKeys')">Run</button>
   <div class="example-result" id="result-getIdentitiesContractKeys"></div>
 </div>
+<div class="example-container">
+  <h5>Example 2 - Filter by Purposes</h5>
+  <div class="example-code" id="code-getIdentitiesContractKeys2">return await window.wasmFunctions.get_identities_contract_keys(sdk, ['5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk'], 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', 'domain', ['0','1']);</div>
+  <button class="run-button" id="run-getIdentitiesContractKeys2" onclick="runExample('getIdentitiesContractKeys2')">Run</button>
+  <div class="example-result" id="result-getIdentitiesContractKeys2"></div>
+</div>

If the exported wasm function indeed only accepts four parameters now, also add a short note stating that purposes are UI-level filtering only (and not passed to the binding).

Also applies to: 614-614


135-138: Cache match paths are absolute; consider subpath-safe URLs

Using absolute URLs with the Cache API can fail when hosting the docs under a subpath. Prefer resolving URLs relative to location to improve portability.

Apply this improvement:

- const wasmResponse = await cache.match('/pkg/wasm_sdk_bg.wasm');
- const jsResponse = await cache.match('/pkg/wasm_sdk.js');
+ const wasmResponse = await cache.match(new URL('./pkg/wasm_sdk_bg.wasm', location.href));
+ const jsResponse = await cache.match(new URL('./pkg/wasm_sdk.js', location.href));

271-279: Service worker scope is root; narrow scope to the docs folder

Registering at an absolute root path can unintentionally claim the whole origin. Consider scoping the SW to the wasm-sdk folder to avoid side effects when served under a larger domain.

- navigator.serviceWorker.register('/service-worker-simple.js')
+ navigator.serviceWorker.register('./service-worker-simple.js')
packages/wasm-sdk/AI_REFERENCE.md (3)

74-76: Clarify key purpose values mapping

Documenting purpose values is useful. Consider briefly noting that these numeric values map to the IdentityPublicKeyPurpose enum in the SDK to eliminate ambiguity.


389-402: Use “Data Contract ID” label for consistency

Parameter renamed to dataContractId is correct. To align labels across the docs, consider updating the label text from “Contract ID” to “Data Contract ID”.

-- `dataContractId` (text, required) - Contract ID
+- `dataContractId` (text, required) - Data Contract ID

514-519: Evonodes by range: add example including optional args

The epoch-first signature is correct. Consider adding a second example showing limit/startAfter/orderAscending so users see the full calling shape.

-const result = await sdk.getEvonodesProposedEpochBlocksByRange(100);
+// Minimal
+const result = await sdk.getEvonodesProposedEpochBlocksByRange(100);
+// With pagination and ordering
+const page = await sdk.getEvonodesProposedEpochBlocksByRange(100, 25, "143dcd6a6b7684f...", true);

Also applies to: 522-523

packages/wasm-sdk/api-definitions.json (4)

2-4: Top-level “source” should reflect canonical JSON, not index.html

Now that the JSON is canonical, set source accordingly to avoid confusion in tooling and audits.

-  "source": "index.html",
+  "source": "api-definitions.json",

606-610: Label nit: prefer “Data Contract ID”

The name is dataContractId but the label is “Contract ID”. Use “Data Contract ID” for clarity and consistency.

-  "label": "Contract ID",
+  "label": "Data Contract ID",

1087-1092: Misleading input name for prefunded balance

Input is named identityId but labeled “Specialized Balance ID”. Consider renaming to specializedBalanceId to prevent confusion and mistakes in UI wiring.

-              "name": "identityId",
-              "type": "text",
-              "label": "Specialized Balance ID",
+              "name": "specializedBalanceId",
+              "type": "text",
+              "label": "Specialized Balance ID",

71-76: Minor naming nit: “identitiesIds” is awkward

Across the JSON, “identitiesIds” reads oddly; “identityIds” is used everywhere else. Consider updating for consistency.

-              "name": "identitiesIds",
+              "name": "identityIds",

Note: This is a breaking change for any consumer expecting the old name; coordinate updates accordingly.

Also applies to: 166-170

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

390-427: Consolidated imports: consider relying on the namespace import to reduce churn

You now import a large number of named exports and also import the same module under a namespace (queryFunctions). While ES module caching avoids duplicate instantiation, maintaining this long named import list is error-prone whenever wasm exports change.

  • Option A (recommended): Keep only the namespace import and reference functions via queryFunctions.<fn>. This minimizes edit surface when exports change.
  • Option B: If you keep named imports for tree-shaking readability, drop the namespace import (it's currently unused).

This refactor aligns with your PR goal of centralizing wiring via JSON definitions and makes it easier to switch to dynamic dispatch later.

Example minimal change:

-import init, { 
-  WasmSdkBuilder, 
-  identity_fetch,
-  ...
-  xprv_to_xpub
-} from './pkg/wasm_sdk.js';
-
-// Import all placeholder query functions
-import * as queryFunctions from './pkg/wasm_sdk.js';
+import * as queryFunctions from './pkg/wasm_sdk.js';
+const { init, WasmSdkBuilder } = queryFunctions;

Also applies to: 429-431


233-235: Nit: window.location.reload(true) is deprecated

Modern browsers ignore the forceReload argument. Use location.reload() (and rely on your SW update handling).

-window.location.reload(true);
+window.location.reload();

Also applies to: 274-275

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ab80785 and ef9f25e.

📒 Files selected for processing (14)
  • packages/wasm-sdk/AI_REFERENCE.md (6 hunks)
  • packages/wasm-sdk/api-definitions.json (6 hunks)
  • packages/wasm-sdk/check_documentation.py (6 hunks)
  • packages/wasm-sdk/docs.css (1 hunks)
  • packages/wasm-sdk/docs.html (7 hunks)
  • packages/wasm-sdk/docs_manifest.json (2 hunks)
  • packages/wasm-sdk/extract_definitions.py (0 hunks)
  • packages/wasm-sdk/extract_inputs.py (0 hunks)
  • packages/wasm-sdk/generate_docs.py (11 hunks)
  • packages/wasm-sdk/index.css (1 hunks)
  • packages/wasm-sdk/index.html (5 hunks)
  • packages/wasm-sdk/save_fixed_definitions.py (0 hunks)
  • packages/wasm-sdk/update_inputs.py (0 hunks)
  • packages/wasm-sdk/update_state_transitions.py (0 hunks)
💤 Files with no reviewable changes (5)
  • packages/wasm-sdk/save_fixed_definitions.py
  • packages/wasm-sdk/extract_inputs.py
  • packages/wasm-sdk/extract_definitions.py
  • packages/wasm-sdk/update_state_transitions.py
  • packages/wasm-sdk/update_inputs.py
🧰 Additional context used
🧠 Learnings (10)
📓 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/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'
📚 Learning: 2025-08-14T15:03:56.670Z
Learnt from: thephez
PR: dashpay/platform#2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.670Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/docs.css
  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/index.css
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/index.css
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/index.css
  • packages/wasm-sdk/generate_docs.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs.html
🪛 Ruff (0.12.2)
packages/wasm-sdk/check_documentation.py

73-73: Loop control variable cat_key not used within loop body

Rename unused cat_key to _cat_key

(B007)


74-74: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

⏰ 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-wasm-sdk
  • GitHub Check: build-and-test-wasm-sdk
🔇 Additional comments (17)
packages/wasm-sdk/docs.css (1)

418-435: Preloader default-hidden fix looks correct

#preloader now defaults to display: none, and visibility is toggled via a separate class. This resolves the previous “always visible” overlay issue.

packages/wasm-sdk/docs_manifest.json (2)

92-95: dpnsSearch entry in manifest looks good

New query is present and categorized under “dpns”, consistent with api-definitions.json and the generator’s manifest logic.


2-2: Confirm manifest freshness policy fits your CI cadence

generated_at is ISO without timezone; the checker warns after 24h. Verify that this threshold aligns with your CI frequency to avoid noisy warnings.

packages/wasm-sdk/docs.html (2)

9-9: External stylesheet extraction is a win

Linking docs.css cleans up the HTML and centralizes styling. No issues spotted here.


1491-1511: Evonodes “by range” parameters updated to epoch-based — LGTM

The parameter names and example align with the epoch-based design and optional pagination args. Looks good.

Also applies to: 1516-1516

packages/wasm-sdk/AI_REFERENCE.md (2)

120-120: Rename to ids is consistent with other batch APIs — good change

The parameter rename to ids matches other endpoints and improves consistency.


331-344: DPNS Search endpoint addition looks correct

The prefix + optional limit signature is clear and matches the docs.html example. All good.

packages/wasm-sdk/api-definitions.json (4)

90-116: “Key Purposes” multiselect: LGTM

The multiselect with enum values and labels reads well and aligns with the new UX.


166-170: ids rename improves consistency

Adopting ids here is consistent with other endpoints.


454-474: New dpnsSearch definition looks correct

Prefix and optional limit inputs match the documented behavior.


823-846: Evonodes by range parameters updated to epoch-based — LGTM

epoch, optional limit/startAfter/orderAscending align with the new API.

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

13-13: External stylesheet link looks good

Moving inline styles to index.css improves maintainability and cacheability. No issues here.


2108-2111: Guarding against missing definitions is correct

The null-safe access and user-facing alert prevent runtime errors when definitions are unavailable. Looks good.


4110-4118: Robust category population

Using the loaded definitions’ category maps and guarding for existence is correct. This keeps UI robust against partially loaded or malformed JSON.


4913-4921: Initialize UI only after definitions load

Good sequencing. Logging counts is useful for diagnostics.


4926-4936: Boot sequence is solid: load definitions → init UI → init WASM

This ordering prevents UI from flashing incomplete options. The explicit status messages improve UX during startup.

Also applies to: 4943-4947


3028-3072: Incorrect — derive_key_from_seed_with_path is synchronous; ignore the async-await warning

Short summary: I inspected the code. derive_key_from_seed_with_path is a synchronous #[wasm_bindgen] Rust function that returns Result<JsValue, JsError>, so the generated JS binding returns the value directly. Awaiting it elsewhere is harmless (awaiting a non-Promise resolves immediately), but not required — the original warning about needing to await to avoid breaking identity creation is incorrect.

Evidence / locations:

  • packages/wasm-sdk/src/wallet/key_derivation.rs — #[wasm_bindgen] pub fn derive_key_from_seed_with_path(...) -> Result<JsValue, JsError> (around line ~251).
  • packages/wasm-sdk/index.html:3000–3060 — identityCreate uses the function synchronously (masterKey.private_key_hex).
  • packages/wasm-sdk/index.html:3828–3936 — derivationPathDip13 shows an awaited usage (result = await rawResult).
  • packages/wasm-sdk/index.html:4218–4240 — another synchronous usage building keysHtml.
  • Note: packages/wasm-sdk/pkg (pkg/wasm_sdk.js) was not present in the repo copy, so verification relied on the Rust source and index.html usages.

Recommendation (optional): you may standardize usage for readability (choose either always-await and make callers async, or always-call synchronously). No functional fix is required to avoid runtime breakage.

Likely an incorrect or invalid review comment.

thephez and others added 3 commits August 14, 2025 12:37
…overy

Add cache: no-store to fetch, persistent error banner with retry button

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thephez thephez marked this pull request as ready for review August 14, 2025 17:19
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

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

255-292: Service worker path should be relative to avoid scope/hosting issues

Using an absolute path ‘/service-worker-simple.js’ breaks when hosting the SDK under a subpath and may register with broader-than-needed scope.

Apply this diff to scope SW to the current directory and improve robustness:

-        navigator.serviceWorker.register('/service-worker-simple.js')
+        navigator.serviceWorker.register('./service-worker-simple.js', { scope: './' })
           .then(registration => {
             console.log('ServiceWorker registration successful:', registration.scope);

4991-5036: WASM fetch should also bypass caches

To keep parity with api-definitions.json and avoid stale modules behind a SW, add cache: 'no-store' to the WASM fetch, especially important during active development.

-          const response = await fetch(wasmUrl);
+          const response = await fetch(wasmUrl, { cache: 'no-store' });

186-209: Duplicate clearResults/copyResults definitions can diverge

There are two definitions for clearResults/copyResults. Only the later window.* versions are needed; remove the earlier functions to avoid drift.

-    // Global functions for button actions
-    function clearResults() {
-      document.getElementById('identityInfo').textContent = '';
-      document.getElementById('identityInfo').classList.add('empty');
-      document.getElementById('identityInfo').classList.remove('error');
-      if (typeof currentResult !== 'undefined') {
-        currentResult = null;
-      }
-    }
-    
-    function copyResults() {
-      const content = document.getElementById('identityInfo').textContent;
-      navigator.clipboard.writeText(content).then(() => {
-        const button = document.getElementById('copyButton');
-        const originalText = button.textContent;
-        button.textContent = 'Copied!';
-        setTimeout(() => {
-          button.textContent = originalText;
-        }, 2000);
-      }).catch(err => {
-        console.error('Failed to copy:', err);
-      });
-    }

Also applies to: 672-699


2479-2558: Hardcoded DPNS contract ID will break on mainnet and custom deployments

dpnsSearch uses a fixed testnet DPNS contract ID. This fails on mainnet and any alternative environments.

Proposed fix: select the DPNS contract ID by network (or preferably read from api-definitions.json if present) and allow overrides via UI.

-          // DPNS contract ID on testnet
-          const DPNS_CONTRACT_ID = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec";
+          // DPNS contract ID by network (fallbacks). Consider sourcing from api-definitions.json.
+          const DPNS_CONTRACT_IDS = {
+            testnet: "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec",
+            mainnet: "REPLACE_WITH_MAINNET_DPNS_CONTRACT_ID"
+          };
+          const DPNS_CONTRACT_ID = DPNS_CONTRACT_IDS[currentNetwork] || DPNS_CONTRACT_IDS.testnet;

Optionally: if your api-definitions.json has a dpns section, use it:

const dpnsContractIdFromDefs = stateTransitionDefinitions?.dpns?.contractId || queryDefinitions?.dpns?.contractId;
const DPNS_CONTRACT_ID = dpnsContractIdFromDefs || DPNS_CONTRACT_IDS[currentNetwork] || DPNS_CONTRACT_IDS.testnet;

Would you like me to wire this to api-definitions.json?


2103-2115: Between operator uses string sort; numeric ranges may be incorrect

You sort boundary values as strings, which can misorder numeric bounds ("10" < "2"). Use numeric sort when both values are numeric, otherwise fall back to strings.

-              const value = [val1, val2].sort();
-              whereClause.push([fieldName, combined.operator, value]);
+              const vals = [val1, val2];
+              const num1 = Number(val1), num2 = Number(val2);
+              const areNumeric = Number.isFinite(num1) && Number.isFinite(num2);
+              const sorted = areNumeric ? [num1, num2].sort((a,b)=>a-b) : vals.sort();
+              whereClause.push([fieldName, combined.operator, sorted]);

2593-2633: Duplicate handlers for epoch/evonodes queries

getFinalizedEpochInfos, getEvonodesProposedEpochBlocksByIds, and getEvonodesProposedEpochBlocksByRange are implemented twice. The later block is unreachable and increases maintenance risk.

Remove the later duplicate block:

-        // Epoch/Block queries
-        else if (queryType === 'getFinalizedEpochInfos') {
-          result = await get_finalized_epoch_infos(
-            sdk,
-            values.startEpoch,
-            values.count,
-            values.ascending
-          );
-          // Result is already a JS object from serde_wasm_bindgen
-        } else if (queryType === 'getEvonodesProposedEpochBlocksByIds') {
-          result = await get_evonodes_proposed_epoch_blocks_by_ids(
-            sdk,
-            values.epoch,
-            values.ids
-          );
-          // Result is already a JS object from serde_wasm_bindgen
-        } else if (queryType === 'getEvonodesProposedEpochBlocksByRange') {
-          result = await get_evonodes_proposed_epoch_blocks_by_range(
-            sdk,
-            values.epoch,
-            values.limit,
-            values.startAfter,
-            values.orderAscending
-          );
-          // Result is already a JS object from serde_wasm_bindgen
-        }

Also applies to: 2896-2920


3075-3077: Do not log derived keys or secret material

Logging masterKey and its fields risks leaking private_key_hex/wif to browser logs.

-            console.log('Master key object:', masterKey);
-            console.log('Master key fields:', Object.keys(masterKey || {}));
packages/wasm-sdk/api-definitions.json (4)

72-76: Fix parameter name to 'identityIds' (plural of identity), not 'identitiesIds'

The current name is awkward and inconsistent with other endpoints.

-              "name": "identitiesIds",
+              "name": "identityIds",

Follow-up: update any generator/UI code relying on the old name. See generate_docs.py mapping if needed.


1878-1900: Use 'tokenPosition' (number) instead of 'tokenId' (text) for token transfer

The label says "Token Contract Position" but the field is named tokenId with type text. This is inconsistent with other token endpoints.

-            {
-              "name": "tokenId",
-              "type": "text",
-              "label": "Token Contract Position",
-              "required": true
-            },
+            {
+              "name": "tokenPosition",
+              "type": "number",
+              "label": "Token Contract Position",
+              "required": true
+            },

1914-1918: Unify token position naming across freeze/unfreeze/destroy-frozen endpoints

Same mismatch appears here; align to tokenPosition (number).

-            {
-              "name": "tokenId",
-              "type": "text",
-              "label": "Token Contract Position",
-              "required": true
-            },
+            {
+              "name": "tokenPosition",
+              "type": "number",
+              "label": "Token Contract Position",
+              "required": true
+            },

Also applies to: 1938-1942, 1962-1966


1092-1098: Rename API param: identityId → specializedBalanceId (wasm-sdk) — update docs/UI/tests

The input named "identityId" for getPrefundedSpecializedBalance is actually a Specialized Balance ID — please rename the field and update the docs/UI/test mappings that currently special-case identityId.

Files/locations to update

  • packages/wasm-sdk/api-definitions.json — change the input name in getPrefundedSpecializedBalance.
  • packages/wasm-sdk/generate_docs.py — remove the special-case mapping for 'identityId' and add mapping for 'specializedBalanceId' (generate_docs.py currently special-cases identityId for this query).
  • packages/wasm-sdk/index.html — update input id/label and JS usages (e.g. input group at ~lines 133–136 and calls/error checks around ~2655–2661) so the get_prefunded_specialized_balance calls use values.specializedBalanceId (or add a new input).
  • packages/wasm-sdk/test/ui-automation/utils/parameter-injector.js — add a selector/mapping for 'specializedBalanceId'.
  • packages/wasm-sdk/test/ui-automation/fixtures/test-data.js (or other test fixtures) — ensure test data provides specialized_balance_id (or add the new key expected by generate_docs.py).
  • Regenerate docs: run packages/wasm-sdk/generate_docs.py after making changes.

Suggested diffs

  • packages/wasm-sdk/api-definitions.json
-            {
-              "name": "identityId",
-              "type": "text",
-              "label": "Specialized Balance ID",
-              "required": true,
-              "placeholder": "AzaU7zqCT7X1kxh8yWxkT9PxAgNqWDu4Gz13emwcRyAT"
-            }
+            {
+              "name": "specializedBalanceId",
+              "type": "text",
+              "label": "Specialized Balance ID",
+              "required": true,
+              "placeholder": "AzaU7zqCT7X1kxh8yWxkT9PxAgNqWDu4Gz13emwcRyAT"
+            }
  • packages/wasm-sdk/generate_docs.py (near the param-value mapping)
-        'identityId': f"'{test_data['specialized_balance_id']}'" if 'getPrefundedSpecializedBalance' in query_key else "'5RG84o6KsTaZudDqS8ytbaRB8QP4YYQ2uwzb6Hj8cfjX'" if 'getTokenPerpetualDistributionLastClaim' in query_key else f"'{test_data['identity_id']}'",
+        'specializedBalanceId': f"'{test_data['specialized_balance_id']}'",
+        'identityId': "'5RG84o6KsTaZudDqS8ytbaRB8QP4YYQ2uwzb6Hj8cfjX'" if 'getTokenPerpetualDistributionLastClaim' in query_key else f"'{test_data['identity_id']}'",

Small JS changes example (index.html)

  • Replace calls that pass values.identityId to get_prefunded_specialized_balance* with values.specializedBalanceId and update the missing-parameter error text and input ID/selector accordingly.

After changes

  • Run: cd packages/wasm-sdk && python3 generate_docs.py
  • Run/update UI tests and parameter-injector to ensure the new param is selectable in the UI automation.
♻️ Duplicate comments (3)
packages/wasm-sdk/index.html (2)

452-466: Stale-cache hardening and UX: addressed (thank you)

You added fetch('./api-definitions.json', { cache: 'no-store' }) and a persistent error banner with Retry, which resolves the prior concern.


3001-3004: Consider dynamic dispatch to leverage JSON definitions fully (optional)

The long if/else cascade in executeQuery can be replaced with a dispatcher keyed by definitions (function names) to reduce boilerplate and drift.

If desired, I can propose a minimal dispatcher pattern and the corresponding api-definitions.json shape to support this.

Also applies to: 437-439

packages/wasm-sdk/generate_docs.py (1)

118-121: Pass a numeric startAtMs in getDataContractHistory example

The example currently passes a string "'0'". Use a numeric timestamp to match the "number" type and provide a more realistic example.

-    elif query_key == 'getDataContractHistory':
-        # getDataContractHistory expects: sdk, id, limit, offset, startAtMs
-        # Use the specific contract ID for getDataContractHistory examples
-        params = ["'HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM'", "10", "0", "'0'"]
+    elif query_key == 'getDataContractHistory':
+        # getDataContractHistory expects: sdk, id, limit, offset, startAtMs
+        # Use a recent starting point (24h ago) for a realistic example
+        params = ["'HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM'", "10", "0", "Date.now() - 86400000"]
🧹 Nitpick comments (14)
packages/wasm-sdk/index.html (2)

26-33: Move banner inline styles to index.css

Inline styles for the API error banner make styling harder to maintain given you’ve externalized CSS. Assign classes and move the styles to index.css.

Apply this diff to replace inline styles with CSS classes:

-  <div id="apiErrorBanner" style="display: none; background-color: #f8d7da; color: #721c24; padding: 15px; margin: 0; border-bottom: 1px solid #f5c6cb; text-align: center;">
-    <div style="display: flex; justify-content: center; align-items: center; gap: 15px; flex-wrap: wrap;">
+  <div id="apiErrorBanner" class="api-error-banner" style="display: none;">
+    <div class="api-error-banner__inner">
       <span id="apiErrorMessage">Failed to load API definitions. Please check your connection and try again.</span>
-      <button id="apiRetryButton" style="background-color: #dc3545; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px;">Retry</button>
+      <button id="apiRetryButton" class="api-error-banner__retry">Retry</button>
     </div>
   </div>

Then add styles in index.css:

.api-error-banner {
  background-color: #f8d7da; color: #721c24; padding: 15px; margin: 0;
  border-bottom: 1px solid #f5c6cb; text-align: center;
}
.api-error-banner__inner {
  display: flex; justify-content: center; align-items: center; gap: 15px; flex-wrap: wrap;
}
.api-error-banner__retry {
  background-color: #dc3545; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px;
}

241-243: Avoid deprecated reload(true) usage

window.location.reload(true) ignores the boolean in modern browsers. Use reload() without arguments.

-          window.location.reload(true);
+          window.location.reload();
-                  refreshBtn.onclick = () => window.location.reload(true);
+                  refreshBtn.onclick = () => window.location.reload();

Also applies to: 282-283

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

391-404: Minor wording: “Contract ID” vs “Data Contract ID”

For consistency, change “Contract ID” to “Data Contract ID”.

-- `dataContractId` (text, required) - Contract ID
+- `dataContractId` (text, required) - Data Contract ID
packages/wasm-sdk/check_documentation.py (5)

69-76: Tighten loops, drop unused variables, and avoid .keys()

Minor cleanup: use _ for unused loop vars and iterate dicts directly without .keys().

-    for cat_key, category in current_defs.get('queries', {}).items():
-        for query_key in category.get('queries', {}).keys():
-            current_queries.add(query_key)
+    for _, category in current_defs.get('queries', {}).items():
+        for query_key in category.get('queries', {}):
+            current_queries.add(query_key)
 
-    for cat_key, category in current_defs.get('transitions', {}).items():
-        for trans_key in category.get('transitions', {}).keys():
-            current_transitions.add(trans_key)
+    for _, category in current_defs.get('transitions', {}).items():
+        for trans_key in category.get('transitions', {}):
+            current_transitions.add(trans_key)

41-52: Validate structure types of 'queries' and 'transitions' in JSON

If api-definitions.json is malformed (e.g., arrays or nulls), iterating will crash later. Add a quick type check and fail fast with a clear error.

     try:
         with open(api_definitions_file, 'r') as f:
             api_data = json.load(f)
         current_defs = {
             'queries': api_data.get('queries', {}),
             'transitions': api_data.get('transitions', {})
         }
+        if not isinstance(current_defs['queries'], dict) or not isinstance(current_defs['transitions'], dict):
+            errors.append("ERROR: Invalid api-definitions.json: 'queries' and 'transitions' must be objects")
+            return errors, warnings

110-116: Also track staleness of docs.css

Since CSS is now generated, warn if api-definitions.json is newer than docs.css.

     if docs_file.exists():
         docs_mtime = os.path.getmtime(docs_file)
         if api_definitions_mtime > docs_mtime:
             warnings.append("WARNING: api-definitions.json has been modified after docs.html was generated")
 
+    css_file = script_dir / 'docs.css'
+    if css_file.exists():
+        css_mtime = os.path.getmtime(css_file)
+        if api_definitions_mtime > css_mtime:
+            warnings.append("WARNING: api-definitions.json has been modified after docs.css was generated")
+
     if ai_ref_file.exists():
         ai_mtime = os.path.getmtime(ai_ref_file)
         if api_definitions_mtime > ai_mtime:
             warnings.append("WARNING: api-definitions.json has been modified after AI_REFERENCE.md was generated")

Also applies to: 117-121


134-134: Use UTC for report timestamp to match manifest times

Consistency with manifest UTC times simplifies cross-file comparisons.

-    report_lines.append(f"Timestamp: {datetime.now().isoformat()}\n")
+    report_lines.append(f"Timestamp: {datetime.now(timezone.utc).isoformat()}\n")

160-165: Write report next to the script for predictability

Writing to CWD can surprise CI. Save alongside the script.

-    with open('documentation-check-report.txt', 'w') as f:
-        f.write(report)
+    report_path = Path(__file__).parent / 'documentation-check-report.txt'
+    with open(report_path, 'w') as f:
+        f.write(report)
packages/wasm-sdk/docs.html (1)

605-609: Consider adding a second example demonstrating 'Key Purposes' usage

You switched to a multiselect "Key Purposes" filter. The example omits it (which is fine if optional), but a short second example showing a filtered call would make the feature discoverable.

I can propose an example snippet if helpful.

Also applies to: 614-614

packages/wasm-sdk/api-definitions.json (2)

2-4: Clarify metadata: set source to this file and include timezone in generated_at

Make it explicit that this JSON is the canonical source and use an ISO8601 timestamp with timezone for consistency.

-  "version": "1.0.3",
-  "generated_at": "2025-08-13T17:10:00.000000",
-  "source": "index.html",
+  "version": "1.0.3",
+  "generated_at": "2025-08-13T17:10:00.000000Z",
+  "source": "api-definitions.json",

612-616: Align label with param: it's a Data Contract ID

Label still says "Contract ID" although the param is named dataContractId.

-              "label": "Contract ID",
+              "label": "Data Contract ID",
packages/wasm-sdk/generate_docs.py (3)

995-1004: Make cache lookups robust to subpath hosting

Using absolute paths breaks when served under a subdirectory (e.g., packages/wasm-sdk/). Build URLs relative to the page instead of '/pkg/...'.

-                    const cache = await caches.open('wasm-sdk-cache-v7');
-                    const wasmResponse = await cache.match('/pkg/wasm_sdk_bg.wasm');
-                    const jsResponse = await cache.match('/pkg/wasm_sdk.js');
+                    const cache = await caches.open('wasm-sdk-cache-v7');
+                    const base = new URL('.', window.location.href);
+                    const wasmUrl = new URL('pkg/wasm_sdk_bg.wasm', base).href;
+                    const jsUrl = new URL('pkg/wasm_sdk.js', base).href;
+                    const wasmResponse = await cache.match(wasmUrl);
+                    const jsResponse = await cache.match(jsUrl);

1132-1139: Register service worker with a relative path

Absolute '/service-worker-simple.js' will fail when hosting under a subpath. Use a relative URL.

-            navigator.serviceWorker.register('/service-worker-simple.js')
+            navigator.serviceWorker.register('service-worker-simple.js')

53-60: If renaming 'Specialized Balance ID' field in JSON, update mapping here

Should you adopt specializedBalanceId in api-definitions.json, update this special-case mapping accordingly.

-        'identityId': f"'{test_data['specialized_balance_id']}'" if 'getPrefundedSpecializedBalance' in query_key else "'5RG84o6KsTaZudDqS8ytbaRB8QP4YYQ2uwzb6Hj8cfjX'" if 'getTokenPerpetualDistributionLastClaim' in query_key else f"'{test_data['identity_id']}'",
+        # Prefer specializedBalanceId if api-definitions.json uses that name
+        'specializedBalanceId': f"'{test_data['specialized_balance_id']}'",
+        'identityId': "'5RG84o6KsTaZudDqS8ytbaRB8QP4YYQ2uwzb6Hj8cfjX'" if 'getTokenPerpetualDistributionLastClaim' in query_key else f"'{test_data['identity_id']}'",
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ef9f25e and 2b18528.

📒 Files selected for processing (7)
  • packages/wasm-sdk/AI_REFERENCE.md (7 hunks)
  • packages/wasm-sdk/api-definitions.json (7 hunks)
  • packages/wasm-sdk/check_documentation.py (5 hunks)
  • packages/wasm-sdk/docs.html (8 hunks)
  • packages/wasm-sdk/docs_manifest.json (2 hunks)
  • packages/wasm-sdk/generate_docs.py (12 hunks)
  • packages/wasm-sdk/index.html (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/wasm-sdk/docs_manifest.json
🧰 Additional context used
📓 Path-based instructions (4)
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
packages/wasm-sdk/generate_docs.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'

Files:

  • packages/wasm-sdk/generate_docs.py
packages/wasm-sdk/**/generate_docs.py

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

When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.

Files:

  • packages/wasm-sdk/generate_docs.py
🧠 Learnings (10)
📓 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/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/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
PR: dashpay/platform#2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/index.html
  • packages/wasm-sdk/generate_docs.py
🪛 Ruff (0.12.2)
packages/wasm-sdk/check_documentation.py

73-73: Loop control variable cat_key not used within loop body

Rename unused cat_key to _cat_key

(B007)


74-74: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

⏰ 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). (1)
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (19)
packages/wasm-sdk/index.html (5)

13-13: External stylesheet linkage looks good

Linking to index.css removes the large inline style block from the document head and supports the refactor goal.


2149-2152: Guard for missing definitions is correct

Checking queryDefinitions[category]?.queries?.[queryType] aligns with the new JSON-driven wiring.


3075-3085: Standardize derive_key_ return types (async vs sync) across the code*

derive_key_from_seed_with_path/derive_key_from_seed_phrase are awaited in some paths and used synchronously in others. This is fragile if signatures change or differ between builds.

Please verify the return types of:

  • derive_key_from_seed_with_path
  • derive_key_from_seed_with_extended_path
  • derive_key_from_seed_phrase

If they are synchronous (returning plain JS objects), remove await usages. If async (Promise), always await and handle errors consistently.

I can prepare a follow-up diff to normalize all call sites once you confirm the intended signatures.

Also applies to: 3944-3954, 3829-3841, 4266-4276


4954-4962: UI initialization after definitions: good sequencing

initializeUI() after loading JSON definitions ensures the dropdowns reflect the new canonical source.


4379-4415: Robust dependency-driven input visibility

The dependency handling for dynamic inputs is clean and avoids stale hidden fields bleeding into values.

packages/wasm-sdk/AI_REFERENCE.md (5)

74-75: Purposes multiselect for getIdentitiesContractKeys documented correctly

Docs now reflect the purposes filter (Authentication, Encryption, Decryption, Transfer, Voting) as numeric codes. Matches PR objective.


120-121: ids rename for getIdentitiesBalances is accurate

Renaming identityIds -> ids aligns with the code’s executeQuery usage.


235-236: startAtMs parameter addition is clearly documented

This matches the updated invocation paths in index.html.


332-345: Confirm dpnsSearch is actually exported by the WASM SDK

The section presents dpnsSearch as an SDK method. In the UI, dpnsSearch is implemented as a composed document query rather than a wasm export. If not exported, please reword to clarify it’s a composite helper (UI-level) rather than a direct SDK function.

Would you like me to rephrase this section and add a short example showing the underlying getDocuments call pattern?


515-520: Evonodes by range parameterization looks correct

Docs reflect epoch-first signature and optional (limit, startAfter, orderAscending).

packages/wasm-sdk/docs.html (4)

9-9: LGTM: CSS extracted to external stylesheet

Linking docs.css cleans up the HTML and improves maintainability.


154-155: LGTM: Preloader visibility via CSS class

Switching to a class-based toggle is cleaner than inline styles and matches the generated CSS.

Also applies to: 190-191, 196-197


403-404: LGTM: DPNS Search added with a clear example

The addition is well-integrated in ToC and provides a focused get_documents example using startsWith and ordering.

Also applies to: 1076-1100


1496-1516: LGTM: Epoch-based params for evonodes range

The new parameterization (epoch, limit, startAfter, orderAscending) and example match the documented UI.

Also applies to: 1521-1521

packages/wasm-sdk/api-definitions.json (2)

829-852: LGTM: Epoch range query inputs reflect new API (epoch/limit/startAfter/orderAscending)

The JSON schema matches the UI and code usage.


461-480: LGTM: dpnsSearch added with sensible inputs

Clear naming and placeholders for the new DPNS search endpoint.

packages/wasm-sdk/generate_docs.py (3)

13-27: LGTM: Centralized loader for API definitions with graceful failure

The helper improves separation of concerns and error handling.


381-857: LGTM: CSS emission extracted and linked in generated HTML

Moving CSS to a separate generator and file is a solid maintainability win.


1656-1663: LGTM: UTC timestamps and manifest generation

Using timezone-aware timestamps in the manifest fixes earlier mixed-naive/aware issues and helps downstream checks.

Also applies to: 1791-1882

thephez and others added 2 commits August 14, 2025 13:39
 - Add missing limit/offset parameters to getIdentityKeys and getIdentityTokenInfos
- Add missing startAfter parameter to getIdentityByNonUniquePublicKeyHash
- Rename epoch to startEpoch in getEpochsInfo to match implementation
- Replace startAtVotePollIdInfo with offset in getContestedResourceIdentityVotes
- Rename time parameters and add offset in getVotePollsByEndDate
- Fix parameter names in getContestedResourceVotersForIdentity
- Add missing ascending parameter to getFinalizedEpochInfos
…ation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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 (4)
packages/wasm-sdk/AI_REFERENCE.md (4)

1266-1269: Fix incorrect encoding guidance for IDs and keys

Identity IDs are base58 (see examples), public keys are base64 in JSON, and asset lock keys are WIF/hex. The current line claims “hex-encoded strings” for all, which is misleading.

Apply:

-2. **Identity Format**: Identity IDs and keys should be hex-encoded strings
+2. **Identity and key formats**:
+   - Identity IDs: base58-encoded strings (e.g., 5DbLwAxG…)
+   - Public keys: base64-encoded data inside JSON objects
+   - Private keys: WIF for asset lock proofs; hex for raw signing keys (where applicable)

699-705: Correct GroveDB path aliases in “Get Path Elements” preface

The listed path values don’t match the table below (Tokens/Balances are swapped; Votes value is off).

-*Access any data in the Dash Platform state tree. This low-level query allows direct access to GroveDB storage by specifying a path through the tree structure and keys to retrieve at that path. Common paths include: Identities (32), Tokens (96), DataContractDocuments (64), Balances (16), Votes (80), and more.*
+*Access any data in the Dash Platform state tree. This low-level query allows direct access to GroveDB storage by specifying a path through the tree structure and keys to retrieve at that path. Common paths include: Identities (32), Tokens (16), DataContractDocuments (64), Balances (96), Votes (112), and more.*

934-941: Unify transition method naming (camelCase) in examples

The examples mix snake_case and camelCase. For consistency with surrounding examples, prefer camelCase.

-const result = await sdk.document_create(
+const result = await sdk.documentCreate(

1127-1134: Use camelCase for Token Transfer example

Align with other examples and exported naming.

-const result = await sdk.token_transfer(
+const result = await sdk.tokenTransfer(
♻️ Duplicate comments (1)
packages/wasm-sdk/docs.html (1)

930-941: Use numeric literal for Start At Timestamp (ms) example

The param is numeric; the example passes a string ('0'). Use 0 to avoid confusion. Acknowledge this page is generated and should be adjusted in the generator.

-                <div class="example-code" id="code-getDataContractHistory">return await window.wasmFunctions.get_data_contract_history(sdk, 'HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM', 10, 0, '0');</div>
+                <div class="example-code" id="code-getDataContractHistory">return await window.wasmFunctions.get_data_contract_history(sdk, 'HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM', 10, 0, 0);</div>

If out of scope again, consider tracking it via a follow-up issue for the generator.

🧹 Nitpick comments (10)
packages/wasm-sdk/AI_REFERENCE.md (1)

347-349: Include optional limit in dpnsSearch example

This endpoint supports an optional limit; reflect it to guide users.

-const result = await sdk.dpnsSearch("prefix");
+const result = await sdk.dpnsSearch("prefix", 10);
packages/wasm-sdk/check_documentation.py (2)

74-80: Minor cleanups: drop .keys() and mark unused loop vars

Silences lints (B007, SIM118) and simplifies iteration.

-for cat_key, category in current_defs.get('queries', {}).items():
-    for query_key in category.get('queries', {}).keys():
-        current_queries.add(query_key)
+for _cat_key, category in current_defs.get('queries', {}).items():
+    for query_key in category.get('queries', {}):
+        current_queries.add(query_key)

-for cat_key, category in current_defs.get('transitions', {}).items():
-    for trans_key in category.get('transitions', {}).keys():
-        current_transitions.add(trans_key)
+for _cat_key, category in current_defs.get('transitions', {}).items():
+    for trans_key in category.get('transitions', {}):
+        current_transitions.add(trans_key)

139-139: Emit a timezone-aware report timestamp

Match the UTC convention you use elsewhere in the script.

-report_lines.append(f"Timestamp: {datetime.now().isoformat()}\n")
+report_lines.append(f"Timestamp: {datetime.now(timezone.utc).isoformat()}\n")
packages/wasm-sdk/docs.html (4)

616-621: Clarify Key Purposes mapping

The UI lists human labels only; include numeric values to match underlying API (0,1,2,3,5) and AI reference.

-                    <br><small>Options: Authentication, Encryption, Decryption, Transfer, Voting</small>
+                    <br><small>Options: Authentication (0), Encryption (1), Decryption (2), Transfer (3), Voting (5)</small>

1102-1127: Add a short note that the demo uses getDocuments under the hood

The “DPNS Search” example invokes get_documents (by design). Make this explicit to avoid confusion.

             <h4 id="query-dpnsSearch">DPNS Search Name</h4>
             <p class="description">Search for DPNS names that start with a given prefix</p>
+            <p class="info-note">Note: This demo leverages a document query under the hood (getDocuments with a prefix filter).</p>

1746-1749: Align option labels with example values (use uppercase)

Examples use "ACTIVE"/"CLOSED". Align labels to reduce ambiguity.

-                    <br><small>Options: Active, Closed</small>
+                    <br><small>Options: ACTIVE, CLOSED</small>

1791-1794: Align option labels with example values (use uppercase)

Same for “Get Group Action Signers”.

-                    <br><small>Options: Active, Closed</small>
+                    <br><small>Options: ACTIVE, CLOSED</small>
packages/wasm-sdk/api-definitions.json (3)

4-4: Update ‘source’ metadata to reflect new canonical origin

This JSON is now the canonical source; pointing to index.html is misleading.

-  "source": "index.html",
+  "source": "api-definitions.json",

84-88: Naming consistency: identitiesIds → identityIds

All other multi-identity params use identityIds/ids. This pluralization is an outlier and trips consumers.

-              "name": "identitiesIds",
+              "name": "identityIds",

If renaming is risky, consider adding an alias mechanism in the generator to accept both while rendering “Identity IDs” in the UI.


642-646: Label consistency: use “Data Contract ID”

Everywhere else this label is “Data Contract ID”.

-              "label": "Contract ID",
+              "label": "Data Contract ID",
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2b18528 and 2677ede.

📒 Files selected for processing (5)
  • packages/wasm-sdk/AI_REFERENCE.md (13 hunks)
  • packages/wasm-sdk/api-definitions.json (16 hunks)
  • packages/wasm-sdk/check_documentation.py (5 hunks)
  • packages/wasm-sdk/docs.html (20 hunks)
  • packages/wasm-sdk/docs_manifest.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/wasm-sdk/docs_manifest.json
🧰 Additional context used
🧠 Learnings (11)
📓 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/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/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/api-definitions.json
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
PR: dashpay/platform#2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/check_documentation.py
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/check_documentation.py
  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/api-definitions.json
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/api-definitions.json
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs.html
  • packages/wasm-sdk/AI_REFERENCE.md
📚 Learning: 2024-10-28T10:33:49.019Z
Learnt from: shumkov
PR: dashpay/platform#2259
File: packages/rs-dapi-client/src/address_list.rs:217-217
Timestamp: 2024-10-28T10:33:49.019Z
Learning: Addressing TODO comments in code may be considered out of scope for this project.

Applied to files:

  • packages/wasm-sdk/docs.html
🪛 Ruff (0.12.2)
packages/wasm-sdk/check_documentation.py

78-78: Loop control variable cat_key not used within loop body

Rename unused cat_key to _cat_key

(B007)


79-79: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

⏰ 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). (3)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: build-and-test-wasm-sdk
  • GitHub Check: build-wasm-sdk
🔇 Additional comments (4)
packages/wasm-sdk/check_documentation.py (1)

61-66: Good: UTC-normalized manifest timestamp

Normalizing naive/aware datetimes to UTC avoids TypeError and makes age calculations robust.

packages/wasm-sdk/docs.html (2)

9-9: Nice: CSS extracted to external file

Externalizing styles improves maintainability and caching.


154-154: Preloader logic improved with CSS class toggle

Using a preloader--visible class is a clean separation of concerns; the show/hide flow looks correct, including error path.

Also applies to: 190-191, 196-197

packages/wasm-sdk/api-definitions.json (1)

491-509: dpnsSearch addition looks good

The new endpoint definition (prefix + optional limit) is clear and aligns with the docs and UI changes.

- startTimeMs and endTimeMs now use number type instead of text
- added numeric examples to placeholders for clarity
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: 0

🔭 Outside diff range comments (1)
packages/wasm-sdk/api-definitions.json (1)

84-88: Nit: identitiesIds vs identityIds

Field name “identitiesIds” is awkward/inconsistent with other endpoints (“identityIds” or “ids”). Recommend renaming for consistency and to reduce downstream confusion.

-              "name": "identitiesIds",
+              "name": "identityIds",

Follow through in generator and any consumers.

♻️ Duplicate comments (2)
packages/wasm-sdk/docs.html (1)

930-934: Use numeric literal for Start At Timestamp (ms) example (duplicate of prior feedback)

The parameter type is number, but the example passes a string '0'. Use 0 (unquoted).

-                <div class="example-code" id="code-getDataContractHistory">return await window.wasmFunctions.get_data_contract_history(sdk, 'HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM', 10, 0, '0');</div>
+                <div class="example-code" id="code-getDataContractHistory">return await window.wasmFunctions.get_data_contract_history(sdk, 'HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM', 10, 0, 0);</div>

Also applies to: 939-941

packages/wasm-sdk/api-definitions.json (1)

728-740: Timestamp placeholders still mention “string” (duplicate of prior feedback)

Types changed to number (good), but placeholder/help text should drop “as string”.

-              "placeholder": "Timestamp in milliseconds as string (e.g., 1650000000000)"
+              "placeholder": "Timestamp in milliseconds since epoch (e.g., 1650000000000)"
-              "placeholder": "Timestamp in milliseconds as string (e.g., 1650086400000)"
+              "placeholder": "Timestamp in milliseconds since epoch (e.g., 1650086400000)"
🧹 Nitpick comments (6)
packages/wasm-sdk/docs.html (3)

132-141: Use relative URLs for Cache Storage lookups

Absolute paths can break when served from subpaths (e.g., GitHub Pages). Use relative URLs consistent with the module import path.

Apply this diff:

-                    const wasmResponse = await cache.match('/pkg/wasm_sdk_bg.wasm');
-                    const jsResponse = await cache.match('/pkg/wasm_sdk.js');
+                    const wasmResponse = await cache.match('pkg/wasm_sdk_bg.wasm');
+                    const jsResponse = await cache.match('pkg/wasm_sdk.js');

271-279: Service worker registration path may be too strict

Registering with an absolute path can 404 or set an unexpected scope when hosted under a subdirectory. Prefer a relative path and explicit scope when needed.

-            navigator.serviceWorker.register('/service-worker-simple.js')
+            navigator.serviceWorker.register('./service-worker-simple.js')
                 .then(registration => {
                     console.log('ServiceWorker registered:', registration.scope);
                 })

1349-1359: Timestamp parameter help text contradicts numeric type

Help text still says “as string” while type is number and examples now use numeric Date.now() values. Update the copy for clarity.

-                    <br><small>Example: Timestamp in milliseconds as string (e.g., 1650000000000)</small>
+                    <br><small>Example: Timestamp in milliseconds since epoch (e.g., 1650000000000)</small>
-                    <br><small>Example: Timestamp in milliseconds as string (e.g., 1650086400000)</small>
+                    <br><small>Example: Timestamp in milliseconds since epoch (e.g., 1650086400000)</small>

Also applies to: 137-137

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

430-436: Time range params: fix help text to match number type

Descriptions still say “as string” while types are numbers.

-  - Example: `Timestamp in milliseconds as string (e.g., 1650000000000)`
+  - Example: `Timestamp in milliseconds since epoch (e.g., 1650000000000)`
-  - Example: `Timestamp in milliseconds as string (e.g., 1650086400000)`
+  - Example: `Timestamp in milliseconds since epoch (e.g., 1650086400000)`

Also applies to: 439-441

packages/wasm-sdk/api-definitions.json (2)

2-5: Metadata “source” appears outdated

With definitions consolidated into this file, “source” should not point to index.html.

-  "source": "index.html",
+  "source": "api-definitions.json",

642-646: Label says “Contract ID” but field is dataContractId

For consistency with other queries, prefer “Data Contract ID”.

-              "label": "Contract ID",
+              "label": "Data Contract ID",
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2677ede and d6f1770.

📒 Files selected for processing (4)
  • packages/wasm-sdk/AI_REFERENCE.md (13 hunks)
  • packages/wasm-sdk/api-definitions.json (15 hunks)
  • packages/wasm-sdk/docs.html (19 hunks)
  • packages/wasm-sdk/docs_manifest.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/wasm-sdk/docs_manifest.json
🧰 Additional context used
🧠 Learnings (8)
📓 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/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/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:42.268Z
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.

Applied to files:

  • packages/wasm-sdk/docs.html
📚 Learning: 2025-07-23T08:31:05.082Z
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'

Applied to files:

  • packages/wasm-sdk/docs.html
📚 Learning: 2024-10-28T10:33:49.019Z
Learnt from: shumkov
PR: dashpay/platform#2259
File: packages/rs-dapi-client/src/address_list.rs:217-217
Timestamp: 2024-10-28T10:33:49.019Z
Learning: Addressing TODO comments in code may be considered out of scope for this project.

Applied to files:

  • packages/wasm-sdk/docs.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). (4)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: build-wasm-sdk
  • GitHub Check: build-and-test-wasm-sdk
🔇 Additional comments (33)
packages/wasm-sdk/docs.html (9)

9-9: External CSS extraction looks good

Linking to docs.css aligns with PR goals to externalize styling.


154-155: Preloader visibility toggling via class is cleaner

Switching to the preloader--visible class improves maintainability and separates concerns with CSS.

Also applies to: 189-191, 196-197


561-571: Pagination parameters for Get Identity Keys

Adding Limit/Offset and updating the example strengthens UX and aligns with API changes.

Also applies to: 576-577


616-620: Key Purposes multiselect for Get Identities Contract Keys

The new purposes multiselect is consistent with the refactor intent.

Also applies to: 625-627


625-626: Double-check argument ordering for get_identities_contract_keys

Example shows (sdk, ids, contractId, 'domain'). If purposes are optional and trailing, this is fine. If the public signature changed order, ensure the docs generator reflects the exact ordering to avoid runtime errors.

Would you like me to scan wasm_sdk.js exports and usages to confirm the signature order and update examples if needed?


761-771: Start After param for Non-Unique Public Key Hash lookup

Adding startAfter and showing null in the example is consistent with pagination patterns.


840-851: Pagination added to Get Identity Token Info

Limit/Offset additions and example update are correct.

Also applies to: 855-857


1102-1127: DPNS Search addition

New DPNS Search Name (prefix + limit) and ToC entry are coherent and leverage document queries properly.

Also applies to: 403-404


1533-1561: Evonodes “by range” parameterization is clearer

Switch to epoch + optional limit/startAfter/orderAscending is a sensible API.

Also applies to: 1557-1559

packages/wasm-sdk/AI_REFERENCE.md (12)

61-63: Added pagination to getIdentityKeys

Adding limit/offset improves discoverability and consistency across queries.


76-78: Key purposes multiselect details

Documenting numeric purpose codes is helpful. Looks consistent with UI.


122-123: ids rename for Get Identities Balances

Renaming identityIds → ids matches the JSON definition and improves brevity.


158-159: startAfter for non-unique key hash lookup

Pagination addition looks correct; example remains minimal and valid.

Also applies to: 160-163


197-199: Pagination for getIdentityTokenInfos

Good addition and consistent with other endpoints.

Also applies to: 200-203


240-241: startAtMs added to Data Contract History

Accurately reflected; ensure example updates in docs.html match numeric usage.

Also applies to: 242-245


337-349: DPNS Search documented

New dpnsSearch(prefix, limit) section is clear and aligned with the UI.


396-405: Contested voters param rename and pagination

Switch to dataContractId and adding startAtIdentifierInfo/count matches query naming conventions.

Also applies to: 409-410


418-419: Offset added to identity votes

Offset complements limit; consistent with other queries.


474-477: Epochs Info param rename

startEpoch and optional ascending mirror api-definitions.json and docs UI.

Also applies to: 479-481


499-500: Finalized epochs ascending flag

Optional ascending flag documented; looks good.

Also applies to: 501-504


522-528: Evonodes By Range parameters and example

Updated parameter list is accurate; example with only epoch is valid.

Also applies to: 531-532

packages/wasm-sdk/api-definitions.json (12)

66-76: getIdentityKeys: pagination inputs

Adding limit/offset is consistent with other query shapes.


102-128: Identities Contract Keys: purposes multiselect

The purposes multiselect and options are correct; matches AI_REFERENCE and UI.


178-179: Rename to ids

identityIds → ids improves concision and is aligned across docs.


220-226: startAfter for Non-Unique Public Key Hash

Good addition to support pagination.


284-294: Pagination for Identity Token Info

Limit/offset inputs are appropriate.


356-362: startAtMs on Data Contract History

Accurately captures the new optional filter.


490-509: DPNS Search endpoint addition

Definition matches docs.html and AI_REFERENCE sections.


673-684: Count placeholder communicates default well

Count with “Default: 100” improves UX.


710-714: Offset added to identity votes

Matches docs.html and AI_REFERENCE.


800-804: startEpoch rename for Get Epochs Info

Matches renamed API and examples.


839-845: Ascending flag for finalized epochs

Optional boolean is consistent with similar queries.


872-895: Evonodes by range: epoch, limit, startAfter, orderAscending

Refactor is well captured and self-consistent.

@QuantumExplorer
Copy link
Member

good job

@QuantumExplorer QuantumExplorer merged commit bcdda30 into v2.1-dev Aug 15, 2025
21 of 22 checks passed
@QuantumExplorer QuantumExplorer deleted the wasm-sdk-docs-refactor branch August 15, 2025 17:46
lklimek pushed a commit that referenced this pull request Sep 1, 2025
Co-authored-by: Claude <noreply@anthropic.com>
@coderabbitai coderabbitai bot mentioned this pull request Sep 17, 2025
9 tasks
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.

2 participants