@bsv/expo-wallet-toolbox 0.7.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.
- package/CHANGELOG.md +1745 -0
- package/README.md +47 -1
- package/core/amountFormatHelpers.ts +20 -2
- package/core/backup/RemoteSyncReader.ts +131 -19
- package/core/backup/appData.ts +157 -0
- package/core/backup/client.ts +15 -1
- package/core/backup/codec.ts +147 -9
- package/core/backup/constants.ts +30 -1
- package/core/backup/cursor.ts +31 -2
- package/core/backup/push.ts +70 -4
- package/core/backup/restore.ts +104 -16
- package/core/backup/restoreOnImport.ts +94 -30
- package/core/backup/status.ts +13 -8
- package/core/constants.ts +14 -1
- package/core/context/ExchangeRateContext.tsx +34 -27
- package/core/context/LocalStorageProvider.tsx +43 -40
- package/core/context/UserContext.tsx +18 -7
- package/core/context/VaultContext.tsx +49 -2
- package/core/context/WalletConnectionContext.tsx +203 -11
- package/core/context/WalletContext.tsx +631 -162
- package/core/headers/OfflineFirstChaintracks.ts +48 -4
- package/core/headers/headerStore.ts +26 -4
- package/core/headers/syncHeaders.ts +12 -1
- package/core/i18n/translations.tsx +953 -25
- package/core/identity/handleRegistry/client.ts +31 -2
- package/core/identity/handleRegistry/keyPinStore.ts +70 -0
- package/core/identity/handleRegistry/resolver.ts +71 -3
- package/core/index.ts +33 -3
- package/core/localpay/build.ts +225 -24
- package/core/localpay/pending.ts +110 -7
- package/core/localpay/pendingAbortAuthority.ts +95 -0
- package/core/localpay/pendingAborts.ts +264 -28
- package/core/localpay/session.ts +42 -17
- package/core/localpay/settlementAck.ts +10 -1
- package/core/localpay/transport/socket.ts +52 -3
- package/core/localpay/verify.ts +100 -10
- package/core/mandala/abortGuard.ts +96 -20
- package/core/mandala/createRuntime.ts +206 -33
- package/core/mandala/drain.ts +89 -11
- package/core/mandala/inboxPrehold.ts +186 -0
- package/core/mandala/permissionModule.ts +202 -20
- package/core/mandala/settlementStore.ts +24 -2
- package/core/mandala/types.ts +40 -5
- package/core/monitor/TaskBackupPush.ts +14 -0
- package/core/monitor/TaskDrainOutbox.ts +14 -0
- package/core/monitor/TaskSendOffline.ts +14 -0
- package/core/net/publicDestination.ts +91 -0
- package/core/net/validateArcUrl.ts +22 -0
- package/core/offline/cancelParked.ts +134 -13
- package/core/offline/payerHold.ts +100 -24
- package/core/offline/plan.ts +36 -7
- package/core/pay/beefRepair.ts +6 -2
- package/core/pay/damagedInbox.ts +24 -0
- package/core/pay/rails/address.ts +107 -12
- package/core/pay/rails/handle.ts +117 -22
- package/core/pay/rails/index.ts +45 -7
- package/core/pay/rails/nativeIntent.ts +61 -0
- package/core/pay/receiveHistory.ts +93 -0
- package/core/pay/recordProof.ts +19 -1
- package/core/pay/refreshProofGuard.ts +42 -1
- package/core/pay/watchlist.ts +5 -2
- package/core/peerpay/control.ts +17 -18
- package/core/peerpay/handleResendRequests.ts +58 -4
- package/core/peerpay/outbox.ts +3 -1
- package/core/recovery/backupMaterial.ts +61 -0
- package/core/recovery/createWallet.ts +95 -0
- package/core/recovery/recoverWallet.ts +120 -0
- package/core/recovery/restoreWallet.ts +170 -0
- package/core/recovery/secret.ts +92 -0
- package/core/recovery/shareCollector.ts +71 -0
- package/core/recovery/shareParsing.ts +87 -0
- package/core/recovery/shares.ts +116 -0
- package/core/recovery/useRecoveryDeps.ts +70 -0
- package/core/services/arcTokenStorage.ts +52 -0
- package/core/services/arcadeBroadcastProvider.ts +232 -48
- package/core/services/autoApprovePolicy.ts +105 -0
- package/core/services/callbackToken.ts +19 -0
- package/core/services/capWalletArgs.ts +14 -2
- package/core/services/connectionAuthority.ts +98 -0
- package/core/services/exchangeRate.ts +35 -12
- package/core/services/externalOrigin.ts +11 -0
- package/core/services/secrets/kek.ts +126 -29
- package/core/services/secrets/migration.ts +16 -4
- package/core/services/secrets/store.ts +42 -14
- package/core/services/vault/VaultKeyService.ts +228 -45
- package/core/services/vault/chainRecovery.ts +483 -0
- package/core/services/vault/driver.ts +9 -1
- package/core/services/vault/enrolledSerialRegistry.ts +150 -0
- package/core/services/vault/guard.ts +218 -32
- package/core/services/vault/hardwareLease.ts +19 -0
- package/core/services/vault/metaAuthority.ts +210 -0
- package/core/services/vault/pivReset.ts +64 -23
- package/core/services/vault/r1comb.ts +139 -3
- package/core/services/vault/session.ts +25 -4
- package/core/services/vault/transfers.ts +866 -170
- package/core/services/vault/types.ts +19 -4
- package/core/services/vault/vaultStore.ts +256 -29
- package/core/services/walletArgLimits.ts +45 -2
- package/core/services/walletConnectionValidation.ts +76 -6
- package/core/services/walletServiceConfig.ts +10 -8
- package/core/storage/StorageExpoSQLite.ts +47 -13
- package/core/storage/methods/findSql.ts +21 -2
- package/core/storage/methods/offlineActions.ts +10 -1
- package/core/storage/methods/processOfflineActions.ts +116 -23
- package/core/storage/schema/createTables.ts +126 -2
- package/core/stores/ConnectionStore.ts +34 -0
- package/core/toolboxConfig.ts +45 -11
- package/core/walletDbRegistry.ts +63 -0
- package/core/walletMonitor.ts +17 -1
- package/core/walletRepair/releaseStuckReservations.ts +72 -0
- package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
- package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
- package/package.json +2 -2
- package/ui/backupShares.ts +26 -169
- package/ui/components/pay/AddressReceive.tsx +13 -6
- package/ui/components/pay/AssetPicker.tsx +30 -9
- package/ui/components/pay/MessageBoxConfig.tsx +16 -0
- package/ui/components/pay/NearbyFlow.tsx +480 -243
- package/ui/components/pay/PaymentSuccessOverlay.tsx +39 -4
- package/ui/components/pay/UniversalSend.tsx +167 -73
- package/ui/components/ui/AlertCard.tsx +38 -5
- package/ui/components/ui/PermissionSheet.tsx +197 -66
- package/ui/components/vault/EnrollWizard.tsx +61 -13
- package/ui/components/vault/vaultErrorCopy.ts +3 -1
- package/ui/components/wallet/ActivityRow.tsx +5 -3
- package/ui/components/wallet/AmountInput.tsx +8 -2
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
- package/ui/components/wallet/Balance.tsx +42 -23
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
- package/ui/exportTransactions.ts +36 -4
- package/ui/hooks/useExportWalletData.ts +25 -2
- package/ui/importDatabases.ts +339 -24
- package/ui/index.ts +9 -3
- package/ui/isImageUrl.ts +6 -0
- package/ui/printRecoveryShares.ts +9 -10
- package/ui/recoveryPrompts.ts +91 -0
- package/ui/resolveIdentity.ts +31 -9
- package/ui/screens/ConnectionsScreen.tsx +86 -19
- package/ui/screens/IdentifierScreen.tsx +30 -8
- package/ui/screens/PairScreen.tsx +74 -2
- package/ui/screens/SettingsScreen.tsx +10 -4
- package/ui/screens/TrustScreen.tsx +99 -4
- package/ui/screens/VaultScreen.tsx +410 -61
- package/ui/screens/VaultTransferScreen.tsx +59 -7
- package/ui/screens/WalletCheckScreen.tsx +17 -6
- package/ui/screens/WalletConfigScreen.tsx +82 -28
- package/ui/screens/WalletHomeScreen.tsx +179 -88
- package/ui/screens/detailActionKeys.ts +55 -0
- package/ui/tokenFormat.ts +44 -4
- package/ui/txStatus.ts +5 -0
- package/core/storage/LocalStorageAdapter.ts +0 -58
|
@@ -71,7 +71,7 @@ interface GroupPermissions {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** Common shape derived from the four existing modals. */
|
|
74
|
-
interface ActivePermission {
|
|
74
|
+
export interface ActivePermission {
|
|
75
75
|
kind: PermissionKind
|
|
76
76
|
requestID: string
|
|
77
77
|
originator: string
|
|
@@ -88,6 +88,52 @@ interface ActivePermission {
|
|
|
88
88
|
renewal?: boolean
|
|
89
89
|
/** Group-specific sub-permissions. */
|
|
90
90
|
groupPermissions?: GroupPermissions
|
|
91
|
+
/**
|
|
92
|
+
* XR-040: set when a `mandala_spend`/`mandala_credit` prompt's per-asset
|
|
93
|
+
* `lines` could not be trusted to be the WHOLE request (absent, malformed,
|
|
94
|
+
* empty, or past `MANDALA_MAX_PROMPT_LINES`) — every asset a single
|
|
95
|
+
* approval would release has to be shown, and a request this sheet cannot
|
|
96
|
+
* fully enumerate must never be approvable. `handleDeny` is unaffected;
|
|
97
|
+
* only the Allow control reads this.
|
|
98
|
+
*/
|
|
99
|
+
approvalBlocked?: boolean
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** One line of a `mandala_spend`/`mandala_credit` prompt's `lines[]` array,
|
|
103
|
+
* as loosely as a JSON.parse of counterparty-adjacent data should be trusted. */
|
|
104
|
+
interface MandalaPromptLine {
|
|
105
|
+
assetId?: unknown
|
|
106
|
+
sendAmount?: unknown
|
|
107
|
+
changeAmount?: unknown
|
|
108
|
+
creditAmount?: unknown
|
|
109
|
+
tokenName?: unknown
|
|
110
|
+
/** Pre-formatted, e.g. "25.00 USDX" — see `MandalaSpendLine`/`MandalaCreditLine`. */
|
|
111
|
+
display?: unknown
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A sane display ceiling for a multi-asset Mandala prompt. Every real prompt
|
|
116
|
+
* this app's own `MandalaTokenModule` builds groups by assetId — a handful at
|
|
117
|
+
* most — so a `lines` array past this is either a bug or a bad-faith caller,
|
|
118
|
+
* either way not something to enumerate as if it were the whole request.
|
|
119
|
+
*/
|
|
120
|
+
const MANDALA_MAX_PROMPT_LINES = 25
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* `promptData.lines`, validated into a bounded array of loosely-typed line
|
|
124
|
+
* objects — or `null` for anything this sheet cannot enumerate in full
|
|
125
|
+
* (absent, not an array, empty, oversized, or containing a non-object entry).
|
|
126
|
+
* `null` is the caller's signal to block approval rather than silently fall
|
|
127
|
+
* back to the primary-only view (XR-040).
|
|
128
|
+
*/
|
|
129
|
+
function sanitizedMandalaLines(raw: unknown): MandalaPromptLine[] | null {
|
|
130
|
+
if (!Array.isArray(raw) || raw.length === 0 || raw.length > MANDALA_MAX_PROMPT_LINES) return null
|
|
131
|
+
const lines: MandalaPromptLine[] = []
|
|
132
|
+
for (const entry of raw) {
|
|
133
|
+
if (!entry || typeof entry !== 'object') return null
|
|
134
|
+
lines.push(entry as MandalaPromptLine)
|
|
135
|
+
}
|
|
136
|
+
return lines
|
|
91
137
|
}
|
|
92
138
|
|
|
93
139
|
// ---------------------------------------------------------------------------
|
|
@@ -98,7 +144,9 @@ interface ActivePermission {
|
|
|
98
144
|
* Derive the human-friendly "what is being asked" description for each
|
|
99
145
|
* permission type. Technical specifics go into the expandable Details section.
|
|
100
146
|
*/
|
|
101
|
-
|
|
147
|
+
// Exported so the mandala prompt's own display-building logic (XR-040) is
|
|
148
|
+
// unit-testable without rendering the whole sheet's component tree.
|
|
149
|
+
export function deriveActive(
|
|
102
150
|
ctx: {
|
|
103
151
|
protocolRequests: any[]
|
|
104
152
|
basketRequests: any[]
|
|
@@ -270,6 +318,11 @@ function deriveActive(
|
|
|
270
318
|
sendAmount?: number
|
|
271
319
|
changeAmount?: number
|
|
272
320
|
creditAmount?: number
|
|
321
|
+
lines?: unknown
|
|
322
|
+
// XR-041: relinquishOutput's own resolved-target fields.
|
|
323
|
+
amount?: number
|
|
324
|
+
display?: string
|
|
325
|
+
outpoint?: string
|
|
273
326
|
} = {}
|
|
274
327
|
try {
|
|
275
328
|
promptData = JSON.parse(r.message)
|
|
@@ -277,12 +330,27 @@ function deriveActive(
|
|
|
277
330
|
// message not valid JSON — ignore, use defaults
|
|
278
331
|
}
|
|
279
332
|
|
|
333
|
+
const isRelinquish = promptData.type === 'mandala_access' && promptData.action === 'relinquishOutput'
|
|
334
|
+
// XR-041: `display` is pre-formatted ("25.00 USDX"); fall back to the raw
|
|
335
|
+
// base-unit amount + token name when it is not a string, same convention
|
|
336
|
+
// as the spend/credit lines below.
|
|
337
|
+
const relinquishAmount =
|
|
338
|
+
typeof promptData.display === 'string'
|
|
339
|
+
? promptData.display
|
|
340
|
+
: promptData.amount != null
|
|
341
|
+
? `${promptData.amount} ${promptData.tokenName || 'Mandala tokens'}`
|
|
342
|
+
: undefined
|
|
343
|
+
|
|
280
344
|
let description: string
|
|
281
345
|
if (promptData.type === 'mandala_spend' && promptData.sendAmount != null) {
|
|
282
346
|
description = `wants to spend ${promptData.sendAmount} ${promptData.tokenName || 'Mandala tokens'}`
|
|
283
347
|
} else if (promptData.type === 'mandala_credit' && promptData.creditAmount != null) {
|
|
284
348
|
description = `wants to credit ${promptData.creditAmount} ${promptData.tokenName || 'Mandala tokens'} to your wallet`
|
|
285
|
-
} else if (
|
|
349
|
+
} else if (isRelinquish && relinquishAmount) {
|
|
350
|
+
// Named, not generic (XR-041): which holding, not just that "a" holding
|
|
351
|
+
// is being removed.
|
|
352
|
+
description = `wants to remove ${relinquishAmount} from your wallet`
|
|
353
|
+
} else if (isRelinquish) {
|
|
286
354
|
description = 'wants to remove a Mandala token holding from your wallet'
|
|
287
355
|
} else if (promptData.type === 'mandala_access') {
|
|
288
356
|
description = 'wants to see your Mandala token balance'
|
|
@@ -291,11 +359,66 @@ function deriveActive(
|
|
|
291
359
|
}
|
|
292
360
|
|
|
293
361
|
const details: { label: string; value: string }[] = []
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (promptData.
|
|
297
|
-
|
|
298
|
-
|
|
362
|
+
let approvalBlocked = false
|
|
363
|
+
|
|
364
|
+
if (promptData.type === 'mandala_spend' || promptData.type === 'mandala_credit') {
|
|
365
|
+
// XR-040: `lines` carries EVERY asset this request touches — rendering
|
|
366
|
+
// only the primary (back-compat) fields below is how a single approval
|
|
367
|
+
// silently released a second, unshown asset. Every sanitized line is
|
|
368
|
+
// rendered; an unsanitizable `lines` blocks approval instead of falling
|
|
369
|
+
// back to a primary-only view that looks complete but is not.
|
|
370
|
+
const lines = sanitizedMandalaLines(promptData.lines)
|
|
371
|
+
if (lines === null) {
|
|
372
|
+
approvalBlocked = true
|
|
373
|
+
details.push({
|
|
374
|
+
label: 'Warning',
|
|
375
|
+
value: 'Could not verify this is the full request — deny and try again.'
|
|
376
|
+
})
|
|
377
|
+
} else {
|
|
378
|
+
const numbered = lines.length > 1
|
|
379
|
+
lines.forEach((line, i) => {
|
|
380
|
+
const suffix = numbered ? ` ${i + 1}` : ''
|
|
381
|
+
if (typeof line.tokenName === 'string' && line.tokenName) {
|
|
382
|
+
details.push({ label: `Token${suffix}`, value: line.tokenName })
|
|
383
|
+
}
|
|
384
|
+
if (typeof line.sendAmount === 'number') {
|
|
385
|
+
details.push({
|
|
386
|
+
label: `Send amount${suffix}`,
|
|
387
|
+
value: typeof line.display === 'string' ? line.display : String(line.sendAmount)
|
|
388
|
+
})
|
|
389
|
+
}
|
|
390
|
+
if (typeof line.changeAmount === 'number' && line.changeAmount !== 0) {
|
|
391
|
+
details.push({ label: `Change${suffix}`, value: String(line.changeAmount) })
|
|
392
|
+
}
|
|
393
|
+
if (typeof line.creditAmount === 'number') {
|
|
394
|
+
details.push({
|
|
395
|
+
label: `Credit amount${suffix}`,
|
|
396
|
+
value: typeof line.display === 'string' ? line.display : String(line.creditAmount)
|
|
397
|
+
})
|
|
398
|
+
}
|
|
399
|
+
if (typeof line.assetId === 'string' && line.assetId) {
|
|
400
|
+
details.push({ label: `Asset ID${suffix}`, value: truncate(line.assetId, 28) })
|
|
401
|
+
}
|
|
402
|
+
})
|
|
403
|
+
}
|
|
404
|
+
} else if (isRelinquish) {
|
|
405
|
+
// XR-041: identify the target the same way mandala_spend/mandala_credit
|
|
406
|
+
// already identify theirs — token, amount, and the exact outpoint.
|
|
407
|
+
if (promptData.tokenName) details.push({ label: 'Token', value: promptData.tokenName })
|
|
408
|
+
if (relinquishAmount) details.push({ label: 'Amount', value: relinquishAmount })
|
|
409
|
+
if (promptData.assetId) details.push({ label: 'Asset ID', value: truncate(promptData.assetId, 28) })
|
|
410
|
+
if (promptData.outpoint) details.push({ label: 'Outpoint', value: truncate(promptData.outpoint, 28) })
|
|
411
|
+
} else {
|
|
412
|
+
if (promptData.assetId) details.push({ label: 'Asset ID', value: truncate(promptData.assetId, 28) })
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Said in the ALWAYS-VISIBLE description, not only the collapsed Details
|
|
416
|
+
// section — the whole point is that this cannot be missed on the way to
|
|
417
|
+
// an (already-disabled) Allow button.
|
|
418
|
+
if (approvalBlocked) {
|
|
419
|
+
description =
|
|
420
|
+
'wants to spend or credit Mandala tokens, but the full request could not be verified — deny and try again.'
|
|
421
|
+
}
|
|
299
422
|
|
|
300
423
|
return {
|
|
301
424
|
kind: 'mandala',
|
|
@@ -304,7 +427,8 @@ function deriveActive(
|
|
|
304
427
|
originator: r.originator || 'Unknown app',
|
|
305
428
|
title: 'Token Spend Request',
|
|
306
429
|
description,
|
|
307
|
-
details
|
|
430
|
+
details,
|
|
431
|
+
approvalBlocked
|
|
308
432
|
}
|
|
309
433
|
}
|
|
310
434
|
|
|
@@ -503,61 +627,67 @@ const PermissionSheet: React.FC = () => {
|
|
|
503
627
|
// the UI can show the checkmark morph for 400 ms before dismissal.
|
|
504
628
|
// Takes an explicit snapshot of the request to act on so it is safe to call
|
|
505
629
|
// from the flush-on-preempt path where `active` may have already changed.
|
|
506
|
-
const executeGrant = useCallback(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
630
|
+
const executeGrant = useCallback(
|
|
631
|
+
(request: ActivePermission) => {
|
|
632
|
+
// Clear the pending ref so flush-on-preempt guards don't double-fire.
|
|
633
|
+
pendingGrantRef.current = null
|
|
634
|
+
|
|
635
|
+
if (request.kind === 'btms') {
|
|
636
|
+
advanceBtmsQueue(true)
|
|
637
|
+
} else if (request.kind === 'mandala') {
|
|
638
|
+
advanceMandalaQueue(true)
|
|
639
|
+
} else if (request.kind === 'spending') {
|
|
640
|
+
managers.permissionsManager?.grantPermission({
|
|
641
|
+
requestID: request.requestID,
|
|
642
|
+
ephemeral: true,
|
|
643
|
+
amount: request.amount
|
|
644
|
+
})
|
|
645
|
+
advanceSpendingQueue()
|
|
646
|
+
setSpendingAuthorizationModalOpen(false)
|
|
647
|
+
} else {
|
|
648
|
+
managers.permissionsManager?.grantPermission({
|
|
649
|
+
requestID: request.requestID
|
|
650
|
+
})
|
|
651
|
+
switch (request.kind) {
|
|
652
|
+
case 'protocol':
|
|
653
|
+
advanceProtocolQueue()
|
|
654
|
+
setProtocolAccessModalOpen(false)
|
|
655
|
+
break
|
|
656
|
+
case 'basket':
|
|
657
|
+
advanceBasketQueue()
|
|
658
|
+
setBasketAccessModalOpen(false)
|
|
659
|
+
break
|
|
660
|
+
case 'certificate':
|
|
661
|
+
advanceCertificateQueue()
|
|
662
|
+
setCertificateAccessModalOpen(false)
|
|
663
|
+
break
|
|
664
|
+
}
|
|
539
665
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
666
|
+
setDetailsExpanded(false)
|
|
667
|
+
// Reset granted so that consecutive BTMS/Mandala requests (sharing sentinel requestID '')
|
|
668
|
+
// don't leave the sheet permanently in granted state / deadlocked.
|
|
669
|
+
setGranted(false)
|
|
670
|
+
},
|
|
671
|
+
[
|
|
672
|
+
managers.permissionsManager,
|
|
673
|
+
advanceProtocolQueue,
|
|
674
|
+
advanceBasketQueue,
|
|
675
|
+
advanceCertificateQueue,
|
|
676
|
+
advanceSpendingQueue,
|
|
677
|
+
advanceBtmsQueue,
|
|
678
|
+
advanceMandalaQueue,
|
|
679
|
+
setProtocolAccessModalOpen,
|
|
680
|
+
setBasketAccessModalOpen,
|
|
681
|
+
setCertificateAccessModalOpen,
|
|
682
|
+
setSpendingAuthorizationModalOpen
|
|
683
|
+
]
|
|
684
|
+
)
|
|
558
685
|
|
|
559
686
|
const handleGrant = useCallback(() => {
|
|
560
|
-
|
|
687
|
+
// XR-040: belt-and-braces alongside the Allow button's own `disabled` —
|
|
688
|
+
// a mandala_spend/mandala_credit prompt whose `lines` this sheet could
|
|
689
|
+
// not fully enumerate must never be approvable, from any call path.
|
|
690
|
+
if (!active || granted || active.approvalBlocked) return
|
|
561
691
|
haptics.success()
|
|
562
692
|
setGranted(true)
|
|
563
693
|
if (grantTimerRef.current !== null) {
|
|
@@ -766,12 +896,13 @@ const PermissionSheet: React.FC = () => {
|
|
|
766
896
|
<PressableScale
|
|
767
897
|
style={[styles.buttonAllow, { backgroundColor: colors.accent }]}
|
|
768
898
|
onPress={handleGrant}
|
|
769
|
-
disabled={granted}
|
|
899
|
+
disabled={granted || active.approvalBlocked}
|
|
770
900
|
>
|
|
771
|
-
{granted
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
901
|
+
{granted ? (
|
|
902
|
+
<Ionicons name="checkmark" size={22} color={colors.textOnAccent} />
|
|
903
|
+
) : (
|
|
904
|
+
<Text style={[styles.buttonAllowText, { color: colors.textOnAccent }]}>{t('authorize')}</Text>
|
|
905
|
+
)}
|
|
775
906
|
</PressableScale>
|
|
776
907
|
</View>
|
|
777
908
|
</View>
|
|
@@ -41,6 +41,7 @@ import { vaultErrorCopy } from './vaultErrorCopy'
|
|
|
41
41
|
import { vaultKeyLabel } from './KeyChooser'
|
|
42
42
|
import {
|
|
43
43
|
useTheme,
|
|
44
|
+
useWallet,
|
|
44
45
|
spacing,
|
|
45
46
|
radii,
|
|
46
47
|
typography,
|
|
@@ -62,7 +63,8 @@ import {
|
|
|
62
63
|
type VaultEnrollmentQuarantine,
|
|
63
64
|
type VaultScopeToken,
|
|
64
65
|
type VaultErrorCode,
|
|
65
|
-
type EnrollPhase
|
|
66
|
+
type EnrollPhase,
|
|
67
|
+
type VaultWalletAuthority
|
|
66
68
|
} from '@bsv/expo-wallet-toolbox'
|
|
67
69
|
|
|
68
70
|
const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
|
|
@@ -264,6 +266,23 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
264
266
|
if (!scopeTokenRef.current) scopeTokenRef.current = vaultStore.captureScopeToken()
|
|
265
267
|
const scopeToken = scopeTokenRef.current
|
|
266
268
|
|
|
269
|
+
// XR-001: the admin-scoped wallet capability every draft/meta authority tag
|
|
270
|
+
// in this wizard is computed and verified with (metaAuthority.ts). The
|
|
271
|
+
// wizard is only ever reached once a wallet is built (VaultScreen gates
|
|
272
|
+
// every door into it), so a missing permissions manager here is treated as
|
|
273
|
+
// the same programmer error `pm as unknown as VaultWallet` casts elsewhere
|
|
274
|
+
// in the vault UI already assume, not a recoverable runtime state.
|
|
275
|
+
const { managers, adminOriginator } = useWallet()
|
|
276
|
+
const authority: VaultWalletAuthority | null = managers?.permissionsManager
|
|
277
|
+
? { wallet: managers.permissionsManager as unknown as VaultWalletAuthority['wallet'], adminOriginator }
|
|
278
|
+
: null
|
|
279
|
+
const requireAuthority = useCallback((): VaultWalletAuthority => {
|
|
280
|
+
if (!authority) {
|
|
281
|
+
throw new VaultError('driver-unavailable', 'Wallet is not ready for a vault enrollment operation')
|
|
282
|
+
}
|
|
283
|
+
return authority
|
|
284
|
+
}, [authority])
|
|
285
|
+
|
|
267
286
|
const [step, setStep] = useState<Step>(mode === 'enroll' ? 'intro' : 'key')
|
|
268
287
|
const [sub, setSub] = useState<KeySub>('pin')
|
|
269
288
|
const [ack, setAck] = useState(false)
|
|
@@ -375,7 +394,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
375
394
|
setBusy(true)
|
|
376
395
|
setStepError(null)
|
|
377
396
|
try {
|
|
378
|
-
await addVaultKey(record, scopeToken)
|
|
397
|
+
await addVaultKey(record, scopeToken, requireAuthority())
|
|
379
398
|
clearKeyInputs()
|
|
380
399
|
haptics.success()
|
|
381
400
|
showToast(t('vault_key_added_toast'), { type: 'success' })
|
|
@@ -398,7 +417,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
398
417
|
setBusy(false)
|
|
399
418
|
}
|
|
400
419
|
},
|
|
401
|
-
[k, mode, onCancel, scopeToken]
|
|
420
|
+
[k, mode, onCancel, scopeToken, requireAuthority]
|
|
402
421
|
)
|
|
403
422
|
|
|
404
423
|
/**
|
|
@@ -436,10 +455,31 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
436
455
|
return [...current, ...ready.map(entry => entry.record).filter(record => !serials.has(record.serial))]
|
|
437
456
|
})
|
|
438
457
|
} else if (ready[0]) {
|
|
439
|
-
// A ready draft
|
|
440
|
-
//
|
|
441
|
-
//
|
|
442
|
-
|
|
458
|
+
// A ready draft is a persisted claim, not proof: nothing here
|
|
459
|
+
// re-verifies it against the card, so a draft never tapped in this
|
|
460
|
+
// run (crash-resumed, or — XR-001 — written straight to storage by
|
|
461
|
+
// something other than a live enrollment challenge) must not gain
|
|
462
|
+
// vault spend authority in an already-funded vault with zero user
|
|
463
|
+
// action. Name it and require an explicit choice before writing it.
|
|
464
|
+
const entry = ready[0]
|
|
465
|
+
void showAlert({
|
|
466
|
+
title: t('vault_resume_draft_confirm_title'),
|
|
467
|
+
message: t('vault_resume_draft_confirm_body', {
|
|
468
|
+
nickname: entry.record.nickname,
|
|
469
|
+
tail: entry.record.serial.slice(-4)
|
|
470
|
+
}),
|
|
471
|
+
buttons: [
|
|
472
|
+
{ text: t('vault_resume_draft_confirm_use'), key: 'use' },
|
|
473
|
+
{ text: t('vault_resume_draft_confirm_discard'), key: 'discard', style: 'destructive' }
|
|
474
|
+
]
|
|
475
|
+
}).then(choice => {
|
|
476
|
+
if (!alive) return
|
|
477
|
+
if (choice === 'use') {
|
|
478
|
+
void saveKeyRef.current(entry.record)
|
|
479
|
+
} else {
|
|
480
|
+
void vaultStore.discardEnrollmentDraft(entry.record.serial, scopeToken).catch(() => {})
|
|
481
|
+
}
|
|
482
|
+
})
|
|
443
483
|
}
|
|
444
484
|
})
|
|
445
485
|
.catch(e => {
|
|
@@ -553,6 +593,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
553
593
|
const known = [...metaKeys.map(r => r.serial), ...pending.map(r => r.serial)]
|
|
554
594
|
try {
|
|
555
595
|
const record = await enrollKey({
|
|
596
|
+
...requireAuthority(),
|
|
556
597
|
scopeToken,
|
|
557
598
|
acknowledgeDedicatedPivApplication: true,
|
|
558
599
|
pendingSerials: known,
|
|
@@ -681,7 +722,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
681
722
|
tapInFlight.current = false
|
|
682
723
|
}
|
|
683
724
|
},
|
|
684
|
-
[k, metaKeys, pending, newPin, newPuk, onCancel, pivAck, saveKey, scopeToken, reloadDraftLists]
|
|
725
|
+
[k, metaKeys, pending, newPin, newPuk, onCancel, pivAck, saveKey, scopeToken, reloadDraftLists, requireAuthority]
|
|
685
726
|
)
|
|
686
727
|
|
|
687
728
|
/** Resume only the non-mutating possession challenge for a protected draft.
|
|
@@ -698,6 +739,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
698
739
|
clearResetConsent()
|
|
699
740
|
try {
|
|
700
741
|
const record = await resumeEnrollmentDraft({
|
|
742
|
+
...requireAuthority(),
|
|
701
743
|
entry,
|
|
702
744
|
scopeToken,
|
|
703
745
|
onPhase: setPhase,
|
|
@@ -753,7 +795,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
753
795
|
tapInFlight.current = false
|
|
754
796
|
}
|
|
755
797
|
},
|
|
756
|
-
[onCancel, newPin, pinOk, pivAck, saveKey, scopeToken]
|
|
798
|
+
[onCancel, newPin, pinOk, pivAck, saveKey, scopeToken, requireAuthority]
|
|
757
799
|
)
|
|
758
800
|
|
|
759
801
|
// ── finish (enroll mode) ────────────────────────────────────────────
|
|
@@ -762,7 +804,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
762
804
|
setBusy(true)
|
|
763
805
|
setStepError(null)
|
|
764
806
|
try {
|
|
765
|
-
await finalizeEnrollment(pending, scopeToken)
|
|
807
|
+
await finalizeEnrollment(pending, scopeToken, requireAuthority())
|
|
766
808
|
// No tone here (see useConfirmationSound): vaultDeposit/vaultWithdraw
|
|
767
809
|
// name an actual transfer, and enrolling isn't one.
|
|
768
810
|
haptics.success()
|
|
@@ -774,7 +816,7 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
774
816
|
} finally {
|
|
775
817
|
setBusy(false)
|
|
776
818
|
}
|
|
777
|
-
}, [pending, busy, scopeToken])
|
|
819
|
+
}, [pending, busy, scopeToken, requireAuthority])
|
|
778
820
|
|
|
779
821
|
const addAnother = useCallback(() => {
|
|
780
822
|
setStepError(null)
|
|
@@ -1410,6 +1452,9 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
1410
1452
|
}
|
|
1411
1453
|
|
|
1412
1454
|
// ── done ────────────────────────────────────────────────────────────
|
|
1455
|
+
// A sixth key is one more than a lock holds: the next step is removing the
|
|
1456
|
+
// key it replaces, not a re-lock (which would be refused).
|
|
1457
|
+
const overLockLimit = mode === 'add-key' && enrolledCount + 1 > VAULT_MAX_KEYS
|
|
1413
1458
|
return (
|
|
1414
1459
|
<View style={[styles.body, styles.doneBody]}>
|
|
1415
1460
|
<Ionicons name="checkmark-circle" size={56} color={colors.success} style={styles.hero} />
|
|
@@ -1419,9 +1464,12 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({ mode, onDone, onCanc
|
|
|
1419
1464
|
<Text style={[styles.p, { color: colors.textSecondary }]}>
|
|
1420
1465
|
{mode === 'enroll'
|
|
1421
1466
|
? t('vault_done_body', { count: pending.length })
|
|
1422
|
-
: t('vault_add_key_done', { nickname: addedNickname })}
|
|
1467
|
+
: t(overLockLimit ? 'vault_add_key_done_over_limit' : 'vault_add_key_done', { nickname: addedNickname })}
|
|
1423
1468
|
</Text>
|
|
1424
|
-
<ActionButton
|
|
1469
|
+
<ActionButton
|
|
1470
|
+
label={mode === 'enroll' || overLockLimit ? t('vault_done_cta') : t('vault_relock_now')}
|
|
1471
|
+
onPress={onDone}
|
|
1472
|
+
/>
|
|
1425
1473
|
</View>
|
|
1426
1474
|
)
|
|
1427
1475
|
}
|
|
@@ -84,13 +84,15 @@ const KEY: Record<VaultErrorCode, string> = {
|
|
|
84
84
|
'key-already-enrolled': 'vault_err_key_already_enrolled',
|
|
85
85
|
'key-not-adopted': 'vault_err_key_not_adopted',
|
|
86
86
|
'too-many-keys': 'vault_err_too_many_keys',
|
|
87
|
+
'too-many-active-keys': 'vault_err_too_many_active_keys',
|
|
87
88
|
'last-keys': 'vault_err_last_keys',
|
|
88
89
|
'relock-required': 'vault_err_relock_required',
|
|
89
90
|
'action-pending': 'vault_err_action_pending',
|
|
90
91
|
'key-not-committed': 'vault_err_key_not_committed',
|
|
91
92
|
'key-cannot-cover': 'vault_err_key_cannot_cover',
|
|
92
93
|
'too-small-to-relock': 'vault_err_too_small_to_relock',
|
|
93
|
-
'bad-version': 'vault_err_bad_version'
|
|
94
|
+
'bad-version': 'vault_err_bad_version',
|
|
95
|
+
'chain-scan-failed': 'vault_err_chain_scan_failed'
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
/**
|
|
@@ -130,7 +130,7 @@ interface Props {
|
|
|
130
130
|
onOpen?: (action: ActivityAction) => void
|
|
131
131
|
onExplorer: (txid: string) => void
|
|
132
132
|
onRefreshTx: (txid: string) => void
|
|
133
|
-
onAbort: (reference: string) => void
|
|
133
|
+
onAbort: (reference: string, action?: ActivityAction) => void
|
|
134
134
|
/** Rebuild and re-deliver a PeerPay token without waiting for a NACK. */
|
|
135
135
|
onSendPaymentDetails?: (txid: string) => void
|
|
136
136
|
/** Start a new payment (or retryDelivery) for a failed outbound row. */
|
|
@@ -319,7 +319,9 @@ function ActivityRowBase({
|
|
|
319
319
|
// they are not, the remote rail is the only one that can still reach them.
|
|
320
320
|
const parked = offlineStatus === 'parked'
|
|
321
321
|
const canCancelParked = parked && !!action.txid && !!onCancelParked
|
|
322
|
-
|
|
322
|
+
// Same rule as the detail sheet (detailActionKeysFor): no plain Cancel once
|
|
323
|
+
// this device recorded handing the payment over — the payee may hold it.
|
|
324
|
+
const canAbort = offlineStatus === undefined && ABORTABLE_STATUSES.has(action.status) && !!action.reference
|
|
323
325
|
// Any outgoing payment this wallet can re-deliver over the message box: both
|
|
324
326
|
// rails write the payee's identity key as a label and the derivation data as
|
|
325
327
|
// customInstructions, so the details can be sent again whether the payment
|
|
@@ -515,7 +517,7 @@ function ActivityRowBase({
|
|
|
515
517
|
label={t('cancel')}
|
|
516
518
|
accessibilityLabel={t('tx_action_abort')}
|
|
517
519
|
danger
|
|
518
|
-
onPress={() => onAbort(action.reference
|
|
520
|
+
onPress={() => onAbort(action.reference!, action)}
|
|
519
521
|
/>
|
|
520
522
|
) : null}
|
|
521
523
|
{canResendDetails ? (
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
formatAmount,
|
|
15
15
|
isFiatCurrency,
|
|
16
16
|
fiatFractionDigits,
|
|
17
|
-
satoshisPerFiatUnit
|
|
17
|
+
satoshisPerFiatUnit,
|
|
18
|
+
decimalSeparator
|
|
18
19
|
} from '@bsv/expo-wallet-toolbox'
|
|
19
20
|
import { parseTokenAmount, tokenAmountInputText, tokenAmountMask } from '../../tokenFormat'
|
|
20
21
|
|
|
@@ -172,7 +173,12 @@ export const AmountInput: React.FC<AmountInputProps> = ({
|
|
|
172
173
|
return
|
|
173
174
|
}
|
|
174
175
|
if (isFiat) {
|
|
175
|
-
|
|
176
|
+
// The mask accepts the ACTIVE LOCALE's own decimal separator (e.g. ','
|
|
177
|
+
// for de-DE), not a hardcoded '.' — otherwise every comma keystroke a
|
|
178
|
+
// comma-decimal locale types is silently dropped here before
|
|
179
|
+
// `parseDisplayToSatoshis` (which normalizes it) ever sees it.
|
|
180
|
+
const sep = decimalSeparator().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
181
|
+
const allowed = fractionDigits === 0 ? /^\d*$/ : new RegExp(`^\\d*${sep}?\\d{0,${fractionDigits}}$`)
|
|
176
182
|
if (text && !allowed.test(text)) return
|
|
177
183
|
setDisplayText(text)
|
|
178
184
|
const sats = parseDisplayToSatoshis(text, currency, satoshisPerUSD, usdToFiat)
|
|
@@ -22,7 +22,7 @@ import { Pressable, StyleSheet, Text, TouchableOpacity, View } from 'react-nativ
|
|
|
22
22
|
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated'
|
|
23
23
|
import { hitTargets, radii, spacing, typography, useTheme } from '@bsv/expo-wallet-toolbox'
|
|
24
24
|
import type { TokenBalance } from '../../../core/mandala/runtime'
|
|
25
|
-
import { tokenAmountParts } from '../../tokenFormat'
|
|
25
|
+
import { shortAssetId, tokenAmountParts } from '../../tokenFormat'
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @expo/vector-icons' index barrel re-exports every icon set, one of which
|
|
@@ -147,6 +147,8 @@ export default function AssetSwitcherDropdown({
|
|
|
147
147
|
key={b.asset.assetId}
|
|
148
148
|
ticker={b.asset.ticker}
|
|
149
149
|
fullName={b.asset.label}
|
|
150
|
+
issuerName={b.asset.issuerName}
|
|
151
|
+
fingerprint={shortAssetId(b.asset.assetId)}
|
|
150
152
|
figure={tokenAmountParts(b.baseUnits, b.asset)}
|
|
151
153
|
selected={selected === b.asset.assetId}
|
|
152
154
|
onPress={() => choose(b.asset.assetId)}
|
|
@@ -161,12 +163,18 @@ export default function AssetSwitcherDropdown({
|
|
|
161
163
|
function CoinRow({
|
|
162
164
|
ticker,
|
|
163
165
|
fullName,
|
|
166
|
+
issuerName,
|
|
167
|
+
fingerprint,
|
|
164
168
|
figure,
|
|
165
169
|
selected,
|
|
166
170
|
onPress
|
|
167
171
|
}: {
|
|
168
172
|
ticker: string
|
|
169
173
|
fullName?: string
|
|
174
|
+
/** XR-044: unverified, issuer-supplied — shown alongside the fingerprint, never in place of it. */
|
|
175
|
+
issuerName?: string
|
|
176
|
+
/** XR-044: `shortAssetId(assetId)` — the one thing a look-alike asset cannot share. Absent for BSV. */
|
|
177
|
+
fingerprint?: string
|
|
170
178
|
figure: { value: string; unit: string } | null
|
|
171
179
|
selected: boolean
|
|
172
180
|
onPress: () => void
|
|
@@ -174,6 +182,10 @@ function CoinRow({
|
|
|
174
182
|
const { colors } = useTheme()
|
|
175
183
|
const Ionicons = loadIonicons()
|
|
176
184
|
const figureText = figure ? `${figure.value} ${figure.unit}`.trim() : ''
|
|
185
|
+
// "Acme Bank · a1b2c3d4…ef01.0", or just the fingerprint when the issuer
|
|
186
|
+
// name could not be resolved — never the fingerprint alone dropped in favor
|
|
187
|
+
// of an unverified name.
|
|
188
|
+
const identityLine = [issuerName, fingerprint].filter(Boolean).join(' · ')
|
|
177
189
|
return (
|
|
178
190
|
<TouchableOpacity
|
|
179
191
|
style={[styles.row, selected && { backgroundColor: colors.fill }]}
|
|
@@ -182,7 +194,7 @@ function CoinRow({
|
|
|
182
194
|
accessibilityRole="button"
|
|
183
195
|
// The checkmark is not the only signal: state travels with the element.
|
|
184
196
|
accessibilityState={{ selected }}
|
|
185
|
-
accessibilityLabel={[ticker, fullName, figureText].filter(Boolean).join(', ')}
|
|
197
|
+
accessibilityLabel={[ticker, fullName, identityLine, figureText].filter(Boolean).join(', ')}
|
|
186
198
|
>
|
|
187
199
|
<View style={styles.body}>
|
|
188
200
|
<Text style={[styles.name, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
@@ -193,6 +205,11 @@ function CoinRow({
|
|
|
193
205
|
{fullName}
|
|
194
206
|
</Text>
|
|
195
207
|
)}
|
|
208
|
+
{!!identityLine && (
|
|
209
|
+
<Text style={[styles.identity, { color: colors.textTertiary }]} numberOfLines={1}>
|
|
210
|
+
{identityLine}
|
|
211
|
+
</Text>
|
|
212
|
+
)}
|
|
196
213
|
</View>
|
|
197
214
|
{figure && (
|
|
198
215
|
<Text style={[styles.figure, { color: colors.textPrimary }]} numberOfLines={1} accessibilityLabel={figureText}>
|
|
@@ -255,6 +272,9 @@ const styles = StyleSheet.create({
|
|
|
255
272
|
body: { flex: 1, minWidth: 0 },
|
|
256
273
|
name: { ...typography.body, fontWeight: '600' },
|
|
257
274
|
detail: { ...typography.footnote, marginTop: 2, fontVariant: ['tabular-nums'] },
|
|
275
|
+
// XR-044: smaller and dimmer than `detail` — an issuer/fingerprint line is
|
|
276
|
+
// provenance for the rare collision, not something every glance needs.
|
|
277
|
+
identity: { ...typography.caption2, marginTop: 1, fontVariant: ['tabular-nums'] },
|
|
258
278
|
figure: { ...typography.body, fontWeight: '600', fontVariant: ['tabular-nums'] },
|
|
259
279
|
unit: { ...typography.footnote },
|
|
260
280
|
check: { width: 20, alignItems: 'center' }
|