Skip to content

feat(swift-example-app): add identity→identity Transfer Credits production UI#3891

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/fervent-stonebraker-0e359b
Jun 14, 2026
Merged

feat(swift-example-app): add identity→identity Transfer Credits production UI#3891
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/fervent-stonebraker-0e359b

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jun 14, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

TEST_PLAN.md row 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_signer in rs-platform-wallet-ffi, and ManagedPlatformWallet.transferCredits(...) in the Swift SDK), so this is pure SwiftExampleApp UI — no FFI/SDK changes.

  • New TransferCreditsView.swift — a sheet with:
    • From: the sender identity + its current balance.
    • Recipient: the shared RecipientPickerView (Local identity / paste base58 id / DPNS name resolution), with the sender excluded.
    • Amount: DASH entry (÷ 1e11, matching PersistentIdentity.formattedBalance and TopUpIdentityView), validated against the sender's balance.
    • Submit + success banner. Structurally mirrors TopUpIdentityView and TokenTransferActionView (submit re-entrancy guard, fresh KeychainSigner per 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.
  • The signed broadcast routes through the wallet's keychain-backed signer: wallet.transferCreditsplatform_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.mdID-04 and the cross-cutting MW-01 updated 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: clean build_ios.sh --target sim (regenerates the xcframework) + xcodebuild app (iphonesimulator, arm64) with a fresh derived-data dir → BUILD SUCCEEDED, no workarounds. TransferCreditsView compiles against the regenerated FFI header. (Rebased onto current v3.1-dev, which now includes fix(rs-sdk-ffi): don't export ContestedResourceVoteChoiceFFI to the C header #3892 — see below.)
  • On-device (iPhone 17 simulator, testnet): drove the flow end-to-end on the clean build — Identities → an on-chain identity → Transfer Credits (renders next to Top Up Balance) → paste recipient identity id (validated, selection summary shown) → enter 0.001 DASH → submit enabled → tap. The flow built and broadcast the real IdentityCreditTransfer; the SDK's consensus result surfaced correctly in the error alert.
  • Credit-landing is environment-limited, not a defect: every on-device test identity was created with AUTH/ENCRYPTION/DECRYPTION keys only — none has a TRANSFER-purpose key (purpose 3), which IdentityCreditTransfer requires on-chain, so the broadcast returns Protocol 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 in rs-platform-wallet should 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 #3883 cbindgen collision (ContestedResourceVoteChoiceFFI emitted as both a C enum tag and a uint8_t typedef → ambiguous for Swift). That is now fixed by #3892 ("don't export ContestedResourceVoteChoiceFFI to the C header"), which is merged into v3.1-dev and rebased into this branch — the verification above is on that clean base, no local patches.

Breaking Changes

None — additive UI only.

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 (n/a — no breaking changes)
  • I have made corresponding changes to the documentation if needed (TEST_PLAN.md)

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new TransferCreditsView SwiftUI screen for credit-to-credit transfers between platform identities. IdentityDetailView gains a "Transfer Credits" button and sheet presentation wired to the new view. TEST_PLAN.md updates entries ID-04 and MW-01 to reflect the new production UI entry point.

Changes

Credit Transfer UI

Layer / File(s) Summary
TransferCreditsView implementation
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransferCreditsView.swift
New 315-line TransferCreditsView with recipient picker, DASH input parsing and validation into whole credit units, canSubmit gating, isSubmitting/submitGeneration double-submit prevention, async ManagedPlatformWallet.transferCredits call with a per-submit KeychainSigner, success summary section, and error alert.
IdentityDetailView wiring and test plan
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentityDetailView.swift, packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
Adds showingTransferCredits state, "Transfer Credits" button alongside "Top Up Balance", and .sheet presenting TransferCreditsView with walletManager. Test plan updates ID-04 and MW-01 from builder-only (🧪) to production UI () with the new IdentityDetailView → Transfer Credits navigation path.

Sequence Diagram

sequenceDiagram
  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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • shumkov
  • llbartekll
  • ZocoLini

Poem

🐇 Hop hop, credits fly,
From one identity to another they glide—
A picker picks, a signer signs,
The DASH amount duly validates in time.
Submit! The Rust persists the deed,
And Done! the sheet bows out with speed. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding production UI for identity-to-identity credit transfers in the Swift example app.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fervent-stonebraker-0e359b

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.

…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>
@QuantumExplorer QuantumExplorer force-pushed the claude/fervent-stonebraker-0e359b branch from e2a0325 to b340e89 Compare June 14, 2026 07:48
@QuantumExplorer QuantumExplorer merged commit 500d586 into v3.1-dev Jun 14, 2026
17 checks passed
@QuantumExplorer QuantumExplorer deleted the claude/fervent-stonebraker-0e359b branch June 14, 2026 08:08
@github-actions

Copy link
Copy Markdown
Contributor

✅ 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:

  • 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