@bsv/expo-wallet-toolbox 0.1.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/LICENSE.txt +28 -0
- package/README.md +512 -0
- package/assets/sounds/payment-receive.wav +0 -0
- package/assets/sounds/payment-send.wav +0 -0
- package/assets/sounds/vault-close.wav +0 -0
- package/assets/sounds/vault-open.wav +0 -0
- package/core/amountFormatHelpers.ts +330 -0
- package/core/backup/RemoteSyncReader.ts +94 -0
- package/core/backup/client.ts +111 -0
- package/core/backup/codec.ts +218 -0
- package/core/backup/constants.ts +88 -0
- package/core/backup/cursor.ts +138 -0
- package/core/backup/derive.ts +46 -0
- package/core/backup/deviceId.ts +33 -0
- package/core/backup/erase.ts +67 -0
- package/core/backup/preference.ts +33 -0
- package/core/backup/push.ts +295 -0
- package/core/backup/restore.ts +152 -0
- package/core/backup/restoreOnImport.ts +119 -0
- package/core/backup/status.ts +46 -0
- package/core/config.tsx +47 -0
- package/core/constants.ts +35 -0
- package/core/context/ExchangeRateContext.tsx +69 -0
- package/core/context/LocalStorageProvider.tsx +225 -0
- package/core/context/UserContext.tsx +129 -0
- package/core/context/VaultContext.tsx +79 -0
- package/core/context/WalletConnectionContext.tsx +454 -0
- package/core/context/WalletContext.tsx +2938 -0
- package/core/context/buildGeneration.ts +37 -0
- package/core/deviceTier.ts +89 -0
- package/core/diskSpace.ts +62 -0
- package/core/displayCurrencies.ts +56 -0
- package/core/headers/OfflineFirstChaintracks.ts +176 -0
- package/core/headers/checkpoints.ts +39 -0
- package/core/headers/fs.ts +119 -0
- package/core/headers/headerStore.ts +333 -0
- package/core/headers/prewarm.ts +36 -0
- package/core/headers/syncHeaders.ts +73 -0
- package/core/hooks/useConfirmationSound.ts +135 -0
- package/core/hooks/useHaptics.ts +51 -0
- package/core/hooks/usePermissionQueue.ts +69 -0
- package/core/i18n/translations.tsx +6692 -0
- package/core/index.ts +295 -0
- package/core/localpay/blePermissions.ts +32 -0
- package/core/localpay/build.ts +392 -0
- package/core/localpay/codec.ts +338 -0
- package/core/localpay/deviceCaps.ts +175 -0
- package/core/localpay/nearbyAdvisory.ts +32 -0
- package/core/localpay/nearbyPermissions.ts +34 -0
- package/core/localpay/pending.ts +385 -0
- package/core/localpay/pendingAborts.ts +67 -0
- package/core/localpay/qr.ts +16 -0
- package/core/localpay/session.ts +277 -0
- package/core/localpay/sessionPolicy.ts +5 -0
- package/core/localpay/transport/awdl.ts +11 -0
- package/core/localpay/transport/ble.ts +159 -0
- package/core/localpay/transport/nearby.ts +12 -0
- package/core/localpay/transport/race.ts +110 -0
- package/core/localpay/transport/select.ts +128 -0
- package/core/localpay/transport/socket.ts +244 -0
- package/core/localpay/types.ts +82 -0
- package/core/localpay/verify.ts +204 -0
- package/core/logging.config.ts +10 -0
- package/core/logging.ts +77 -0
- package/core/mnemonicWallet.ts +180 -0
- package/core/monitor/TaskBackupPush.ts +168 -0
- package/core/monitor/TaskCreditInbox.ts +116 -0
- package/core/monitor/TaskDrainOutbox.ts +122 -0
- package/core/monitor/TaskSendOffline.ts +123 -0
- package/core/monitor/unfailRetry.ts +116 -0
- package/core/net/chainMatch.ts +34 -0
- package/core/net/online.ts +34 -0
- package/core/offline/cancelParked.ts +56 -0
- package/core/offline/hold.ts +127 -0
- package/core/offline/order.ts +109 -0
- package/core/offline/payerHold.ts +144 -0
- package/core/offline/plan.ts +264 -0
- package/core/offline/queueGrace.ts +52 -0
- package/core/parsePeerPayURI.ts +119 -0
- package/core/pay/beefRepair.ts +106 -0
- package/core/pay/creditErrors.ts +46 -0
- package/core/pay/creditInbox.ts +202 -0
- package/core/pay/damagedInbox.ts +64 -0
- package/core/pay/proofNudge.ts +23 -0
- package/core/pay/provenTxFromBump.ts +31 -0
- package/core/pay/rails/address.ts +329 -0
- package/core/pay/rails/handle.ts +617 -0
- package/core/pay/rails/index.ts +197 -0
- package/core/pay/rails/nearby.ts +79 -0
- package/core/pay/receiveFocus.ts +13 -0
- package/core/pay/recordProof.ts +91 -0
- package/core/pay/refreshProofGuard.ts +34 -0
- package/core/pay/sweeper.ts +75 -0
- package/core/pay/tokenAmount.ts +18 -0
- package/core/pay/userError.ts +18 -0
- package/core/pay/watchlist.ts +126 -0
- package/core/peerpay/control.ts +122 -0
- package/core/peerpay/handleResendRequests.ts +475 -0
- package/core/peerpay/inboxAttempts.ts +33 -0
- package/core/peerpay/metadataDecryptor.ts +42 -0
- package/core/peerpay/offlineNacks.ts +96 -0
- package/core/peerpay/outbox.ts +209 -0
- package/core/peerpay/rebuildToken.ts +76 -0
- package/core/peerpay/resendBeef.ts +115 -0
- package/core/services/arcadeBroadcastProvider.ts +214 -0
- package/core/services/capWalletArgs.ts +99 -0
- package/core/services/exchangeRate.ts +63 -0
- package/core/services/secrets/envelope.ts +102 -0
- package/core/services/secrets/hkdf.ts +37 -0
- package/core/services/secrets/index.ts +63 -0
- package/core/services/secrets/kek.ts +274 -0
- package/core/services/secrets/migration.ts +188 -0
- package/core/services/secrets/policy.ts +120 -0
- package/core/services/secrets/storage.ts +54 -0
- package/core/services/secrets/store.ts +125 -0
- package/core/services/secrets/types.ts +85 -0
- package/core/services/usdFxRates.ts +101 -0
- package/core/services/vault/VaultKeyService.ts +312 -0
- package/core/services/vault/backupAttestation.ts +136 -0
- package/core/services/vault/ceremony.ts +972 -0
- package/core/services/vault/ceremonyHost.ts +46 -0
- package/core/services/vault/devMock.ts +22 -0
- package/core/services/vault/driver.ts +197 -0
- package/core/services/vault/guard.ts +90 -0
- package/core/services/vault/k1.ts +75 -0
- package/core/services/vault/mockYubiKey.ts +217 -0
- package/core/services/vault/random.ts +20 -0
- package/core/services/vault/sealing.ts +84 -0
- package/core/services/vault/session.ts +59 -0
- package/core/services/vault/transfers.ts +1151 -0
- package/core/services/vault/types.ts +109 -0
- package/core/services/vault/vaultDerivation.ts +152 -0
- package/core/services/vault/vaultPassphrase.ts +287 -0
- package/core/services/vault/vaultStore.ts +104 -0
- package/core/services/walletArgLimits.ts +234 -0
- package/core/services/walletServiceConfig.ts +170 -0
- package/core/storage/LocalStorageAdapter.ts +58 -0
- package/core/storage/README.md +391 -0
- package/core/storage/StorageExpoSQLite.ts +2008 -0
- package/core/storage/errors.ts +73 -0
- package/core/storage/index.ts +3 -0
- package/core/storage/methods/findSql.ts +286 -0
- package/core/storage/methods/historyNotes.ts +61 -0
- package/core/storage/methods/listActionsSql.ts +212 -0
- package/core/storage/methods/listOutputsSql.ts +211 -0
- package/core/storage/methods/offlineActions.ts +156 -0
- package/core/storage/methods/processOfflineActions.ts +503 -0
- package/core/storage/methods/reclaim.ts +135 -0
- package/core/storage/methods/reviewStatusSql.ts +167 -0
- package/core/storage/methods/unprovenWithoutReqSql.ts +26 -0
- package/core/storage/methods/walletBalanceSql.ts +55 -0
- package/core/storage/schema/createTables.ts +385 -0
- package/core/storage/skipQueuedAncestors.ts +29 -0
- package/core/storage/sqlUpdateValue.ts +12 -0
- package/core/stores/ConnectionStore.ts +71 -0
- package/core/theme/ThemeContext.tsx +182 -0
- package/core/theme/assertThemeContrast.ts +109 -0
- package/core/theme/motion.ts +50 -0
- package/core/theme/tokens.ts +232 -0
- package/core/theme/useThemeStyles.tsx +156 -0
- package/core/walletDbRegistry.ts +110 -0
- package/core/walletMonitor.ts +149 -0
- package/core/walletRepair/runWalletCheck.ts +195 -0
- package/core/walletRepair/shouldReleaseUtxo.ts +18 -0
- package/package.json +86 -0
- package/ui/backupShares.ts +367 -0
- package/ui/components/QRScanner.tsx +353 -0
- package/ui/components/pay/AddressReceive.tsx +507 -0
- package/ui/components/pay/AvailableBalance.tsx +61 -0
- package/ui/components/pay/HandleReceive.tsx +896 -0
- package/ui/components/pay/MessageBoxConfig.tsx +256 -0
- package/ui/components/pay/NearbyAdvisoryModal.tsx +111 -0
- package/ui/components/pay/NearbyFlow.tsx +2542 -0
- package/ui/components/pay/OfflineNotice.tsx +337 -0
- package/ui/components/pay/PayCellRow.tsx +101 -0
- package/ui/components/pay/PayForm.tsx +223 -0
- package/ui/components/pay/PaymentQrDisplay.tsx +105 -0
- package/ui/components/pay/PaymentSuccessOverlay.tsx +266 -0
- package/ui/components/pay/RecipientField.tsx +308 -0
- package/ui/components/pay/RequestHub.tsx +75 -0
- package/ui/components/pay/ResultBanner.tsx +69 -0
- package/ui/components/pay/UniversalSend.tsx +687 -0
- package/ui/components/pay/useRecipientInput.ts +270 -0
- package/ui/components/security/WalletLockNotice.tsx +138 -0
- package/ui/components/ui/AlertCard.tsx +223 -0
- package/ui/components/ui/AppLogo.tsx +166 -0
- package/ui/components/ui/BlurChrome.tsx +72 -0
- package/ui/components/ui/Celebration.tsx +84 -0
- package/ui/components/ui/ChoiceSheet.ts +69 -0
- package/ui/components/ui/CustomSafeArea.tsx +74 -0
- package/ui/components/ui/ErrorBoundary.tsx +154 -0
- package/ui/components/ui/GroupedList.tsx +125 -0
- package/ui/components/ui/IconButton.tsx +105 -0
- package/ui/components/ui/ListRow.tsx +197 -0
- package/ui/components/ui/PermissionSheet.tsx +920 -0
- package/ui/components/ui/PresenceRow.tsx +215 -0
- package/ui/components/ui/PressableScale.tsx +105 -0
- package/ui/components/ui/ScreenGradient.tsx +47 -0
- package/ui/components/ui/ScrollFade.tsx +76 -0
- package/ui/components/ui/Sheet.tsx +342 -0
- package/ui/components/ui/Toast.tsx +142 -0
- package/ui/components/ui/index.ts +8 -0
- package/ui/components/vault/EnrollWizard.tsx +627 -0
- package/ui/components/vault/PassphraseField.tsx +306 -0
- package/ui/components/vault/PhraseBackupSheet.tsx +227 -0
- package/ui/components/vault/VaultBackdrop.tsx +354 -0
- package/ui/components/vault/VaultCeremonySheet.tsx +327 -0
- package/ui/components/wallet/ActivityRow.tsx +408 -0
- package/ui/components/wallet/AmountDisplay.tsx +48 -0
- package/ui/components/wallet/AmountInput.tsx +256 -0
- package/ui/components/wallet/BackupReminderSheet.tsx +168 -0
- package/ui/components/wallet/Balance.tsx +144 -0
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +133 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +93 -0
- package/ui/exportDatabases.ts +122 -0
- package/ui/exportTransactions.ts +129 -0
- package/ui/hooks/useOfflineNoticeActions.ts +136 -0
- package/ui/hooks/useOnline.ts +70 -0
- package/ui/hooks/useSpendableBalance.ts +58 -0
- package/ui/hooks/useVaultBalance.ts +50 -0
- package/ui/importDatabases.ts +170 -0
- package/ui/index.ts +136 -0
- package/ui/isImageUrl.ts +10 -0
- package/ui/printRecoveryShares.ts +93 -0
- package/ui/resolveIdentity.ts +125 -0
- package/ui/screens/ConnectionsScreen.tsx +438 -0
- package/ui/screens/LogsScreen.tsx +432 -0
- package/ui/screens/PairScreen.tsx +288 -0
- package/ui/screens/PayScreen.tsx +479 -0
- package/ui/screens/SettingsScreen.tsx +180 -0
- package/ui/screens/TrustScreen.tsx +831 -0
- package/ui/screens/VaultRecoverScreen.tsx +226 -0
- package/ui/screens/VaultScreen.tsx +423 -0
- package/ui/screens/VaultTransferScreen.tsx +293 -0
- package/ui/screens/WalletCheckScreen.tsx +539 -0
- package/ui/screens/WalletConfigScreen.tsx +1095 -0
- package/ui/screens/WalletHomeScreen.tsx +1597 -0
- package/ui/screens/homeBadges.ts +18 -0
- package/ui/txStatus.ts +79 -0
- package/ui/validateTrust.ts +44 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
SafeAreaView,
|
|
8
|
+
ActivityIndicator,
|
|
9
|
+
} from 'react-native'
|
|
10
|
+
import { WalletClient } from '@bsv/sdk'
|
|
11
|
+
import {
|
|
12
|
+
useWallet,
|
|
13
|
+
useTheme,
|
|
14
|
+
spacing,
|
|
15
|
+
radii,
|
|
16
|
+
typography,
|
|
17
|
+
useWalletConnection,
|
|
18
|
+
guardVaultAccess,
|
|
19
|
+
capWalletArgs,
|
|
20
|
+
ADMIN_ORIGINATOR
|
|
21
|
+
} from '@bsv/expo-wallet-toolbox'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* expo-router is required lazily rather than imported at module scope: this
|
|
25
|
+
* file is barrel-exported from the package's `ui` entry point, and a static
|
|
26
|
+
* top-level `import` of expo-router pulls in its own untransformed JSX
|
|
27
|
+
* source (Navigator.js etc.), which Jest cannot parse for any consumer of the
|
|
28
|
+
* barrel, even one that never navigates. Same pattern as this package's other
|
|
29
|
+
* lazy expo-router loads (WalletHomeScreen.tsx, VaultScreen.tsx, etc.).
|
|
30
|
+
*/
|
|
31
|
+
type ExpoRouterModule = typeof import('expo-router')
|
|
32
|
+
let expoRouterMod: ExpoRouterModule | undefined
|
|
33
|
+
function loadExpoRouter(): ExpoRouterModule {
|
|
34
|
+
if (!expoRouterMod) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
36
|
+
expoRouterMod = require('expo-router') as ExpoRouterModule
|
|
37
|
+
}
|
|
38
|
+
return expoRouterMod
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function domainFromOrigin(origin: string): string {
|
|
42
|
+
try { return new URL(origin).hostname } catch { return origin }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function PairScreen() {
|
|
46
|
+
const { colors } = useTheme()
|
|
47
|
+
const { managers } = useWallet()
|
|
48
|
+
const { useLocalSearchParams, router } = loadExpoRouter()
|
|
49
|
+
const params = useLocalSearchParams<{
|
|
50
|
+
topic: string
|
|
51
|
+
backendIdentityKey: string
|
|
52
|
+
protocolID: string
|
|
53
|
+
origin: string
|
|
54
|
+
expiry: string
|
|
55
|
+
sig?: string
|
|
56
|
+
reconnect?: string
|
|
57
|
+
}>()
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
status, sessionMeta, errorMsg,
|
|
61
|
+
connect, disconnect,
|
|
62
|
+
startNavTimer, cancelNavTimer,
|
|
63
|
+
} = useWalletConnection()
|
|
64
|
+
|
|
65
|
+
// Pre-connection validation error (before connect() is called)
|
|
66
|
+
const [preConnectError, setPreConnectError] = useState<string | null>(null)
|
|
67
|
+
|
|
68
|
+
// Whether this mount is a reconnect (explicitly passed from connections screen)
|
|
69
|
+
const isReconnect = params.reconnect === 'true'
|
|
70
|
+
|
|
71
|
+
// Track current status for unmount cleanup without re-running the effect
|
|
72
|
+
const statusRef = useRef(status)
|
|
73
|
+
useEffect(() => { statusRef.current = status }, [status])
|
|
74
|
+
|
|
75
|
+
// Reset error state when leaving this screen so the next scan starts fresh
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
return () => {
|
|
78
|
+
if (statusRef.current === 'error' || statusRef.current === 'disconnected') {
|
|
79
|
+
disconnect()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, []) // eslint-disable-line react-hooks/exhaustive-deps
|
|
83
|
+
|
|
84
|
+
// Validate QR params on mount — only for fresh pairings
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (isReconnect) return
|
|
87
|
+
|
|
88
|
+
const { topic, backendIdentityKey, protocolID, origin, expiry } = params
|
|
89
|
+
if (!topic || !backendIdentityKey || !protocolID || !origin || !expiry) {
|
|
90
|
+
setPreConnectError('Invalid or missing pairing parameters')
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
if (Date.now() / 1000 > Number(expiry)) {
|
|
94
|
+
setPreConnectError('QR code has expired')
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
}, []) // eslint-disable-line react-hooks/exhaustive-deps
|
|
98
|
+
|
|
99
|
+
// Nav timer — start when leaving this screen, cancel when returning
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
cancelNavTimer()
|
|
102
|
+
return () => { if (status === 'connected') startNavTimer() }
|
|
103
|
+
}, [status]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
104
|
+
|
|
105
|
+
async function handleApprove() {
|
|
106
|
+
if (!managers.permissionsManager) {
|
|
107
|
+
setPreConnectError('Wallet not ready — please log in first')
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
const originator = domainFromOrigin(params.origin)
|
|
111
|
+
// Guarded exactly like every sibling call site (connections.tsx): this is
|
|
112
|
+
// an external surface (the desktop/browser pairing peer dispatches
|
|
113
|
+
// BRC-100 methods by name), so it must never receive the unguarded
|
|
114
|
+
// manager — see guard.ts for what that would otherwise expose.
|
|
115
|
+
const wallet = new WalletClient(capWalletArgs(guardVaultAccess(managers.permissionsManager as any, ADMIN_ORIGINATOR)), originator)
|
|
116
|
+
try {
|
|
117
|
+
await connect({
|
|
118
|
+
topic: params.topic,
|
|
119
|
+
backendIdentityKey: params.backendIdentityKey,
|
|
120
|
+
protocolID: params.protocolID,
|
|
121
|
+
origin: params.origin,
|
|
122
|
+
expiry: params.expiry,
|
|
123
|
+
sig: params.sig,
|
|
124
|
+
}, wallet)
|
|
125
|
+
} catch (err) {
|
|
126
|
+
setPreConnectError(err instanceof Error ? err.message : 'Connection failed')
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function handleReject() {
|
|
131
|
+
disconnect()
|
|
132
|
+
router.back()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const styles = makeStyles(colors)
|
|
136
|
+
const displayOrigin = sessionMeta?.origin ?? params.origin ?? ''
|
|
137
|
+
|
|
138
|
+
function renderContent() {
|
|
139
|
+
// Pre-connect validation errors
|
|
140
|
+
if (preConnectError) {
|
|
141
|
+
return (
|
|
142
|
+
<View style={styles.centered}>
|
|
143
|
+
<Text style={styles.errorTitle}>Connection Failed</Text>
|
|
144
|
+
<Text style={styles.errorMsg}>{preConnectError}</Text>
|
|
145
|
+
<TouchableOpacity style={styles.secondaryBtn} onPress={() => { disconnect(); router.back() }}>
|
|
146
|
+
<Text style={styles.secondaryBtnText}>Go Back</Text>
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
</View>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Post-connect errors (from context)
|
|
153
|
+
if (status === 'error' || status === 'disconnected') {
|
|
154
|
+
return (
|
|
155
|
+
<View style={styles.centered}>
|
|
156
|
+
<Text style={styles.errorTitle}>Connection Failed</Text>
|
|
157
|
+
<Text style={styles.errorMsg}>{errorMsg ?? 'Something went wrong'}</Text>
|
|
158
|
+
<TouchableOpacity style={styles.secondaryBtn} onPress={() => { disconnect(); router.back() }}>
|
|
159
|
+
<Text style={styles.secondaryBtnText}>Go Back</Text>
|
|
160
|
+
</TouchableOpacity>
|
|
161
|
+
</View>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Fresh pairing — waiting for user approval
|
|
166
|
+
if (status === 'idle' && !isReconnect) {
|
|
167
|
+
return (
|
|
168
|
+
<View style={styles.card}>
|
|
169
|
+
<Text style={styles.title}>Connect Wallet</Text>
|
|
170
|
+
<Text style={styles.subtitle}>A site wants to connect to your wallet</Text>
|
|
171
|
+
|
|
172
|
+
<View style={styles.infoBox}>
|
|
173
|
+
<View style={styles.infoRow}>
|
|
174
|
+
<Text style={styles.infoLabel}>Origin</Text>
|
|
175
|
+
<Text style={styles.infoValue} numberOfLines={1}>{params.origin}</Text>
|
|
176
|
+
</View>
|
|
177
|
+
<View style={styles.divider} />
|
|
178
|
+
<View style={styles.infoRow}>
|
|
179
|
+
<Text style={styles.infoLabel}>Permissions</Text>
|
|
180
|
+
<Text style={styles.infoValue}>getPublicKey, listOutputs + more</Text>
|
|
181
|
+
</View>
|
|
182
|
+
</View>
|
|
183
|
+
|
|
184
|
+
<View style={styles.buttonRow}>
|
|
185
|
+
<TouchableOpacity style={styles.rejectBtn} onPress={handleReject}>
|
|
186
|
+
<Text style={styles.rejectBtnText}>Reject</Text>
|
|
187
|
+
</TouchableOpacity>
|
|
188
|
+
<TouchableOpacity style={styles.approveBtn} onPress={() => void handleApprove()}>
|
|
189
|
+
<Text style={styles.approveBtnText}>Approve</Text>
|
|
190
|
+
</TouchableOpacity>
|
|
191
|
+
</View>
|
|
192
|
+
</View>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Connected
|
|
197
|
+
if (status === 'connected') {
|
|
198
|
+
return (
|
|
199
|
+
<View style={styles.centered}>
|
|
200
|
+
<View style={styles.successIcon}>
|
|
201
|
+
<Text style={styles.successCheck}>✓</Text>
|
|
202
|
+
</View>
|
|
203
|
+
<Text style={styles.title}>Wallet Connected</Text>
|
|
204
|
+
<Text style={styles.subtitle}>
|
|
205
|
+
Ready to sign requests from{'\n'}
|
|
206
|
+
<Text style={{ fontWeight: '600', color: colors.textPrimary }}>{displayOrigin}</Text>
|
|
207
|
+
</Text>
|
|
208
|
+
<Text style={styles.sessionId} numberOfLines={1}>
|
|
209
|
+
Session: {(sessionMeta?.topic ?? params.topic)?.slice(0, 16)}…
|
|
210
|
+
</Text>
|
|
211
|
+
</View>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Connecting spinner (both fresh and reconnect flows)
|
|
216
|
+
return (
|
|
217
|
+
<View style={styles.centered}>
|
|
218
|
+
<ActivityIndicator size="large" color={colors.info} />
|
|
219
|
+
<Text style={[styles.subtitle, { marginTop: spacing.lg }]}>Connecting…</Text>
|
|
220
|
+
</View>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<SafeAreaView style={styles.container}>
|
|
226
|
+
{renderContent()}
|
|
227
|
+
</SafeAreaView>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function makeStyles(colors: ReturnType<typeof import('@bsv/expo-wallet-toolbox').useTheme>['colors']) {
|
|
232
|
+
return StyleSheet.create({
|
|
233
|
+
container: {
|
|
234
|
+
flex: 1,
|
|
235
|
+
backgroundColor: colors.backgroundSecondary,
|
|
236
|
+
justifyContent: 'center',
|
|
237
|
+
padding: spacing.xxl,
|
|
238
|
+
},
|
|
239
|
+
centered: { alignItems: 'center' },
|
|
240
|
+
card: {
|
|
241
|
+
backgroundColor: colors.backgroundElevated,
|
|
242
|
+
borderRadius: radii.xl,
|
|
243
|
+
padding: spacing.xxl,
|
|
244
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
245
|
+
borderColor: colors.separator,
|
|
246
|
+
shadowColor: '#000',
|
|
247
|
+
shadowOpacity: 0.08,
|
|
248
|
+
shadowRadius: 12,
|
|
249
|
+
elevation: 3,
|
|
250
|
+
},
|
|
251
|
+
title: { ...typography.title2, color: colors.textPrimary, marginBottom: spacing.xs },
|
|
252
|
+
subtitle: { ...typography.subhead, color: colors.textSecondary, marginBottom: spacing.xxl, textAlign: 'center' },
|
|
253
|
+
infoBox: {
|
|
254
|
+
backgroundColor: colors.backgroundSecondary,
|
|
255
|
+
borderRadius: radii.lg,
|
|
256
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
257
|
+
borderColor: colors.separator,
|
|
258
|
+
marginBottom: spacing.xxl,
|
|
259
|
+
},
|
|
260
|
+
infoRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: spacing.md },
|
|
261
|
+
divider: { height: StyleSheet.hairlineWidth, backgroundColor: colors.separator },
|
|
262
|
+
infoLabel: { ...typography.footnote, color: colors.textSecondary },
|
|
263
|
+
infoValue: { ...typography.footnote, fontWeight: '500', color: colors.textPrimary, maxWidth: '60%', textAlign: 'right' },
|
|
264
|
+
buttonRow: { flexDirection: 'row', gap: spacing.md },
|
|
265
|
+
rejectBtn: {
|
|
266
|
+
flex: 1, paddingVertical: spacing.md + 2, borderRadius: radii.lg,
|
|
267
|
+
borderWidth: StyleSheet.hairlineWidth, borderColor: colors.separator,
|
|
268
|
+
backgroundColor: colors.fillSecondary, alignItems: 'center',
|
|
269
|
+
},
|
|
270
|
+
rejectBtnText: { ...typography.callout, fontWeight: '500', color: colors.textPrimary },
|
|
271
|
+
approveBtn: { flex: 1, paddingVertical: spacing.md + 2, borderRadius: radii.lg, backgroundColor: colors.accent, alignItems: 'center' },
|
|
272
|
+
approveBtnText: { ...typography.callout, fontWeight: '600', color: colors.textOnAccent },
|
|
273
|
+
secondaryBtn: {
|
|
274
|
+
marginTop: spacing.xxl, paddingVertical: spacing.md, paddingHorizontal: spacing.xxl,
|
|
275
|
+
borderRadius: radii.md, borderWidth: StyleSheet.hairlineWidth, borderColor: colors.separator,
|
|
276
|
+
},
|
|
277
|
+
secondaryBtnText: { ...typography.subhead, color: colors.textSecondary },
|
|
278
|
+
errorTitle: { ...typography.title3, color: colors.error, marginBottom: spacing.sm },
|
|
279
|
+
errorMsg: { ...typography.subhead, color: colors.textSecondary, textAlign: 'center' },
|
|
280
|
+
successIcon: {
|
|
281
|
+
width: 64, height: 64, borderRadius: 32,
|
|
282
|
+
backgroundColor: colors.fillTertiary,
|
|
283
|
+
justifyContent: 'center', alignItems: 'center', marginBottom: spacing.lg,
|
|
284
|
+
},
|
|
285
|
+
successCheck: { fontSize: 28, color: colors.success, fontWeight: '700' },
|
|
286
|
+
sessionId: { marginTop: spacing.lg, ...typography.caption2, color: colors.textTertiary },
|
|
287
|
+
})
|
|
288
|
+
}
|