@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,432 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
ScrollView,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
ActivityIndicator,
|
|
9
|
+
Platform
|
|
10
|
+
} from 'react-native'
|
|
11
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
|
+
import { showToast } from '../components/ui/Toast'
|
|
13
|
+
import { useTheme, spacing, typography, radii, useWallet } from '@bsv/expo-wallet-toolbox'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
|
|
17
|
+
* etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
|
|
18
|
+
* that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
|
|
19
|
+
* Ionicons is loaded lazily, only when actually rendering, same pattern as
|
|
20
|
+
* this package's other native-module-boundary fixes (expo-router, expo-blur).
|
|
21
|
+
*/
|
|
22
|
+
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
23
|
+
let ioniconsComponent: IoniconsComponent | undefined
|
|
24
|
+
function loadIonicons(): IoniconsComponent {
|
|
25
|
+
if (!ioniconsComponent) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
27
|
+
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
28
|
+
}
|
|
29
|
+
return ioniconsComponent
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* expo-router is required lazily rather than imported at module scope: this
|
|
34
|
+
* file is barrel-exported from the package's `ui` entry point, and a static
|
|
35
|
+
* top-level `import` of expo-router pulls in its own untransformed JSX
|
|
36
|
+
* source (Navigator.js etc.), which Jest cannot parse for any consumer of the
|
|
37
|
+
* barrel, even one that never navigates. Same pattern as this package's other
|
|
38
|
+
* lazy expo-router loads (WalletHomeScreen.tsx, VaultScreen.tsx, etc.).
|
|
39
|
+
*/
|
|
40
|
+
type ExpoRouterModule = typeof import('expo-router')
|
|
41
|
+
let expoRouterMod: ExpoRouterModule | undefined
|
|
42
|
+
function loadExpoRouter(): ExpoRouterModule {
|
|
43
|
+
if (!expoRouterMod) {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
45
|
+
expoRouterMod = require('expo-router') as ExpoRouterModule
|
|
46
|
+
}
|
|
47
|
+
return expoRouterMod
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @react-native-clipboard/clipboard reaches for its native TurboModule at
|
|
52
|
+
* import time (`TurboModuleRegistry.getEnforcing`), which throws under Jest
|
|
53
|
+
* (no native binary registered there) even though the module itself
|
|
54
|
+
* transforms fine. Required lazily, only when a handler actually copies
|
|
55
|
+
* something, so importing the `ui` barrel never touches the native module.
|
|
56
|
+
*/
|
|
57
|
+
type ClipboardModule = typeof import('@react-native-clipboard/clipboard').default
|
|
58
|
+
let clipboardModule: ClipboardModule | undefined
|
|
59
|
+
function loadClipboard(): ClipboardModule {
|
|
60
|
+
if (!clipboardModule) {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
62
|
+
clipboardModule = require('@react-native-clipboard/clipboard').default as ClipboardModule
|
|
63
|
+
}
|
|
64
|
+
return clipboardModule
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface LogEntry {
|
|
68
|
+
id: string
|
|
69
|
+
taskName: string
|
|
70
|
+
timestamp: string
|
|
71
|
+
output: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function LogsScreen() {
|
|
75
|
+
const { colors } = useTheme()
|
|
76
|
+
const insets = useSafeAreaInsets()
|
|
77
|
+
const { router } = loadExpoRouter()
|
|
78
|
+
const Ionicons = loadIonicons()
|
|
79
|
+
const { runMonitorTask, getMonitorTaskNames, checkUtxoSpendability, releaseStuckReservations } = useWallet()
|
|
80
|
+
|
|
81
|
+
const [taskNames, setTaskNames] = useState<string[]>([])
|
|
82
|
+
const [logs, setLogs] = useState<LogEntry[]>([])
|
|
83
|
+
const [running, setRunning] = useState<string | null>(null)
|
|
84
|
+
const [copiedId, setCopiedId] = useState<string | null>(null)
|
|
85
|
+
const scrollRef = useRef<ScrollView>(null)
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
setTaskNames(getMonitorTaskNames())
|
|
89
|
+
}, [getMonitorTaskNames])
|
|
90
|
+
|
|
91
|
+
const runTask = useCallback(
|
|
92
|
+
async (name: string) => {
|
|
93
|
+
setRunning(name)
|
|
94
|
+
try {
|
|
95
|
+
const output = await runMonitorTask(name)
|
|
96
|
+
const entry: LogEntry = {
|
|
97
|
+
id: `${Date.now()}_${name}`,
|
|
98
|
+
taskName: name,
|
|
99
|
+
timestamp: new Date().toISOString(),
|
|
100
|
+
output: output || '(no output)'
|
|
101
|
+
}
|
|
102
|
+
setLogs(prev => [...prev, entry])
|
|
103
|
+
setTimeout(() => scrollRef.current?.scrollToEnd({ animated: true }), 100)
|
|
104
|
+
} catch (e: any) {
|
|
105
|
+
const entry: LogEntry = {
|
|
106
|
+
id: `${Date.now()}_${name}`,
|
|
107
|
+
taskName: name,
|
|
108
|
+
timestamp: new Date().toISOString(),
|
|
109
|
+
output: `Error: ${e.message || 'unknown'}`
|
|
110
|
+
}
|
|
111
|
+
setLogs(prev => [...prev, entry])
|
|
112
|
+
} finally {
|
|
113
|
+
setRunning(null)
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
[runMonitorTask]
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
const runUtxoCheck = useCallback(async () => {
|
|
120
|
+
const name = 'CheckUTXOs'
|
|
121
|
+
setRunning(name)
|
|
122
|
+
try {
|
|
123
|
+
const output = await checkUtxoSpendability()
|
|
124
|
+
const entry: LogEntry = {
|
|
125
|
+
id: `${Date.now()}_${name}`,
|
|
126
|
+
taskName: name,
|
|
127
|
+
timestamp: new Date().toISOString(),
|
|
128
|
+
output: output || '(no output)'
|
|
129
|
+
}
|
|
130
|
+
setLogs(prev => [...prev, entry])
|
|
131
|
+
setTimeout(() => scrollRef.current?.scrollToEnd({ animated: true }), 100)
|
|
132
|
+
} catch (e: any) {
|
|
133
|
+
const entry: LogEntry = {
|
|
134
|
+
id: `${Date.now()}_${name}`,
|
|
135
|
+
taskName: name,
|
|
136
|
+
timestamp: new Date().toISOString(),
|
|
137
|
+
output: `Error: ${e.message || 'unknown'}`
|
|
138
|
+
}
|
|
139
|
+
setLogs(prev => [...prev, entry])
|
|
140
|
+
} finally {
|
|
141
|
+
setRunning(null)
|
|
142
|
+
}
|
|
143
|
+
}, [checkUtxoSpendability])
|
|
144
|
+
|
|
145
|
+
const runRelease = useCallback(async () => {
|
|
146
|
+
const name = 'ReleaseStuck'
|
|
147
|
+
setRunning(name)
|
|
148
|
+
try {
|
|
149
|
+
const output = await releaseStuckReservations()
|
|
150
|
+
setLogs(prev => [
|
|
151
|
+
...prev,
|
|
152
|
+
{ id: `${Date.now()}_${name}`, taskName: name, timestamp: new Date().toISOString(), output: output || '(no output)' }
|
|
153
|
+
])
|
|
154
|
+
setTimeout(() => scrollRef.current?.scrollToEnd({ animated: true }), 100)
|
|
155
|
+
} catch (e: any) {
|
|
156
|
+
setLogs(prev => [
|
|
157
|
+
...prev,
|
|
158
|
+
{ id: `${Date.now()}_${name}`, taskName: name, timestamp: new Date().toISOString(), output: `Error: ${e.message || 'unknown'}` }
|
|
159
|
+
])
|
|
160
|
+
} finally {
|
|
161
|
+
setRunning(null)
|
|
162
|
+
}
|
|
163
|
+
}, [releaseStuckReservations])
|
|
164
|
+
|
|
165
|
+
const runAll = useCallback(async () => {
|
|
166
|
+
for (const name of taskNames) {
|
|
167
|
+
await runTask(name)
|
|
168
|
+
}
|
|
169
|
+
}, [taskNames, runTask])
|
|
170
|
+
|
|
171
|
+
const copyEntry = useCallback((entry: LogEntry) => {
|
|
172
|
+
loadClipboard().setString(`[${entry.timestamp}] ${entry.taskName}\n${entry.output}`)
|
|
173
|
+
setCopiedId(entry.id)
|
|
174
|
+
setTimeout(() => setCopiedId(null), 1500)
|
|
175
|
+
}, [])
|
|
176
|
+
|
|
177
|
+
const copyAll = useCallback(() => {
|
|
178
|
+
const text = logs
|
|
179
|
+
.map(e => `[${e.timestamp}] ${e.taskName}\n${e.output}`)
|
|
180
|
+
.join('\n\n')
|
|
181
|
+
loadClipboard().setString(text)
|
|
182
|
+
showToast('Copied all logs', { type: 'success' })
|
|
183
|
+
}, [logs])
|
|
184
|
+
|
|
185
|
+
const clearLogs = useCallback(() => {
|
|
186
|
+
setLogs([])
|
|
187
|
+
}, [])
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<View style={[styles.container, { backgroundColor: colors.backgroundSecondary, paddingTop: insets.top }]}>
|
|
191
|
+
{/* Header */}
|
|
192
|
+
<View style={[styles.header, { borderBottomColor: colors.separator }]}>
|
|
193
|
+
<TouchableOpacity onPress={() => router.back()} style={styles.headerBtn}>
|
|
194
|
+
<Ionicons name="chevron-back" size={24} color={colors.textSecondary} />
|
|
195
|
+
</TouchableOpacity>
|
|
196
|
+
<Text style={[styles.headerTitle, { color: colors.textPrimary }]}>Debugging</Text>
|
|
197
|
+
<View style={styles.headerActions}>
|
|
198
|
+
{logs.length > 0 && (
|
|
199
|
+
<TouchableOpacity onPress={copyAll} style={styles.headerBtn}>
|
|
200
|
+
<Ionicons name="copy-outline" size={20} color={colors.accent} />
|
|
201
|
+
</TouchableOpacity>
|
|
202
|
+
)}
|
|
203
|
+
{logs.length > 0 && (
|
|
204
|
+
<TouchableOpacity onPress={clearLogs} style={styles.headerBtn}>
|
|
205
|
+
<Ionicons name="trash-outline" size={20} color={colors.textSecondary} />
|
|
206
|
+
</TouchableOpacity>
|
|
207
|
+
)}
|
|
208
|
+
</View>
|
|
209
|
+
</View>
|
|
210
|
+
|
|
211
|
+
{/* Task buttons */}
|
|
212
|
+
<View style={[styles.taskBar, { borderBottomColor: colors.separator }]}>
|
|
213
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.taskBarContent}>
|
|
214
|
+
<TouchableOpacity
|
|
215
|
+
onPress={runAll}
|
|
216
|
+
disabled={!!running}
|
|
217
|
+
style={[styles.taskPill, { backgroundColor: colors.accent, opacity: running ? 0.5 : 1 }]}
|
|
218
|
+
>
|
|
219
|
+
{running ? (
|
|
220
|
+
<ActivityIndicator size="small" color={colors.background} />
|
|
221
|
+
) : (
|
|
222
|
+
<Text style={[styles.taskPillText, { color: colors.background }]}>Run All</Text>
|
|
223
|
+
)}
|
|
224
|
+
</TouchableOpacity>
|
|
225
|
+
{taskNames.map(name => (
|
|
226
|
+
<TouchableOpacity
|
|
227
|
+
key={name}
|
|
228
|
+
onPress={() => runTask(name)}
|
|
229
|
+
disabled={!!running}
|
|
230
|
+
style={[
|
|
231
|
+
styles.taskPill,
|
|
232
|
+
{
|
|
233
|
+
backgroundColor: running === name ? colors.accent : colors.backgroundSecondary,
|
|
234
|
+
borderColor: colors.separator,
|
|
235
|
+
borderWidth: running === name ? 0 : StyleSheet.hairlineWidth,
|
|
236
|
+
opacity: running && running !== name ? 0.5 : 1
|
|
237
|
+
}
|
|
238
|
+
]}
|
|
239
|
+
>
|
|
240
|
+
{running === name ? (
|
|
241
|
+
<ActivityIndicator size="small" color={colors.background} />
|
|
242
|
+
) : (
|
|
243
|
+
<Text
|
|
244
|
+
style={[styles.taskPillText, { color: running === name ? colors.background : colors.textPrimary }]}
|
|
245
|
+
numberOfLines={1}
|
|
246
|
+
>
|
|
247
|
+
{name}
|
|
248
|
+
</Text>
|
|
249
|
+
)}
|
|
250
|
+
</TouchableOpacity>
|
|
251
|
+
))}
|
|
252
|
+
<TouchableOpacity
|
|
253
|
+
onPress={runUtxoCheck}
|
|
254
|
+
disabled={!!running}
|
|
255
|
+
style={[
|
|
256
|
+
styles.taskPill,
|
|
257
|
+
{
|
|
258
|
+
backgroundColor: running === 'CheckUTXOs' ? colors.accent : colors.backgroundSecondary,
|
|
259
|
+
borderColor: colors.separator,
|
|
260
|
+
borderWidth: running === 'CheckUTXOs' ? 0 : StyleSheet.hairlineWidth,
|
|
261
|
+
opacity: running && running !== 'CheckUTXOs' ? 0.5 : 1
|
|
262
|
+
}
|
|
263
|
+
]}
|
|
264
|
+
>
|
|
265
|
+
{running === 'CheckUTXOs' ? (
|
|
266
|
+
<ActivityIndicator size="small" color={colors.background} />
|
|
267
|
+
) : (
|
|
268
|
+
<Text
|
|
269
|
+
style={[styles.taskPillText, { color: running === 'CheckUTXOs' ? colors.background : colors.textPrimary }]}
|
|
270
|
+
numberOfLines={1}
|
|
271
|
+
>
|
|
272
|
+
CheckUTXOs
|
|
273
|
+
</Text>
|
|
274
|
+
)}
|
|
275
|
+
</TouchableOpacity>
|
|
276
|
+
<TouchableOpacity
|
|
277
|
+
onPress={runRelease}
|
|
278
|
+
disabled={!!running}
|
|
279
|
+
style={[
|
|
280
|
+
styles.taskPill,
|
|
281
|
+
{
|
|
282
|
+
backgroundColor: running === 'ReleaseStuck' ? colors.accent : colors.backgroundSecondary,
|
|
283
|
+
borderColor: colors.separator,
|
|
284
|
+
borderWidth: running === 'ReleaseStuck' ? 0 : StyleSheet.hairlineWidth,
|
|
285
|
+
opacity: running && running !== 'ReleaseStuck' ? 0.5 : 1
|
|
286
|
+
}
|
|
287
|
+
]}
|
|
288
|
+
>
|
|
289
|
+
{running === 'ReleaseStuck' ? (
|
|
290
|
+
<ActivityIndicator size="small" color={colors.background} />
|
|
291
|
+
) : (
|
|
292
|
+
<Text
|
|
293
|
+
style={[styles.taskPillText, { color: running === 'ReleaseStuck' ? colors.background : colors.textPrimary }]}
|
|
294
|
+
numberOfLines={1}
|
|
295
|
+
>
|
|
296
|
+
Release stuck
|
|
297
|
+
</Text>
|
|
298
|
+
)}
|
|
299
|
+
</TouchableOpacity>
|
|
300
|
+
</ScrollView>
|
|
301
|
+
</View>
|
|
302
|
+
|
|
303
|
+
{/* Log output */}
|
|
304
|
+
<ScrollView
|
|
305
|
+
ref={scrollRef}
|
|
306
|
+
style={[styles.terminal, { backgroundColor: '#12161D' }]}
|
|
307
|
+
contentContainerStyle={styles.terminalContent}
|
|
308
|
+
>
|
|
309
|
+
{logs.length === 0 && (
|
|
310
|
+
<Text style={styles.emptyText}>Tap a task above to run it and see output here.</Text>
|
|
311
|
+
)}
|
|
312
|
+
{logs.map(entry => {
|
|
313
|
+
const isCopied = copiedId === entry.id
|
|
314
|
+
return (
|
|
315
|
+
<TouchableOpacity
|
|
316
|
+
key={entry.id}
|
|
317
|
+
onPress={() => copyEntry(entry)}
|
|
318
|
+
activeOpacity={0.7}
|
|
319
|
+
style={[styles.logEntry, { borderBottomColor: 'rgba(255,255,255,0.08)' }]}
|
|
320
|
+
>
|
|
321
|
+
<View style={styles.logHeader}>
|
|
322
|
+
<Text style={styles.logTaskName}>{entry.taskName}</Text>
|
|
323
|
+
<Text style={styles.logTimestamp}>
|
|
324
|
+
{new Date(entry.timestamp).toLocaleTimeString()}
|
|
325
|
+
</Text>
|
|
326
|
+
<Ionicons
|
|
327
|
+
name={isCopied ? 'checkmark' : 'copy-outline'}
|
|
328
|
+
size={14}
|
|
329
|
+
color={isCopied ? '#34C77B' : 'rgba(235,240,248,0.38)'}
|
|
330
|
+
style={{ marginLeft: 6 }}
|
|
331
|
+
/>
|
|
332
|
+
</View>
|
|
333
|
+
<Text style={styles.logOutput} selectable>
|
|
334
|
+
{entry.output}
|
|
335
|
+
</Text>
|
|
336
|
+
</TouchableOpacity>
|
|
337
|
+
)
|
|
338
|
+
})}
|
|
339
|
+
<View style={{ height: insets.bottom + 20 }} />
|
|
340
|
+
</ScrollView>
|
|
341
|
+
</View>
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const styles = StyleSheet.create({
|
|
346
|
+
container: {
|
|
347
|
+
flex: 1
|
|
348
|
+
},
|
|
349
|
+
header: {
|
|
350
|
+
flexDirection: 'row',
|
|
351
|
+
alignItems: 'center',
|
|
352
|
+
justifyContent: 'space-between',
|
|
353
|
+
paddingHorizontal: spacing.sm,
|
|
354
|
+
paddingVertical: spacing.md,
|
|
355
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
356
|
+
},
|
|
357
|
+
headerBtn: {
|
|
358
|
+
width: 44,
|
|
359
|
+
height: 44,
|
|
360
|
+
alignItems: 'center',
|
|
361
|
+
justifyContent: 'center'
|
|
362
|
+
},
|
|
363
|
+
headerTitle: {
|
|
364
|
+
...typography.headline,
|
|
365
|
+
fontWeight: '600',
|
|
366
|
+
flex: 1,
|
|
367
|
+
textAlign: 'center'
|
|
368
|
+
},
|
|
369
|
+
headerActions: {
|
|
370
|
+
flexDirection: 'row'
|
|
371
|
+
},
|
|
372
|
+
taskBar: {
|
|
373
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
374
|
+
paddingVertical: spacing.sm
|
|
375
|
+
},
|
|
376
|
+
taskBarContent: {
|
|
377
|
+
paddingHorizontal: spacing.md,
|
|
378
|
+
gap: spacing.xs
|
|
379
|
+
},
|
|
380
|
+
taskPill: {
|
|
381
|
+
paddingHorizontal: spacing.md,
|
|
382
|
+
paddingVertical: spacing.xs + 2,
|
|
383
|
+
borderRadius: radii.sm,
|
|
384
|
+
minWidth: 60,
|
|
385
|
+
alignItems: 'center'
|
|
386
|
+
},
|
|
387
|
+
taskPillText: {
|
|
388
|
+
...typography.caption1,
|
|
389
|
+
fontWeight: '600'
|
|
390
|
+
},
|
|
391
|
+
terminal: {
|
|
392
|
+
flex: 1
|
|
393
|
+
},
|
|
394
|
+
terminalContent: {
|
|
395
|
+
padding: spacing.md
|
|
396
|
+
},
|
|
397
|
+
emptyText: {
|
|
398
|
+
color: 'rgba(235,240,248,0.38)',
|
|
399
|
+
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
|
400
|
+
fontSize: 13,
|
|
401
|
+
textAlign: 'center',
|
|
402
|
+
marginTop: spacing.xxl
|
|
403
|
+
},
|
|
404
|
+
logEntry: {
|
|
405
|
+
marginBottom: spacing.md,
|
|
406
|
+
paddingBottom: spacing.md,
|
|
407
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
408
|
+
},
|
|
409
|
+
logHeader: {
|
|
410
|
+
flexDirection: 'row',
|
|
411
|
+
alignItems: 'center',
|
|
412
|
+
marginBottom: 4
|
|
413
|
+
},
|
|
414
|
+
logTaskName: {
|
|
415
|
+
color: '#FF9F0A',
|
|
416
|
+
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
|
417
|
+
fontSize: 12,
|
|
418
|
+
fontWeight: '700'
|
|
419
|
+
},
|
|
420
|
+
logTimestamp: {
|
|
421
|
+
color: 'rgba(235,240,248,0.38)',
|
|
422
|
+
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
|
423
|
+
fontSize: 11,
|
|
424
|
+
marginLeft: 'auto'
|
|
425
|
+
},
|
|
426
|
+
logOutput: {
|
|
427
|
+
color: '#E4E8EF',
|
|
428
|
+
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
|
429
|
+
fontSize: 12,
|
|
430
|
+
lineHeight: 18
|
|
431
|
+
}
|
|
432
|
+
})
|