@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/CHANGELOG.md CHANGED
@@ -1,5 +1,260 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ 0.6.0 was tagged in this file but never published to npm. Hosts upgrading from
6
+ 0.5.0 should read both sections.
7
+
8
+ ### @bsv dependency bump (breaking for hosts)
9
+
10
+ Peer ranges move to `@bsv/sdk` ^2.8.2, `@bsv/wallet-toolbox-mobile` ^2.14.0,
11
+ `@bsv/message-box-client` ^2.5.3, `@bsv/templates` ^1.10.3,
12
+ `@bsv/btms-permission-module` ^1.2.1 and `@bsv/air-gap` ^0.1.3.
13
+
14
+ `@bsv/wallet-toolbox-mobile` now ships as one bundle whose exports map exposes
15
+ only its root, so this package imports everything from the root. Types the
16
+ toolbox exports only under its `sdk` namespace come through
17
+ `core/toolboxTypes.ts`. From 2.14.0 the toolbox exports `WalletMonitorTask`,
18
+ `attemptToPostReqsToNetwork`, `parseJsonRpc`, `stringifyJsonRpc` and
19
+ `verifyUnlockScripts` itself, and ships the permissions-manager sendMax fix,
20
+ the relinquish and internalize basket checks and best-effort Monitor
21
+ subscriptions, so none of that is patched any more.
22
+
23
+ Hosts must carry this repo's two remaining `patches/` for those exact
24
+ versions: `@bsv+sdk+2.8.2.patch` (native secp256k1 and transaction-engine
25
+ routing) and `@bsv+wallet-toolbox-mobile+2.14.0.patch` (the Vault authorization
26
+ hooks, the Vault deposit funding plan, batched native key derivation and shadow
27
+ engine verification). The `@bsv/message-box-client` and `@bsv/templates`
28
+ patches are gone: 2.5.3 reports a send failure as
29
+ `Message Box send failed with HTTP 400 (ERR_DUPLICATE_MESSAGE).`, which
30
+ `isDuplicateMessageError` recognises, and both packages' CommonJS builds load
31
+ under Node again.
32
+
33
+ - `ADMIN_ORIGINATOR` is now `internal-admin.bsv-wallet.invalid`. @bsv/sdk 2.8
34
+ accepts only canonical hostnames as originators, so the old
35
+ `urn:bsv-wallet:internal-admin` label rejected every internal wallet call.
36
+ `parseExternalOrigin` refuses the whole `.invalid` TLD, and pending aborts
37
+ queued under the old label replay under the new one
38
+ (`LEGACY_ADMIN_ORIGINATOR`).
39
+ - `OfflineFirstChaintracks` takes an optional third `chain` argument and
40
+ answers `getChain` from it, and forwards the remote's `supportsReorgEvents`,
41
+ so the toolbox Monitor does not subscribe through the HTTP client at all. A
42
+ subscription that fails anyway resolves to an inert id instead of throwing,
43
+ so the Monitor's subscriptions settle once instead of failing, and fetching
44
+ the chain over the network, on every tick while offline.
45
+ - Header validation uses the toolbox's `validateHeaderProofOfWork`, which
46
+ checks the compact target encoding and honours its consensus exceptions.
47
+
48
+ ### Transaction detail and activity words (breaking for direct callers)
49
+
50
+ - Tapping an activity row opens a full-screen transaction detail view, pushed
51
+ in from the right, instead of expanding the row in place. The utilities that
52
+ used to unfold under a row live in the view's overflow menu. New `ui`
53
+ exports: `TransactionDetailScreen` (default) with its `TransactionDetailParams`
54
+ and `TransactionAction` types, and `SlideOverFromRight` (default, props
55
+ `{ visible, onClosed?, children }`). `ActivityRow` takes an optional
56
+ `onOpen?: (action: ActivityAction) => void`; when given, a tap calls it and
57
+ the old inline expansion is not rendered. Its `token` prop gains an optional
58
+ `status?: TxStatusView`.
59
+ - The detail view's headline is the exact satoshi count the transaction moved,
60
+ never shortened or converted to BSV. When the display currency is fiat, the
61
+ fiat amount is a separate line beneath it. A `Block` row shows the block
62
+ height from local storage (one-row query, no network); an unproven
63
+ transaction reads "Waiting for a block." `StorageExpoSQLite` gains
64
+ `getProvenTxHeight(txid): Promise<number | null>`.
65
+ - A BSV row says what it did from the moment it is handed to the network:
66
+ `completed`, `unproven` and `sending` all read "Sent" or "Received" instead
67
+ of "Confirmed", "Accepted" and "Broadcasting". An outgoing action that no
68
+ Pay / Get paid rail made (no `peerpay`, `localpay`, `legacy` or `mandala`
69
+ label: a connected app or the wallet itself) reads "Spent". Vault deposits,
70
+ withdrawals and relocks read "Transferred" in either direction.
71
+ - `txStatusView(status, offlineStatus?, incoming?, labels?)` takes two new
72
+ optional arguments. **A host calling it directly must pass `incoming` (and
73
+ `labels`)**: without them, `completed`, `unproven` and `sending` now resolve
74
+ to "Spent". New exports from `ui/txStatus.ts`: `activityKind(incoming,
75
+ labels)`, the one place a row's word is decided, returning the new
76
+ `ActivityKind` (`'sent' | 'received' | 'spent' | 'transferred'`), and
77
+ `isPaymentAction(labels)`.
78
+ - Token (Mandala) rows use the same words: "Sent" or "Received" once settled,
79
+ "Pending" while settling. Only `refused`, `reversed` and `stuck` keep their
80
+ own word. New `ui` export `tokenRowStatusView(status, incoming)`.
81
+ - A row shows its status dot only when its tone is not the quiet settled one
82
+ (in flight, needs attention, failed), so a normal history is no longer a
83
+ column of dots.
84
+
85
+ ### Activity filter and search
86
+
87
+ - A filter button beside Export opens a search field with All / Sent /
88
+ Received / Spent / Transferred chips; the list narrows as the user types or
89
+ picks a chip. Search matches every typed word, in any order, case- and
90
+ accent-insensitive, against the row's note (or the name recorded at send)
91
+ and a saved contact's name and handle for its counterparty. It is local only:
92
+ no network lookups, so a non-contact's handle is found only if the note says
93
+ it. A leading `@` is ignored. While a filter is active the list pages into
94
+ older history, and "No matching activity" shows only once history is
95
+ exhausted. Closing the panel clears the search and resets to All.
96
+ - The Export button reads "Export" (`tx_export`); its accessibility label is
97
+ still `tx_export_csv`. CSV export ignores the filter and writes the full
98
+ history.
99
+
100
+ ### Amounts
101
+
102
+ - New `core` exports: `formatSatoshisExact(satoshis, showPlus?)`, the exact
103
+ satoshi count for the detail view; `splitAmountFraction(value)`, which splits
104
+ a formatted amount so its minor units can be drawn smaller; and
105
+ `getNumberLocale()`, the device locale every amount formatter prints through.
106
+ - `AmountFormatOptions` gains an optional `compact`, and `formatSatoshisAsBsv`
107
+ and `formatSatoshisAsFiat` gain a trailing `compact = false` parameter. With
108
+ it, large figures shorten to k / M / B (`$1.2k`, `1.5M BSV`), and a value
109
+ that rounds to 1000 of a unit promotes to the next one. Only activity rows
110
+ pass it. `abbreviate` still shortens only the unit word ("sats"), as in
111
+ 0.6.0, so existing calls are unchanged.
112
+ - Currency symbols come from the toolbox's own table (`$` for USD, AUD, CAD and
113
+ NZD; `£`, `¥`, `₹`, `₽`, `zł`, `R$`, `Rp`) with `narrowSymbol`, not from
114
+ whatever the device language implies: a device that printed "US$" or "NZ$"
115
+ now prints `$`. Where `Intl.NumberFormat` throws (seen on Hermes), the
116
+ fallback prints that symbol before locale-formatted digits instead of the ISO
117
+ code ("USD 3.45"). Hosts with snapshot tests on formatted currency should
118
+ expect the symbol change.
119
+
120
+ ### Home screen
121
+
122
+ - The balance stays on one line at any length: its type shrinks to fit the
123
+ available width, down to a 12pt floor, and grows back when a shorter value
124
+ follows. This replaces `adjustsFontSizeToFit`, which on iOS Fabric ignores
125
+ `minimumFontScale` and bottoms out at 4pt.
126
+ - Its minor units are drawn smaller and raised, price-tag style. Abbreviated
127
+ figures and whole amounts render as one run.
128
+ - Tapping the balance to switch currency has a descriptive accessibility label
129
+ naming the destination unit (`wallet_balance_show_in`, e.g. "Show in USD").
130
+ - Pay and Get paid show their icon beside the label, in pill-shaped buttons.
131
+ The import-from-backup card's icon sits in a filled circle, with corners
132
+ concentric with the screen's.
133
+
134
+ ### Profile picture
135
+
136
+ - The user can pick an icon as their profile picture; Home's profile button
137
+ shows it, falling back to the previous person glyph when none is chosen.
138
+ New `core` exports: `getUserAvatarIcon`, `setUserAvatarIcon`,
139
+ `loadUserAvatarIcon`, `subscribeUserAvatar`, `useUserAvatarIcon`, and the
140
+ `AvatarIcon` / `AvatarIconFamily` types. New `ui` exports: `UserAvatar`
141
+ (default), `AvatarGlyph`, `AVATAR_ICON_GROUPS` with the `AvatarIconOption` /
142
+ `AvatarIconGroup` types, `IconPickerSheet` (default, props
143
+ `{ visible, onClose }`) and `EditPictureSheet` (default, props
144
+ `{ visible, options: EditPictureOption[], onClose }`) with
145
+ `EditPictureOption`.
146
+
147
+ ### Handle registry fixes
148
+
149
+ - A typed `handle@domain` whose domain is complete in its own right resolves
150
+ as that domain: `alice@deggen.co` is no longer answered as a prefix of
151
+ `deggen.com`, which returned every `*@deggen.com` neighbour for an address
152
+ on someone else's registry.
153
+ - A half-typed prefix of the pinned domain that matches nothing returns an
154
+ empty result instead of the "search unavailable" banner.
155
+ - Registry search results are capped at 10 rows (`MAX_SEARCH_RESULTS`) before
156
+ any certificate is verified, so an uncapped response from a foreign registry
157
+ cannot freeze recipient search.
158
+ - A handle arriving through a deep-linked `/contact/add?handle=…` is checked
159
+ against the registry for the key it claims before it is written to
160
+ `cachedHandle`; an unproven one is left blank for the background refresh.
161
+ - Registry requests bound the response body by the same ~8s deadline as the
162
+ headers. Writes are serialized, so a stalled body used to block every later
163
+ write for the life of the process.
164
+ - An outstanding registration journal takes priority at every entry point
165
+ (`registerHandle`, `updateProfile`, `changeHandle`), not only on resume, so a
166
+ retried claim and release can no longer leave the user holding neither
167
+ handle.
168
+ - A rollback that finishes on a later launch still names the handle the user
169
+ tried to claim (`attemptedPaymail` in the pending journal).
170
+ - Failed writes carry a `code` (`invalid_handle`, `wrong_domain`,
171
+ `same_handle`, `clock_ahead`). Profile shows `clock_ahead` and `wrong_domain`
172
+ in the user's language; the other two still show the diagnostic message.
173
+ - A contact's screen tracks its avatar refresh and registry refresh
174
+ separately, so a registry lookup no longer suppresses the avatar refresh.
175
+ - In Pay, a registry display name that contains `@` is not shown as the
176
+ recipient's name (it falls back to the handle); the review card shows the
177
+ recipient's `handle@domain` rather than an abbreviated key; identity-search
178
+ and registry-search errors share one dismissible banner.
179
+
180
+ ### Copy and translations
181
+
182
+ - 17 new keys, in all 12 languages, none removed: `tx_status_received`,
183
+ `tx_status_sent`, `tx_status_spent`, `tx_status_transferred`,
184
+ `tx_status_pending`, `tx_export`, `activity_filter`, `activity_filter_all`,
185
+ `activity_search_placeholder`, `activity_search_clear`,
186
+ `activity_filter_no_match`, `wallet_balance_show_in`, `tx_detail_block`,
187
+ `tx_detail_block_pending`, `profile_handle_clock_ahead`,
188
+ `profile_handle_wrong_registry`, `profile_display_name_publish_failed`.
189
+ `tx_status_confirmed`, `tx_status_accepted` and `tx_status_broadcasting` are
190
+ kept but no longer used by default.
191
+ - `biometric_advisory_body` is shorter in every language: "Protect your assets
192
+ with Face ID or your fingerprint".
193
+
194
+ ### Fixes
195
+
196
+ - `TransactionDetailScreen` loads Ionicons lazily, like the rest of the
197
+ package, so importing the `ui` barrel under Jest no longer fails on
198
+ expo-font's ESM.
199
+
200
+ ## 0.6.0
201
+
202
+ ### Handle registry (breaking)
203
+
204
+ Handle registration talks to go-message-box-server's paymail profile registry
205
+ instead of a certifier that was never deployed. A handle is now
206
+ `handle@domain`: a self-signed BRC-52 profile certificate the registry stores
207
+ and anybody can verify. Spec:
208
+ `docs/superpowers/specs/2026-09-18-handle-registry-client-design.md`.
209
+
210
+ Removed exports and configuration:
211
+
212
+ - `core/identity/handleCertificate.ts` in full — `HANDLE_CERT_TYPE`,
213
+ `HandleCertWallet`, `isValidHandleFormat` (the 3-20 rule),
214
+ `HandleAvailability`, `checkHandleAvailability`, `registerHandle`,
215
+ `RegisterHandleResult`.
216
+ - `ToolboxConfig.handleCertifier`, `HandleCertifierConfig`,
217
+ `getHandleCertifierConfig`. Neither the type nor the getter was on the
218
+ public barrel; the config key was.
219
+
220
+ New:
221
+
222
+ - `ToolboxConfig.handleRegistry?: Partial<Record<AppChain, HandleRegistryConfig>>`
223
+ and `getHandleRegistryConfig(chain)`, both exported from the `core` barrel.
224
+ Fail-closed: a malformed or half-stated entry reads as no registry. `https`
225
+ is required except for localhost and RFC 1918 hosts in development.
226
+ - `mergeContactCache` / `ContactCache` (`core/contacts/contactCache.ts`).
227
+ - `core/identity/handleRegistry/` — `rules`, `profileCert`, `resolver`,
228
+ `client`, `registration`. Not on the barrel: the UI in this package is the
229
+ only consumer, and the surface is still settling.
230
+
231
+ Behaviour:
232
+
233
+ - The display name is **public** when set: a plaintext field of the profile
234
+ certificate, and the default name someone sees when they add you. The
235
+ in-app hint says so, in all 12 languages.
236
+ - Profile shows `handle@domain`, and the registry — not
237
+ `profile_registered_handle` — is the source of truth for which handle this
238
+ key holds, so a restored wallet gets its handle back.
239
+ - Every write is journaled in `key_value_store` (`profile_handle_pending`) and
240
+ replayed on the next Profile mount, so a crash, a double tap or a lost
241
+ response settles to the same state.
242
+ - Pay's recipient search gains a registry tier between contacts and the
243
+ overlay, and `RecipientField` shows its loading spinner as a footer instead
244
+ of replacing the list — the local contacts tier is no longer hidden for the
245
+ whole debounce.
246
+ - A query that is a complete `handle@domain` answers that row and nothing
247
+ else. The registry's own search is a prefix, skeleton and substring search,
248
+ so a typed address would otherwise be answered with its neighbours and its
249
+ look-alikes.
250
+ - `contacts.cachedHandle` has a production writer for the first time: the
251
+ `handle` route param on `/contact/add` (validated as a paymail — the route
252
+ is deep-linkable), and `ContactScreen`'s background refresh, which
253
+ distinguishes "the registry says there is none" from "the registry did not
254
+ answer" and only clears the column for the first.
255
+ - A handle is displayed without a prepended `@` wherever it already carries
256
+ its own domain: Profile, Contacts, a contact, and the Identifier QR screen.
257
+
3
258
  ## 0.5.0
4
259
 
5
260
  ### 1-of-N YubiKey vault (breaking)
package/README.md CHANGED
@@ -194,6 +194,25 @@ handshake posts to the origin root, so a path, query or fragment is rejected.
194
194
  Every `services` field is optional and falls back to the built-in public
195
195
  endpoint for that chain. Chains are `main`, `test` and `teratest`.
196
196
 
197
+ `handleRegistry` names the paymail domain this build's handles live under and
198
+ the host that serves it, per chain:
199
+
200
+ ```tsx
201
+ configureToolbox({
202
+ backupUrl: null,
203
+ handleRegistry: {
204
+ test: { domain: 'deggen.com', url: 'https://messagebox.bsvblockchain.tech' }
205
+ }
206
+ })
207
+ ```
208
+
209
+ Both fields are required together — a domain with no URL is a registry nothing
210
+ can reach, and a URL with no domain is a host whose certificates nothing can be
211
+ checked against — and the URL must be `https` unless it points at `localhost`,
212
+ `127.0.0.1`, `10.0.2.2` or RFC 1918 space, which is a development allowance. A
213
+ chain with no complete entry shows "not available yet" on the Profile screen
214
+ and adds no registry tier to Pay's recipient search.
215
+
197
216
  Reading configuration before `configureToolbox` has run **throws**. An
198
217
  unconfigured build fails loudly rather than behaving like a deliberately
199
218
  disabled one.