@bsv/expo-wallet-toolbox 0.11.8 → 0.13.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 (62) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/core/backup/erase.ts +7 -1
  3. package/core/backup/preference.ts +12 -4
  4. package/core/backup/push.ts +8 -1
  5. package/core/backup/status.ts +6 -2
  6. package/core/config.tsx +1 -1
  7. package/core/context/WalletContext.tsx +904 -184
  8. package/core/i18n/translations.tsx +496 -12
  9. package/core/identity/handleRegistry/registration.ts +57 -3
  10. package/core/index.ts +26 -1
  11. package/core/mandala/createRuntime.ts +3 -3
  12. package/core/mandala/runtime.ts +7 -2
  13. package/core/mnemonicWallet.ts +46 -40
  14. package/core/monitor/MonitorSupervisor.ts +35 -1
  15. package/core/monitor/TaskCreditInbox.ts +24 -0
  16. package/core/pay/beefRepair.ts +8 -3
  17. package/core/pay/rails/address.ts +43 -3
  18. package/core/pay/rails/handle.ts +5 -3
  19. package/core/pay/sweeper.ts +39 -4
  20. package/core/peerpay/outbox.ts +11 -1
  21. package/core/profiles/assertProfileEmpty.ts +287 -0
  22. package/core/profiles/discovery.ts +84 -0
  23. package/core/profiles/profileLabel.ts +13 -0
  24. package/core/profiles/profileStore.ts +265 -0
  25. package/core/profiles/purgeProfile.ts +76 -0
  26. package/core/profiles/removeProfile.ts +257 -0
  27. package/core/push/events.ts +189 -0
  28. package/core/push/identities.ts +55 -0
  29. package/core/push/profilePush.ts +143 -0
  30. package/core/push/pushAdvisory.ts +33 -0
  31. package/core/push/registration.ts +391 -0
  32. package/core/push/types.ts +35 -0
  33. package/core/services/arcTokenStorage.ts +17 -2
  34. package/core/services/vault/transfers.ts +6 -1
  35. package/core/services/vault/vaultStore.ts +16 -3
  36. package/core/stores/ConnectionStore.ts +11 -7
  37. package/core/toolboxConfig.ts +31 -4
  38. package/core/userAvatar.ts +12 -5
  39. package/core/walletDbRegistry.ts +73 -0
  40. package/package.json +1 -1
  41. package/ui/backupShares.ts +2 -3
  42. package/ui/components/pay/HandleReceive.tsx +141 -16
  43. package/ui/components/pay/MessageBoxConfig.tsx +6 -5
  44. package/ui/components/pay/NotificationAdvisoryModal.tsx +124 -0
  45. package/ui/components/ui/PencilEditField.tsx +5 -2
  46. package/ui/components/wallet/Balance.tsx +3 -1
  47. package/ui/components/wallet/ProfileButton.tsx +92 -18
  48. package/ui/components/wallet/ProfileSwitcherPopover.tsx +247 -0
  49. package/ui/hooks/useOfflineNoticeActions.ts +2 -1
  50. package/ui/hooks/useSpendableBalance.ts +3 -1
  51. package/ui/index.ts +1 -0
  52. package/ui/printRecoveryShares.ts +6 -7
  53. package/ui/screens/PairScreen.tsx +2 -1
  54. package/ui/screens/PayScreen.tsx +53 -0
  55. package/ui/screens/ProfileScreen.tsx +195 -4
  56. package/ui/screens/SettingsScreen.tsx +80 -6
  57. package/ui/screens/VaultScreen.tsx +31 -2
  58. package/ui/screens/VaultTransferScreen.tsx +25 -2
  59. package/ui/screens/WalletCheckScreen.tsx +2 -1
  60. package/ui/screens/WalletConfigScreen.tsx +51 -21
  61. package/ui/screens/WalletHomeScreen.tsx +6 -3
  62. package/ui/tokenSeen.ts +13 -9
@@ -0,0 +1,124 @@
1
+ /**
2
+ * One-time heads-up shown the first time the user picks "Share remote link" on
3
+ * "Get paid", before the OS asks to allow notifications. Same rationale as
4
+ * NearbyAdvisoryModal and BiometricAdvisoryModal: never let an OS permission
5
+ * dialog be the user's first signal that something is about to happen — say
6
+ * what it is for, briefly, first.
7
+ *
8
+ * The OS prompt is fired only on Continue. Either button records that the
9
+ * advisory was shown, and neither blocks the link flow underneath.
10
+ */
11
+ import React from 'react'
12
+ import { Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
13
+ import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
14
+ import PressableScale from '../ui/PressableScale'
15
+
16
+ const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
17
+
18
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
19
+ let ioniconsComponent: IoniconsComponent | undefined
20
+ function loadIonicons(): IoniconsComponent {
21
+ if (!ioniconsComponent) {
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
23
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
24
+ }
25
+ return ioniconsComponent
26
+ }
27
+
28
+ /**
29
+ * Whether the advisory should be on screen. Pure so the gating is testable
30
+ * without rendering the screen: only on the remote-link method, only once per
31
+ * device, and only while the OS would still ask (granted/denied are final, and
32
+ * `null` means the state has not loaded yet — show nothing rather than flash).
33
+ */
34
+ export function shouldShowNotificationAdvisory(s: {
35
+ method: string | null
36
+ advisorySeen: boolean | null
37
+ permission: 'granted' | 'denied' | 'undetermined' | null
38
+ }): boolean {
39
+ return s.method === 'get-handle' && s.advisorySeen === false && s.permission === 'undetermined'
40
+ }
41
+
42
+ export const NotificationAdvisoryModal: React.FC<{
43
+ visible: boolean
44
+ onNotNow: () => void
45
+ onContinue: () => void
46
+ }> = ({ visible, onNotNow, onContinue }) => {
47
+ const { colors } = useTheme()
48
+ const Ionicons = loadIonicons()
49
+
50
+ if (!visible) return null
51
+
52
+ return (
53
+ <Modal
54
+ transparent
55
+ visible
56
+ animationType="fade"
57
+ onRequestClose={onNotNow}
58
+ statusBarTranslucent={Platform.OS === 'android'}
59
+ navigationBarTranslucent={Platform.OS === 'android'}
60
+ >
61
+ <View style={[styles.backdrop, { backgroundColor: colors.scrim }]}>
62
+ <Pressable
63
+ style={StyleSheet.absoluteFill}
64
+ onPress={onNotNow}
65
+ accessible={true}
66
+ accessibilityRole="button"
67
+ accessibilityLabel="Close"
68
+ accessibilityHint="Dismisses this advisory"
69
+ />
70
+ <View style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.separator }]}>
71
+ <View style={[styles.heroIcon, { backgroundColor: colors.fillTertiary }]}>
72
+ <Ionicons name="notifications-outline" size={26} color={colors.accent} />
73
+ </View>
74
+ <Text style={[styles.title, { color: colors.textPrimary }]}>{t('push_advisory_title')}</Text>
75
+ <Text style={[styles.body, { color: colors.textSecondary }]}>{t('push_advisory_body')}</Text>
76
+
77
+ <PressableScale
78
+ haptic="confirm"
79
+ onPress={onContinue}
80
+ style={[styles.primary, { backgroundColor: colors.accent }]}
81
+ >
82
+ <Text style={[styles.primaryLabel, { color: colors.textOnAccent }]}>{t('push_advisory_continue')}</Text>
83
+ </PressableScale>
84
+
85
+ <PressableScale haptic="tap" onPress={onNotNow} style={styles.secondary}>
86
+ <Text style={[styles.secondaryLabel, { color: colors.textSecondary }]}>{t('push_advisory_not_now')}</Text>
87
+ </PressableScale>
88
+ </View>
89
+ </View>
90
+ </Modal>
91
+ )
92
+ }
93
+
94
+ const styles = StyleSheet.create({
95
+ backdrop: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: spacing.xl },
96
+ card: {
97
+ width: '100%',
98
+ maxWidth: 360,
99
+ borderRadius: radii.xl,
100
+ borderWidth: StyleSheet.hairlineWidth,
101
+ padding: spacing.xl,
102
+ alignItems: 'center',
103
+ gap: spacing.md
104
+ },
105
+ heroIcon: {
106
+ width: 56,
107
+ height: 56,
108
+ borderRadius: 28,
109
+ alignItems: 'center',
110
+ justifyContent: 'center',
111
+ marginBottom: spacing.xs
112
+ },
113
+ title: { ...typography.title2, textAlign: 'center' },
114
+ body: { ...typography.subhead, textAlign: 'center', marginBottom: spacing.sm },
115
+ primary: {
116
+ width: '100%',
117
+ borderRadius: radii.md,
118
+ paddingVertical: spacing.lg,
119
+ alignItems: 'center'
120
+ },
121
+ primaryLabel: { ...typography.headline },
122
+ secondary: { paddingVertical: spacing.sm, alignItems: 'center' },
123
+ secondaryLabel: { ...typography.body }
124
+ })
@@ -30,6 +30,8 @@ export interface PencilEditFieldProps {
30
30
  saveAccessibilityLabel: string
31
31
  autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters'
32
32
  maxLength?: number
33
+ /** Let the text be emptied and saved as '' (a name that can go back to its default). */
34
+ allowEmpty?: boolean
33
35
  }
34
36
 
35
37
  export function PencilEditField({
@@ -40,7 +42,8 @@ export function PencilEditField({
40
42
  editAccessibilityLabel,
41
43
  saveAccessibilityLabel,
42
44
  autoCapitalize = 'words',
43
- maxLength
45
+ maxLength,
46
+ allowEmpty = false
44
47
  }: PencilEditFieldProps) {
45
48
  const { colors } = useTheme()
46
49
  const Ionicons = loadIonicons()
@@ -50,7 +53,7 @@ export function PencilEditField({
50
53
  // re-seeds the field; an in-progress edit is never clobbered, because the
51
54
  // parent's value only changes once our own save has gone through.
52
55
  useEffect(() => setText(value), [value])
53
- const changed = text.trim() !== '' && text.trim() !== value.trim()
56
+ const changed = (allowEmpty || text.trim() !== '') && text.trim() !== value.trim()
54
57
 
55
58
  const save = async () => {
56
59
  if (!changed) return
@@ -5,6 +5,7 @@ import AmountDisplay from './AmountDisplay'
5
5
  import AppLogo from '../ui/AppLogo'
6
6
  import { sdk } from '@bsv/wallet-toolbox-mobile'
7
7
  import AsyncStorage from '@react-native-async-storage/async-storage'
8
+ import { profileScopedKey, useActiveProfileIndex } from '../../../core/profiles/profileStore'
8
9
 
9
10
  // XR-058: scoped by network (matching useSpendableBalance's pattern) rather
10
11
  // than a single global key, so one wallet/network context can never read
@@ -16,7 +17,8 @@ const CACHE_DURATION = 30000 // 30 seconds
16
17
  export default function Balance() {
17
18
  const { colors } = useTheme()
18
19
  const { managers, adminOriginator, txStatusVersion, selectedNetwork } = useWallet()
19
- const cacheKey = `${BALANCE_CACHE_PREFIX}${selectedNetwork}`
20
+ const activeProfile = useActiveProfileIndex()
21
+ const cacheKey = profileScopedKey(`${BALANCE_CACHE_PREFIX}${selectedNetwork}`, activeProfile)
20
22
  const timestampKey = `${cacheKey}_timestamp`
21
23
  // { key, value } rather than a bare number: `key` is compared against the
22
24
  // live `cacheKey` everywhere below, so a figure read for a since-departed
@@ -8,13 +8,18 @@
8
8
  * host app's `app/index.tsx`, so this needed no package API change. Same disc
9
9
  * as the settings button on the right (surfaceRaised + hairline), so the two
10
10
  * bookend the header as a matched pair.
11
+ *
12
+ * With wallet profiles (a mnemonic wallet), pressing opens the profile
13
+ * switcher; the active profile's row is the way into Profile. A recovered-key
14
+ * wallet has no profiles, so it keeps going straight to Profile.
11
15
  */
12
- import React from 'react'
13
- import { StyleSheet } from 'react-native'
14
- import { useTheme, useUserAvatarIcon } from '@bsv/expo-wallet-toolbox'
16
+ import React, { useRef, useState } from 'react'
17
+ import { StyleSheet, View } from 'react-native'
18
+ import { useTheme, useUserAvatarIcon, useWallet } from '@bsv/expo-wallet-toolbox'
15
19
  import { useTranslation } from 'react-i18next'
16
20
  import PressableScale from '../ui/PressableScale'
17
21
  import { AvatarGlyph } from './UserAvatar'
22
+ import ProfileSwitcherPopover from './ProfileSwitcherPopover'
18
23
 
19
24
  type ExpoRouterModule = typeof import('expo-router')
20
25
  let expoRouterMod: ExpoRouterModule | undefined
@@ -31,22 +36,91 @@ export default function ProfileButton() {
31
36
  const { t } = useTranslation()
32
37
  const { router } = loadExpoRouter()
33
38
  const avatar = useUserAvatarIcon()
39
+ const {
40
+ profilesSupported,
41
+ profiles,
42
+ activeProfile,
43
+ switchProfile,
44
+ addProfile,
45
+ walletBuilding,
46
+ switchingProfile,
47
+ removingProfile
48
+ } = useWallet()
49
+ const discRef = useRef<View>(null)
50
+ const [open, setOpen] = useState(false)
51
+ /** Which profile the running switch is headed to, for the cover's label. */
52
+ const [target, setTarget] = useState<number | null>(null)
53
+ // Until the first layout measure lands: roughly where Home's top bar puts the disc.
54
+ const [anchor, setAnchor] = useState({ x: 16, y: 54, height: 34 })
55
+
56
+ const openProfile = () => router.push('/profile' as never)
57
+
58
+ // Where the card hangs from, kept current from layout so a press opens at once.
59
+ const measure = () => {
60
+ discRef.current?.measureInWindow?.((x, y, _w, height) => {
61
+ if (Number.isFinite(x) && Number.isFinite(y)) setAnchor({ x, y, height: height || 34 })
62
+ })
63
+ }
64
+
65
+ const onPress = () => {
66
+ if (!profilesSupported) {
67
+ openProfile()
68
+ return
69
+ }
70
+ measure()
71
+ setOpen(true)
72
+ }
73
+
74
+ const run = (to: number, action: () => Promise<void>) => {
75
+ setTarget(to)
76
+ setOpen(false)
77
+ action()
78
+ .catch(err => console.warn('[ProfileButton] profile action failed:', err))
79
+ .finally(() => setTarget(null))
80
+ }
81
+
34
82
  return (
35
- <PressableScale
36
- onPress={() => router.push('/profile' as never)}
37
- haptic="tap"
38
- hitSlop={5}
39
- style={[styles.disc, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
40
- accessibilityRole="button"
41
- accessibilityLabel={t('profile')}
42
- >
43
- <AvatarGlyph
44
- family={avatar?.family ?? 'ionicons'}
45
- name={avatar?.name ?? 'person-outline'}
46
- size={17}
47
- color={colors.textSecondary}
48
- />
49
- </PressableScale>
83
+ <>
84
+ <View ref={discRef} collapsable={false} onLayout={measure}>
85
+ <PressableScale
86
+ onPress={onPress}
87
+ haptic="tap"
88
+ hitSlop={5}
89
+ style={[styles.disc, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
90
+ accessibilityRole="button"
91
+ accessibilityLabel={profilesSupported ? t('profile_switcher_a11y') : t('profile')}
92
+ >
93
+ <AvatarGlyph
94
+ family={avatar?.family ?? 'ionicons'}
95
+ name={avatar?.name ?? 'person-outline'}
96
+ size={17}
97
+ color={colors.textSecondary}
98
+ />
99
+ </PressableScale>
100
+ </View>
101
+ {profilesSupported && (
102
+ <ProfileSwitcherPopover
103
+ visible={open || switchingProfile}
104
+ onClose={() => setOpen(false)}
105
+ anchor={anchor}
106
+ profiles={profiles}
107
+ active={activeProfile}
108
+ avatar={avatar}
109
+ busy={walletBuilding || switchingProfile}
110
+ // A removal is started from the Profile screen, not from here, so `target` is
111
+ // empty for it: the cover names the profile being removed instead.
112
+ switchingTo={switchingProfile ? (target ?? removingProfile ?? activeProfile) : null}
113
+ removing={typeof removingProfile === 'number'}
114
+ onSelect={n => run(n, () => switchProfile(n))}
115
+ onOpenProfile={() => {
116
+ setOpen(false)
117
+ openProfile()
118
+ }}
119
+ // The full list, removed profiles included: that count is the index the new profile gets.
120
+ onAdd={() => run(profiles.length, addProfile)}
121
+ />
122
+ )}
123
+ </>
50
124
  )
51
125
  }
52
126
 
@@ -0,0 +1,247 @@
1
+ /**
2
+ * The profile switcher: what the Home avatar opens.
3
+ *
4
+ * One row per wallet profile (one mnemonic, many wallets — see
5
+ * core/profiles/profileStore), a checkmark on the active one, and "Add profile"
6
+ * underneath. Tapping the active row opens that profile's own screen (name,
7
+ * handle, picture); tapping another switches the whole wallet to it.
8
+ *
9
+ * A small card hanging under the avatar, styled like the coin switcher
10
+ * (AssetSwitcherDropdown). It sits in a transparent Modal rather than in-tree
11
+ * because the avatar lives inside the header slot, whose box would clip it.
12
+ *
13
+ * While a switch runs, the same Modal turns into a full-screen cover: tearing
14
+ * one wallet down and building the next takes a moment, and the old wallet must
15
+ * not sit there looking live meanwhile. One Modal for both, because iOS will
16
+ * not present a second one while the first is still dismissing.
17
+ */
18
+ import React from 'react'
19
+ import {
20
+ ActivityIndicator,
21
+ Modal,
22
+ Pressable,
23
+ StyleSheet,
24
+ Text,
25
+ TouchableOpacity,
26
+ View,
27
+ useWindowDimensions
28
+ } from 'react-native'
29
+ import { useTranslation } from 'react-i18next'
30
+ import { hitTargets, radii, spacing, typography, useTheme } from '@bsv/expo-wallet-toolbox'
31
+ import type { ProfileRecord } from '../../../core/profiles/profileStore'
32
+ import { profileLabel } from '../../../core/profiles/profileLabel'
33
+ import type { AppChain } from '../../../core/config'
34
+ import type { AvatarIcon } from '../../../core/userAvatar'
35
+ import { AvatarGlyph } from './UserAvatar'
36
+
37
+ /** Same lazy load as AssetSwitcherDropdown — see the note there. */
38
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
39
+ let ioniconsComponent: IoniconsComponent | undefined
40
+ function loadIonicons(): IoniconsComponent {
41
+ if (!ioniconsComponent) {
42
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
43
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
44
+ }
45
+ return ioniconsComponent
46
+ }
47
+
48
+ const NETWORK_LABEL_KEY: Record<AppChain, string> = { main: 'mainnet', test: 'testnet', teratest: 'teratest' }
49
+
50
+ export interface ProfileSwitcherPopoverProps {
51
+ visible: boolean
52
+ onClose: () => void
53
+ /** Window coordinates of the avatar the card hangs from. */
54
+ anchor: { x: number; y: number; height: number }
55
+ /** Every record, removed ones included (their indices stay the other profiles' numbers); the card lists the live ones. */
56
+ profiles: ProfileRecord[]
57
+ active: number
58
+ /** The active profile's avatar; other profiles show the default glyph. */
59
+ avatar: AvatarIcon | null
60
+ /** A build or switch is in flight: rows and Add are inert. */
61
+ busy: boolean
62
+ onSelect: (index: number) => void
63
+ onOpenProfile: () => void
64
+ onAdd: () => void
65
+ /** A switch is running: show the full-screen cover instead of the card. */
66
+ switchingTo?: number | null
67
+ /** The running transition is the removal of `switchingTo`, not a switch to it. */
68
+ removing?: boolean
69
+ }
70
+
71
+ export default function ProfileSwitcherPopover({
72
+ visible,
73
+ onClose,
74
+ anchor,
75
+ profiles,
76
+ active,
77
+ avatar,
78
+ busy,
79
+ onSelect,
80
+ onOpenProfile,
81
+ onAdd,
82
+ switchingTo = null,
83
+ removing = false
84
+ }: ProfileSwitcherPopoverProps) {
85
+ const { colors } = useTheme()
86
+ const { t } = useTranslation()
87
+ const { width } = useWindowDimensions()
88
+ const Ionicons = loadIonicons()
89
+ const cardWidth = Math.min(280, width - spacing.lg * 2)
90
+ const left = Math.max(spacing.lg, Math.min(anchor.x, width - spacing.lg - cardWidth))
91
+ const live = profiles.filter(p => !p.deleted)
92
+
93
+ if (switchingTo !== null) {
94
+ // Add heads for an index with no record yet, so fall back to the default label.
95
+ const target = profiles.find(p => p.index === switchingTo) ?? { index: switchingTo }
96
+ return (
97
+ <Modal visible transparent animationType="fade" onRequestClose={() => {}} statusBarTranslucent>
98
+ <View
99
+ testID="profile-switch-cover"
100
+ style={[styles.cover, { backgroundColor: colors.background }]}
101
+ accessibilityViewIsModal
102
+ accessibilityLiveRegion="polite"
103
+ >
104
+ <ActivityIndicator size="large" color={colors.textSecondary} />
105
+ <Text style={[styles.coverLabel, { color: colors.textSecondary }]}>
106
+ {t(removing ? 'profile_removing' : 'profile_switching', { profile: profileLabel(target, t) })}
107
+ </Text>
108
+ </View>
109
+ </Modal>
110
+ )
111
+ }
112
+
113
+ return (
114
+ <Modal visible={visible} transparent animationType="fade" onRequestClose={onClose} statusBarTranslucent>
115
+ <Pressable
116
+ style={StyleSheet.absoluteFill}
117
+ onPress={onClose}
118
+ accessibilityRole="button"
119
+ accessibilityLabel={t('cancel')}
120
+ />
121
+ <View
122
+ testID="profile-switcher"
123
+ style={[
124
+ styles.card,
125
+ {
126
+ top: anchor.y + anchor.height + spacing.xs,
127
+ left,
128
+ width: cardWidth,
129
+ backgroundColor: colors.surfaceRaised,
130
+ borderColor: colors.surfaceRaisedBorder,
131
+ shadowColor: colors.textPrimary
132
+ }
133
+ ]}
134
+ >
135
+ <View style={styles.list}>
136
+ {live.map(p => {
137
+ const selected = p.index === active
138
+ const label = profileLabel(p, t)
139
+ const network = p.network !== 'main' ? t(NETWORK_LABEL_KEY[p.network]) : undefined
140
+ return (
141
+ <TouchableOpacity
142
+ key={p.index}
143
+ testID={`profile-row-${p.index}`}
144
+ style={[styles.row, selected && { backgroundColor: colors.fill }]}
145
+ onPress={() => (selected ? onOpenProfile() : onSelect(p.index))}
146
+ disabled={busy}
147
+ activeOpacity={0.6}
148
+ accessibilityRole="button"
149
+ accessibilityState={{ selected, disabled: busy }}
150
+ accessibilityLabel={[label, network].filter(Boolean).join(', ')}
151
+ >
152
+ <View
153
+ style={[styles.disc, { backgroundColor: colors.background, borderColor: colors.surfaceRaisedBorder }]}
154
+ >
155
+ <AvatarGlyph
156
+ family={selected && avatar ? avatar.family : 'ionicons'}
157
+ name={selected && avatar ? avatar.name : 'person-outline'}
158
+ size={15}
159
+ color={colors.textSecondary}
160
+ />
161
+ </View>
162
+ <View style={styles.body}>
163
+ <Text style={[styles.name, { color: colors.textPrimary }]} numberOfLines={1}>
164
+ {label}
165
+ </Text>
166
+ {!!network && (
167
+ <Text style={[styles.detail, { color: colors.textSecondary }]} numberOfLines={1}>
168
+ {network}
169
+ </Text>
170
+ )}
171
+ </View>
172
+ <View style={styles.check}>
173
+ {selected && <Ionicons name="checkmark" size={20} color={colors.accent} />}
174
+ </View>
175
+ </TouchableOpacity>
176
+ )
177
+ })}
178
+ </View>
179
+ <View style={[styles.separator, { backgroundColor: colors.separator }]} />
180
+ <TouchableOpacity
181
+ testID="profile-add"
182
+ style={styles.row}
183
+ onPress={onAdd}
184
+ disabled={busy}
185
+ activeOpacity={0.6}
186
+ accessibilityRole="button"
187
+ accessibilityState={{ disabled: busy }}
188
+ accessibilityLabel={t('profile_add')}
189
+ >
190
+ <View style={styles.disc}>
191
+ <Ionicons name="add-circle-outline" size={22} color={colors.accent} />
192
+ </View>
193
+ <Text style={[styles.name, styles.body, { color: colors.accent }]}>{t('profile_add')}</Text>
194
+ </TouchableOpacity>
195
+ </View>
196
+ </Modal>
197
+ )
198
+ }
199
+
200
+ const styles = StyleSheet.create({
201
+ card: {
202
+ position: 'absolute',
203
+ // Same numbers as the coin switcher card, so the two read as one family.
204
+ borderRadius: 20,
205
+ borderWidth: StyleSheet.hairlineWidth,
206
+ padding: 6,
207
+ elevation: 12,
208
+ shadowOffset: { width: 0, height: 16 },
209
+ shadowOpacity: 0.22,
210
+ shadowRadius: 30
211
+ },
212
+ list: { gap: 2 },
213
+ row: {
214
+ flexDirection: 'row',
215
+ alignItems: 'center',
216
+ gap: spacing.md,
217
+ minHeight: hitTargets.minimum,
218
+ paddingVertical: 9,
219
+ paddingHorizontal: 10,
220
+ borderRadius: radii.lg
221
+ },
222
+ disc: {
223
+ width: 30,
224
+ height: 30,
225
+ borderRadius: 15,
226
+ borderWidth: StyleSheet.hairlineWidth,
227
+ borderColor: 'transparent',
228
+ alignItems: 'center',
229
+ justifyContent: 'center'
230
+ },
231
+ body: { flex: 1, minWidth: 0 },
232
+ name: { ...typography.body, fontWeight: '600' },
233
+ detail: { ...typography.footnote, marginTop: 1 },
234
+ check: { width: 20, alignItems: 'center' },
235
+ separator: { height: StyleSheet.hairlineWidth, marginHorizontal: 10, marginVertical: 4 },
236
+ cover: {
237
+ position: 'absolute',
238
+ top: 0,
239
+ left: 0,
240
+ right: 0,
241
+ bottom: 0,
242
+ alignItems: 'center',
243
+ justifyContent: 'center',
244
+ gap: spacing.lg
245
+ },
246
+ coverLabel: { ...typography.body }
247
+ })
@@ -12,9 +12,10 @@ import { updateOfflineAction, type OfflineActionRow } from '../../core/storage/m
12
12
  import type { StorageExpoSQLite } from '../../core/storage/StorageExpoSQLite'
13
13
  import { showToast } from '../components/ui/Toast'
14
14
  import { offlineActionDetails } from '../components/pay/OfflineNotice'
15
+ import { profileScopedKey } from '../../core/profiles/profileStore'
15
16
 
16
17
  async function readMessageBoxUrl(): Promise<string | undefined> {
17
- const saved = await AsyncStorage.getItem(MESSAGE_BOX_URL_KEY)
18
+ const saved = await AsyncStorage.getItem(profileScopedKey(MESSAGE_BOX_URL_KEY))
18
19
  if (saved === NO_MESSAGE_BOX) return undefined
19
20
  if (!saved || saved === LEGACY_MESSAGE_BOX_URL) return DEFAULT_MESSAGE_BOX_URL
20
21
  return saved
@@ -12,10 +12,12 @@ import AsyncStorage from '@react-native-async-storage/async-storage'
12
12
  import { sdk } from '@bsv/wallet-toolbox-mobile'
13
13
  import { useWallet, readWalletBalance } from '@bsv/expo-wallet-toolbox'
14
14
  import { storageMatchesNetwork } from '../../core/net/chainMatch'
15
+ import { profileScopedKey, useActiveProfileIndex } from '../../core/profiles/profileStore'
15
16
 
16
17
  export function useSpendableBalance(): number | null {
17
18
  const { managers, adminOriginator, selectedNetwork, storage, txStatusVersion, walletUserId } = useWallet()
18
- const cacheKey = `cached_wallet_balance_${selectedNetwork}`
19
+ const activeProfile = useActiveProfileIndex()
20
+ const cacheKey = profileScopedKey(`cached_wallet_balance_${selectedNetwork}`, activeProfile)
19
21
  const [balance, setBalance] = useState<{ key: string; value: number } | null>(null)
20
22
  // Serialize reads, retaining the latest invalidation while one is in flight.
21
23
  // A plain busy flag loses it: the old effect is cancelled, while the new one
package/ui/index.ts CHANGED
@@ -59,6 +59,7 @@ export { default as HandleReceive } from './components/pay/HandleReceive'
59
59
  export { useMessageBoxConfig, ConfigPanel } from './components/pay/MessageBoxConfig'
60
60
  export { default as NearbyFlow, type NearbyFlowProps } from './components/pay/NearbyFlow'
61
61
  export { NearbyAdvisoryModal } from './components/pay/NearbyAdvisoryModal'
62
+ export { NotificationAdvisoryModal } from './components/pay/NotificationAdvisoryModal'
62
63
  export { default as OfflineNotice, offlineActionDetails, type OfflineNoticeProps } from './components/pay/OfflineNotice'
63
64
  export { default as PayCellRow, type PayCellRowProps } from './components/pay/PayCellRow'
64
65
  export {
@@ -81,12 +81,11 @@ export async function printRecoveryShares(sources: PrintSharesSources): Promise<
81
81
  return { ok: false, reason: 'no-material' }
82
82
  }
83
83
 
84
- // XR-110: one native print job per share, never all of them in a single
85
- // document. The 2-of-3 threshold means any single job — spooled, retained
86
- // or logged anywhere along the OS print pipeline — must not by itself carry
87
- // enough shares to reconstruct the wallet.
88
- for (let i = 0; i < shares.length; i++) {
89
- await Print.printAsync({ html: await generatePrintHTML(shares, identityKey, format, sources.appName, i) })
90
- }
84
+ // All shares go in one print job as a multi-page document, so the user gets
85
+ // one dialog (and one PDF, if they save rather than print) with every page.
86
+ // XR-110 split this into one job per share so no single spooled job held the
87
+ // 2-of-3 threshold; the owner reverted that (2026-10-01) as accepted risk —
88
+ // the follow-on dialogs were invisible, and users kept only the first share.
89
+ await Print.printAsync({ html: await generatePrintHTML(shares, identityKey, format, sources.appName) })
91
90
  return { ok: true, format }
92
91
  }
@@ -26,6 +26,7 @@ import {
26
26
  AUTO_APPROVE_DAILY_CAP_SATS
27
27
  } from '@bsv/expo-wallet-toolbox'
28
28
  import { computeConnectionAuthorityTag } from '../../core/services/connectionAuthority'
29
+ import { profileScopedKey } from '../../core/profiles/profileStore'
29
30
 
30
31
  /**
31
32
  * expo-router is required lazily rather than imported at module scope: this
@@ -78,7 +79,7 @@ export function PairScreen() {
78
79
  // reads for spendingAuthorizationCallback — 0/unset means auto-approve is off.
79
80
  const [autoApproveThreshold, setAutoApproveThreshold] = useState(DEFAULT_AUTO_APPROVE_THRESHOLD)
80
81
  useEffect(() => {
81
- AsyncStorage.getItem(AUTO_APPROVE_STORAGE_KEY)
82
+ AsyncStorage.getItem(profileScopedKey(AUTO_APPROVE_STORAGE_KEY))
82
83
  .then(v => { if (v !== null) setAutoApproveThreshold(Number(v) || 0) })
83
84
  .catch(() => {})
84
85
  }, [])