@bsv/expo-wallet-toolbox 0.5.0 → 0.7.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 (90) hide show
  1. package/CHANGELOG.md +255 -0
  2. package/README.md +19 -0
  3. package/core/amountFormatHelpers.ts +238 -34
  4. package/core/backup/RemoteSyncReader.ts +2 -5
  5. package/core/backup/codec.ts +2 -2
  6. package/core/backup/push.ts +1 -1
  7. package/core/config.tsx +12 -5
  8. package/core/contacts/contactActivity.ts +153 -0
  9. package/core/contacts/contactCache.ts +41 -0
  10. package/core/contacts/contactsStore.ts +183 -0
  11. package/core/context/WalletContext.tsx +55 -10
  12. package/core/demo/demoAssets.ts +60 -0
  13. package/core/demo/demoLedger.ts +240 -0
  14. package/core/demo/demoMandalaRuntime.ts +96 -0
  15. package/core/demo/demoMode.ts +38 -0
  16. package/core/demo/demoWallet.ts +25 -0
  17. package/core/demo/index.ts +26 -0
  18. package/core/demo/useDemo.ts +59 -0
  19. package/core/headers/OfflineFirstChaintracks.ts +52 -14
  20. package/core/headers/headerStore.ts +7 -10
  21. package/core/i18n/translations.tsx +1234 -74
  22. package/core/identity/contactLink.ts +36 -0
  23. package/core/identity/handleRegistry/client.ts +285 -0
  24. package/core/identity/handleRegistry/profileCert.ts +254 -0
  25. package/core/identity/handleRegistry/registration.ts +559 -0
  26. package/core/identity/handleRegistry/resolver.ts +247 -0
  27. package/core/identity/handleRegistry/rules.ts +104 -0
  28. package/core/index.ts +20 -2
  29. package/core/localpay/pendingAborts.ts +5 -1
  30. package/core/monitor/MonitorSupervisor.ts +121 -0
  31. package/core/monitor/TaskBackupPush.ts +1 -1
  32. package/core/monitor/TaskCreditInbox.ts +1 -1
  33. package/core/monitor/TaskDrainOutbox.ts +1 -1
  34. package/core/monitor/TaskSendOffline.ts +1 -1
  35. package/core/net/online.ts +49 -0
  36. package/core/numberFormat.ts +19 -0
  37. package/core/offline/plan.ts +1 -1
  38. package/core/pay/recordProof.ts +2 -6
  39. package/core/services/arcadeBroadcastProvider.ts +1 -4
  40. package/core/services/exchangeRate.ts +1 -1
  41. package/core/services/externalOrigin.ts +5 -2
  42. package/core/services/vault/transfers.ts +2 -2
  43. package/core/services/walletServiceConfig.ts +31 -20
  44. package/core/storage/StorageExpoSQLite.ts +41 -34
  45. package/core/storage/methods/findSql.ts +3 -0
  46. package/core/storage/methods/listActionsSql.ts +8 -5
  47. package/core/storage/methods/listOutputsSql.ts +2 -2
  48. package/core/storage/methods/processOfflineActions.ts +2 -3
  49. package/core/storage/methods/reviewStatusSql.ts +7 -2
  50. package/core/storage/schema/createTables.ts +29 -0
  51. package/core/toolboxConfig.ts +70 -0
  52. package/core/toolboxTypes.ts +40 -0
  53. package/core/userAvatar.ts +79 -0
  54. package/core/walletMonitor.ts +8 -3
  55. package/package.json +7 -7
  56. package/ui/activityFilter.ts +115 -0
  57. package/ui/components/pay/PaymentSuccessOverlay.tsx +46 -6
  58. package/ui/components/pay/RecipientField.tsx +84 -70
  59. package/ui/components/pay/StepBar.tsx +32 -0
  60. package/ui/components/pay/UniversalSend.tsx +677 -149
  61. package/ui/components/ui/PencilEditField.tsx +109 -0
  62. package/ui/components/ui/SlideOverFromRight.tsx +86 -0
  63. package/ui/components/wallet/ActivityRow.tsx +222 -120
  64. package/ui/components/wallet/AmountInput.tsx +18 -6
  65. package/ui/components/wallet/ContactActivityList.tsx +149 -0
  66. package/ui/components/wallet/ContactSigil.tsx +49 -0
  67. package/ui/components/wallet/EditPictureSheet.tsx +99 -0
  68. package/ui/components/wallet/FitAmount.tsx +148 -0
  69. package/ui/components/wallet/IconPickerSheet.tsx +168 -0
  70. package/ui/components/wallet/IdentifierRow.tsx +69 -0
  71. package/ui/components/wallet/ImportFromBackupPrompt.tsx +35 -13
  72. package/ui/components/wallet/ProfileButton.tsx +62 -0
  73. package/ui/components/wallet/UserAvatar.tsx +85 -0
  74. package/ui/components/wallet/avatarIcons.ts +122 -0
  75. package/ui/hooks/useContactsStore.ts +10 -0
  76. package/ui/hooks/useMandala.ts +18 -1
  77. package/ui/hooks/useOnline.ts +65 -20
  78. package/ui/index.ts +26 -1
  79. package/ui/screens/ContactScreen.tsx +289 -0
  80. package/ui/screens/ContactsScreen.tsx +373 -0
  81. package/ui/screens/IdentifierScreen.tsx +234 -0
  82. package/ui/screens/NewContactScreen.tsx +362 -0
  83. package/ui/screens/PayScreen.tsx +20 -7
  84. package/ui/screens/ProfileScreen.tsx +783 -0
  85. package/ui/screens/TransactionDetailScreen.tsx +419 -0
  86. package/ui/screens/TrustScreen.tsx +1 -1
  87. package/ui/screens/WalletConfigScreen.tsx +42 -0
  88. package/ui/screens/WalletHomeScreen.tsx +528 -83
  89. package/ui/tokenStatus.ts +21 -0
  90. package/ui/txStatus.ts +43 -5
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' }
@@ -42,12 +75,17 @@ export function txStatusView(status: string, offlineStatus?: string): TxStatusVi
42
75
  }
43
76
 
44
77
  switch (status) {
78
+ // The chain words ("Confirmed", "Accepted") answered a question about the
79
+ // ledger; the user's question is what happened to their money. A settled
80
+ // row therefore says what it DID — Received or Sent — from the moment it is
81
+ // handed to the network: the block proof that follows changes nothing the
82
+ // holder can act on. The states below that DO need action keep their own words.
45
83
  case 'completed':
46
- return { key: 'tx_status_confirmed', tone: 'settled' }
47
84
  case 'unproven':
48
- return { key: 'tx_status_accepted', tone: 'settled' }
85
+ return { key: done, tone: 'settled' }
86
+ // Already handed to the network: say what it does, Sent or Received.
49
87
  case 'sending':
50
- return { key: 'tx_status_broadcasting', tone: 'inflight' }
88
+ return { key: done, tone: 'inflight' }
51
89
  case 'nosend':
52
90
  return { key: 'tx_status_not_sent', tone: 'attention' }
53
91
  case 'unsigned':