Skip to content

Conversation

@shumkov
Copy link
Collaborator

@shumkov shumkov commented Dec 28, 2025

Issue being fixed or feature implemented

Currently, state transition methods accept many arguments instead of typed objects, which is a better UX.

What was done?

  • Refactored state transitions methods to accept typed objects with a signer.
  • Updated return values.

How Has This Been Tested?

With functional tests

Breaking Changes

Public API of Evo SDK is changed

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

    • Six new document operations available: create, replace, delete, transfer, purchase, and set price.
  • Refactor

    • Simplified contract and identity operation signatures to accept single options objects instead of multiple parameters.
    • Enhanced result types with structured getters for improved data access.
    • Strengthened TypeScript bindings and input validation across state transition operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@shumkov shumkov self-assigned this Dec 28, 2025
@github-actions github-actions bot added this to the v3.0.0 milestone Dec 28, 2025
@shumkov shumkov moved this to In review / testing in Platform team Dec 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The PR refactors the WASM SDK API from granular, multi-parameter method signatures to a consolidated options-based approach. It introduces helper functions for extracting and converting values from JavaScript option objects, replaces contract and identity state transition methods with option-driven signatures, and adds comprehensive document operation support with strongly-typed result objects.

Changes

Cohort / File(s) Summary
Helper Functions for Options Extraction
packages/wasm-dpp2/src/data_contract/model.rs, packages/wasm-dpp2/src/identity/public_key.rs, packages/wasm-sdk/src/settings.rs
Adds three new public helper methods: DataContractWasm::try_from_options(), IdentityPublicKeyWasm::try_from_options(), and extract_settings_from_options(). Each retrieves and validates a typed field from a JavaScript options object, returning errors for missing, undefined, or null values, and handles type conversion via to_wasm() or dedicated parsing.
Contract State Transitions
packages/wasm-sdk/src/state_transitions/contracts/mod.rs
Refactors contract_publish() and contract_update() methods to accept single option objects (ContractPublishOptionsJs, ContractUpdateOptionsJs) instead of individual parameters. Introduces option extraction via helper functions (try_from_options(), extract_settings_from_options()) for contract, signer, and settings data. Removes manual per-field argument handling and consolidates broadcast logic.
Document State Transitions
packages/wasm-sdk/src/state_transitions/documents/mod.rs
Adds six new async methods (document_create, document_replace, document_delete, document_transfer, document_purchase, document_set_price) with corresponding option types and result wrappers. Introduces consistent pattern: parse options, extract identity/contract data, construct document instances, build batch transitions, and broadcast. Replaces ad-hoc signer/key handling with new WASM-based bindings.
Identity State Transitions
packages/wasm-sdk/src/state_transitions/identity/mod.rs
Refactors six methods (identity_create, identity_top_up, identity_credit_transfer, identity_credit_withdrawal, identity_update, masternode_vote) from multi-parameter signatures to single option object parameters. Introduces corresponding option input types, result wrappers with typed getters, and deserialization helpers. Replaces manual cryptographic argument parsing with WASM-dpp2 abstractions for asset lock proofs, private keys, and signers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Options bundled, parameters freed,
From scattered args to structs we plead,
Document ops bloom in six-fold grace,
Each broadcast finds its helper place,
The API garden grows more neat!

Pre-merge checks and finishing touches

✅ Passed checks (3 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: refactoring state transition methods to accept typed parameters instead of individual arguments, which is the primary objective across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@shumkov shumkov marked this pull request as draft December 28, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review / testing

Development

Successfully merging this pull request may close these issues.

2 participants