Skip to content

feat(swift-sdk): add v3 state transitions - #3008

Merged
QuantumExplorer merged 1 commit into
feat/iOSSupportfrom
feat/state_transitions
Jan 22, 2026
Merged

QuantumExplorer merged 1 commit into
feat/iOSSupportfrom
feat/state_transitions

Conversation

@alfie-dash

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

This PR implements support for all 6 address-related state transitions from Dash Platform v3.0, along with 4 new address query operations. These features enable iOS applications to fully interact with Platform addresses, including transferring funds, withdrawing to Core addresses, and managing identity funding operations.

What was done?

Address State Transitions (6 total)

  1. AddressFundsTransferTransition - Transfer credits between Platform addresses

    • Rust FFI: dash_sdk_address_transfer_funds
    • Swift SDK: Addresses.transferFunds(inputs:outputs:feeFromInputIndex:)
    • UI: TransferAddressFundsView with input/output address management
  2. AddressCreditWithdrawalTransition - Withdraw credits from Platform addresses to Core (L1) Dash addresses

    • Rust FFI: dash_sdk_address_withdraw_funds
    • Swift SDK: Addresses.withdrawFunds(inputs:coreAddress:coreFeePerByte:pooling:feeFromInputIndex:changeAddress:)
    • UI: WithdrawAddressFundsView with pooling strategy selection
  3. AddressFundingFromAssetLockTransition - Top up Platform address from asset lock

    • Rust FFI: dash_sdk_address_top_up_from_asset_lock
    • Swift SDK: Addresses.topUpAddressFromAssetLock(...)
    • UI: TopUpAddressFromAssetLockView supporting both instant and chain lock proofs
  4. IdentityTopUpFromAddressesTransition - Top up identity using Platform address balances

    • Rust FFI: dash_sdk_identity_top_up_from_addresses
    • Swift SDK: Addresses.topUpIdentityFromAddresses(identityId:inputs:)
    • UI: TopUpIdentityFromAddressesView
  5. IdentityCreditTransferToAddressesTransition - Transfer credits from identity to Platform addresses

    • Rust FFI: dash_sdk_identity_transfer_credits_to_addresses
    • Swift SDK: Addresses.transferCreditsToAddresses(identityId:outputs:identityPrivateKey:publicKeyId:)
    • UI: TransferIdentityToAddressesView
  6. IdentityCreateFromAddressesTransition - Create identity funded by Platform addresses

    • Rust FFI: dash_sdk_identity_create_from_addresses
    • Swift SDK: Addresses.createIdentityFromAddresses(identityId:inputs:output:identityPrivateKey:)
    • UI: CreateIdentityFromAddressesView

Address Queries (4 new)

  1. getAddressesTrunkState - Fetch top-level state of address tree

    • Rust FFI: dash_sdk_address_fetch_trunk_state
    • Swift SDK: Addresses.getTrunkState()
    • UI: GetTrunkStateView with copy functionality for keys and hashes
  2. getAddressesBranchState - Fetch state of specific branch in address tree

    • Rust FFI: dash_sdk_address_fetch_branch_state
    • Swift SDK: Addresses.getBranchState(key:depth:expectedHash:checkpointHeight:)
    • UI: GetBranchStateView with expanded fields to prevent truncation
  3. getRecentAddressBalanceChanges - Fetch recent, uncompacted address balance changes

    • Rust FFI: dash_sdk_address_fetch_recent_balance_changes
    • Swift SDK: Addresses.getRecentBalanceChanges(startHeight:)
    • UI: GetRecentBalanceChangesView with block-by-block change display
  4. getRecentCompactedAddressBalanceChanges - Fetch recent, compacted address balance changes

    • Rust FFI: dash_sdk_address_fetch_compacted_balance_changes
    • Swift SDK: Addresses.getCompactedBalanceChanges(startBlockHeight:)
    • UI: GetCompactedBalanceChangesView with compacted range display

Additional Features

  • Bech32m Address Support: Full encoding/decoding support for bech32m Platform addresses

    • Bech32m.decode(_:) and Bech32m.isValidPlatformAddress(_:) helper methods
    • Auto-detection of address format (hex or bech32m) in query methods
    • Display of addresses in bech32m format in UI
    • Balance display in both credits and DASH (1 DASH = 10^11 credits)
  • UI Organization: All address-related state transitions are accessible through "Platform -> State Transitions -> Address" menu, separate from address queries

Technical Implementation

  • Rust FFI Layer: All state transitions implemented with proper error handling, memory management, and panic protection
  • Swift SDK: Type-safe Swift wrappers with async/await support and proper resource cleanup
  • iOS UI: Complete SwiftUI forms with validation, error handling, and result display
  • Type Safety: Fixed-size array interop handled correctly (OutPointTuple, PrivateKeyTuple for C compatibility)

How Has This Been Tested?

  • Build Verification: All Rust FFI code compiles successfully for iOS (arm64 device and simulator)
  • Swift Compilation: Swift SDK and Example App compile without errors
  • UI Testing: All 6 state transition views and 4 query views are accessible and functional in the iOS Example App
  • Integration: State transitions are properly integrated into the navigation hierarchy under "Platform -> State Transitions -> Address"
  • Address Format Support: Tested with both hex and bech32m address formats
  • Error Handling: Verified error messages display correctly for invalid inputs

Breaking Changes

No breaking changes. This is a feature addition that extends the existing Addresses service class with new methods and adds new UI views.

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

@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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.


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.

@alfie-dash alfie-dash changed the title State Transitions feat(ios): state transitions Jan 21, 2026
@alfie-dash alfie-dash changed the title feat(ios): state transitions feat(swift-sdk): add state transitions Jan 21, 2026
@QuantumExplorer
QuantumExplorer merged commit 6b7b0dc into feat/iOSSupport Jan 22, 2026
@QuantumExplorer
QuantumExplorer deleted the feat/state_transitions branch January 22, 2026 10:15
@QuantumExplorer QuantumExplorer changed the title feat(swift-sdk): add state transitions feat(swift-sdk): add v3 state transitions Jan 22, 2026
shumkov added a commit that referenced this pull request May 22, 2026
Restore the descriptive legacy name across rs-platform-wallet,
rs-platform-wallet-ffi, Swift SDK, and SwiftExampleApp. The previous
`top_up` name was ambiguous next to the identity-side
`register_identity_with_funding` and conflicted with the prior legacy
`fund_from_asset_lock` terminology.

Pre-existing `TopUpAddress` SDK trait and `top_up_with_signers` method
in rs-sdk (added in #2875/#3008) are untouched — they're shared SDK API,
not part of this PR's surface. Same for `AssetLockFundingType::*TopUp`
enum variants.

Build verified: cargo check -p platform-wallet-ffi, ./build_ios.sh
(sim, debug), xcodebuild SwiftExampleApp — all green.
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