Skip to content

fix(wallet): log the two wallet-startup outcomes added by the SDK - #1108

Closed
romchornyi wants to merge 1 commit into
developfrom
fix/wallet-startup-outcomes
Closed

romchornyi wants to merge 1 commit into
developfrom
fix/wallet-startup-outcomes

Conversation

@romchornyi

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

develop does not compile against the current v4.2-dev. WalletStartupStatus gained two cases — seedBindingUnverified and identityScanIncomplete — and the DashPay readiness log switches over it exhaustively:

DashPayContactAddressReadiness.swift:61:9: error: switch must be exhaustive

Reproduced by building develop's copy of the file against v4.2-dev head; restoring this change is what makes the build pass again.

What was done?

Logs the two new outcomes, in the shape the neighbouring cases already use.

Both are warnings rather than errors. discoveryFailed next to them is logged at error precisely because it is a local fault that nothing in this session or the next will clear on its own; these two are not that:

  • seedBindingUnverified — the signer handed to the call belongs to a different wallet, so the contact-account drain derived nothing rather than write receiving addresses from the wrong seed. The work stays queued and a rerun with the matching signer completes it.
  • identityScanIncomplete — the contact sync and drain both ran for the identity that is known, but the gap-limit scan left indices unanswered, so the identity set is not established. The verdict stays on record and the next launch re-scans instead of taking the warm shortcut.

How Has This Been Tested?

xcodebuild -workspace DashWallet.xcworkspace -scheme dashpay -sdk iphonesimulator ARCHS=arm64 against v4.2-dev head: fails with the error above using develop's file, succeeds with this change. No behaviour outside the log statements is touched.

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 made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

`WalletStartupStatus` gained `seedBindingUnverified` and
`identityScanIncomplete`, so the DashPay readiness log stopped compiling.

Both are logged as warnings rather than errors: unlike `discoveryFailed`,
which is a local fault nothing will clear on its own, each of these is
recoverable on a later start — a rerun with the matching signer completes the
queued contact-account work, and an incomplete identity scan stays on record
so the next launch re-scans instead of taking the warm shortcut.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 9a874cb3-fa66-4a36-8f90-260bbb8fdc35

📥 Commits

Reviewing files that changed from the base of the PR and between c01d562 and 63cb2d6.

📒 Files selected for processing (1)
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/Contacts/DashPayContactAddressReadiness.swift

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.

@thepastaclaw

thepastaclaw commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🕓 Ready for review — 37 ahead in queue (commit 63cb2d6)
Queue position: 38/55 · 2 reviews active
ETA: start ~05:10 UTC · complete ~06:05 UTC (median 54m across 30 recent reviews; 2 slots)
Queued 13h 48m ago · Last checked: 2026-09-03 12:40 UTC

@llbartekll

Copy link
Copy Markdown
Collaborator

Superseded — develop already handles both cases.

The two switch arms landed in #1095 (96bbf242d, merged today), and #1030 (1b8fda631) added the @unknown default on top, so the exhaustiveness error this PR fixes no longer reproduces. That is also why this branch shows as conflicting: applying it on top of current develop would produce duplicate case .seedBindingUnverified / case .identityScanIncomplete arms and break the build.

Two details from here are still worth having, if you want to open a small follow-up:

  • .seedBindingUnverified is logged at error on develop, and the reasoning in this PR for warning holds — the condition clears on a rerun with the matching signer, unlike discoveryFailed. The comment already on develop says the same thing ("The queued work remains intact for a later run") while still logging at error.
  • That log line is the only arm in the switch that omits \(seconds)s; the version here includes it.

@llbartekll llbartekll closed this Sep 3, 2026
romchornyi pushed a commit that referenced this pull request Sep 8, 2026
…ified token id

Six findings from the automated review of #1109, plus one merge repair.

**A failed purchase is no longer offered for a blind retry.** Every
approval builds, signs and submits a NEW direct purchase against the
identity's next nonce, and the SDK reports one opaque error for both "the
transition was rejected" and "it was submitted and waiting on the outcome
failed". The old catch called all of it an incomplete request and left the
sheet ready to approve again, so a purchase Platform had already accepted
could be bought a second time. `approveTokenPurchase` now throws
`DashConnectTokenPurchaseFailure`, which says which side of submission the
failure came from: everything up to and including authentication is
`beforeSubmission` and keeps today's retry-in-place, while anything out of
`tokenPurchase(...)` is `outcomeUnknown` — the sheet closes and the user
is told to check this identity's tokens and credit balance before buying
again.

**The token id on the sheet is now the token that gets bought.** The id
was copied from the untrusted payload while the purchase is rebuilt from
the contract id and position alone, so a crafted payload could display one
token and buy another. The request is now refused unless the payload's id
matches `calculateTokenId(contractId:position:)` — the protocol formula
the SDK itself derives from.

Also:

- `expectedTotalCost` is a ceiling, not an exact price: Platform rejects a
  higher current price and charges a lower one. Both comments claiming the
  shown and charged amounts "cannot diverge" said more than that.
- The sheet renders the price at full credit precision. Credits are 1e11
  per DASH, and the eight-decimal rendering rounded away a sub-duff
  remainder that is nevertheless charged — on a money-authorization
  surface.
- The credits-per-DASH divisor comes from `PlatformCreditsFormatter`
  instead of a second literal definition.
- Tests cover the token-purchase parse branch and the credits→DASH
  conversion, including zero, a whole DASH, a whole-duff value and a
  single credit (the sub-duff case the display used to drop).

The merge repair: this branch carried its own copy of the
`WalletStartupStatus` cases while the same fix landed on develop as #1108,
so the merge left the switch with two of each. Kept develop's.

Built against platform `v4.2-dev` (which now carries dashpay/platform#4584);
succeeds.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01RstH83XqqRc6oudvpu7UxZ
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.

4 participants