Skip to content

refactor(swift-sdk): data transformers#3045

Open
alfie-dash wants to merge 2 commits intofeat/iOSSupportfrom
refactor/phase-2-data-transformers
Open

refactor(swift-sdk): data transformers#3045
alfie-dash wants to merge 2 commits intofeat/iOSSupportfrom
refactor/phase-2-data-transformers

Conversation

@alfie-dash
Copy link
Collaborator

Issue being fixed or feature implemented

Phase 2 of Swift SDK refactoring: Extract data transformation logic into centralized utilities for better code reuse and maintainability.

What was done?

Added DataTransformers.swift with centralized utilities for data conversion:

  • AddressTransformer: hex/Data conversion, bech32m parsing, identity ID normalization, address formatting
  • NumberTransformer: UInt64/UInt32 parsing, amount formatting, credits/duffs to Dash conversion
  • ResponseParser: PlatformAddressInfo parsing and formatting utilities
  • TransferInputBuilder: create transfer inputs/outputs from form string parameters

Updated ViewModels to use new transformers:

  • AddressTransferViewModel
  • WithdrawAddressFundsViewModel
  • TopUpAddressFromAssetLockViewModel

How Has This Been Tested?

  • Added 39 unit tests for all transformer functionality in DataTransformersTests.swift
  • All existing tests pass (91 total tests)
  • Build verified on iOS Simulator

Breaking Changes

None

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

- Add new validator methods to AddressValidator:
  - validateBech32mAddress() for bech32m Platform addresses
  - validateAddress() with auto-detection (hex or bech32m)
  - validateHash() for 32-byte hashes
  - validateIdentityIdHex() and isHexIdentityId() for identity IDs

- Create comprehensive unit tests for all validators (40+ tests)
  covering AddressValidator, TransferInputValidator,
  WithdrawInputValidator, TopUpAddressFromAssetLockValidator,
  and Identity validators

- Update views to use centralized validators:
  - AddressQueriesView: use validateHash()
  - DocumentWithPriceView: use isHexIdentityId()
  - TransitionDetailView: use isHexIdentityId()
Add DataTransformers.swift with utilities for address, number, and response transformations:
- AddressTransformer: hex/Data conversion, bech32m parsing, identity ID normalization
- NumberTransformer: UInt64/UInt32 parsing, amount formatting, credits/duffs to Dash
- ResponseParser: PlatformAddressInfo parsing and formatting
- TransferInputBuilder: create transfer inputs/outputs from form strings

Update ViewModels to use new transformers:
- AddressTransferViewModel: use TransferInputBuilder
- WithdrawAddressFundsViewModel: use TransferInputBuilder and NumberTransformer
- TopUpAddressFromAssetLockViewModel: use AddressTransformer and NumberTransformer

Add comprehensive unit tests for all transformer functionality (39 tests).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

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.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/phase-2-data-transformers

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


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.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

✅ DashSDKFFI.xcframework built for this PR.

SwiftPM (host the zip at a stable URL, then use):

.binaryTarget(
  name: "DashSDKFFI",
  url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
  checksum: "d917a28a90ad66ee8bdd5d68b93b2249bb71140c867b9a33cad70c59fffa83a0"
)

Xcode manual integration:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

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.

1 participant