Skip to content

feat(wasm-dpp2): expose immutable document properties to JavaScript - #4817

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/immutable-fields-js-support
Sep 18, 2026
Merged

QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/immutable-fields-js-support

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Follow-up to #4815 (merged as 96fb252), which adds the immutable and immutableAllowSetting document-type keywords to consensus; this one lets JavaScript discover them without hand-parsing a contract's raw JSON schema, and gives callers a branchable code for the replace rejection they produce. Same arrangement as the refersTo surface (#4450).

What was done?

  • wasm-dpp2: two accessors on DataContract, mirroring documentTypeReferences / documentReferences:
    • documentTypeImmutableProperties(documentTypeName) returns { immutable: string[], immutableAllowSetting: string[] } (keys are the schema keywords' own, arrays sorted by name); empty arrays for a type declaring nothing, a throw for an unknown type so "no such type" and "nothing frozen" stay distinguishable.
    • documentImmutableProperties getter: a Map of the same shape for every document type that freezes at least one property.
    • DocumentImmutabilityErrorCode.DocumentImmutablePropertyChanged = 40128 plus ConsensusError.documentImmutabilityErrorCode, next to the existing DocumentReferenceErrorCode.
    • TypeScript type DocumentTypeImmutableProperties in the generated .d.ts.
  • wasm-sdk / js-evo-sdk: nothing to add in code, the accessors reach @dashevo/evo-sdk through pub use wasm_dpp2::* and export * from '@dashevo/wasm-sdk'. The wasm-sdk unit spec pins the re-export like it does for refersTo, and the js-evo-sdk README gets an "Immutable properties" section (table of contents entry, discovery example, error-code example).

The wrapper delegates to DocumentTypeV2Getters::immutable_fields() / immutable_fields_allow_setting() from #4815 and adds no validation of its own, per wasm-dpp2's conventions; the parser refuses malformed lists at contract registration, which the spec pins.

How Has This Been Tested?

  • wasm-dpp2 Rust unit test: the JS enum's code is derived from the real DocumentImmutablePropertyChangedError through ErrorWithCode, and a neighbouring code is not claimed.
  • wasm-dpp2 mocha spec DocumentTypeImmutableProperties.spec.ts: both lists sorted, empty lists for a type declaring nothing, throw for an unknown type, pre-v14 contract reports nothing while schemas still shows the raw keywords, registration refuses an immutableAllowSetting entry outside immutable, the Map getter keys by type and omits types freezing nothing, and the error code round-trips both ways.
  • wasm-sdk data-contract.spec.ts: re-export pin for both accessors and the error code.
  • cargo clippy -p wasm-dpp2 -p wasm-sdk --tests clean; wasm-dpp2 built with yarn build and the spec run against the bundle.

Breaking Changes

None. Additive JS surface; protocol version 14 is unreleased.

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

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 119d9827-be20-4316-9a99-e891f2173844

📥 Commits

Reviewing files that changed from the base of the PR and between 96fb252 and 4b98232.

📒 Files selected for processing (7)
  • packages/js-evo-sdk/README.md
  • packages/wasm-dpp2/src/consensus_error.rs
  • packages/wasm-dpp2/src/data_contract/document_type_immutability.rs
  • packages/wasm-dpp2/src/data_contract/mod.rs
  • packages/wasm-dpp2/src/data_contract/model.rs
  • packages/wasm-dpp2/tests/unit/DocumentTypeImmutableProperties.spec.ts
  • packages/wasm-sdk/tests/unit/data-contract.spec.ts

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.

@thepastaclaw

thepastaclaw commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ DEGRADED — Queued for automated review — 32nd in line, estimated start in ~17 h (commit 4b04e00)
Estimated review time once started: ~1.1 h (two-phase automated review; median of recent runs).
The primary review models are currently out of quota; this review will run on stand-in models and be marked as degraded.

  • Request priority review — click to move this review to the front of the queue.

@QuantumExplorer
QuantumExplorer force-pushed the claude/immutable-fields-js-support branch from d74e81a to e31a435 Compare September 18, 2026 13:51
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.53%. Comparing base (ba01d4c) to head (4b98232).
⚠️ Report is 3 commits behind head on v4.2-dev.

Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4817      +/-   ##
============================================
+ Coverage     77.73%   79.53%   +1.80%     
============================================
  Files          2963     2963              
  Lines        425602   426728    +1126     
============================================
+ Hits         330849   339409    +8560     
+ Misses        94753    87319    -7434     
Components Coverage Δ
dpp 76.69% <66.29%> (+1.43%) ⬆️
drive 80.43% <69.23%> (+1.37%) ⬆️
drive-abci 82.11% <71.87%> (+3.03%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 87.20% <97.02%> (+0.59%) ⬆️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 29.26% <ø> (+1.81%) ⬆️
🚀 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.

@QuantumExplorer
QuantumExplorer force-pushed the claude/immutable-fields-js-support branch from e31a435 to 4b04e00 Compare September 18, 2026 14:10
Base automatically changed from claude/immutable-fields-mutable-docs-d07225 to v4.2-dev September 18, 2026 14:11
@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Hygiene

State: waiting-bots · commit 4b98232ec6544b75a6c01a5de3f6545643ac092b

  • coderabbitai has not reported for the current head
  • thepastaclaw has not reported for the current head

Self-review is an author attestation that you have read the diff:
/self-reviewed — covers everything pushed so far; post it again after a new push.

This report does not bypass CI or repository protection rules.

@github-actions

Copy link
Copy Markdown
Contributor

PR Hygiene

State: waiting-bots · commit 4b04e00f24aaf0ec9916383ab8e26ad958cf1afa

  • coderabbitai has not reported for the current head
  • thepastaclaw has not reported for the current head

Self-review is an author attestation that you have read the diff:
/self-reviewed — covers everything pushed so far; post it again after a new push.

This report does not bypass CI or repository protection rules.

Discovery of the `immutable` / `immutableAllowSetting` declarations
(protocol version 14) without hand-parsing a contract's raw schema, in
the shape of the existing `refersTo` surface:

- `DataContract.documentTypeImmutableProperties(name)` returns
  `{ immutable, immutableAllowSetting }` (schema keyword names, sorted),
  throwing for an unknown document type.
- `DataContract.documentImmutableProperties` maps every document type
  freezing at least one property to the same shape.
- `DocumentImmutabilityErrorCode.DocumentImmutablePropertyChanged`
  (40128) and `ConsensusError.documentImmutabilityErrorCode`.

The accessors reach @dashevo/evo-sdk through the wasm-sdk re-export;
the wasm-sdk spec pins that, and the js-evo-sdk README documents the
feature.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@QuantumExplorer
QuantumExplorer force-pushed the claude/immutable-fields-js-support branch from 4b04e00 to 4b98232 Compare September 18, 2026 14:13
@QuantumExplorer
QuantumExplorer merged commit d141164 into v4.2-dev Sep 18, 2026
8 of 11 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/immutable-fields-js-support branch September 18, 2026 14:15
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