@bsv/expo-wallet-toolbox 0.29.0 → 1.0.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 CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.0
6
+
7
+ The first stable release. It adds one fix to 0.30.0: Delete Wallet no longer builds the departing wallet again. No native change: hosts do not rebuild. No API changes, so no host action is necessary.
8
+
9
+ ### Fixed
10
+
11
+ - **No wallet build during `logout()`.** `logout()` resets `configStatus` and `walletBuilt` long before it erases the recovery phrase, its last step. It awaits the push unregistration (a network call) and several storage sweeps in between. In that window, the startup config effect set `configStatus` to `configured` again, and the auto-build effect then built the departing wallet from the phrase that was still in the keychain, on top of the teardown. A new `loggingOutRef` is set at the start of `logout()`. The auto-build effect, `buildWalletFromMnemonic` and `buildWalletFromRecoveredKey` do nothing while it is set. When `logout()` ends, it clears the ref and requests one build. With the phrase gone, that build finds no wallet. After a failed erasure, it opens the wallet that is still there.
12
+
13
+ ## 0.30.0
14
+
15
+ The BSV Wallet app's last patch of the toolbox, upstreamed: a backup carries the wallet's look, and the vault chain check shows its progress and can be skipped. No native change: hosts do not rebuild. Every new prop and option is optional, so no host action is necessary.
16
+
17
+ ### Added
18
+
19
+ - **`appData.walletLook` and `WALLET_LOOK_KEY`.** The backup carries the host's `wallet_look` row as it is, so a restored wallet looks as it did. The toolbox never reads the value. An empty row is not carried. When two devices merge, the first device's look wins. A `walletLook` that is not a string makes the decode fail, as other malformed `appData` fields do.
20
+ - **Progress and "Skip" for the vault chain check.** `EnrollWizard`'s `cardGate.check` now gets a second argument, `{ onProgress, signal }`. The wizard shows a bar with a percent while the check runs, and a "Skip the check" button. A skip aborts `signal` and gives an `unknown` answer with `reason: 'skipped'`, never `clear`, so a reset still needs the loss sentence. After a skip, "Check the blockchain" runs the check again. An `unknown` answer with another reason shows that reason. A `check` that ignores the second argument works as before.
21
+ - **6 strings in all 14 locales:** `vault_card_progress`, `vault_card_skip`, `vault_card_skipped_title`, `vault_card_skipped_body`, `vault_card_check` and `vault_card_reason`.
22
+
5
23
  ## 0.29.0
6
24
 
7
25
  The BSV Wallet app's nearby-payment changes, upstreamed from its patch of 0.27.0: a host can draw the failure screen and explain a stopped radio, a failure names its cause as a code, and 16 payment strings are reworded. No native change: hosts do not rebuild. Every new prop is optional, and the new fields are on values that the toolbox gives to the host, so no host action is necessary.
@@ -13,12 +31,13 @@ The BSV Wallet app's nearby-payment changes, upstreamed from its patch of 0.27.0
13
31
  - **`NearbyFailed.declineReason`.** The payee's own decline code, when the payee refused the payment.
14
32
  - **`NearbyFlowProps.explainRadio`, `{ label, onPress(kind) }`.** With it, each "radio stopped" notice has an (i) button that calls `onPress` with the radio that stopped. `label` is the accessibility label of the button. The button is absent when Local Network access is off, because that notice has its own Settings button. Without the prop, the notice is the same as before.
15
33
  - **Wallet identity keys on the host values.** `recipient.identityKey` on `NearbyConfirm`, `NearbySending` and `NearbyShowCode`, `recipientKey` on `NearbyDone`, and `payerKey` on `NearbyReceived`. A host can draw the same face for the person that it draws in other screens.
34
+ - **Icelandic (`is`).** A full catalog, and `supportedLanguages` lists it. It merged after this entry was written, and the 0.29.0 package includes it.
16
35
  - **14 German strings.** The German catalog lacked 13 keys, and one more value had old wording.
17
36
 
18
37
  ### Changed
19
38
 
20
39
  - **The embedded "Scan the payer's code" control is now a button.** In the embedded payee flow it was a 13 px line of grey text. It is now the same `SecondaryButton` as in the full-screen flow. Every host that embeds `NearbyFlow` sees this.
21
- - **16 payment strings are reworded, in all 13 locales.** No key is added, renamed or dropped. Every host sees the new copy.
40
+ - **16 payment strings are reworded, in all 14 locales.** No key is added, renamed or dropped. Every host sees the new copy.
22
41
  - Outside Settings › Advanced, the copy does not name the message box. It says what occurred and what to do: `message_box_off_hint`, `message_box_unreachable`, `resend_sending`, `direct_pay_status_not_set_up_body`, `direct_pay_fallback_title`, `direct_pay_fallback_offline`, `direct_pay_fallback_link_failed`, `direct_pay_fallback_too_large`, `direct_pay_failed_offline` and `direct_pay_failed_no_message_box`.
23
42
  - `local_pay_ble_unavailable`, `local_pay_nearby_unavailable` and `local_pay_floor_peer_bt_off` are shorter.
24
43
  - `local_pay_root_unverified` and `local_pay_declined_root_unverified` now say what to do: the payee goes online, then the same code is scanned again.
@@ -50,6 +50,12 @@ import { getIssuedDates, setIssuedDates } from '../pay/receiveHistory'
50
50
  import type { AppDataSnapshot } from './codec'
51
51
  import { mergeContacts } from './contactsBackup'
52
52
 
53
+ /**
54
+ * The app's own row for how it draws this wallet (its avatar). The toolbox never reads its
55
+ * value: it backs the row up and writes it back, so a restored wallet looks as it did.
56
+ */
57
+ export const WALLET_LOOK_KEY = 'wallet_look'
58
+
53
59
  export interface KVStorage {
54
60
  getKeyValue(k: string): Promise<string | undefined>
55
61
  setKeyValue(k: string, v: string): Promise<void>
@@ -65,6 +71,7 @@ export function isEmptyAppData(appData: AppDataSnapshot | undefined): boolean {
65
71
  (appData.localpayPending === undefined &&
66
72
  appData.peerpayOutbox === undefined &&
67
73
  appData.contacts === undefined &&
74
+ appData.walletLook === undefined &&
68
75
  (appData.receiveIssuedDates?.length ?? 0) === 0)
69
76
  )
70
77
  }
@@ -76,15 +83,18 @@ export function isEmptyAppData(appData: AppDataSnapshot | undefined): boolean {
76
83
  * only ever rides an already-non-empty chunk.
77
84
  */
78
85
  export async function captureAppDataSnapshot(storage: KVStorage): Promise<AppDataSnapshot> {
79
- const [localpayPending, peerpayOutbox, receiveIssuedDates] = await Promise.all([
86
+ const [localpayPending, peerpayOutbox, receiveIssuedDates, walletLook] = await Promise.all([
80
87
  storage.getKeyValue(PENDING_KEY),
81
88
  storage.getKeyValue(OUTBOX_KEY),
82
- getIssuedDates(storage)
89
+ getIssuedDates(storage),
90
+ storage.getKeyValue(WALLET_LOOK_KEY)
83
91
  ])
84
92
  const snapshot: AppDataSnapshot = {}
85
93
  if (localpayPending !== undefined) snapshot.localpayPending = localpayPending
86
94
  if (peerpayOutbox !== undefined) snapshot.peerpayOutbox = peerpayOutbox
87
95
  if (receiveIssuedDates.length > 0) snapshot.receiveIssuedDates = receiveIssuedDates
96
+ // an empty row is "none set": nothing to carry
97
+ if (walletLook) snapshot.walletLook = walletLook
88
98
  return snapshot
89
99
  }
90
100
 
@@ -101,6 +111,7 @@ export async function applyAppData(storage: KVStorage, snapshot: AppDataSnapshot
101
111
  if (snapshot.receiveIssuedDates !== undefined && snapshot.receiveIssuedDates.length > 0) {
102
112
  await setIssuedDates(storage, snapshot.receiveIssuedDates)
103
113
  }
114
+ if (snapshot.walletLook) await storage.setKeyValue(WALLET_LOOK_KEY, snapshot.walletLook)
104
115
  }
105
116
 
106
117
  /** Parses a KV row's raw JSON text into an array of plain objects, never throwing — a
@@ -157,6 +168,8 @@ export function mergeAppData(a: AppDataSnapshot | undefined, b: AppDataSnapshot
157
168
  ? undefined
158
169
  : [...new Set([...(a?.receiveIssuedDates ?? []), ...(b?.receiveIssuedDates ?? [])])].sort(),
159
170
  // everyone either device knew, each as they were last changed (contactsBackup.ts)
160
- contacts: mergeContacts(a?.contacts, b?.contacts)
171
+ contacts: mergeContacts(a?.contacts, b?.contacts),
172
+ // one look per wallet, not a list: the first device's (the primary, folded in first) wins
173
+ walletLook: a?.walletLook ?? b?.walletLook
161
174
  }
162
175
  }
@@ -111,7 +111,10 @@ export function estimateEncodedBytes(chunk: SyncChunk): number {
111
111
  export function estimateAppDataBytes(appData: AppDataSnapshot | undefined): number {
112
112
  if (appData == null) return 0
113
113
  let bytes =
114
- (appData.localpayPending?.length ?? 0) + (appData.peerpayOutbox?.length ?? 0) + (appData.contacts?.length ?? 0)
114
+ (appData.localpayPending?.length ?? 0) +
115
+ (appData.peerpayOutbox?.length ?? 0) +
116
+ (appData.contacts?.length ?? 0) +
117
+ (appData.walletLook?.length ?? 0)
115
118
  for (const d of appData.receiveIssuedDates ?? []) bytes += d.length
116
119
  return bytes
117
120
  }
@@ -180,6 +183,11 @@ export interface AppDataSnapshot {
180
183
  receiveIssuedDates?: string[]
181
184
  /** The contacts table, as JSON (backup/contactsBackup.ts). */
182
185
  contacts?: string
186
+ /**
187
+ * Verbatim value of key_value_store['wallet_look']: how the app draws this wallet (its
188
+ * avatar), as the app's own JSON. The toolbox only carries it.
189
+ */
190
+ walletLook?: string
183
191
  }
184
192
 
185
193
  /**
@@ -345,6 +353,7 @@ function decodeAppData(raw: unknown): AppDataSnapshot | undefined {
345
353
  peerpayOutbox?: unknown
346
354
  receiveIssuedDates?: unknown
347
355
  contacts?: unknown
356
+ walletLook?: unknown
348
357
  }
349
358
  if (a.localpayPending !== undefined && typeof a.localpayPending !== 'string') {
350
359
  throw new Error('backup appData.localpayPending is malformed')
@@ -361,11 +370,15 @@ function decodeAppData(raw: unknown): AppDataSnapshot | undefined {
361
370
  if (a.contacts !== undefined && typeof a.contacts !== 'string') {
362
371
  throw new Error('backup appData.contacts is malformed')
363
372
  }
373
+ if (a.walletLook !== undefined && typeof a.walletLook !== 'string') {
374
+ throw new Error('backup appData.walletLook is malformed')
375
+ }
364
376
  return {
365
377
  localpayPending: a.localpayPending as string | undefined,
366
378
  peerpayOutbox: a.peerpayOutbox as string | undefined,
367
379
  receiveIssuedDates: a.receiveIssuedDates as string[] | undefined,
368
- ...(a.contacts !== undefined ? { contacts: a.contacts as string } : {})
380
+ ...(a.contacts !== undefined ? { contacts: a.contacts as string } : {}),
381
+ ...(a.walletLook !== undefined ? { walletLook: a.walletLook as string } : {})
369
382
  }
370
383
  }
371
384
 
@@ -854,6 +854,16 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
854
854
  * handing anything to React. See core/context/buildGeneration.ts.
855
855
  */
856
856
  const buildGenRef = useRef(makeBuildGeneration())
857
+ /**
858
+ * True from the first line of logout() until it returns. Logout resets
859
+ * configStatus and walletBuilt long before it erases the secrets (it awaits
860
+ * the push unregistration, a network call, in between). Without this, the
861
+ * auto-build effect saw "configured, not built" in that window and could
862
+ * build the departing wallet again from the secrets still in the keychain,
863
+ * on top of the teardown (a second database, monitor and key prompt for a
864
+ * wallet being deleted).
865
+ */
866
+ const loggingOutRef = useRef(false)
857
867
  const [settings, setSettings] = useState(DEFAULT_SETTINGS)
858
868
  const [txStatusVersion, setTxStatusVersion] = useState(0)
859
869
  // The active user's storage id, for scoping `offline_actions` reads (see
@@ -2921,6 +2931,8 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
2921
2931
  if (walletBuiltRef.current || walletBuildingRef.current) {
2922
2932
  return
2923
2933
  }
2934
+ // Never during Delete Wallet: see loggingOutRef.
2935
+ if (loggingOutRef.current) return
2924
2936
  const buildToken = buildGenRef.current.current()
2925
2937
 
2926
2938
  // Only build if wallet is properly configured
@@ -3085,6 +3097,8 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
3085
3097
  async (wif: string, opts?: WalletBuildOptions) => {
3086
3098
  if (walletBuiltRef.current || walletBuildingRef.current) return
3087
3099
  if (configStatus !== 'configured') return
3100
+ // Never during Delete Wallet: see loggingOutRef.
3101
+ if (loggingOutRef.current) return
3088
3102
 
3089
3103
  walletBuildingRef.current = true
3090
3104
  setWalletBuilding(true)
@@ -3587,6 +3601,11 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
3587
3601
  useEffect(() => {
3588
3602
  // A profile switch is mid-way: it requests the build itself once ready.
3589
3603
  if (profileTransitionRef.current) return
3604
+ // Delete Wallet is mid-way and the secrets may still be there: building now
3605
+ // would bring the departing wallet back. Logout requests a build when it
3606
+ // ends (see loggingOutRef), which finds no wallet, or the one a failed
3607
+ // erasure left.
3608
+ if (loggingOutRef.current) return
3590
3609
  if (configStatus !== 'configured' || walletBuilt) return
3591
3610
  // Signal that a build attempt is starting. buildWalletFromMnemonic /
3592
3611
  // buildWalletFromRecoveredKey will clear this flag on completion or error.
@@ -4069,6 +4088,22 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
4069
4088
  // comment warned about — everything above this point already ran
4070
4089
  // synchronously before any promise existed to await.
4071
4090
  return (async () => {
4091
+ try {
4092
+ // No build may start until this logout has ended. Set here, in the
4093
+ // try, so the finally always clears it; nothing above has yielded, so
4094
+ // no effect can have run in between.
4095
+ loggingOutRef.current = true
4096
+ return await runLogout()
4097
+ } finally {
4098
+ // The auto-build effect was held off for the whole logout, so ask it
4099
+ // once now: with the secrets gone it finds no wallet and settles; if
4100
+ // the erasure failed, it opens the wallet that is still there.
4101
+ loggingOutRef.current = false
4102
+ setAutoBuildRequest(r => r + 1)
4103
+ }
4104
+ })()
4105
+
4106
+ async function runLogout(): Promise<boolean> {
4072
4107
  // Push listeners and the registration sync belong to the wallet being
4073
4108
  // torn down; nothing may fire them against it from here on.
4074
4109
  pushDetachRef.current?.()
@@ -4241,7 +4276,7 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
4241
4276
  router.dismissAll()
4242
4277
  router.replace('/')
4243
4278
  return true
4244
- })()
4279
+ }
4245
4280
  }, [deleteAllWalletKeys, storage])
4246
4281
 
4247
4282
  /**
@@ -350,6 +350,12 @@ const resources = {
350
350
  vault_card_unknown_body:
351
351
  'The key was not changed. Try again. If you reset it without checking, any vault it opens is lost for good.',
352
352
  vault_card_retry: 'Try again',
353
+ vault_card_progress: '{{percent}}% checked',
354
+ vault_card_skip: 'Skip the check',
355
+ vault_card_skipped_title: 'Check skipped',
356
+ vault_card_skipped_body: 'The blockchain was not checked. If this key opens a vault, its funds are lost for good when you reset it.',
357
+ vault_card_check: 'Check the blockchain',
358
+ vault_card_reason: 'Reason: {{reason}}',
353
359
  vault_card_loss_ack: 'Any funds in a vault that uses this key are lost for good if you reset it.',
354
360
  vault_reset_unknown_ack:
355
361
  "This device cannot confirm whether this key still secures a different profile's vault. I understand erasing it may destroy that key for good.",
@@ -1604,6 +1610,12 @@ const resources = {
1604
1610
  vault_card_unknown_title: '无法检查区块链',
1605
1611
  vault_card_unknown_body: '密钥未被更改。请重试。如果不检查就重置,它所打开的任何保险库都将永久丢失。',
1606
1612
  vault_card_retry: '重试',
1613
+ vault_card_progress: '已检查 {{percent}}%',
1614
+ vault_card_skip: '跳过检查',
1615
+ vault_card_skipped_title: '已跳过检查',
1616
+ vault_card_skipped_body: '未检查区块链。如果此密钥可打开某个保险库,重置后其中的资金将永久丢失。',
1617
+ vault_card_check: '检查区块链',
1618
+ vault_card_reason: '原因:{{reason}}',
1607
1619
  vault_card_loss_ack: '如果重置,使用此密钥的保险库中的任何资金都将永久丢失。',
1608
1620
  vault_reset_unknown_ack:
1609
1621
  '本设备无法确认这把密钥是否仍在为另一个身份的保险库提供保护。我明白抹除它可能会永久销毁那把密钥。',
@@ -2794,6 +2806,12 @@ const resources = {
2794
2806
  vault_card_unknown_body:
2795
2807
  'कुंजी में कोई बदलाव नहीं हुआ। दोबारा कोशिश करें। अगर आप जाँचे बिना इसे रीसेट करते हैं, तो इससे खुलने वाला कोई भी वॉल्ट हमेशा के लिए खो जाएगा।',
2796
2808
  vault_card_retry: 'पुनः प्रयास',
2809
+ vault_card_progress: '{{percent}}% जाँचा गया',
2810
+ vault_card_skip: 'जाँच छोड़ें',
2811
+ vault_card_skipped_title: 'जाँच छोड़ी गई',
2812
+ vault_card_skipped_body: 'ब्लॉकचेन की जाँच नहीं हुई। यदि यह कुंजी किसी वॉल्ट को खोलती है, तो रीसेट करने पर उसकी राशि हमेशा के लिए खो जाएगी।',
2813
+ vault_card_check: 'ब्लॉकचेन जाँचें',
2814
+ vault_card_reason: 'कारण: {{reason}}',
2797
2815
  vault_card_loss_ack:
2798
2816
  'अगर आप इसे रीसेट करते हैं, तो इस कुंजी का उपयोग करने वाले वॉल्ट में मौजूद सारे फ़ंड हमेशा के लिए खो जाएँगे।',
2799
2817
  vault_reset_unknown_ack:
@@ -4050,6 +4068,12 @@ const resources = {
4050
4068
  vault_card_unknown_body:
4051
4069
  'La llave no se modificó. Inténtalo de nuevo. Si la restableces sin comprobarlo, cualquier caja fuerte que abra se perderá para siempre.',
4052
4070
  vault_card_retry: 'Reintentar',
4071
+ vault_card_progress: '{{percent}}% comprobado',
4072
+ vault_card_skip: 'Omitir la comprobación',
4073
+ vault_card_skipped_title: 'Comprobación omitida',
4074
+ vault_card_skipped_body: 'No se comprobó la blockchain. Si esta llave abre una caja fuerte, sus fondos se pierden para siempre al restablecerla.',
4075
+ vault_card_check: 'Comprobar la blockchain',
4076
+ vault_card_reason: 'Motivo: {{reason}}',
4053
4077
  vault_card_loss_ack:
4054
4078
  'Si la restableces, cualquier fondo de una caja fuerte que use esta llave se perderá para siempre.',
4055
4079
  vault_reset_unknown_ack:
@@ -5333,6 +5357,12 @@ const resources = {
5333
5357
  vault_card_unknown_body:
5334
5358
  'La clé n’a pas été modifiée. Réessayez. Si vous la réinitialisez sans vérifier, tout coffre qu’elle ouvre sera perdu définitivement.',
5335
5359
  vault_card_retry: 'Réessayer',
5360
+ vault_card_progress: '{{percent}} % vérifié',
5361
+ vault_card_skip: 'Passer la vérification',
5362
+ vault_card_skipped_title: 'Vérification ignorée',
5363
+ vault_card_skipped_body: 'La blockchain n’a pas été vérifiée. Si cette clé ouvre un coffre, ses fonds sont perdus pour toujours si vous la réinitialisez.',
5364
+ vault_card_check: 'Vérifier la blockchain',
5365
+ vault_card_reason: 'Raison : {{reason}}',
5336
5366
  vault_card_loss_ack:
5337
5367
  'Si vous la réinitialisez, tous les fonds d’un coffre qui utilise cette clé seront perdus définitivement.',
5338
5368
  vault_reset_unknown_ack:
@@ -6600,6 +6630,12 @@ const resources = {
6600
6630
  vault_card_unknown_body:
6601
6631
  'لم يتم تغيير المفتاح. حاول مرة أخرى. إذا أعدت ضبطه دون فحص، فستضيع أي خزنة يفتحها إلى الأبد.',
6602
6632
  vault_card_retry: 'إعادة المحاولة',
6633
+ vault_card_progress: 'تم فحص {{percent}}%',
6634
+ vault_card_skip: 'تخطي الفحص',
6635
+ vault_card_skipped_title: 'تم تخطي الفحص',
6636
+ vault_card_skipped_body: 'لم يتم فحص البلوكتشين. إذا كان هذا المفتاح يفتح خزنة، فستضيع أموالها نهائيًا عند إعادة تعيينه.',
6637
+ vault_card_check: 'فحص البلوكتشين',
6638
+ vault_card_reason: 'السبب: {{reason}}',
6603
6639
  vault_card_loss_ack: 'ستضيع إلى الأبد أي أموال في خزنة تستخدم هذا المفتاح إذا أعدت ضبطه.',
6604
6640
  vault_reset_unknown_ack:
6605
6641
  'لا يمكن لهذا الجهاز التأكد مما إذا كان هذا المفتاح لا يزال يؤمّن خزنة ملف شخصي آخر. أفهم أن محوه قد يدمّر ذلك المفتاح نهائيًا.',
@@ -7824,6 +7860,12 @@ const resources = {
7824
7860
  vault_card_unknown_body:
7825
7861
  'A chave não foi alterada. Tente novamente. Se a repuser sem verificar, qualquer cofre que ela abra será perdido para sempre.',
7826
7862
  vault_card_retry: 'Tentar novamente',
7863
+ vault_card_progress: '{{percent}}% verificado',
7864
+ vault_card_skip: 'Pular a verificação',
7865
+ vault_card_skipped_title: 'Verificação pulada',
7866
+ vault_card_skipped_body: 'A blockchain não foi verificada. Se esta chave abre um cofre, os fundos dele serão perdidos para sempre ao redefini-la.',
7867
+ vault_card_check: 'Verificar a blockchain',
7868
+ vault_card_reason: 'Motivo: {{reason}}',
7827
7869
  vault_card_loss_ack: 'Se repuser esta chave, qualquer fundo num cofre que a use será perdido para sempre.',
7828
7870
  vault_reset_unknown_ack:
7829
7871
  'Este dispositivo não pode confirmar se esta chave ainda protege o cofre de outro perfil. Compreendo que apagá-la pode destruir essa chave para sempre.',
@@ -9096,6 +9138,12 @@ const resources = {
9096
9138
  vault_card_unknown_body:
9097
9139
  'কী পরিবর্তন করা হয়নি। আবার চেষ্টা করুন। যাচাই না করে রিসেট করলে এই কী যে ভল্ট খোলে তা চিরতরে হারিয়ে যাবে।',
9098
9140
  vault_card_retry: 'পুনরায় চেষ্টা',
9141
+ vault_card_progress: '{{percent}}% যাচাই হয়েছে',
9142
+ vault_card_skip: 'যাচাই বাদ দিন',
9143
+ vault_card_skipped_title: 'যাচাই বাদ দেওয়া হয়েছে',
9144
+ vault_card_skipped_body: 'ব্লকচেইন যাচাই করা হয়নি। এই কী কোনো ভল্ট খুললে, রিসেট করলে তার অর্থ চিরতরে হারিয়ে যাবে।',
9145
+ vault_card_check: 'ব্লকচেইন যাচাই করুন',
9146
+ vault_card_reason: 'কারণ: {{reason}}',
9099
9147
  vault_card_loss_ack: 'রিসেট করলে এই কী ব্যবহার করা ভল্টের সব ফান্ড চিরতরে হারিয়ে যাবে।',
9100
9148
  vault_reset_unknown_ack:
9101
9149
  'এই ডিভাইসটি নিশ্চিত করতে পারে না যে এই কীটি অন্য কোনো প্রোফাইলের ভল্ট এখনও সুরক্ষিত করছে কিনা। আমি বুঝেছি এটি মুছে ফেললে ওই কী চিরতরে নষ্ট হতে পারে।',
@@ -10345,6 +10393,12 @@ const resources = {
10345
10393
  vault_card_unknown_body:
10346
10394
  'Ключ не изменён. Повторите попытку. Если сбросить его без проверки, любое хранилище, которое он открывает, будет потеряно безвозвратно.',
10347
10395
  vault_card_retry: 'Повторить',
10396
+ vault_card_progress: 'Проверено {{percent}}%',
10397
+ vault_card_skip: 'Пропустить проверку',
10398
+ vault_card_skipped_title: 'Проверка пропущена',
10399
+ vault_card_skipped_body: 'Блокчейн не проверен. Если этот ключ открывает хранилище, его средства будут потеряны навсегда после сброса.',
10400
+ vault_card_check: 'Проверить блокчейн',
10401
+ vault_card_reason: 'Причина: {{reason}}',
10348
10402
  vault_card_loss_ack:
10349
10403
  'Если сбросить ключ, все средства в хранилище, использующем этот ключ, будут потеряны безвозвратно.',
10350
10404
  vault_reset_unknown_ack:
@@ -11611,6 +11665,12 @@ const resources = {
11611
11665
  vault_card_unknown_body:
11612
11666
  'Kunci tidak diubah. Coba lagi. Jika Anda menyetel ulang tanpa memeriksa, brankas apa pun yang dibukanya hilang selamanya.',
11613
11667
  vault_card_retry: 'Coba lagi',
11668
+ vault_card_progress: '{{percent}}% diperiksa',
11669
+ vault_card_skip: 'Lewati pemeriksaan',
11670
+ vault_card_skipped_title: 'Pemeriksaan dilewati',
11671
+ vault_card_skipped_body: 'Blockchain tidak diperiksa. Jika kunci ini membuka brankas, dananya hilang selamanya saat kunci direset.',
11672
+ vault_card_check: 'Periksa blockchain',
11673
+ vault_card_reason: 'Alasan: {{reason}}',
11614
11674
  vault_card_loss_ack:
11615
11675
  'Dana apa pun di brankas yang memakai kunci ini hilang selamanya jika Anda menyetel ulangnya.',
11616
11676
  vault_reset_unknown_ack:
@@ -12883,6 +12943,12 @@ const resources = {
12883
12943
  vault_card_unknown_body:
12884
12944
  '鍵は変更されていません。もう一度お試しください。確認せずにリセットすると、この鍵で開く保管庫は永久に失われます。',
12885
12945
  vault_card_retry: '再試行',
12946
+ vault_card_progress: '{{percent}}% 確認済み',
12947
+ vault_card_skip: '確認をスキップ',
12948
+ vault_card_skipped_title: '確認をスキップしました',
12949
+ vault_card_skipped_body: 'ブロックチェーンは確認されていません。この鍵で開く保管庫がある場合、リセットするとその資金は永久に失われます。',
12950
+ vault_card_check: 'ブロックチェーンを確認',
12951
+ vault_card_reason: '理由: {{reason}}',
12886
12952
  vault_card_loss_ack: 'この鍵を使う保管庫の資金は、リセットすると永久に失われます。',
12887
12953
  vault_reset_unknown_ack:
12888
12954
  'このデバイスでは、このキーが別のプロファイルの保管庫を保護しているかどうかを確認できません。消去するとその鍵が永久に失われる可能性があることを理解しました。',
@@ -14155,6 +14221,12 @@ const resources = {
14155
14221
  vault_card_unknown_body:
14156
14222
  'Klucz nie został zmieniony. Spróbuj ponownie. Jeśli zresetujesz go bez sprawdzenia, każdy sejf, który otwiera, przepadnie na zawsze.',
14157
14223
  vault_card_retry: 'Spróbuj ponownie',
14224
+ vault_card_progress: 'Sprawdzono {{percent}}%',
14225
+ vault_card_skip: 'Pomiń sprawdzanie',
14226
+ vault_card_skipped_title: 'Pominięto sprawdzanie',
14227
+ vault_card_skipped_body: 'Blockchain nie został sprawdzony. Jeśli ten klucz otwiera sejf, jego środki przepadną na zawsze po zresetowaniu klucza.',
14228
+ vault_card_check: 'Sprawdź blockchain',
14229
+ vault_card_reason: 'Powód: {{reason}}',
14158
14230
  vault_card_loss_ack:
14159
14231
  'Jeśli zresetujesz ten klucz, wszystkie środki w sejfie używającym tego klucza przepadną na zawsze.',
14160
14232
  vault_reset_unknown_ack:
@@ -15448,6 +15520,12 @@ const resources = {
15448
15520
  vault_card_unknown_body:
15449
15521
  'Der Schlüssel wurde nicht verändert. Versuch es erneut. Wenn du ihn ohne Prüfung zurücksetzt, ist jeder Tresor, den er öffnet, endgültig verloren.',
15450
15522
  vault_card_retry: 'Erneut versuchen',
15523
+ vault_card_progress: '{{percent}} % geprüft',
15524
+ vault_card_skip: 'Prüfung überspringen',
15525
+ vault_card_skipped_title: 'Prüfung übersprungen',
15526
+ vault_card_skipped_body: 'Die Blockchain wurde nicht geprüft. Wenn dieser Schlüssel einen Tresor öffnet, ist dessen Guthaben beim Zurücksetzen endgültig verloren.',
15527
+ vault_card_check: 'Blockchain prüfen',
15528
+ vault_card_reason: 'Grund: {{reason}}',
15451
15529
  vault_card_loss_ack:
15452
15530
  'Alle Guthaben in einem Tresor, der diesen Schlüssel nutzt, sind endgültig verloren, wenn du ihn zurücksetzt.',
15453
15531
  vault_reset_unknown_ack:
@@ -16718,6 +16796,12 @@ const resources = {
16718
16796
  vault_card_unknown_body:
16719
16797
  'Lyklinum var ekki breytt. Reyndu aftur. Ef þú endurstillir hann án þess að athuga glatast öll öryggishólf sem hann opnar fyrir fullt og allt.',
16720
16798
  vault_card_retry: 'Reyna aftur',
16799
+ vault_card_progress: '{{percent}}% athugað',
16800
+ vault_card_skip: 'Sleppa athuguninni',
16801
+ vault_card_skipped_title: 'Athugun sleppt',
16802
+ vault_card_skipped_body: 'Blokkarkeðjan var ekki athuguð. Ef þessi lykill opnar öryggishólf glatast féð í því fyrir fullt og allt þegar þú endurstillir hann.',
16803
+ vault_card_check: 'Athuga blokkarkeðjuna',
16804
+ vault_card_reason: 'Ástæða: {{reason}}',
16721
16805
  vault_card_loss_ack:
16722
16806
  'Ef þú endurstillir þennan lykil glatast allt fé í öryggishólfi sem notar hann fyrir fullt og allt.',
16723
16807
  vault_reset_unknown_ack:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/expo-wallet-toolbox",
3
- "version": "0.29.0",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
6
6
  "license": "Apache-2.0",
@@ -314,7 +314,17 @@ export interface EnrollWizardProps {
314
314
  * tell whether the card opens a vault: it treats that as "unknown" and a reset needs the affirmation.
315
315
  */
316
316
  cardGate?: {
317
- check: (serial: string) => Promise<VaultCardFunds>
317
+ /**
318
+ * `onProgress` gets how far the scan is (0 to 1) after each place it checks. `signal` is aborted when the
319
+ * person skips the check or the page closes: the check then ends soon, and its answer is ignored.
320
+ */
321
+ check: (
322
+ serial: string,
323
+ options?: {
324
+ onProgress?: (progress: { checked: number; fraction: number }) => void
325
+ signal?: AbortSignal
326
+ }
327
+ ) => Promise<VaultCardFunds>
318
328
  args: (
319
329
  result: VaultCardFunds | null,
320
330
  affirmed: boolean
@@ -400,6 +410,10 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({
400
410
  /** The chain check for the card on the reset page or the slot-occupied page. null while it runs. */
401
411
  const [cardCheck, setCardCheck] = useState<VaultCardFunds | null>(null)
402
412
  const [checkRound, setCheckRound] = useState(0)
413
+ /** How far the running check is, 0 to 1. null before the scan reports, or with no cardGate. */
414
+ const [cardProgress, setCardProgress] = useState<number | null>(null)
415
+ /** The running check: `skipCardCheck` stops it and drops its answer. */
416
+ const cardRunRef = useRef<{ live: boolean; stop: () => void } | null>(null)
403
417
  /** "Any funds in a vault that uses this key are lost for good if you reset it." */
404
418
  const [lossAck, setLossAck] = useState(false)
405
419
  /** A write (finalizeEnrollment / addVaultKey) is in flight. */
@@ -458,23 +472,43 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({
458
472
  sub === 'reset' || (sub === 'error' && keyError?.code === 'slot-occupied') ? keyError?.resetSerial : undefined
459
473
  useEffect(() => {
460
474
  setCardCheck(null)
475
+ setCardProgress(null)
461
476
  // a new check starts: the sentence ticked for an earlier result is not carried over to this one
462
477
  setLossAck(false)
463
478
  if (!gateSerial) return
464
- let live = true
465
479
  const unknown = (reason: string): VaultCardFunds => ({ kind: 'unknown', serial: gateSerial, reason, problems: 0 })
466
480
  if (!cardGate) {
467
481
  setCardCheck(unknown('no-check'))
468
482
  return
469
483
  }
470
- cardGate.check(gateSerial).then(
471
- result => live && setCardCheck(result),
472
- () => live && setCardCheck(unknown('check-failed'))
473
- )
484
+ const controller = new AbortController()
485
+ const run = { live: true, stop: () => controller.abort() }
486
+ cardRunRef.current = run
487
+ cardGate
488
+ .check(gateSerial, {
489
+ onProgress: progress => run.live && setCardProgress(progress.fraction),
490
+ signal: controller.signal
491
+ })
492
+ .then(
493
+ result => run.live && setCardCheck(result),
494
+ () => run.live && setCardCheck(unknown('check-failed'))
495
+ )
474
496
  return () => {
475
- live = false
497
+ // the page closed or a new check started: this scan stops sending requests, and its answer is dropped
498
+ run.live = false
499
+ run.stop()
500
+ if (cardRunRef.current === run) cardRunRef.current = null
476
501
  }
477
502
  }, [gateSerial, cardGate, checkRound])
503
+ /** The person does not wait for the check. The answer is "unknown": a reset still needs the loss sentence. */
504
+ const skipCardCheck = () => {
505
+ const run = cardRunRef.current
506
+ if (run) {
507
+ run.live = false
508
+ run.stop()
509
+ }
510
+ if (gateSerial) setCardCheck({ kind: 'unknown', serial: gateSerial, reason: 'skipped', problems: 0 })
511
+ }
478
512
  /** What resetPivApplication takes, or null while the card may not be reset or replaced. */
479
513
  const gateArgs: { fundsClearance: VaultResetClearance } | { acknowledgeFundsLoss: true } | null = cardGate
480
514
  ? cardGate.args(cardCheck, lossAck)
@@ -1149,7 +1183,27 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({
1149
1183
  const cardGateBlock = (
1150
1184
  <>
1151
1185
  {cardCheck === null && (
1152
- <BalancedText style={[styles.p, { color: colors.textSecondary }]}>{t('vault_card_checking')}</BalancedText>
1186
+ <>
1187
+ <BalancedText style={[styles.p, { color: colors.textSecondary }]}>{t('vault_card_checking')}</BalancedText>
1188
+ {(() => {
1189
+ const percent = Math.floor((cardProgress ?? 0) * 100)
1190
+ return (
1191
+ <View
1192
+ style={styles.progress}
1193
+ accessibilityRole="progressbar"
1194
+ accessibilityValue={{ min: 0, max: 100, now: percent }}
1195
+ >
1196
+ <View style={[styles.progressTrack, { backgroundColor: colors.backgroundSecondary }]}>
1197
+ <View style={[styles.progressFill, { backgroundColor: colors.accent, width: `${percent}%` }]} />
1198
+ </View>
1199
+ <Text style={[styles.progressLabel, { color: colors.textSecondary }]}>
1200
+ {t('vault_card_progress', { percent })}
1201
+ </Text>
1202
+ </View>
1203
+ )
1204
+ })()}
1205
+ <ActionButton label={t('vault_card_skip')} variant="outline" onPress={skipCardCheck} />
1206
+ </>
1153
1207
  )}
1154
1208
  {cardCheck?.kind === 'funds' && (
1155
1209
  <>
@@ -1162,10 +1216,30 @@ export const EnrollWizard: React.FC<EnrollWizardProps> = ({
1162
1216
  )}
1163
1217
  </>
1164
1218
  )}
1165
- {cardCheck?.kind === 'unknown' && (
1219
+ {cardCheck?.kind === 'unknown' && cardCheck.reason === 'skipped' && (
1220
+ <>
1221
+ <Text style={[styles.h1, { color: colors.textPrimary }]}>{t('vault_card_skipped_title')}</Text>
1222
+ <BalancedText style={[styles.p, { color: colors.textSecondary }]}>
1223
+ {t('vault_card_skipped_body')}
1224
+ </BalancedText>
1225
+ <ActionButton
1226
+ label={t('vault_card_check')}
1227
+ variant="outline"
1228
+ onPress={() => setCheckRound(round => round + 1)}
1229
+ />
1230
+ </>
1231
+ )}
1232
+ {cardCheck?.kind === 'unknown' && cardCheck.reason !== 'skipped' && (
1166
1233
  <>
1167
1234
  <Text style={[styles.h1, { color: colors.textPrimary }]}>{t('vault_card_unknown_title')}</Text>
1168
- <BalancedText style={[styles.p, { color: colors.textSecondary }]}>{t('vault_card_unknown_body')}</BalancedText>
1235
+ <BalancedText style={[styles.p, { color: colors.textSecondary }]}>
1236
+ {t('vault_card_unknown_body')}
1237
+ </BalancedText>
1238
+ {cardCheck.reason !== 'no-check' && (
1239
+ <Text style={[styles.warn, { color: colors.textTertiary }]}>
1240
+ {t('vault_card_reason', { reason: cardCheck.reason })}
1241
+ </Text>
1242
+ )}
1169
1243
  {cardGate && (
1170
1244
  <ActionButton
1171
1245
  label={t('vault_card_retry')}