refactor(swift-sdk): key management#3050
Conversation
- 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).
Add PrivateKeyUtils.swift with utilities for private key management: - KeyFormatDetector: detect hex vs WIF format - PrivateKeyParser: parse keys from hex or WIF with detailed error messages - KeyValidator: validate private keys against public keys - KeySizeValidator: validate key sizes for different key types - KeyFormatter: format keys for display (hex, WIF, truncated) Add comprehensive unit tests for all key utilities (29 tests). Update KeyDetailView to use centralized PrivateKeyParser and KeyValidator instead of inline parsing logic.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. 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 |
|
✅ 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: "b08c4ea2b28883b77e4a016680b8a15e464a99e9cb7d2159877276173bc1affa"
)Xcode manual integration:
|
Extracts the resumable-asset-lock filter from CreateIdentityView into a pure static `resumableLocks(in:usedIndices:walletId:)` generic over a new `AssetLockResumeRow` protocol so unit tests can exercise the business logic without spinning up a SwiftData ModelContainer. View keeps its private `resumableAssetLocks(for:)` entry point as a one-line wrapper that supplies the live `@Query` results. Eight test cases cover the three pieces of logic that can silently regress: - walletId match (cross-wallet bleed) - statusRaw >= 2 floor (Built/Broadcast rejected, ISLock/CLock accepted, forward-compatible for any future status >= 2) - anti-join against the per-wallet used-slot set (including the Int32 -> UInt32 bitPattern bridge for the negative-index edge) Drive-by fix: KeyManagerTests:178 was calling `KeyFormatter.toWIF(_, isTestnet:)` but the SDK changed the signature to `network:` in #3050 (Feb 2026); the test target couldn't build. Updated the call so `xcodebuild test` works again. All 8 new tests pass on iPhone 17 Pro sim (iOS 26.4.1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Issue being fixed or feature implemented
Phase 3 of Swift SDK refactoring: Centralize private key management utilities for better code reuse and consistent error handling.
What was done?
Added
PrivateKeyUtils.swiftwith centralized utilities for private key operations:Updated Views to use new centralized utilities:
KeyDetailView: UsesPrivateKeyParserandKeyValidatorinstead of inline parsing logicHow Has This Been Tested?
KeyManagerTests.swiftBreaking Changes
None
Checklist: