Skip to content

fix(wasm-sdk): label getTokenContractInfo parameter as tokenId, not contractId#3851

Merged
QuantumExplorer merged 4 commits into
v3.1-devfrom
fix/wasm-sdk-getTokenContractInfo-param
Jun 11, 2026
Merged

fix(wasm-sdk): label getTokenContractInfo parameter as tokenId, not contractId#3851
QuantumExplorer merged 4 commits into
v3.1-devfrom
fix/wasm-sdk-getTokenContractInfo-param

Conversation

@thephez

@thephez thephez commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

getTokenContractInfo / getTokenContractInfoWithProofInfo (wasm-sdk) and the tokens.contractInfo / tokens.contractInfoWithProof facade (js-evo-sdk) labeled their single parameter dataContractId / contractId. The query is actually keyed by token ID, which is a distinct value derived from a data contract ID and the token's position (token_id = sha256d("dash_token" || contract_id || position)).

Because the Drive query is a single-key GroveDB lookup keyed by token_id, passing a contract ID — as the parameter name invited — matched no record and silently resolved to undefined rather than erroring. Developers following the parameter name would conclude the token had no contract info.

The Rust SDK query type (TokenContractInfoQuery { token_id }), the gRPC proto field, and the Drive layer were already correctly named token_id; the mislabeling existed only at the WASM/JS surface.

What was done?

  • Renamed the parameter to tokenId on getTokenContractInfo and getTokenContractInfoWithProofInfo, corrected the error messages to "Invalid token ID", and added doc comments that state the argument is a token ID and point to calculateTokenIdFromContract for deriving one.
  • Renamed the parameter to tokenId on the tokens.contractInfo / tokens.contractInfoWithProof facade methods with matching JSDoc.
  • Fixed the wasm-sdk functional test, which previously passed a contract ID with no assertion (silently exercising the bug). It now derives a token ID via calculateTokenIdFromContract and asserts the returned contractId / tokenContractPosition.

The generated dist/*.d.ts regenerate from the wasm_bindgen js_name and TS source on build, so they were not hand-edited.

How Has This Been Tested?

  • cargo build -p wasm-sdk — compiles clean.
  • yarn workspace @dashevo/wasm-sdk test:functional — the rewritten getTokenContractInfo() test now asserts the result, so it fails loudly if a contract ID (silent None) is ever passed again.
  • yarn workspace @dashevo/evo-sdk test:unit — facade pass-through tests.

Breaking Changes

None at runtime. wasm_bindgen generates positional JS arguments, so renaming the parameter does not change the call signature for existing callers — it only corrects the TypeScript parameter label and generated docs. The old dataContractId / contractId label was actively misleading and is the reason for this change.

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

  • API Changes
    • Methods returning token contract info now accept token IDs (parameter renamed) in both JS and WASM bindings, aligning public interfaces.
  • Documentation
    • JSDoc/wasm-bindgen metadata updated to clarify token ID input and how to derive it.
  • Tests
    • Unit and functional tests updated to use calculated token IDs and to assert behavior with the new parameter name.

thephez and others added 2 commits June 10, 2026 14:20
…ctId

getTokenContractInfo and getTokenContractInfoWithProofInfo labeled their parameter dataContractId, but the query is keyed by token ID. A token ID is a distinct value derived from a contract ID and position, so passing a contract ID matched no record and silently resolved to undefined.

Rename the parameter to tokenId, correct the error messages, and add doc comments pointing callers to calculateTokenIdFromContract.

The functional test passed a contract ID with no assertion, so it silently exercised the bug. It now derives a token ID and asserts the returned contract info.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The contractInfo and contractInfoWithProof facade methods labeled their parameter contractId, but the underlying query is keyed by token ID, so passing a contract ID silently resolved to undefined.

Rename the parameter to tokenId with JSDoc pointing callers to TokensFacade.calculateId, and update the unit tests to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b3587bc-f5ab-40ee-9747-4e3bd0714dc8

📥 Commits

Reviewing files that changed from the base of the PR and between 2876fac and 8c28488.

📒 Files selected for processing (1)
  • packages/wasm-sdk/src/queries/token.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/wasm-sdk/src/queries/token.rs

📝 Walkthrough

Walkthrough

Token contract info query methods in the WASM SDK are refactored to accept and parse token IDs instead of data contract IDs, with parameter names updated throughout the JS SDK facade and corresponding unit and functional tests adjusted accordingly.

Changes

Token Contract Info Query Refactoring

Layer / File(s) Summary
WASM SDK token contract info methods
packages/wasm-sdk/src/queries/token.rs
get_token_contract_info and get_token_contract_info_with_proof_info now accept tokenId (JS name tokenId), parse it as a token Identifier, and fetch contract info / proof keyed by token ID; docs and wasm-bindgen names updated.
WASM SDK functional tests
packages/wasm-sdk/tests/functional/tokens.spec.ts
Removed unused TOKEN_CONTRACT_3; getTokenContractInfo() now computes and passes a token ID and asserts returned info.contractId and info.tokenContractPosition; getTokenPerpetualDistributionLastClaim() token ID computation updated.
JS SDK facade and unit tests
packages/js-evo-sdk/src/tokens/facade.ts, packages/js-evo-sdk/tests/unit/facades/tokens.spec.ts
TokensFacade methods contractInfo and contractInfoWithProof renamed their public parameter from contractId to tokenId with JSDoc clarifying the input is a token ID; unit tests updated to pass and assert tokenId.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • shumkov
  • thepastaclaw

Poem

I’m a rabbit with a tiny key,
Hopping through IDs, swift and free,
Token names now guide the way,
From WASM call to JS relay,
A tidy hop, a clearer day 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: renaming the parameter from contractId to tokenId in wasm-sdk methods, which is the primary fix across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wasm-sdk-getTokenContractInfo-param

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@thephez thephez marked this pull request as ready for review June 10, 2026 18:43
@thepastaclaw

thepastaclaw commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit 8c28488)

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.15%. Comparing base (93b657d) to head (8c28488).

Additional details and impacted files
@@            Coverage Diff            @@
##           v3.1-dev    #3851   +/-   ##
=========================================
  Coverage     87.15%   87.15%           
=========================================
  Files          2641     2641           
  Lines        327793   327793           
=========================================
  Hits         285701   285701           
  Misses        42092    42092           
Components Coverage Δ
dpp 87.66% <ø> (ø)
drive 86.04% <ø> (ø)
drive-abci 89.40% <ø> (ø)
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.20% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 49.55% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

Small, well-scoped labeling fix that renames the public WASM/JS parameter from contract/dataContract ID to tokenId on getTokenContractInfo and its proof variant. Underlying query and FFI behavior are unchanged. One valid documentation nitpick: the new JSDoc example calls the static token-ID helper as an instance method.

💬 1 nitpick(s)

Comment thread packages/wasm-sdk/src/queries/token.rs Outdated

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

Verified prior-1 against current head: the JSDoc example at packages/wasm-sdk/src/queries/token.rs:476 now correctly uses the static form WasmSdk.calculateTokenIdFromContract(...), matching how wasm-bindgen exposes the helper (it has no &self receiver). Both agents and CodeRabbit converge on no new in-scope findings for the 8c28488 delta (rustfmt + doc nit fix on top of the parameter renames). PR is a clean, well-scoped fix.

@QuantumExplorer QuantumExplorer merged commit f4ed60f into v3.1-dev Jun 11, 2026
24 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/wasm-sdk-getTokenContractInfo-param branch June 11, 2026 21:48
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.

3 participants