@bsv/expo-wallet-toolbox 0.5.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/CHANGELOG.md +2000 -0
  2. package/README.md +66 -1
  3. package/core/amountFormatHelpers.ts +258 -36
  4. package/core/backup/RemoteSyncReader.ts +133 -24
  5. package/core/backup/appData.ts +157 -0
  6. package/core/backup/client.ts +15 -1
  7. package/core/backup/codec.ts +149 -11
  8. package/core/backup/constants.ts +30 -1
  9. package/core/backup/cursor.ts +31 -2
  10. package/core/backup/push.ts +71 -5
  11. package/core/backup/restore.ts +104 -16
  12. package/core/backup/restoreOnImport.ts +94 -30
  13. package/core/backup/status.ts +13 -8
  14. package/core/config.tsx +12 -5
  15. package/core/constants.ts +14 -1
  16. package/core/contacts/contactActivity.ts +153 -0
  17. package/core/contacts/contactCache.ts +41 -0
  18. package/core/contacts/contactsStore.ts +183 -0
  19. package/core/context/ExchangeRateContext.tsx +34 -27
  20. package/core/context/LocalStorageProvider.tsx +43 -40
  21. package/core/context/UserContext.tsx +18 -7
  22. package/core/context/VaultContext.tsx +49 -2
  23. package/core/context/WalletConnectionContext.tsx +203 -11
  24. package/core/context/WalletContext.tsx +685 -171
  25. package/core/demo/demoAssets.ts +60 -0
  26. package/core/demo/demoLedger.ts +240 -0
  27. package/core/demo/demoMandalaRuntime.ts +96 -0
  28. package/core/demo/demoMode.ts +38 -0
  29. package/core/demo/demoWallet.ts +25 -0
  30. package/core/demo/index.ts +26 -0
  31. package/core/demo/useDemo.ts +59 -0
  32. package/core/headers/OfflineFirstChaintracks.ts +99 -17
  33. package/core/headers/headerStore.ts +33 -14
  34. package/core/headers/syncHeaders.ts +12 -1
  35. package/core/i18n/translations.tsx +2186 -98
  36. package/core/identity/contactLink.ts +36 -0
  37. package/core/identity/handleRegistry/client.ts +314 -0
  38. package/core/identity/handleRegistry/keyPinStore.ts +70 -0
  39. package/core/identity/handleRegistry/profileCert.ts +254 -0
  40. package/core/identity/handleRegistry/registration.ts +559 -0
  41. package/core/identity/handleRegistry/resolver.ts +315 -0
  42. package/core/identity/handleRegistry/rules.ts +104 -0
  43. package/core/index.ts +53 -5
  44. package/core/localpay/build.ts +225 -24
  45. package/core/localpay/pending.ts +110 -7
  46. package/core/localpay/pendingAbortAuthority.ts +95 -0
  47. package/core/localpay/pendingAborts.ts +266 -26
  48. package/core/localpay/session.ts +42 -17
  49. package/core/localpay/settlementAck.ts +10 -1
  50. package/core/localpay/transport/socket.ts +52 -3
  51. package/core/localpay/verify.ts +100 -10
  52. package/core/mandala/abortGuard.ts +96 -20
  53. package/core/mandala/createRuntime.ts +206 -33
  54. package/core/mandala/drain.ts +89 -11
  55. package/core/mandala/inboxPrehold.ts +186 -0
  56. package/core/mandala/permissionModule.ts +202 -20
  57. package/core/mandala/settlementStore.ts +24 -2
  58. package/core/mandala/types.ts +40 -5
  59. package/core/monitor/MonitorSupervisor.ts +121 -0
  60. package/core/monitor/TaskBackupPush.ts +15 -1
  61. package/core/monitor/TaskCreditInbox.ts +1 -1
  62. package/core/monitor/TaskDrainOutbox.ts +15 -1
  63. package/core/monitor/TaskSendOffline.ts +15 -1
  64. package/core/net/online.ts +49 -0
  65. package/core/net/publicDestination.ts +91 -0
  66. package/core/net/validateArcUrl.ts +22 -0
  67. package/core/numberFormat.ts +19 -0
  68. package/core/offline/cancelParked.ts +134 -13
  69. package/core/offline/payerHold.ts +100 -24
  70. package/core/offline/plan.ts +37 -8
  71. package/core/pay/beefRepair.ts +6 -2
  72. package/core/pay/damagedInbox.ts +24 -0
  73. package/core/pay/rails/address.ts +107 -12
  74. package/core/pay/rails/handle.ts +117 -22
  75. package/core/pay/rails/index.ts +45 -7
  76. package/core/pay/rails/nativeIntent.ts +61 -0
  77. package/core/pay/receiveHistory.ts +93 -0
  78. package/core/pay/recordProof.ts +21 -7
  79. package/core/pay/refreshProofGuard.ts +42 -1
  80. package/core/pay/watchlist.ts +5 -2
  81. package/core/peerpay/control.ts +17 -18
  82. package/core/peerpay/handleResendRequests.ts +58 -4
  83. package/core/peerpay/outbox.ts +3 -1
  84. package/core/recovery/backupMaterial.ts +61 -0
  85. package/core/recovery/createWallet.ts +95 -0
  86. package/core/recovery/recoverWallet.ts +120 -0
  87. package/core/recovery/restoreWallet.ts +170 -0
  88. package/core/recovery/secret.ts +92 -0
  89. package/core/recovery/shareCollector.ts +71 -0
  90. package/core/recovery/shareParsing.ts +87 -0
  91. package/core/recovery/shares.ts +116 -0
  92. package/core/recovery/useRecoveryDeps.ts +70 -0
  93. package/core/services/arcTokenStorage.ts +52 -0
  94. package/core/services/arcadeBroadcastProvider.ts +233 -52
  95. package/core/services/autoApprovePolicy.ts +105 -0
  96. package/core/services/callbackToken.ts +19 -0
  97. package/core/services/capWalletArgs.ts +14 -2
  98. package/core/services/connectionAuthority.ts +98 -0
  99. package/core/services/exchangeRate.ts +36 -13
  100. package/core/services/externalOrigin.ts +16 -2
  101. package/core/services/secrets/kek.ts +126 -29
  102. package/core/services/secrets/migration.ts +16 -4
  103. package/core/services/secrets/store.ts +42 -14
  104. package/core/services/vault/VaultKeyService.ts +228 -45
  105. package/core/services/vault/chainRecovery.ts +483 -0
  106. package/core/services/vault/driver.ts +9 -1
  107. package/core/services/vault/enrolledSerialRegistry.ts +150 -0
  108. package/core/services/vault/guard.ts +218 -32
  109. package/core/services/vault/hardwareLease.ts +19 -0
  110. package/core/services/vault/metaAuthority.ts +210 -0
  111. package/core/services/vault/pivReset.ts +64 -23
  112. package/core/services/vault/r1comb.ts +139 -3
  113. package/core/services/vault/session.ts +25 -4
  114. package/core/services/vault/transfers.ts +868 -172
  115. package/core/services/vault/types.ts +19 -4
  116. package/core/services/vault/vaultStore.ts +256 -29
  117. package/core/services/walletArgLimits.ts +45 -2
  118. package/core/services/walletConnectionValidation.ts +76 -6
  119. package/core/services/walletServiceConfig.ts +40 -27
  120. package/core/storage/StorageExpoSQLite.ts +88 -47
  121. package/core/storage/methods/findSql.ts +24 -2
  122. package/core/storage/methods/listActionsSql.ts +8 -5
  123. package/core/storage/methods/listOutputsSql.ts +2 -2
  124. package/core/storage/methods/offlineActions.ts +10 -1
  125. package/core/storage/methods/processOfflineActions.ts +117 -25
  126. package/core/storage/methods/reviewStatusSql.ts +7 -2
  127. package/core/storage/schema/createTables.ts +155 -2
  128. package/core/stores/ConnectionStore.ts +34 -0
  129. package/core/toolboxConfig.ts +104 -0
  130. package/core/toolboxTypes.ts +40 -0
  131. package/core/userAvatar.ts +79 -0
  132. package/core/walletDbRegistry.ts +63 -0
  133. package/core/walletMonitor.ts +25 -4
  134. package/core/walletRepair/releaseStuckReservations.ts +72 -0
  135. package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
  136. package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
  137. package/package.json +7 -7
  138. package/ui/activityFilter.ts +115 -0
  139. package/ui/backupShares.ts +26 -169
  140. package/ui/components/pay/AddressReceive.tsx +13 -6
  141. package/ui/components/pay/AssetPicker.tsx +30 -9
  142. package/ui/components/pay/MessageBoxConfig.tsx +16 -0
  143. package/ui/components/pay/NearbyFlow.tsx +480 -243
  144. package/ui/components/pay/PaymentSuccessOverlay.tsx +85 -10
  145. package/ui/components/pay/RecipientField.tsx +84 -70
  146. package/ui/components/pay/StepBar.tsx +32 -0
  147. package/ui/components/pay/UniversalSend.tsx +827 -205
  148. package/ui/components/ui/AlertCard.tsx +38 -5
  149. package/ui/components/ui/PencilEditField.tsx +109 -0
  150. package/ui/components/ui/PermissionSheet.tsx +197 -66
  151. package/ui/components/ui/SlideOverFromRight.tsx +86 -0
  152. package/ui/components/vault/EnrollWizard.tsx +61 -13
  153. package/ui/components/vault/vaultErrorCopy.ts +3 -1
  154. package/ui/components/wallet/ActivityRow.tsx +227 -123
  155. package/ui/components/wallet/AmountInput.tsx +26 -8
  156. package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
  157. package/ui/components/wallet/Balance.tsx +42 -23
  158. package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
  159. package/ui/components/wallet/ContactActivityList.tsx +149 -0
  160. package/ui/components/wallet/ContactSigil.tsx +49 -0
  161. package/ui/components/wallet/EditPictureSheet.tsx +99 -0
  162. package/ui/components/wallet/FitAmount.tsx +148 -0
  163. package/ui/components/wallet/IconPickerSheet.tsx +168 -0
  164. package/ui/components/wallet/IdentifierRow.tsx +69 -0
  165. package/ui/components/wallet/ImportFromBackupPrompt.tsx +35 -13
  166. package/ui/components/wallet/ProfileButton.tsx +62 -0
  167. package/ui/components/wallet/UserAvatar.tsx +85 -0
  168. package/ui/components/wallet/avatarIcons.ts +122 -0
  169. package/ui/exportTransactions.ts +36 -4
  170. package/ui/hooks/useContactsStore.ts +10 -0
  171. package/ui/hooks/useExportWalletData.ts +25 -2
  172. package/ui/hooks/useMandala.ts +18 -1
  173. package/ui/hooks/useOnline.ts +65 -20
  174. package/ui/importDatabases.ts +339 -24
  175. package/ui/index.ts +33 -2
  176. package/ui/isImageUrl.ts +6 -0
  177. package/ui/printRecoveryShares.ts +9 -10
  178. package/ui/recoveryPrompts.ts +91 -0
  179. package/ui/resolveIdentity.ts +31 -9
  180. package/ui/screens/ConnectionsScreen.tsx +86 -19
  181. package/ui/screens/ContactScreen.tsx +289 -0
  182. package/ui/screens/ContactsScreen.tsx +373 -0
  183. package/ui/screens/IdentifierScreen.tsx +256 -0
  184. package/ui/screens/NewContactScreen.tsx +362 -0
  185. package/ui/screens/PairScreen.tsx +74 -2
  186. package/ui/screens/PayScreen.tsx +20 -7
  187. package/ui/screens/ProfileScreen.tsx +783 -0
  188. package/ui/screens/SettingsScreen.tsx +10 -4
  189. package/ui/screens/TransactionDetailScreen.tsx +419 -0
  190. package/ui/screens/TrustScreen.tsx +100 -5
  191. package/ui/screens/VaultScreen.tsx +410 -61
  192. package/ui/screens/VaultTransferScreen.tsx +59 -7
  193. package/ui/screens/WalletCheckScreen.tsx +17 -6
  194. package/ui/screens/WalletConfigScreen.tsx +124 -28
  195. package/ui/screens/WalletHomeScreen.tsx +640 -104
  196. package/ui/screens/detailActionKeys.ts +55 -0
  197. package/ui/tokenFormat.ts +44 -4
  198. package/ui/tokenStatus.ts +21 -0
  199. package/ui/txStatus.ts +48 -5
  200. package/core/storage/LocalStorageAdapter.ts +0 -58
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Which detail-sheet action chips apply to an activity row.
3
+ *
4
+ * Extracted out of WalletHomeScreen's `detailActions()` (a pure decision, no
5
+ * JSX or translated labels) so the parked/abort guard is unit-testable
6
+ * without mounting the whole screen. See ActivityRow's `canAbort`, which
7
+ * already carries this same `!parked` guard for the expanded-row surface —
8
+ * this is the detail-sheet surface's copy of that decision.
9
+ */
10
+
11
+ /**
12
+ * Statuses whose transaction is still local and therefore abortable — the same
13
+ * set `ActivityRow` gates its own Cancel chip on. Duplicated as a constant
14
+ * rather than imported so the row keeps owning its own copy while both
15
+ * surfaces exist.
16
+ */
17
+ export const ABORTABLE_DETAIL_STATUSES = new Set(['unsigned', 'nosend', 'nonfinal', 'failed'])
18
+
19
+ export type DetailActionKey = 'refresh' | 'explorer' | 'abort' | 'cancel-parked' | 'request-confirmation'
20
+
21
+ /** Labels of the outgoing rails whose payment can be re-delivered over the
22
+ * message box (the same set ActivityRow's `resendableOutbound` uses). */
23
+ const REDELIVERABLE_LABELS = new Set(['peerpay', 'localpay', 'mandala'])
24
+
25
+ export function detailActionKeysFor(args: {
26
+ txid?: string
27
+ reference?: string
28
+ status: string
29
+ offlineStatus?: string
30
+ isOutgoing?: boolean
31
+ labels?: string[]
32
+ }): DetailActionKey[] {
33
+ const { txid, reference, status, offlineStatus, isOutgoing, labels } = args
34
+ const parked = offlineStatus === 'parked'
35
+ const out: DetailActionKey[] = []
36
+ if (txid && !parked && offlineStatus !== 'queued' && offlineStatus !== 'posting') out.push('refresh')
37
+ if (txid && !parked) out.push('explorer')
38
+ // XR-095: a parked nearby payment's inputs may already be a payee's to
39
+ // broadcast (FIX F) — cancelling it must always go through
40
+ // `cancelParkedPayment`'s chain-status gate, never this unconditional
41
+ // abort. Mirrors the `!parked` guard already used above for
42
+ // 'refresh'/'explorer', and the one `ActivityRow`'s `canAbort` already has.
43
+ //
44
+ // 2026-09-25: and never on a payment this device recorded handing over
45
+ // (queued, posting, sent, acknowledged, rejected, import_hold): the payee may
46
+ // hold it, and an abort would free inputs their copy spends. Plain abort is
47
+ // for a payment with no offline record at all — one that provably never
48
+ // left the device.
49
+ if (reference && offlineStatus === undefined && ABORTABLE_DETAIL_STATUSES.has(status)) out.push('abort')
50
+ if (parked && txid) out.push('cancel-parked')
51
+ // Re-deliver the same payment over the message box, whatever rail it first
52
+ // took (the owner's "request confirmation from recipient").
53
+ if (txid && isOutgoing === true && !!labels?.some(l => REDELIVERABLE_LABELS.has(l))) out.push('request-confirmation')
54
+ return out
55
+ }
package/ui/tokenFormat.ts CHANGED
@@ -18,6 +18,19 @@
18
18
  * vouching for someone else's peg (ux §6.1).
19
19
  */
20
20
 
21
+ /**
22
+ * XR-043: mirrored at every other boundary that ever reads a token's
23
+ * decimals — `core/localpay/session.ts`'s session codec and
24
+ * `core/mandala/createRuntime.ts`'s asset-metadata resolution enforce the
25
+ * same bound at THEIR boundaries; this is the last line of defense inside
26
+ * the formatters themselves, since a decimals value can reach here from a
27
+ * path neither of those touches (a stale cached asset, a test double, a
28
+ * future caller). Nothing token-shaped this wallet knows of uses more than a
29
+ * handful; an unbounded decimals value is how `String(...).padStart` (and
30
+ * an unbounded regex quantifier below) blows up the confirmation UI.
31
+ */
32
+ const MAX_TOKEN_DECIMALS = 18
33
+
21
34
  /** Grouping separators for the integer part, in the device's own locale. */
22
35
  function groupInteger(digits: string): string {
23
36
  const n = Number(digits)
@@ -37,7 +50,8 @@ export function formatTokenAmount(
37
50
  decimals: number,
38
51
  opts: { showPlus?: boolean } = {}
39
52
  ): string | null {
40
- if (!Number.isFinite(baseUnits) || !Number.isFinite(decimals) || decimals < 0) return null
53
+ if (!Number.isFinite(baseUnits) || !Number.isInteger(decimals) || decimals < 0 || decimals > MAX_TOKEN_DECIMALS)
54
+ return null
41
55
  const d = Math.floor(decimals)
42
56
  const rounded = Math.round(Math.abs(baseUnits))
43
57
  const digits = String(rounded).padStart(d + 1, '0')
@@ -78,7 +92,7 @@ export function formatTokenAmountWithUnit(
78
92
  * different amount than the one on screen.
79
93
  */
80
94
  export function parseTokenAmount(text: string, decimals: number): number | null {
81
- if (!Number.isFinite(decimals) || decimals < 0) return null
95
+ if (!Number.isInteger(decimals) || decimals < 0 || decimals > MAX_TOKEN_DECIMALS) return null
82
96
  const trimmed = text.trim()
83
97
  if (!trimmed) return null
84
98
  const d = Math.floor(decimals)
@@ -92,9 +106,17 @@ export function parseTokenAmount(text: string, decimals: number): number | null
92
106
  return Number.isSafeInteger(value) ? value : null
93
107
  }
94
108
 
95
- /** The input mask for an asset's decimals: digits, one point, at most N places. */
109
+ /**
110
+ * The input mask for an asset's decimals: digits, one point, at most N places.
111
+ *
112
+ * XR-043: clamped rather than refused (unlike the formatters above) — this
113
+ * always has to return SOME usable mask for the field to render with, so an
114
+ * out-of-range `decimals` is treated as `MAX_TOKEN_DECIMALS` instead of
115
+ * reaching an unbounded regex quantifier.
116
+ */
96
117
  export function tokenAmountMask(decimals: number): RegExp {
97
- const d = Math.max(0, Math.floor(decimals))
118
+ const bounded = Number.isFinite(decimals) ? decimals : 0
119
+ const d = Math.min(MAX_TOKEN_DECIMALS, Math.max(0, Math.floor(bounded)))
98
120
  return d === 0 ? /^\d*$/ : new RegExp(`^\\d*\\.?\\d{0,${d}}$`)
99
121
  }
100
122
 
@@ -106,3 +128,21 @@ export function tokenAmountInputText(baseUnits: number, decimals: number): strin
106
128
  // cannot produce and `parseTokenAmount` would refuse on the next keystroke.
107
129
  return formatted.replace(/[^\d.]/g, '')
108
130
  }
131
+
132
+ /**
133
+ * A short, human-scannable form of a long `'<64-hex>.<vout>'` assetId —
134
+ * `"a1b2c3d4…ef01.0"`. Same truncation `core/mandala/permissionModule.ts`'s
135
+ * own (unexported) `shortAssetId` uses for prompt copy, kept as a small
136
+ * separate copy here rather than an import so the UI layer does not reach
137
+ * into `core/mandala` for a pure string helper.
138
+ *
139
+ * XR-044: an issuer-chosen ticker/label is not unique — a look-alike asset
140
+ * from a different issuer can share both. `assetId` is the one thing that
141
+ * cannot collide, so every asset-selection row and the final send
142
+ * confirmation show this fingerprint alongside the ticker/label, not instead
143
+ * of it.
144
+ */
145
+ export function shortAssetId(assetId: string): string {
146
+ if (!assetId || assetId.length <= 16) return assetId
147
+ return `${assetId.slice(0, 8)}…${assetId.slice(-6)}`
148
+ }
package/ui/tokenStatus.ts CHANGED
@@ -11,6 +11,7 @@
11
11
  * and painting it amber would make the normal case look like a fault.
12
12
  */
13
13
  import type { TokenActivityStatus } from '../core/mandala/runtime'
14
+ import type { TxStatusView } from './txStatus'
14
15
 
15
16
  export type TokenStatusTone = 'neutral' | 'positive' | 'warning' | 'error'
16
17
 
@@ -34,6 +35,26 @@ export function tokenStatusKey(status: TokenActivityStatus): string {
34
35
  return KEYS[status] ?? KEYS.settling
35
36
  }
36
37
 
38
+ /**
39
+ * A token row's status in an activity list, in the same words and tones a BSV
40
+ * row uses: a finished transfer says what it did (Sent / Received), one still
41
+ * on its way to the issuer is plain "Pending", and only the states the holder
42
+ * may have to act on keep their own word and get colour.
43
+ */
44
+ export function tokenRowStatusView(status: TokenActivityStatus, incoming: boolean): TxStatusView {
45
+ switch (status) {
46
+ case 'settled':
47
+ return { key: incoming ? 'tx_status_received' : 'tx_status_sent', tone: 'settled' }
48
+ case 'refused':
49
+ case 'reversed':
50
+ return { key: KEYS[status], tone: 'failed' }
51
+ case 'stuck':
52
+ return { key: KEYS.stuck, tone: 'attention' }
53
+ default:
54
+ return { key: 'tx_status_pending', tone: 'settled' }
55
+ }
56
+ }
57
+
37
58
  export function tokenStatusTone(status: TokenActivityStatus): TokenStatusTone {
38
59
  return TONES[status] ?? 'neutral'
39
60
  }
package/ui/txStatus.ts CHANGED
@@ -22,11 +22,44 @@ export interface TxStatusView {
22
22
  * Map a raw action status (and any live offline-queue state) to a tone.
23
23
  *
24
24
  * The offline queue row outranks the raw status: a held transaction sits at
25
- * 'unproven' (which would read as a settled "Accepted") or at 'nosend' when
25
+ * 'unproven' (which would read as a quiet "Pending") or at 'nosend' when
26
26
  * payer-side promotion failed, so without this the user would see a confirmed
27
27
  * payment that has not actually gone anywhere.
28
28
  */
29
- export function txStatusView(status: string, offlineStatus?: string): TxStatusView {
29
+ /**
30
+ * Labels the Pay / Get paid rails write on their actions: handle and nearby
31
+ * payments, address payments, and stablecoin transfers. An outgoing action
32
+ * without one was made by a connected app or the wallet itself (an identity
33
+ * certificate, say), so it reads "Spent", not "Sent".
34
+ */
35
+ const PAYMENT_LABELS = new Set(['peerpay', 'localpay', 'legacy', 'mandala'])
36
+
37
+ export function isPaymentAction(labels?: readonly string[]): boolean {
38
+ return Boolean(labels?.some(l => PAYMENT_LABELS.has(l)))
39
+ }
40
+
41
+ /** What a row says it did once it settles. Its i18n key is `tx_status_<kind>`. */
42
+ export type ActivityKind = 'sent' | 'received' | 'spent' | 'transferred'
43
+
44
+ /**
45
+ * The one place a row's word is decided, so the status line and the activity
46
+ * filter can never disagree about which word a row says.
47
+ */
48
+ export function activityKind(incoming: boolean | undefined, labels?: readonly string[]): ActivityKind {
49
+ // A vault move stays the holder's money whichever way it goes.
50
+ if (labels?.includes('vault')) return 'transferred'
51
+ if (incoming) return 'received'
52
+ return isPaymentAction(labels) ? 'sent' : 'spent'
53
+ }
54
+
55
+ export function txStatusView(
56
+ status: string,
57
+ offlineStatus?: string,
58
+ incoming?: boolean,
59
+ labels?: readonly string[]
60
+ ): TxStatusView {
61
+ const done = `tx_status_${activityKind(incoming, labels)}`
62
+
30
63
  switch (offlineStatus) {
31
64
  case 'queued':
32
65
  return { key: 'tx_status_offline_queued', tone: 'inflight' }
@@ -39,15 +72,25 @@ export function txStatusView(status: string, offlineStatus?: string): TxStatusVi
39
72
  // says the payment is waiting on a hand-over that may not have happened.
40
73
  case 'parked':
41
74
  return { key: 'tx_status_parked', tone: 'attention' }
75
+ // Written only by a raw database import (XR-085): a copied-in 'queued'/
76
+ // 'posting' row held back from the automatic drain pending the user's
77
+ // renewed review, not silently resumed or dropped.
78
+ case 'import_hold':
79
+ return { key: 'tx_status_import_hold', tone: 'attention' }
42
80
  }
43
81
 
44
82
  switch (status) {
83
+ // The chain words ("Confirmed", "Accepted") answered a question about the
84
+ // ledger; the user's question is what happened to their money. A settled
85
+ // row therefore says what it DID — Received or Sent — from the moment it is
86
+ // handed to the network: the block proof that follows changes nothing the
87
+ // holder can act on. The states below that DO need action keep their own words.
45
88
  case 'completed':
46
- return { key: 'tx_status_confirmed', tone: 'settled' }
47
89
  case 'unproven':
48
- return { key: 'tx_status_accepted', tone: 'settled' }
90
+ return { key: done, tone: 'settled' }
91
+ // Already handed to the network: say what it does, Sent or Received.
49
92
  case 'sending':
50
- return { key: 'tx_status_broadcasting', tone: 'inflight' }
93
+ return { key: done, tone: 'inflight' }
51
94
  case 'nosend':
52
95
  return { key: 'tx_status_not_sent', tone: 'attention' }
53
96
  case 'unsigned':
@@ -1,58 +0,0 @@
1
- /**
2
- * Adapter to make StorageExpoSQLite work with the wallet-toolbox ecosystem
3
- *
4
- * This is a temporary adapter that allows using local SQLite storage
5
- * until StorageExpoSQLite fully implements the WalletStorageProvider interface
6
- */
7
-
8
- import { StorageProvider } from '@bsv/wallet-toolbox-mobile'
9
- import { StorageExpoSQLite } from './StorageExpoSQLite'
10
- import type { AppChain } from '../config'
11
- import { toWalletChain } from '../config'
12
-
13
- export interface LocalStorageConfig {
14
- network: AppChain
15
- identityKey: string
16
- storageName?: string
17
- }
18
-
19
- /**
20
- * Initialize local storage for the wallet
21
- */
22
- export async function initializeLocalStorage(config: LocalStorageConfig): Promise<StorageExpoSQLite> {
23
- const { network, identityKey, storageName = 'bsv-wallet' } = config
24
-
25
- // Create storage instance
26
- const storage = new StorageExpoSQLite({
27
- ...StorageProvider.createStorageBaseOptions(toWalletChain(network))
28
- })
29
-
30
- // Initialize database
31
- await storage.migrate(storageName, identityKey)
32
-
33
- // Verify it's ready
34
- await storage.makeAvailable()
35
-
36
- return storage
37
- }
38
-
39
- /**
40
- * Check if a storage URL indicates local storage
41
- */
42
- export function isLocalStorage(storageUrl: string): boolean {
43
- return storageUrl === 'local'
44
- }
45
-
46
- /**
47
- * Get storage display name
48
- */
49
- export function getStorageDisplayName(storageUrl: string): string {
50
- if (isLocalStorage(storageUrl)) {
51
- return 'Local Storage (On Device)'
52
- }
53
- try {
54
- return new URL(storageUrl).hostname
55
- } catch {
56
- return storageUrl
57
- }
58
- }