Repository navigation
feat(swift-sdk)!: read Rust's payment class on every PlatformWalletError - #6380
Conversation
…the wallet Every wallet error now carries a payment class set once in Rust: `NotSent` (nothing left the wallet, retryable as Rust decides), `MaybeSent` (a dispatch happened; do not retry), or `LockHeld` (an asset lock exists and names the outpoint its resume can finish). This first part of the split of #5928 holds the class itself (`PaymentDelivery`, `PlatformWalletError::payment_class`/`is_retryable`), the funded-lock seam (`with_funded_lock`) that names a held lock on every failure after it exists, and the flows built on that seam: identity registration, invitation create and claim (with the SDK's `InvitationError` now saying whether a claim was broadcast), the Platform address and shielded fundings from an asset lock, and the external identity top-up from addresses. The FFI only adapts to the new variant shapes here; carrying the class to the hosts follows in the next PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-class wrapper Until the FFI carries the payment class (next PR of the stack), the blanket conversion and every result mapper read the error a RefusedBeforeDispatch or PaymentAlreadyDispatched wraps, so its own code, JSON detail and consensus code still reach the host. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… never sent The drain records NotSent for a refusal before any lock exists; its error now says NotSent too (before_dispatch) instead of MaybeSent. A RefusedBeforeDispatch is never retryable, and its docs say so: its source is a variant that also ends dispatched payments, so running the call again is the user's decision. Co-Authored-By: Claude Opus 5.5 <[email protected]>
refuses_resume read only the outer variant with matches!, so a new variant took the false arm silently. It now reads through the payment-class wrappers and names every PlatformWalletError variant. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lback fails The InstantSend claim before the fallback may have been sent, so any fallback failure, a local one before its own broadcast included, now arrives as StateTransitionResultUnconfirmed rather than a never-sent error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit 8785c53) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
Changes requested: 7 blockers
- An unclassified wallet result is treated as if no payment was attempted —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift:63-68(new)
Impact: A paid operation that crosses the FFI with unknown delivery can be retried after the original call may already have reached the network, causing duplicate payments or duplicate funded operations. - The Swift SDK turns Rust payment metadata into retry and resume policy —
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:761-789(new)
Impact: Swift SDK consumers receive host recovery decisions and presentation text from binding-layer code, allowing payment retry or resume policy to diverge from the Rust-owned wallet state machine and other language bindings. - Marketplace actions remain submittable after an ambiguous payment failure —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DpnsMarketplaceView.swift:625-631(new)
Impact: After a purchase, listing, delisting, or transfer may have reached Platform, dismissing the alert leaves the same action sheet able to submit another paid transition. - An ambiguous invitation failure can fund a second voucher —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/CreateInvitationSheet.swift:255-260(new)
Impact: If invitation creation may have funded a voucher but failed to return its URI, the user can retry from the same sheet and leave another voucher funded while the first remains unresolved. - Address-funded identity registration re-enables after a possibly sent result —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/CreateIdentityView.swift:1417-1422(new)
Impact: A failed address-funded registration that may have reached Platform leaves the Create Identity form active, allowing another paid registration attempt for the same identity slot. - Platform-to-shielded failures lose their payment hold when the sheet closes —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ShieldedFundFromAssetLockView.swift:832-838(new)
Impact: A platform-balance shield classified as possibly sent can be dismissed and started again from a newly opened sheet, potentially shielding the same credits twice. - Identity top-up loses its payment hold when the view is cancelled —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TopUpIdentityView.swift:791-803(new)
Impact: After a maybe-sent or unclassified top-up, cancelling the pending screen and reopening it allows another top-up even though the original operation is unresolved.
This PR propagates Rust-owned payment-delivery metadata through the Swift SDK and updates SwiftExampleApp payment flows to present recovery guidance. The Kotlin SDK build check failed in an unrelated Kotlin authentication test; no Swift-specific CI failure is reported.
🔴 7 blocking | 🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 8: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate change across Swift wallet error handling and recovery flows that directly affects funds movement and asset-lock recovery semantics, particularly in PlatformWalletResult.swift and the wallet drain, funding, registration, and payment-failure coordinators. - Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
- Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift:63-68: An unclassified wallet result is treated as if no payment was attempted
Impact: A paid operation that crosses the FFI with unknown delivery can be retried after the original call may already have reached the network, causing duplicate payments or duplicate funded operations.
The `Unknown` FFI delivery explicitly means that no wallet error established whether funds left the wallet, but `PlatformWalletResult.paymentClass` maps it to `nil` and this helper then returns `nil` for every `PlatformWalletError` without a class. Callers consequently treat the error as an ordinary pre-payment failure, clear their in-flight state, and allow a new submission. Preserve an explicit unclassified payment failure for payment-operation callers, or pass operation-attempt context so only errors proven to occur before the payment call are treated as safe non-payment errors.
In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:761-789: The Swift SDK turns Rust payment metadata into retry and resume policy
Impact: Swift SDK consumers receive host recovery decisions and presentation text from binding-layer code, allowing payment retry or resume policy to diverge from the Rust-owned wallet state machine and other language bindings.
The public `PlatformPaymentRecovery` type decides whether the host should retry, wait, reconcile, or resume and supplies the corresponding user-facing guidance. Although it currently derives those values from Rust's fields, this is still payment-operation policy in the Swift SDK rather than a faithful transport of the Rust result. The project layering rule requires Swift and FFI wrappers to marshal Rust-owned decisions rather than decide whether to retry, rebuild, or replay an operation. Keep the SDK types as mirrors of delivery, retryability, and the held outpoint, and move recovery/action presentation to the application or another host-owned layer.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DpnsMarketplaceView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DpnsMarketplaceView.swift:625-631: Marketplace actions remain submittable after an ambiguous payment failure
Impact: After a purchase, listing, delisting, or transfer may have reached Platform, dismissing the alert leaves the same action sheet able to submit another paid transition.
The catch creates `PaymentFailure` only to render the alert, then resets `isSubmitting`; the confirmation button is disabled only by `!canSubmit || isSubmitting`. `confirmed` remains unset, so dismissing the alert re-enables the same action even for `.maybeSent`, `.lockHeld`, or an unclassified result. Retain the failure as terminal action-sheet state and gate confirmation and dismissal until reconciliation or the exact permitted lock resume; only a Rust-approved `.notSent` result should release the form.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/CreateInvitationSheet.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/CreateInvitationSheet.swift:255-260: An ambiguous invitation failure can fund a second voucher
Impact: If invitation creation may have funded a voucher but failed to return its URI, the user can retry from the same sheet and leave another voucher funded while the first remains unresolved.
The `defer` resets `isCreating` after every failure, and the submit button is disabled only by `isCreating` and amount validity. The new code stores only `PaymentFailure.message`, so a `.maybeSent`, `.lockHeld`, or unclassified result loses its hold as soon as the alert text is dismissed. Store the payment failure or an equivalent operation guard and keep the form blocked until the voucher is reclaimed or reconciled; only a proven `.notSent` result may release it.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/CreateIdentityView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/CreateIdentityView.swift:1417-1422: Address-funded identity registration re-enables after a possibly sent result
Impact: A failed address-funded registration that may have reached Platform leaves the Create Identity form active, allowing another paid registration attempt for the same identity slot.
This direct `registerIdentityFromAddresses` path bypasses the existing registration coordinator. Its catch converts the payment classification into a temporary `SubmitError` and sets `isCreating` to `false`; `canSubmit` has no retained payment hold. Dismissing the alert therefore permits another submission even when Rust classified the original result as `.maybeSent`, `.lockHeld`, or unclassified. Route this path through the registration coordinator or retain the payment failure and identity-slot guard until reconciliation, releasing it only for a Rust-approved `.notSent` result.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ShieldedFundFromAssetLockView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ShieldedFundFromAssetLockView.swift:832-838: Platform-to-shielded failures lose their payment hold when the sheet closes
Impact: A platform-balance shield classified as possibly sent can be dismissed and started again from a newly opened sheet, potentially shielding the same credits twice.
The platform branch converts `PaymentFailure` into `PlatformShieldPhase.failed(title:message:)`, retaining no delivery class or operation guard. The toolbar becomes dismissible as soon as the call leaves `.inFlight`, and dismissing the sheet destroys the phase; the next presentation starts at `.idle` and `canSubmit` allows a fresh shield. Retain this operation through the wallet/coordinator or persist an equivalent reconciliation gate so reopening the screen cannot initiate a second payment after an ambiguous result.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TopUpIdentityView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TopUpIdentityView.swift:791-803: Identity top-up loses its payment hold when the view is cancelled
Impact: After a maybe-sent or unclassified top-up, cancelling the pending screen and reopening it allows another top-up even though the original operation is unresolved.
The view stores the failure only in local `@State`; `.maybeSent` switches to `isPending`, and the Cancel button is re-enabled once `isToppingUp` becomes false. Dismissing the view destroys both the pending and failure state, while the wallet-level pending rows shown below do not gate a new address-funded top-up. Keep the unresolved operation in a wallet-level coordinator or persisted pending record and make re-entry consult that owner before allowing another submission.
In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift`:
- [SUGGESTION] packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:397-411: Read-only network failures lose their normal retry guidance
Impact: SDK users performing ordinary queries or other non-payment requests receive a non-retryable error for every network failure or timeout, even though those operations have no payment-delivery ambiguity.
This shared formatter now hard-codes `isRetryable: false` for every `SDKError.networkError` and `.timeout`. Those same error types are produced by read-only SDK operations, where the generic retry suggestion remains appropriate; the formatter has no operation context with which to apply a payment-specific fail-closed policy. Restore the category-based behavior here and apply conservative payment handling only in payment-operation owners or a payment-specific presentation helper.
cf107e7 to
ccc37aa
Compare
The ChainLock fallback's error is wrapped as unconfirmed, which hid Platform's consumed-outpoint verdict from the adoption check, so a claim whose InstantSend primary had landed reported a failure instead of its identity. The check now reads the verdict through the wrapper and keeps the wrapper when nothing is adopted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ror to the hosts Second part of the split of #5928, on top of the payment class itself. The remaining wallet paths now set their class (DPNS and the marketplace, contact requests, credit and token shielded spends and plans, shielded tips, the shielded seed batch and the wallet drain, masternode withdrawals), and every FFI result carries Rust's class: `payment_delivery`, `retryable` and the held asset lock's outpoint on `PlatformWalletFFIResult`, set from the wallet error by the blanket conversion and every result mapper, never inferred from the code. A panic in a payment export is classed as possibly sent. ERROR_CODE_REGISTRY.md documents the class per code. Swift and Kotlin read it in the next two PRs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ever sent The mainnet gate, the wallet id check, the starting notes count, the recipient and the first batch's fee and amount refuse the run before any lock is built, so they are NotSent (before_dispatch); after an earlier batch dispatched they stay the run's MaybeSent failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…esults PlatformWalletFFIResult gains payment_delivery, held_asset_lock and retryable in this PR, so Swift's init(code:message:) fills them with Rust's own defaults and the test that builds a result field by field names them; Swift reads them in the next PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…assified A null pointer, an invalid handle, a different or removed wallet generation and an unrepresentable txid are refused by the FFI, not by a wallet error; they crossed with a class stamped from a wallet error made up for the call. They now cross as Unknown, as the result's contract says. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Third part of the split of #5928. `PlatformWalletError` carries the FFI result's `PlatformPaymentClass` (delivery, retry, and the held asset lock under `LockHeld`) on every case, read from the result and never derived from the code; texts and recovery suggestions follow it, and a guard that throws after a successful FFI call carries a class too. SwiftExampleApp presents a payment failure by its class: it holds a payment's slot unless nothing was sent, names a held voucher or lock, and releases a hold only once the user reconciled it. BREAKING CHANGE: `PlatformWalletError` cases gain a `payment:` field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`PlatformWalletError.invalidParameter` now carries `payment:`, so the single-binding catch pattern bound a tuple and the test target did not compile. No other single-binding pattern over a `PlatformWalletError` case remains in the Swift SDK, its tests or the example app. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every guard that throws after Rust reported a paid write as done now carries `payment: .maybeSent`, including an output that does not decode: the DPNS give-up result, the contract fee claim (missing JSON and its decode), and every signed moderation call (missing JSON and its decode, through `moderationCall`). The moderation offer read still carries no class. `PlatformWalletError.readingPaidOutput` reclasses a decode refusal of such an output. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd name the lock its Resume resumes A drain failure carries Rust's class, and the drain's own Resume names the outpoint it resumes: - `WalletDrainAttemptError` carries the class of the outcome's error (`attemptError`), `.notSent` for a not-sent outcome whose error has none, and keeps the class when a resume finds no tracked lock (`resumeError`). `PaymentFailure.paymentClass(of:)` reads it, so a not-sent drain releases its slot instead of holding it as unconfirmed. - `run` passes `resuming:` to `startFunding`: `nil` for a start, the resumed outpoint from `resume`, so a failure that holds that lock lets the drain's Resume run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e voucher outpoint claim The submit docs of the shielded and address funding controllers and the identity registration controller said a slot restarts only after a retryable failure; any `.notSent` failure releases it. The invitation create comment said `out_outpoint` names the held voucher lock, but nothing reads it: a success without a URI throws `.maybeSent`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…duled A slot that holds a failed Max refuses a new one by re-presenting the failure without running its body. `start` now removes the id it just stored in that case too, as it does for a start blocked by another funding, so a refused start leaves no marker behind. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aybe sent Token transfer, burn and mint read the balances Rust returns through `tokenReadingBalancesJSON` after the write succeeded; a map that does not parse now throws `.deserialization` with `payment: .maybeSent`, like the other guards after a paid write. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The SDK marshals Rust's payment class (delivery, isRetryable, the held lock) and no longer turns it into a recovery, a title or user-facing text. `PlatformPaymentRecovery` and `ErrorRecovery.suggestion(for: PlatformPaymentClass?)` are removed; the example app's `PaymentFailure` now owns the same mapping as `PaymentFailure.Recovery`, with its suggestion and invitation-voucher texts. `ErrorCategorizer` / `ErrorFormatter` show a wallet error as its own text, titled by its category, with Rust's retry and no suggestion. The `.transactionBroadcastUnconfirmed` text and title are back to the base branch's. BREAKING CHANGE: `PlatformPaymentRecovery` and `ErrorRecovery.suggestion(for: PlatformPaymentClass?)` are gone; a host decides retry, wait or resume from `PlatformWalletError.payment`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ErrorCategorizer` had started presenting every `SDKError.networkError` and `.timeout` as not retryable with no suggestion. That is a decision the SDK does not own, and it also hit read-only queries. The base branch's category-based answer is back; a payment screen decides from Rust's class in the app. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed payment `PaymentFailure.ofPayment` returned nil for a `PlatformWalletError` without a class, so the screen showed it as a plain refusal and let a new payment go. The FFI's `Unknown` delivery also decodes to no class, so a paid call can come back that way. As in Kotlin's `PaymentFailure.ofPayment`, every SDK error is now a payment failure; a classless one is unconfirmed and holds its slot until the user releases it after checking the history. Only an error that is not an SDK error (the screen's own input check) shows as its own message. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r an unresolved failure Every example-app screen that starts a payment now keeps its last `PaymentFailure` and, while it holds its slot (`.maybeSent`, `.lockHeld` or no class), refuses a fresh payment from that screen: the control is disabled and the action itself checks `PaymentFailure.permitsFreshPayment`. The failure clears only on a success, a later `.notSent` result, or the user's confirmed release (`ReleasePaymentHoldButton`, offered when `releasableAfterReconciliation`). `PaymentFailure.keptAfter` keeps a hold across an error that is not an SDK error (← Kotlin). Applied at: - CreateInvitationSheet: create is refused while a voucher lock is held (its text sends the user to reclaim it under Sent invitations) or the create may have gone through. - DpnsMarketplaceView: one screen-level trade failure gates list, delist, transfer and purchase (menu items and the sheet's confirm); search, sync and history stay available. - TopUpAddressFromAssetLockViewModel / AddressQueriesView: the top-up button and `executeTopUp` are refused; a form reset keeps the hold. - CreateIdentityView: the Platform-payment registration's failure is kept and gates submit before any key is persisted. - SendViewModel: a rejected Core broadcast is read by its payment class like an unknown one, so a holding class keeps the form refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eded A reopened Erase sheet whose opening read failed showed the Erase button (no lifecycle and no submission yet), so an operator following the unknown-outcome alert could pay for the next chunk without seeing what the first attempt left. Erase is now offered, and submit() accepted, only once a lifecycle read succeeded; a failed read offers a read-only "Read Lifecycle Again" instead. Rust still decides eligibility. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re the suggestion not shown inline (thepastaclaw, |
|
Waiting for bot review — thepastaclaw reviewed an earlier commit, not yet this one. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
GitHub still shows changes requested by this bot (review of
7c9421a8). Nothing on this head blocks except the disputed finding(s) below, which are left to the maintainers: a maintainer can dismiss that earlier review if they agree it no longer applies.
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: The latest commit makes the Swift example app's Erase sheet wait for a successful lifecycle read before offering a paid submission, and adds a read-only retry when the observation is unavailable. On this head, the Swift and Kotlin SDK builds and tests and the Swift frozen-schema check passed; PR Hygiene and the review check are pending.
🟡 2 suggestion(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate change spanning Swift wallet error handling and payment recovery flows that directly affect funds movement, transaction retry decisions, asset-lock resumption, and wallet-drain behavior. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:900-902: Erase stays unavailable when the document's contract is missing from the SDK cache
Impact: An operator with an erasable document saved locally cannot proceed from the Erase sheet if its custom contract was not loaded into the SDK, even when Platform is reachable.
Tapping “Read Lifecycle Again” cannot recover from this cache miss. This commit makes the lifecycle read mandatory, but `dash_sdk_document_fetch_history` calls `wrapper.data_contract` before sending the history query, and the app's adaptive context provider resolves contracts only from its local cache or the built-in system contracts. A saved custom contract can be missing from that cache: startup skips rows without `binarySerialization` and continues after preload errors. The wallet's erase path already fetches and registers the contract before reading history. Keep the successful-read gate, and have the Rust SDK's history path fetch and register a missing contract for proof verification, with the FFI delegating to that path.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:1019-1024: Erase gives no reason when the required lifecycle read fails
Impact: An operator on a network below protocol 15 or without an initialized SDK sees the same “Read Lifecycle Again” button as someone whose connection timed out.
The operator cannot tell whether trying again will help. The history API preserves the protocol refusal and transport errors in `SDKError`, and `documentGetLifecycle` throws a serialization error if the lifecycle block is incomplete. The sheet's `try?` discards those diagnostics, while optional chaining turns an unavailable SDK into the same `nil`. Keep Erase disabled, show the read error next to the read-only retry, give an explicit message when the SDK is unavailable, and clear the message when a read succeeds.
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Bots are done — your move: post |
The read-only retry that replaces Erase after a failed lifecycle read gave no reason, so a protocol refusal, a missing SDK and a timeout looked the same. The sheet now shows the read's error next to the retry, says so explicitly when the SDK is not initialized, and clears the message once a read succeeds. Erase stays unavailable until then. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw reviewed an earlier commit, not yet this one. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
GitHub still shows changes requested by this bot (review of
7c9421a8). Nothing on this head blocks except the disputed finding(s) below, which are left to the maintainers: a maintainer can dismiss that earlier review if they agree it no longer applies.
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: The Erase sheet now explains why a lifecycle read failed, distinguishes an unavailable SDK, and clears the diagnostic after a successful read. Retrying is read-only, and the paid action still requires an observed deleted or erasing lifecycle. The Swift SDK build and tests, frozen-schema check, and Kotlin SDK build and tests passed; PastaClaw review and PR Hygiene were pending.
🟡 1 suggestion(s)
Still open from earlier rounds (1)
- 🟡 Suggestion: Erase stays unavailable when the document's contract is missing from the SDK cache —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:900-902(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This large, intricate change modifies payment failure classification and recovery behavior in Swift wallet flows, including wallet-drain, asset-lock funding, identity top-up, and lock-resume paths that directly affect funds movement (for example,PlatformWalletResult.swiftandPaymentFailure.swift). - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:900-902: Erase stays unavailable when the document's contract is missing from the SDK cache
(carried; thread: https://github.com/dashpay/platform/pull/6380#discussion_r4783082371)
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
llbartekll
left a comment
There was a problem hiding this comment.
Approving at 8785c53. Static review only (nothing built or run here).
The SDK side reads cleanly: the class comes only from the result's own fields, Unknown decodes to nil, an unrecognised delivery ordinal reads as .maybeSent, and the guards after a successful Rust call consistently carry .maybeSent. The disputed PastaClaw finding (Swift assigning .maybeSent in readingPaidOutput) is a layering inconsistency rather than a double-payment risk, since both a classless error and .maybeSent hold the form; fine to settle in #6464.
Two non-blocking notes on SwiftExampleApp, both on the conservative side (neither allows a second payment), so a follow-up is fine:
-
A classless failure overwrites a held lock and leaves Resume dead. When a slot is
.failed(lockHeld(X))and the resume of X throws before Rust is asked (e.g.admitNativeOpduring shutdown, or a parameter guard), the controller'scatchreplaces the phase withPaymentFailure(error), which is unconfirmed and has noheldLock. From then onpermitsRestart(resuming: X)is false, so Resume X and Dismiss are both refused and the only exit is "Payment checked in history — release", for a payment that was never sent. Applies to the shielded, address and registration coordinators (ShieldedFundFromAssetLockController.submit,AddressFundFromAssetLockController,IdentityRegistrationController). No test has a classless failure following a.lockHeldone. Keeping the previous held lock when the new error carries no class would cover it. -
Address top-up: resuming a held lock to a different recipient may strand the original slot (not verified against Rust).
FundFromAssetLockPlatformAddressViewlets resume mode re-pick the account and recipient, while the coordinator's slot key includes the recipient. Resuming lock L to recipient B runs under a new key; slot A stays.failed(lockHeld(L))with no Dismiss and no Release, and L is consumed, so A stays blocked until the app restarts. I only found the recorded-recipient check (AssetLockRecipientMismatch) on the shielded path, so I could not confirm whether Rust refuses this for platform addresses; if it does, this is moot.
|
Thanks @llbartekll. Both notes are tracked in #6009 (#6009 (comment)) and will be fixed in a follow-up, not on this head. On the second one I checked Rust: funding owned Platform addresses records no recipients on |
…tity-create-chargeable-failure #6380 gave every PlatformWalletError case Rust's payment class. The inputs-consumed identity create (code 91) takes it the same way: in the case, its errorDescription and payment arms and the result-code mapping. The every-case class test lists 91 among the header's codes, and the typed-case test matches the new shape. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Issue being fixed or feature implemented
Part of #5926. Whether a failed payment may have left the wallet was decided by every host from lists of error codes (Swift, Kotlin
isRetryable, the apps), with different defaults per platform, while rs-platform-wallet already knows it and kept it crate-private (BroadcastDelivery). Rust now owns the answer; FFI, JNI, Swift and Kotlin only carry it.Stack
This is part 3 of 4 of #5928, split for review (about 3–5k lines each). Each part builds and tests on its own base and is safe to merge into
v5.2-devalone; merge them in order.What was done?
PlatformPaymentDelivery { notSent, maybeSent, lockHeld(AssetLockBuiltOutPoint) }andPlatformPaymentClass(class and retry). EveryPlatformWalletErrorcase carriespayment: PlatformPaymentClass?, whichinit(result:)fills from the result's ownpayment_delivery,held_asset_lockandretryable, never from the code.payment,deliveryandisRetryableread it, so Swift and Kotlin report the same class and retry for every result.Open points for review
PaymentFailure): MaybeSent, LockHeld or an unclassified payment failure holds the form, any NotSent releases it, LockHeld offers the resume of its named lock (an invitation's voucher is reclaimed)..maybeSent.How Has This Been Tested?
build_ios.sh --target sim). SwiftExampleAppWalletDrainRecoveryTests,ShieldedFundFromAssetLockCoordinatorTests,PaymentFailureTests: 95 passed.ContractFeeClaimDecodingTestsandMasternodesByVotingKeyTestspass. The full suite runs in CI.Breaking Changes
CoreTransactionBroadcastOutcome.rejectedand.unknowngain a trailingpayment: PlatformPaymentClass? = nil(Rust's class for the broadcast). Construction with two arguments still compiles; a pattern that binds them positionally needs a third element, e.g..unknown(let txid, let reason, _)or.rejected(_, let reason, _).payment/deliveryand is not retryable. Swift guards that throw after Rust returned success but no output keep.maybeSent.PlatformWalletErrorcase gains a trailingpayment: PlatformPaymentClass? = nil(class and retry).PlatformWalletError(result:)fills it from the result's own fields, never from the code._, e.g..invalidHandle(let m, _).(String) -> Errorfunction must be wrapped in a closure..maybeSent.PlatformWalletError.payment,.deliveryand.isRetryable.ShieldedIdentityCreateUnconfirmedErrorgainspayment,deliveryandisRetryable.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull request🤖 Generated with Claude Code
PR Hygiene ·
8785c53When every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit