@bsv/expo-wallet-toolbox 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -21,7 +21,7 @@ app's own TypeScript config transpile it like any other workspace source.
21
21
  ## Install
22
22
 
23
23
  ```bash
24
- npm install @bsv/expo-wallet-toolbox react-native-localpay-transport react-native-engine-native react-native-secp-native react-native-nitro-modules
24
+ npm install @bsv/expo-wallet-toolbox @bsv/react-native-localpay-transport react-native-engine-native react-native-secp-native react-native-nitro-modules
25
25
  ```
26
26
 
27
27
  `react-native-yubikey` is optional — the vault subsystem
@@ -119,14 +119,15 @@ Expo SDK line.
119
119
  | Package | Notes |
120
120
  | --- | --- |
121
121
  | `react-native-nitro-modules` | ^0.35.2. Nitro codegen runtime the three below build on. |
122
- | `react-native-localpay-transport` | Local WiFi/Bluetooth P2P payment transport. |
122
+ | `@bsv/react-native-localpay-transport` | Local WiFi/Bluetooth/BLE P2P payment transport. Published independently — see `packages/react-native-localpay-transport`. |
123
123
  | `react-native-engine-native` | Native wallet-toolbox engine bindings. |
124
124
  | `react-native-secp-native` | Native secp256k1 signing. |
125
125
 
126
- These three ship as sibling `packages/` in this repo and are not yet
127
- published to npm independently — when they are, pin to their published
128
- version; each declares `react-native` and `react-native-nitro-modules`
129
- as its own peer dependencies.
126
+ `react-native-engine-native` and `react-native-secp-native` ship as sibling
127
+ `packages/` in this repo and are not yet published to npm independently —
128
+ when they are, pin to their published version. Each of the three declares
129
+ `react-native` and `react-native-nitro-modules` as its own peer
130
+ dependencies.
130
131
 
131
132
  ### Optional
132
133
 
@@ -355,7 +356,7 @@ repo's:
355
356
  ```
356
357
 
357
358
  Required for the Nitro/xcframework native modules
358
- (`react-native-localpay-transport`, `react-native-engine-native`,
359
+ (`@bsv/react-native-localpay-transport`, `react-native-engine-native`,
359
360
  `react-native-secp-native`, `react-native-yubikey`) to build on iOS.
360
361
 
361
362
  ### `metro.config.js`
@@ -378,6 +378,9 @@ export const WalletManagersContext = createContext<WalletManagersSlice>({
378
378
  walletBuilding: false
379
379
  })
380
380
 
381
+ /** Subscribes to just the managers/storage slice — see WalletManagersContext above. */
382
+ export const useWalletManagers = (): WalletManagersSlice => useContext(WalletManagersContext)
383
+
381
384
  type PermissionType = 'identity' | 'protocol' | 'renewal' | 'basket'
382
385
 
383
386
  type BasketAccessRequest = {
package/core/index.ts CHANGED
@@ -279,17 +279,21 @@ export * from './hooks/useHaptics'
279
279
  export * from './hooks/useConfirmationSound'
280
280
 
281
281
  // WalletContext — the core hub wiring together storage, headers, localpay,
282
- // backup, vault-ceremony bridging, and monitor tasks. Only its two actually-
283
- // consumed exports are re-exported here (WalletContextProvider, useWallet) —
284
- // its narrow selector hooks (useWalletStatus, useWalletQueues,
285
- // useTxStatusVersion), WalletManagersContext, and the various *Value/*Slice
286
- // types have zero current consumers anywhere in the app, so they are left
287
- // off the barrel for now (same "only what's actually used" convention as
288
- // Task 3's motion.ts/useThemeStyles.tsx) — reachable via a relative import
289
- // from inside the package if a future task needs them, and easy to add here
290
- // once a real consumer exists. WalletContextProvider takes an optional
291
- // onToast prop (see WalletContext.tsx's WalletContextToast type) rather than
292
- // importing a ui Toast component directly — core must never import from ui,
293
- // same boundary as VaultContext's onToast above.
294
- export { WalletContextProvider, useWallet, WalletContext } from './context/WalletContext'
282
+ // backup, vault-ceremony bridging, and monitor tasks. Its narrow selector
283
+ // hooks (useWalletStatus, useWalletQueues, useTxStatusVersion) and the
284
+ // various *Value/*Slice types still have zero current consumers anywhere in
285
+ // the app, so they stay off the barrel for now (same "only what's actually
286
+ // used" convention as Task 3's motion.ts/useThemeStyles.tsx) — reachable via
287
+ // a relative import from inside the package if a future task needs them.
288
+ // WalletManagersContext/useWalletManagers ARE exported: a host embedding the
289
+ // wallet as a sub-screen inside a larger app (e.g. a browser driving a
290
+ // BRC-100 bridge from its own WebView tabs) needs the manager/storage handle
291
+ // without mounting a second WalletContextProvider — a second provider means
292
+ // a second createWalletMonitor and a second StorageExpoSQLite on the same
293
+ // .db file, which is a SIGSEGV waiting to happen. WalletContextProvider
294
+ // takes an optional onToast prop (see WalletContext.tsx's WalletContextToast
295
+ // type) rather than importing a ui Toast component directly — core must
296
+ // never import from ui, same boundary as VaultContext's onToast above.
297
+ export { WalletContextProvider, useWallet, WalletContext, WalletManagersContext, useWalletManagers } from './context/WalletContext'
298
+ export type { WalletManagersSlice } from './context/WalletContext'
295
299
  export { usePermissionQueue } from './hooks/usePermissionQueue'
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import { Platform } from 'react-native'
20
20
  import NetInfo, { type NetInfoState } from '@react-native-community/netinfo'
21
- import { getLocalPayBleTransport } from 'react-native-localpay-transport'
21
+ import { getLocalPayBleTransport } from '@bsv/react-native-localpay-transport'
22
22
  import {
23
23
  HINT_BT,
24
24
  HINT_NET,
@@ -1,4 +1,4 @@
1
- import { getLocalPayTransport } from 'react-native-localpay-transport'
1
+ import { getLocalPayTransport } from '@bsv/react-native-localpay-transport'
2
2
  import { makeSocketTransport } from './socket'
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { Platform } from 'react-native'
2
- import { getLocalPayBleTransport, type LocalPayBleTransport } from 'react-native-localpay-transport'
2
+ import { getLocalPayBleTransport, type LocalPayBleTransport } from '@bsv/react-native-localpay-transport'
3
3
  import { unsealFrame, sealFrame, type PaymentFrame } from '../codec'
4
4
  import { instanceName, type Session } from '../session'
5
5
  import type { Ack, LocalPaymentTransport, ReceivedFrame } from '../types'
@@ -1,4 +1,4 @@
1
- import { getLocalPayTransport } from 'react-native-localpay-transport'
1
+ import { getLocalPayTransport } from '@bsv/react-native-localpay-transport'
2
2
  import { makeSocketTransport } from './socket'
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { Platform } from 'react-native'
2
- import { getLocalPayBleTransport, getLocalPayTransport } from 'react-native-localpay-transport'
2
+ import { getLocalPayBleTransport, getLocalPayTransport } from '@bsv/react-native-localpay-transport'
3
3
  import { CAP_AWDL, CAP_BLE, CAP_BLE_SCAN, CAP_NEARBY, HINT_BT, RUNG_MASK, type Session } from '../session'
4
4
  import type { BluetoothState } from '../deviceCaps'
5
5
 
@@ -1,4 +1,4 @@
1
- import type { LocalPayTransport } from 'react-native-localpay-transport'
1
+ import type { LocalPayTransport } from '@bsv/react-native-localpay-transport'
2
2
  import { sealFrame, unsealFrame, type PaymentFrame } from '../codec'
3
3
  import { instanceName, type Session } from '../session'
4
4
  import {
@@ -9,7 +9,7 @@
9
9
  * makes a crash recoverable.
10
10
  */
11
11
  import { PeerPayClient, type IncomingPayment } from '@bsv/message-box-client'
12
- import { Beef, P2PKH, PublicKey, Random, Transaction, Utils } from '@bsv/sdk'
12
+ import { Beef, P2PKH, PublicKey, Random, Transaction, Utils, type AtomicBEEF } from '@bsv/sdk'
13
13
  import { BRC29_PROTOCOL_ID } from './address'
14
14
  import {
15
15
  getOutboxEntries,
@@ -169,7 +169,7 @@ async function acknowledgeCredited(
169
169
  }
170
170
 
171
171
  /** The AtomicBEEF subject txid, or undefined if the bytes will not parse. */
172
- function safeAtomicTxid(tx: number[]): string | undefined {
172
+ function safeAtomicTxid(tx: AtomicBEEF): string | undefined {
173
173
  try {
174
174
  return Beef.fromBinary(Array.from(tx)).atomicTxid
175
175
  } catch {
@@ -304,7 +304,7 @@ export async function autoAcceptInbox<T extends { messageId: string | number }>(
304
304
  */
305
305
  export async function discardIncoming(
306
306
  client: Pick<PeerPayClient, 'acknowledgeMessage' | 'sendMessage'>,
307
- payment: { messageId: string; sender?: string; token?: { transaction?: number[] } },
307
+ payment: { messageId: string; sender?: string; token?: { transaction?: AtomicBEEF } },
308
308
  reason: ResendReason = 'uncreditible'
309
309
  ): Promise<void> {
310
310
  const txid = payment.token?.transaction ? safeAtomicTxid(payment.token.transaction) : undefined
@@ -1,7 +1,7 @@
1
- import { Transaction } from '@bsv/sdk'
1
+ import { Transaction, type AtomicBEEF } from '@bsv/sdk'
2
2
 
3
3
  export function satoshisFromToken(token: {
4
- transaction: number[]
4
+ transaction: AtomicBEEF
5
5
  outputIndex?: number
6
6
  amount?: number
7
7
  }): { satoshis: number; claimedAgrees: boolean } | undefined {
@@ -1,5 +1,3 @@
1
- import AsyncStorage from '@react-native-async-storage/async-storage'
2
-
3
1
  /**
4
2
  * Wallet database filename registry.
5
3
  *
@@ -81,6 +79,22 @@ export function selectLatestDb(filenames: string[]): string {
81
79
 
82
80
  // ── AsyncStorage-backed registry ────────────────────────────────────────────
83
81
 
82
+ // Required lazily, on first call, rather than imported statically — this
83
+ // file is barrel-exported from the package root, and a static top-level
84
+ // `import` of a native module gets eagerly evaluated for every consumer of
85
+ // the barrel, which breaks a plain `jest` host that never touches the
86
+ // registry (no native module to resolve). Same class of issue documented on
87
+ // useHaptics.ts and services/vault/driver.ts/random.ts's lazy requires.
88
+ type AsyncStorageModule = typeof import('@react-native-async-storage/async-storage')['default']
89
+ let asyncStorage: AsyncStorageModule | undefined
90
+ function getAsyncStorage(): AsyncStorageModule {
91
+ if (!asyncStorage) {
92
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
93
+ asyncStorage = require('@react-native-async-storage/async-storage').default as AsyncStorageModule
94
+ }
95
+ return asyncStorage
96
+ }
97
+
84
98
  function registryKey(keySuffix: string, chain: string): string {
85
99
  return `walletDbs-${keySuffix}-${chain}net`
86
100
  }
@@ -89,7 +103,7 @@ function registryKey(keySuffix: string, chain: string): string {
89
103
  * Return all registered wallet DB filenames for the given identity + chain.
90
104
  */
91
105
  export async function getRegisteredDbs(keySuffix: string, chain: string): Promise<string[]> {
92
- const raw = await AsyncStorage.getItem(registryKey(keySuffix, chain))
106
+ const raw = await getAsyncStorage().getItem(registryKey(keySuffix, chain))
93
107
  if (!raw) return []
94
108
  try {
95
109
  const arr = JSON.parse(raw)
@@ -106,5 +120,5 @@ export async function registerDb(keySuffix: string, chain: string, filename: str
106
120
  const existing = await getRegisteredDbs(keySuffix, chain)
107
121
  if (existing.includes(filename)) return
108
122
  existing.push(filename)
109
- await AsyncStorage.setItem(registryKey(keySuffix, chain), JSON.stringify(existing))
123
+ await getAsyncStorage().setItem(registryKey(keySuffix, chain), JSON.stringify(existing))
110
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/expo-wallet-toolbox",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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": "SEE LICENSE IN LICENSE.txt",
@@ -22,26 +22,29 @@
22
22
  ],
23
23
  "main": "core/index.ts",
24
24
  "types": "core/index.ts",
25
- "files": ["core", "ui", "assets"],
25
+ "files": [
26
+ "core",
27
+ "ui",
28
+ "assets"
29
+ ],
26
30
  "peerDependencies": {
27
- "react": "^19.2.0",
28
- "react-native": "^0.83.6",
29
- "expo-router": "~55.0.16",
30
-
31
- "@bsv/sdk": "^2.4.1",
32
- "@bsv/wallet-toolbox-mobile": "^2.4.3",
33
- "@bsv/btms-permission-module": "^1.1.0",
34
31
  "@bsv/air-gap": "^0.1.1",
35
32
  "@bsv/backup-cache-client": "^0.1.0",
33
+ "@bsv/btms-permission-module": "^1.1.0",
36
34
  "@bsv/message-box-client": "^2.2.1",
35
+ "@bsv/react-native-localpay-transport": "*",
36
+ "@bsv/sdk": "^2.4.1",
37
37
  "@bsv/templates": "^1.10.0",
38
+ "@bsv/wallet-toolbox-mobile": "^2.4.3",
39
+ "@expo/vector-icons": "^15.0.3",
38
40
  "@noble/curves": "^2.3.0",
39
- "qrcode": "^1.5.4",
40
-
41
- "expo-sqlite": "~55.0.16",
42
- "expo-secure-store": "~55.0.14",
43
- "expo-camera": "~55.0.19",
41
+ "@react-native-async-storage/async-storage": "^2.2.0",
42
+ "@react-native-clipboard/clipboard": "^1.16.2",
43
+ "@react-native-community/netinfo": "^11.5.2",
44
+ "date-fns": "^4.1.0",
44
45
  "expo-audio": "~55.0.16",
46
+ "expo-blur": "~55.0.14",
47
+ "expo-camera": "~55.0.19",
45
48
  "expo-clipboard": "~55.0.13",
46
49
  "expo-crypto": "~55.0.15",
47
50
  "expo-device": "~55.0.17",
@@ -51,36 +54,33 @@
51
54
  "expo-local-authentication": "~55.0.14",
52
55
  "expo-localization": "~55.0.15",
53
56
  "expo-print": "~55.0.15",
57
+ "expo-router": "~55.0.16",
58
+ "expo-secure-store": "~55.0.14",
54
59
  "expo-sharing": "~55.0.19",
60
+ "expo-sqlite": "~55.0.16",
55
61
  "expo-status-bar": "~55.0.6",
56
- "expo-blur": "~55.0.14",
57
- "@expo/vector-icons": "^15.0.3",
58
-
59
- "@react-native-async-storage/async-storage": "^2.2.0",
60
- "@react-native-clipboard/clipboard": "^1.16.2",
61
- "@react-native-community/netinfo": "^11.5.2",
62
+ "i18next": "^25.2.1",
63
+ "mobx": "^6.13.7",
64
+ "mobx-react-lite": "^4.1.0",
65
+ "qrcode": "^1.5.4",
66
+ "react": "^19.2.0",
67
+ "react-i18next": "^15.5.3",
68
+ "react-native": "^0.83.6",
69
+ "react-native-engine-native": "*",
62
70
  "react-native-gesture-handler": "~2.30.0",
63
71
  "react-native-localize": "^3.4.1",
72
+ "react-native-nitro-modules": "^0.35.2",
64
73
  "react-native-qrcode-svg": "^6.3.15",
65
74
  "react-native-reanimated": "^4.2.1",
66
75
  "react-native-safe-area-context": "~5.6.0",
67
- "react-native-svg": "^15.15.3",
68
- "react-native-sse": "^1.2.1",
69
-
70
- "mobx": "^6.13.7",
71
- "mobx-react-lite": "^4.1.0",
72
- "i18next": "^25.2.1",
73
- "react-i18next": "^15.5.3",
74
- "date-fns": "^4.1.0",
75
-
76
- "react-native-nitro-modules": "^0.35.2",
77
- "react-native-localpay-transport": "*",
78
- "react-native-engine-native": "*",
79
76
  "react-native-secp-native": "*",
80
-
77
+ "react-native-sse": "^1.2.1",
78
+ "react-native-svg": "^15.15.3",
81
79
  "react-native-yubikey": "*"
82
80
  },
83
81
  "peerDependenciesMeta": {
84
- "react-native-yubikey": { "optional": true }
82
+ "react-native-yubikey": {
83
+ "optional": true
84
+ }
85
85
  }
86
86
  }
@@ -122,7 +122,10 @@ function loadQRCode(): QRCodeComponent {
122
122
  */
123
123
  const HISTORY_POLL_MS = 5000
124
124
 
125
- export default function AddressReceive({ initialSats }: { initialSats?: number } = {}) {
125
+ export default function AddressReceive({
126
+ initialSats,
127
+ dismissTo = '/'
128
+ }: { initialSats?: number; dismissTo?: string } = {}) {
126
129
  const { t } = useTranslation()
127
130
  const { colors } = useTheme()
128
131
  const Ionicons = loadIonicons()
@@ -436,7 +439,12 @@ export default function AddressReceive({ initialSats }: { initialSats?: number }
436
439
  {/* The moment money arrives. A Modal, so it covers the header too, and it
437
440
  stays until acknowledged. */}
438
441
  {received && (
439
- <ReceivedOverlay amount={received.amount} count={received.count} onDismiss={() => setReceived(null)} />
442
+ <ReceivedOverlay
443
+ amount={received.amount}
444
+ count={received.count}
445
+ onDismiss={() => setReceived(null)}
446
+ dismissTo={dismissTo}
447
+ />
440
448
  )}
441
449
  </ScrollView>
442
450
  )
@@ -346,7 +346,10 @@ function AttentionRow({
346
346
  )
347
347
  }
348
348
 
349
- export default function HandleReceive({ initialSats }: { initialSats?: number } = {}) {
349
+ export default function HandleReceive({
350
+ initialSats,
351
+ dismissTo = '/'
352
+ }: { initialSats?: number; dismissTo?: string } = {}) {
350
353
  const { t } = useTranslation()
351
354
  const { colors } = useTheme()
352
355
  const Ionicons = loadIonicons()
@@ -754,7 +757,12 @@ export default function HandleReceive({ initialSats }: { initialSats?: number }
754
757
 
755
758
  {/* The moment money arrives. A Modal, so it covers the header too. */}
756
759
  {received && (
757
- <ReceivedOverlay amount={received.amount} count={received.count} onDismiss={() => setReceived(null)} />
760
+ <ReceivedOverlay
761
+ amount={received.amount}
762
+ count={received.count}
763
+ onDismiss={() => setReceived(null)}
764
+ dismissTo={dismissTo}
765
+ />
758
766
  )}
759
767
  </ScrollView>
760
768
  )
@@ -387,9 +387,17 @@ export interface NearbyFlowProps {
387
387
  initialSession?: Session
388
388
  /** Payee only: mint immediately for this amount (undefined = open request). Skips receive_amount. */
389
389
  initialRequest?: { sats?: number }
390
+ /** Where the post-payment overlay and an exited QR flow send the user. Defaults to `/`. */
391
+ dismissTo?: string
390
392
  }
391
393
 
392
- export default function NearbyFlow({ role: initialRole, onExit, initialSession, initialRequest }: NearbyFlowProps) {
394
+ export default function NearbyFlow({
395
+ role: initialRole,
396
+ onExit,
397
+ initialSession,
398
+ initialRequest,
399
+ dismissTo = '/'
400
+ }: NearbyFlowProps) {
393
401
  const { t } = useTranslation()
394
402
  const { colors } = useTheme()
395
403
  const Ionicons = loadIonicons()
@@ -1591,10 +1599,10 @@ export default function NearbyFlow({ role: initialRole, onExit, initialSession,
1591
1599
  // — and its Resend and Cancel — actually is.
1592
1600
  reset()
1593
1601
  onExit()
1594
- router.dismissTo('/')
1602
+ router.dismissTo(dismissTo)
1595
1603
  return leavingScreen
1596
1604
  },
1597
- [completeQrDelivery, reset, onExit, router]
1605
+ [completeQrDelivery, reset, onExit, router, dismissTo]
1598
1606
  )
1599
1607
 
1600
1608
  useEffect(() => {
@@ -2301,6 +2309,7 @@ export default function NearbyFlow({ role: initialRole, onExit, initialSession,
2301
2309
  // The overlay navigates to the wallet after this; goBack ends the
2302
2310
  // session and resets the cell so /pay is not left mid-flow beneath.
2303
2311
  onDismiss={goBack}
2312
+ dismissTo={dismissTo}
2304
2313
  />
2305
2314
  )}
2306
2315
  </View>
@@ -70,6 +70,12 @@ export interface ReceivedOverlayProps {
70
70
  direction?: 'received' | 'sent'
71
71
  /** Sent only: the resolved counterparty (name, handle, or abbreviated address). */
72
72
  recipientName?: string
73
+ /**
74
+ * Where acknowledging the overlay sends the user. Defaults to `/`, the
75
+ * wallet's own home route. A host that embeds the wallet as a sub-screen
76
+ * (rather than as the app root) should pass its own wallet-home route here.
77
+ */
78
+ dismissTo?: string
73
79
  /**
74
80
  * Acknowledged. The only way this screen closes. Clean up local state here —
75
81
  * the overlay itself then returns the user to the wallet, so the updated
@@ -84,6 +90,7 @@ export default function PaymentSuccessOverlay({
84
90
  broadcast = true,
85
91
  direction = 'received',
86
92
  recipientName,
93
+ dismissTo = '/',
87
94
  onDismiss
88
95
  }: ReceivedOverlayProps) {
89
96
  const sent = direction === 'sent'
@@ -127,8 +134,8 @@ export default function PaymentSuccessOverlay({
127
134
  */
128
135
  const acknowledge = useCallback(() => {
129
136
  onDismiss()
130
- router.dismissTo('/')
131
- }, [onDismiss])
137
+ router.dismissTo(dismissTo)
138
+ }, [onDismiss, dismissTo])
132
139
 
133
140
  const settleIn = reducedMotion
134
141
  ? undefined
@@ -188,6 +188,8 @@ export interface UniversalSendProps {
188
188
  openScannerOnMount?: boolean
189
189
  /** A nearby-session code was scanned. The Pay screen swaps this form for NearbyFlow. */
190
190
  onNearbySession: (session: Session) => void
191
+ /** Where the post-payment overlay sends the user. Defaults to `/`. */
192
+ dismissTo?: string
191
193
  }
192
194
 
193
195
  export default function UniversalSend({
@@ -195,7 +197,8 @@ export default function UniversalSend({
195
197
  initialSats,
196
198
  initialNotice,
197
199
  openScannerOnMount = false,
198
- onNearbySession
200
+ onNearbySession,
201
+ dismissTo = '/'
199
202
  }: UniversalSendProps) {
200
203
  const { t } = useTranslation()
201
204
  const { colors } = useTheme()
@@ -570,6 +573,7 @@ export default function UniversalSend({
570
573
  amount={sent.amount}
571
574
  recipientName={sent.recipient}
572
575
  onDismiss={() => setSent(null)}
576
+ dismissTo={dismissTo}
573
577
  />
574
578
  )}
575
579
  </ScrollView>
@@ -10,7 +10,7 @@
10
10
  * ── Why there is no separate "device found" ──
11
11
  *
12
12
  * The AWDL transport surfaces exactly two things to JS: a decoded frame, or an
13
- * error (see packages/react-native-localpay-transport — `startListening`,
13
+ * error (see @bsv/react-native-localpay-transport — `startListening`,
14
14
  * `sendFrame`). There is no connection callback, so neither side can observe
15
15
  * discovery separately from the TLS-PSK handshake. By the time anything reaches
16
16
  * JS, the peer has been found AND the encrypted channel has carried real bytes.
package/ui/index.ts CHANGED
@@ -83,6 +83,7 @@ export {
83
83
  // Pay screen (Task 21 — extracted from app/pay.tsx) and the online-status hook
84
84
  // it, and several pay cells above, depend on.
85
85
  export { PayScreen } from './screens/PayScreen'
86
+ export type { PayScreenProps } from './screens/PayScreen'
86
87
  export { useOnline } from './hooks/useOnline'
87
88
 
88
89
  // Settings + wallet-config screens (Task 22 — extracted from app/settings.tsx
@@ -92,7 +92,17 @@ const METHOD_TITLE_KEYS: Record<RequestMethod, string> = {
92
92
  const isRequestMethod = (v: string | undefined): v is RequestMethod =>
93
93
  v === 'get-nearby' || v === 'get-handle' || v === 'get-address'
94
94
 
95
- export function PayScreen() {
95
+ export interface PayScreenProps {
96
+ /**
97
+ * Where a finished payment (or "back" from the form) sends the user.
98
+ * Defaults to `/`, the wallet's own home route. A host that mounts this
99
+ * screen somewhere other than the app root — e.g. a browser app that puts
100
+ * the wallet at `/wallet` — should pass that route here instead.
101
+ */
102
+ dismissTo?: string
103
+ }
104
+
105
+ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
96
106
  const { t } = useTranslation()
97
107
  const { colors } = useTheme()
98
108
  const Ionicons = loadIonicons()
@@ -321,8 +331,8 @@ export function PayScreen() {
321
331
  * discarding them.
322
332
  */
323
333
  const goBack = useCallback(() => {
324
- router.dismissTo('/')
325
- }, [])
334
+ router.dismissTo(dismissTo)
335
+ }, [dismissTo])
326
336
 
327
337
  const onNearbySession = useCallback((session: Session) => {
328
338
  // One camera raise per deep link; a cancelled advisory must not re-open it.
@@ -355,7 +365,9 @@ export function PayScreen() {
355
365
  const body = () => {
356
366
  if (direction === 'pay') {
357
367
  if (nearbySession) {
358
- return nearbyAdvisorySeen ? <NearbyFlow role="payer" initialSession={nearbySession} onExit={goBack} /> : null
368
+ return nearbyAdvisorySeen ? (
369
+ <NearbyFlow role="payer" initialSession={nearbySession} onExit={goBack} dismissTo={dismissTo} />
370
+ ) : null
359
371
  }
360
372
  return (
361
373
  <>
@@ -366,6 +378,7 @@ export function PayScreen() {
366
378
  initialNotice={peerPayNotice}
367
379
  openScannerOnMount={scanOnMount}
368
380
  onNearbySession={onNearbySession}
381
+ dismissTo={dismissTo}
369
382
  />
370
383
  </>
371
384
  )
@@ -373,11 +386,13 @@ export function PayScreen() {
373
386
  const sats = requestSatsFrom(requestSats)
374
387
  switch (method) {
375
388
  case 'get-nearby':
376
- return nearbyAdvisorySeen ? <NearbyFlow role="payee" initialRequest={{ sats }} onExit={goBack} /> : null
389
+ return nearbyAdvisorySeen ? (
390
+ <NearbyFlow role="payee" initialRequest={{ sats }} onExit={goBack} dismissTo={dismissTo} />
391
+ ) : null
377
392
  case 'get-handle':
378
- return <HandleReceive initialSats={sats} />
393
+ return <HandleReceive initialSats={sats} dismissTo={dismissTo} />
379
394
  case 'get-address':
380
- return <AddressReceive initialSats={sats} />
395
+ return <AddressReceive initialSats={sats} dismissTo={dismissTo} />
381
396
  default:
382
397
  return (
383
398
  <>