-
Notifications
You must be signed in to change notification settings - Fork 45
feat(sdk)!: state transition broadcast result for Evo SDK #3077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3.1-dev
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a new StateTransitionsFacade to the JS SDK (moved waitForStateTransitionResult out of SystemFacade), introduces typed WASM bindings for StateTransitionProofResult with conversion helpers, updates impl_wasm_conversions macro to target concrete types, and enables serde (de)serialization on many wasm-dpp2 wrapper types; includes new tests and some test removals. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 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 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In @.claude/skills/pr-description/SKILL.md:
- Line 78: Update the wording in the instruction string that currently says
"```markdown" (the language tag in the triple-backtick example) to use the
proper noun "Markdown" (capitalized) so the output guidance reads "```Markdown";
locate the exact phrase in the SKILL.md text that begins "Output the entire PR
description (title + body) as a single raw markdown code block" and change the
lowercase "markdown" to "Markdown" in that sentence and in the triple-backtick
language tag example to keep both occurrences consistent.
…acros Move all 21 StateTransitionProofResult WASM wrapper types from wasm-sdk to wasm-dpp2 where the underlying Rust enum lives. Use undefined instead of null for optional absent values. Add #[serde(transparent)] to all newtype wrappers so impl_wasm_conversions! can serialize self directly, eliminating the need for a separate impl_wasm_serde_conversions! macro. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In `@packages/wasm-dpp2/src/identity/transitions/credit_withdrawal_transition.rs`:
- Around line 99-102: The wrapper struct IdentityCreditWithdrawalTransitionWasm
is missing the Clone derive which other wrappers have and which callers (e.g.,
impl_wasm_conversions!) expect; add Clone to the derive attributes for
IdentityCreditWithdrawalTransitionWasm so it becomes #[derive(Clone,
serde::Serialize, serde::Deserialize)] (keep the existing #[wasm_bindgen(...)]
and #[serde(transparent)] attributes intact).
In `@packages/wasm-dpp2/tests/unit/ProofResult.spec.ts`:
- Around line 1-3: Rename the test file from ProofResult.spec.ts to kebab-case
proof-result.spec.ts and update any references/imports to that filename in the
test suite or build/test configs; locate the file by the imports shown (expect,
initWasm, wasm, identifier) and ensure test runner entries and any relative
import paths are updated so tests continue to import the same symbols from the
new filename.
🧹 Nitpick comments (3)
packages/wasm-dpp2/src/state_transitions/proof_result.rs (2)
690-698:doc_to_wasmuses placeholder metadata — verify consumers handle this.
Identifier::default()(all-zeros) and an empty string fordocument_type_namemeans consumers inspecting the contract ID or type name on documents returned by proof results will get meaningless values. The comment explains the trade-off, but if JS consumers usecontractIdordocumentTypeNameon theseDocumentWasminstances, they'll silently get wrong data instead of an error.Consider whether the metadata should be made optional or if a sentinel value/warning should be added to the TS type.
119-121:Reflect::geterror messages are slightly misleading.
js_sys::Reflect::getreturnsErrwhen the target itself is null/undefined (not when the property is absent — that returnsOk(undefined)). The error messages like"Missing property: dataContract"suggest a missing property, but this error path only triggers when the inputvalueis not an object at all. The actual missing-property case would surface as a downstream deserialization error.This is a very minor cosmetic issue and consistent across the file — not blocking.
Also applies to: 134-136, 271-273, 344-346, 531-533, 585-587, 598-600, 654-656, 668-670
packages/wasm-dpp2/tests/unit/ProofResult.spec.ts (1)
7-9: Top-levelbeforehook is outsidedescribeblock.The
beforehook on line 7 is at the file/module level, not within adescribeblock. While Mocha allows this (it becomes a root-level hook), placing it inside thedescribe('StateTransitionProofResult types', ...)block would scope it more clearly and is a more conventional pattern.
packages/wasm-dpp2/src/identity/transitions/credit_withdrawal_transition.rs
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ionWasm Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Issue being fixed or feature implemented
waitForResponseandbroadcastAndWaitreturned untypedunknownin TypeScript. SDK consumers had no way to work with proof results in a type-safe way. Also,waitForStateTransitionResultwas misplaced onSystemFacade.What was done?
Typed WASM proof result wrappers
packages/wasm-sdk/src/state_transitions/proof_result.rs— 21 typed#[wasm_bindgen]structs (one perStateTransitionProofResultvariant) with typed getters,toObject/fromObject/toJSON/fromJSON, and__structdiscriminatorStateTransitionProofResultTypefor all variantswaitForResponseandbroadcastAndWaitnow returnStateTransitionProofResultTypeJsu64balances exposed asBigIntJS Evo SDK
StateTransitionsFacade(packages/js-evo-sdk/src/state-transitions/facade.ts) withbroadcastStateTransition,waitForResponse,broadcastAndWait,waitForStateTransitionResultwaitForStateTransitionResultfromSystemFacade→StateTransitionsFacadeHow Has This Been Tested?
packages/wasm-sdk/tests/unit/proof-result.spec.ts— exports,__structdiscriminator, conversion methods, and round-trip serialization for all 21 variant typespackages/js-evo-sdk/tests/unit/facades/state-transitions.spec.ts— all 4 facade methods correctly delegate to WASM SDK with and without settingspackages/js-evo-sdk/tests/unit/facades/system.spec.ts— removed moved methodBreaking Changes
sdk.system.waitForStateTransitionResult()→sdk.stateTransitions.waitForStateTransitionResult()waitForResponse()/broadcastAndWait()return typedStateTransitionProofResultTypeinstead ofunknownChecklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Improvements
Breaking Changes
Tests