feat(wasm-dpp2): expose immutable document properties to JavaScript - #4817
Conversation
|
Warning Review limit reachedNext included review available in 36 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
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. Comment |
|
|
d74e81a to
e31a435
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
e31a435 to
4b04e00
Compare
PR HygieneState: waiting-bots · commit
Self-review is an author attestation that you have read the diff: This report does not bypass CI or repository protection rules. |
PR HygieneState: waiting-bots · commit
Self-review is an author attestation that you have read the diff: 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>
4b04e00 to
4b98232
Compare
Issue being fixed or feature implemented
Follow-up to #4815 (merged as 96fb252), which adds the
immutableandimmutableAllowSettingdocument-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 therefersTosurface (#4450).What was done?
DataContract, mirroringdocumentTypeReferences/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.documentImmutablePropertiesgetter: aMapof the same shape for every document type that freezes at least one property.DocumentImmutabilityErrorCode.DocumentImmutablePropertyChanged = 40128plusConsensusError.documentImmutabilityErrorCode, next to the existingDocumentReferenceErrorCode.DocumentTypeImmutablePropertiesin the generated.d.ts.@dashevo/evo-sdkthroughpub use wasm_dpp2::*andexport * from '@dashevo/wasm-sdk'. The wasm-sdk unit spec pins the re-export like it does forrefersTo, 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?
DocumentImmutablePropertyChangedErrorthroughErrorWithCode, and a neighbouring code is not claimed.DocumentTypeImmutableProperties.spec.ts: both lists sorted, empty lists for a type declaring nothing, throw for an unknown type, pre-v14 contract reports nothing whileschemasstill shows the raw keywords, registration refuses animmutableAllowSettingentry outsideimmutable, theMapgetter keys by type and omits types freezing nothing, and the error code round-trips both ways.data-contract.spec.ts: re-export pin for both accessors and the error code.cargo clippy -p wasm-dpp2 -p wasm-sdk --testsclean; wasm-dpp2 built withyarn buildand the spec run against the bundle.Breaking Changes
None. Additive JS surface; protocol version 14 is unreleased.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code