feat(swift-example-app): add identity→identity Transfer Credits production UI#3891
Conversation
📝 WalkthroughWalkthroughAdds a new ChangesCredit Transfer UI
Sequence DiagramsequenceDiagram
participant User
participant IdentityDetailView
participant TransferCreditsView
participant RecipientPickerView
participant ManagedPlatformWallet
User->>IdentityDetailView: tap Transfer Credits
IdentityDetailView->>TransferCreditsView: present sheet(identity:walletManager:)
User->>RecipientPickerView: select recipient
RecipientPickerView-->>TransferCreditsView: recipient identity/wallet resolved
User->>TransferCreditsView: enter DASH amount and submit
TransferCreditsView->>ManagedPlatformWallet: transferCredits(from:to:credits:signer:)
ManagedPlatformWallet-->>TransferCreditsView: success or error
TransferCreditsView-->>IdentityDetailView: dismiss (didComplete / parent `@Query` refresh)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
…ction UI Adds a per-identity "Transfer Credits" happy-path flow so credits can be sent from one identity to another without the generic Settings → Platform State Transitions builder. - New `TransferCreditsView` sheet: From (sender + balance), recipient via the shared `RecipientPickerView` (local / paste base58 / DPNS name), DASH amount with balance validation, and a success banner. Mirrors `TopUpIdentityView` and `TokenTransferActionView`. - `IdentityDetailView`: "Transfer Credits" button next to "Top Up Balance" (same on-chain + loaded-wallet gating) presenting the sheet. - Routes the whole signed broadcast through the wallet's keychain-backed signer: `wallet.transferCredits` → `platform_wallet_transfer_credits_with_signer`. No orchestration is assembled in Swift; the view only parses/validates the amount. - TEST_PLAN.md: ID-04 and MW-01 updated to the production entry point (✅); §3 entry-point note clarified (the State Transitions builder + Platform Queries catalog live under the Settings → Platform section). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e2a0325 to
b340e89
Compare
|
✅ 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: "bd02c0d2e29efe644fcef2490c0c3f226821ff4d24c5866a81fbf0ad2f885a41"
)Xcode manual integration:
|
Issue being fixed or feature implemented
TEST_PLAN.mdrow ID-04 ("Transfer credits identity → identity") is an Essential-tier test and the "platform-to-platform" anchor, but the app had no production UI for it — identity→identity credit transfer was reachable only through the generic Settings → Platform State Transitions demo builder (TransitionDetailView, which signs with a test signer). There was no per-identity "happy path" button, so a normal user could not send credits from one of their identities to another.This adds that production flow, next to the existing "Top Up Balance" action.
What was done?
The lower layers already existed (
platform_wallet_transfer_credits_with_signerinrs-platform-wallet-ffi, andManagedPlatformWallet.transferCredits(...)in the Swift SDK), so this is pure SwiftExampleApp UI — no FFI/SDK changes.TransferCreditsView.swift— a sheet with:RecipientPickerView(Local identity / paste base58 id / DPNS name resolution), with the sender excluded.1e11, matchingPersistentIdentity.formattedBalanceandTopUpIdentityView), validated against the sender's balance.TopUpIdentityViewandTokenTransferActionView(submit re-entrancy guard, freshKeychainSignerper submit).IdentityDetailView.swift— a "Transfer Credits" button next to "Top Up Balance" (same gating: on-chain identity backed by a loaded wallet), presenting the sheet.wallet.transferCredits→platform_wallet_transfer_credits_with_signer. No orchestration is assembled in Swift — the view only parses/validates the amount, per the swift-sdk architectural rules.TEST_PLAN.md—ID-04and the cross-cuttingMW-01updated from 🧪 to ✅ with the new production entry point; the §3 "entry-point reality check" note clarified. (Note: the Platform State Transitions builder and Platform Queries catalog are not absent from the build as once suspected — they live under the Settings → Platform section, below Network/Data; verified on-device.)How Has This Been Tested?
build_ios.sh --target sim(regenerates the xcframework) +xcodebuildapp (iphonesimulator, arm64) with a fresh derived-data dir → BUILD SUCCEEDED, no workarounds.TransferCreditsViewcompiles against the regenerated FFI header. (Rebased onto currentv3.1-dev, which now includes fix(rs-sdk-ffi): don't export ContestedResourceVoteChoiceFFI to the C header #3892 — see below.)0.001 DASH→ submit enabled → tap. The flow built and broadcast the realIdentityCreditTransfer; the SDK's consensus result surfaced correctly in the error alert.IdentityCreditTransferrequires on-chain, so the broadcast returnsProtocol error: missing key: no transfer public key(the old builder path fails identically). Confirming "recipient balance increases" needs an identity provisioned with a transfer key — tracked as a separate follow-up (the registration key set inrs-platform-walletshould include a TRANSFER/CRITICAL key so ID-04 and ID-10 can land).Note on the SDK build
An earlier revision of this branch hit a pre-existing
#3883cbindgen collision (ContestedResourceVoteChoiceFFIemitted as both a Cenumtag and auint8_ttypedef → ambiguous for Swift). That is now fixed by #3892 ("don't export ContestedResourceVoteChoiceFFI to the C header"), which is merged intov3.1-devand rebased into this branch — the verification above is on that clean base, no local patches.Breaking Changes
None — additive UI only.
Checklist:
For repository code-owners and collaborators only