@bsv/expo-wallet-toolbox 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -30
- package/README.md +79 -79
- package/core/backup/RemoteSyncReader.ts +26 -24
- package/core/backup/appData.ts +9 -8
- package/core/backup/codec.ts +21 -18
- package/core/backup/constants.ts +5 -5
- package/core/backup/contactsBackup.ts +8 -8
- package/core/backup/cursor.ts +12 -7
- package/core/backup/derive.ts +3 -3
- package/core/backup/deviceId.ts +2 -2
- package/core/backup/erase.ts +2 -2
- package/core/backup/preference.ts +2 -2
- package/core/backup/push.ts +10 -12
- package/core/backup/restore.ts +22 -14
- package/core/backup/restoreOnImport.ts +3 -2
- package/core/config.tsx +17 -13
- package/core/constants.ts +34 -11
- package/core/contacts/contactsStore.ts +4 -3
- package/core/context/WalletConnectionContext.tsx +294 -212
- package/core/context/WalletContext.tsx +132 -97
- package/core/context/defaultWalletSettings.ts +4 -2
- package/core/demo/demoLedger.ts +1 -5
- package/core/directpay/DirectPayProvider.tsx +15 -24
- package/core/directpay/receive.ts +2 -1
- package/core/headers/checkpoints.ts +10 -1
- package/core/headers/headerStore.ts +13 -2
- package/core/hooks/useConfirmationSound.ts +3 -3
- package/core/hooks/useHaptics.ts +23 -6
- package/core/i18n/translations.tsx +303 -123
- package/core/index.ts +2 -0
- package/core/localpay/codec.ts +12 -6
- package/core/localpay/deviceCaps.ts +4 -14
- package/core/localpay/pending.ts +2 -1
- package/core/localpay/qr.ts +1 -1
- package/core/localpay/settlementAck.ts +1 -4
- package/core/localpay/transport/ble.ts +2 -2
- package/core/localpay/transport/socket.ts +1 -1
- package/core/mandala/abortGuard.ts +1 -1
- package/core/mandala/drain.ts +3 -0
- package/core/mandala/permissionModule.ts +3 -2
- package/core/mandala/resendTransfer.ts +4 -1
- package/core/mandala/runtime.ts +4 -4
- package/core/monitor/TaskBackupPush.ts +10 -13
- package/core/net/chainMatch.ts +8 -5
- package/core/networks.ts +145 -0
- package/core/parsePeerPayURI.ts +4 -1
- package/core/pay/beefRepair.ts +6 -3
- package/core/pay/creditErrors.ts +37 -1
- package/core/pay/rails/address.ts +10 -6
- package/core/pay/rails/handle.ts +84 -11
- package/core/pay/rails/index.ts +18 -2
- package/core/pay/receiveHistory.ts +8 -8
- package/core/peerpay/handleResendRequests.ts +11 -18
- package/core/peerpay/inboxAttempts.ts +1 -4
- package/core/peerpay/rebuildToken.ts +12 -9
- package/core/profiles/profileStore.ts +2 -1
- package/core/profiles/removalProblems.ts +3 -1
- package/core/services/arcTokenStorage.ts +2 -1
- package/core/services/arcadeBroadcastProvider.ts +7 -17
- package/core/services/secrets/envelope.ts +1 -6
- package/core/services/secrets/hkdf.ts +1 -6
- package/core/services/secrets/index.ts +3 -22
- package/core/services/usdFxRates.ts +1 -4
- package/core/services/vault/VaultKeyService.ts +2 -1
- package/core/services/vault/chainRecovery.ts +48 -21
- package/core/services/vault/metaAuthority.ts +4 -1
- package/core/services/vault/r1comb.ts +113 -51
- package/core/services/vault/session.ts +5 -1
- package/core/services/vault/transfers.ts +699 -576
- package/core/services/vault/vaultStore.ts +12 -10
- package/core/services/walletArgLimits.ts +1 -2
- package/core/services/walletConnectionValidation.ts +44 -28
- package/core/services/walletServiceConfig.ts +9 -40
- package/core/storage/StorageExpoSQLite.ts +7 -21
- package/core/storage/methods/listActionsSql.ts +81 -67
- package/core/storage/methods/listOutputsSql.ts +21 -16
- package/core/storage/methods/reviewStatusSql.ts +1 -4
- package/core/stores/ConnectionStore.ts +1 -1
- package/core/theme/ThemeContext.tsx +12 -16
- package/core/theme/motion.ts +3 -3
- package/core/theme/tokens.ts +6 -6
- package/core/toolboxConfig.ts +23 -0
- package/core/walletDbRegistry.ts +7 -5
- package/core/walletRepair/runWalletCheck.ts +1 -4
- package/package.json +2 -2
- package/ui/components/pay/AddressReceive.tsx +3 -3
- package/ui/components/pay/HandleReceive.tsx +58 -15
- package/ui/components/pay/MessageBoxConfig.tsx +46 -20
- package/ui/components/pay/NearbyFlow.tsx +575 -507
- package/ui/components/pay/OfflineNotice.tsx +1 -3
- package/ui/components/pay/PayCellRow.tsx +1 -4
- package/ui/components/pay/PayForm.tsx +1 -3
- package/ui/components/pay/RequestHub.tsx +14 -6
- package/ui/components/pay/UniversalSend.tsx +137 -40
- package/ui/components/pay/tokenSendCopy.ts +1 -2
- package/ui/components/pay/useRecipientInput.ts +2 -2
- package/ui/components/security/WalletLockNotice.tsx +1 -3
- package/ui/components/ui/AlertCard.tsx +44 -45
- package/ui/components/ui/BlurChrome.tsx +4 -15
- package/ui/components/ui/Celebration.tsx +3 -3
- package/ui/components/ui/ChoiceSheet.ts +1 -3
- package/ui/components/ui/ErrorBoundary.tsx +2 -6
- package/ui/components/ui/GroupedList.tsx +13 -31
- package/ui/components/ui/IconButton.tsx +6 -9
- package/ui/components/ui/ListRow.tsx +19 -25
- package/ui/components/ui/PresenceRow.tsx +4 -4
- package/ui/components/ui/PressableScale.tsx +24 -20
- package/ui/components/ui/Toast.tsx +23 -16
- package/ui/components/vault/KeyChooser.tsx +9 -6
- package/ui/components/vault/VaultBackdrop.tsx +1 -8
- package/ui/components/vault/VaultCeremonySheet.tsx +5 -5
- package/ui/components/wallet/ActivityRow.tsx +3 -2
- package/ui/components/wallet/BackupReminderSheet.tsx +1 -5
- package/ui/components/wallet/Balance.tsx +4 -1
- package/ui/components/wallet/ContactActivityList.tsx +7 -7
- package/ui/components/wallet/IconPickerSheet.tsx +1 -5
- package/ui/components/wallet/ProfileSwitcherPopover.tsx +6 -1
- package/ui/components/wallet/tokenEviction.ts +4 -1
- package/ui/hooks/useMandala.ts +1 -7
- package/ui/hooks/useOfflineNoticeActions.ts +21 -27
- package/ui/hooks/useSpendableBalance.ts +2 -2
- package/ui/hooks/useVaultCoverage.ts +7 -1
- package/ui/index.ts +9 -1
- package/ui/resolveIdentity.ts +20 -8
- package/ui/screens/ConnectionsScreen.tsx +44 -18
- package/ui/screens/LogsScreen.tsx +24 -22
- package/ui/screens/PairScreen.tsx +85 -54
- package/ui/screens/PayScreen.tsx +5 -1
- package/ui/screens/ProfileScreen.tsx +0 -3
- package/ui/screens/TrustScreen.tsx +125 -80
- package/ui/screens/VaultScreen.tsx +19 -7
- package/ui/screens/VaultTransferScreen.tsx +5 -1
- package/ui/screens/WalletCheckScreen.tsx +14 -17
- package/ui/screens/WalletConfigScreen.tsx +414 -376
- package/ui/screens/WalletHomeScreen.tsx +47 -42
package/core/backup/restore.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface RestoreResult {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/** What the user can choose between when more than one device has a backup. */
|
|
72
|
-
export async function listBackups
|
|
72
|
+
export async function listBackups(deps: {
|
|
73
73
|
primaryKey: number[]
|
|
74
74
|
chain: BackupChain
|
|
75
75
|
baseUrl?: string
|
|
@@ -89,11 +89,11 @@ export async function listBackups (deps: {
|
|
|
89
89
|
* result says which way this restore was chosen; the chunk-count check below still runs
|
|
90
90
|
* either way as the last line of defence.
|
|
91
91
|
*/
|
|
92
|
-
export async function restoreFromBackup
|
|
92
|
+
export async function restoreFromBackup(deps: RestoreDeps): Promise<RestoreResult> {
|
|
93
93
|
const client = resolveClient(deps)
|
|
94
94
|
const wallet = deriveBackupWallet(deps.primaryKey, deps.chain)
|
|
95
95
|
|
|
96
|
-
const devices = deps.manifest ?? await client.manifest()
|
|
96
|
+
const devices = deps.manifest ?? (await client.manifest())
|
|
97
97
|
if (devices.length === 0) {
|
|
98
98
|
throw new Error('No backup found for this wallet')
|
|
99
99
|
}
|
|
@@ -140,14 +140,17 @@ export async function restoreFromBackup (deps: RestoreDeps): Promise<RestoreResu
|
|
|
140
140
|
offsets: []
|
|
141
141
|
})
|
|
142
142
|
|
|
143
|
-
const result = await deps.storage.processSyncChunk(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
const result = await deps.storage.processSyncChunk(
|
|
144
|
+
{
|
|
145
|
+
identityKey: deps.identityKey,
|
|
146
|
+
fromStorageIdentityKey: chosen.deviceId,
|
|
147
|
+
toStorageIdentityKey: settings.storageIdentityKey,
|
|
148
|
+
maxRoughSize: 0,
|
|
149
|
+
maxItems: 0,
|
|
150
|
+
offsets: []
|
|
151
|
+
},
|
|
152
|
+
chunk
|
|
153
|
+
)
|
|
151
154
|
|
|
152
155
|
if (result.done) {
|
|
153
156
|
if (chunks < reader.length) throw new Error('Backup replay completed before all indexed chunks were applied')
|
|
@@ -179,7 +182,7 @@ export async function restoreFromBackup (deps: RestoreDeps): Promise<RestoreResu
|
|
|
179
182
|
* which also reconciles notification IDs and preserves completed transactions.
|
|
180
183
|
* Run only after the entire log lands, before the wallet/monitor is published.
|
|
181
184
|
*/
|
|
182
|
-
async function reconcileRestoredProofs
|
|
185
|
+
async function reconcileRestoredProofs(storage: StorageExpoSQLite, onActivity?: () => void): Promise<void> {
|
|
183
186
|
const limit = 1
|
|
184
187
|
for (let offset = 0; ; offset += limit) {
|
|
185
188
|
if (offset > 0) onActivity?.()
|
|
@@ -240,7 +243,7 @@ export interface PickedTarget {
|
|
|
240
243
|
* newest generation" heuristic, with `verified: false` so the caller can warn rather than
|
|
241
244
|
* silently claim a verified restore.
|
|
242
245
|
*/
|
|
243
|
-
export async function pickTarget
|
|
246
|
+
export async function pickTarget(
|
|
244
247
|
devices: DeviceSummary[],
|
|
245
248
|
client: BackupClient,
|
|
246
249
|
wallet: CompletedProtoWallet,
|
|
@@ -303,7 +306,12 @@ export async function pickTarget (
|
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
308
|
|
|
306
|
-
function resolveClient
|
|
309
|
+
function resolveClient(deps: {
|
|
310
|
+
primaryKey: number[]
|
|
311
|
+
chain: BackupChain
|
|
312
|
+
baseUrl?: string
|
|
313
|
+
client?: BackupClient
|
|
314
|
+
}): BackupClient {
|
|
307
315
|
if (deps.client != null) return deps.client
|
|
308
316
|
if (deps.baseUrl == null || deps.baseUrl === '') {
|
|
309
317
|
throw new Error('restore requires either a client or a baseUrl')
|
|
@@ -95,8 +95,9 @@ export interface RestoreOnImportResult {
|
|
|
95
95
|
verified?: boolean
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export async function restoreOnImport
|
|
99
|
-
const client =
|
|
98
|
+
export async function restoreOnImport(deps: RestoreOnImportDeps): Promise<RestoreOnImportResult> {
|
|
99
|
+
const client =
|
|
100
|
+
deps.client ?? (hasUrl(deps.baseUrl) ? new BackupClient(deps.baseUrl!, deps.primaryKey, deps.chain) : null)
|
|
100
101
|
if (client == null) {
|
|
101
102
|
return { restored: false, chunks: 0, reason: 'not-configured' }
|
|
102
103
|
}
|
package/core/config.tsx
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Chain as ToolboxChain } from '@bsv/wallet-toolbox-mobile'
|
|
2
|
+
import { NETWORKS, type AppChain } from './networks'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
* The wallet-toolbox `Chain` type used by @bsv/wallet-toolbox-mobile.
|
|
5
|
-
* Mirrors `Chain = 'main' | 'test' | 'ttn' | 'mock'` from the toolbox sdk.
|
|
6
|
-
*/
|
|
7
|
-
export type WalletChain = 'main' | 'test' | 'ttn'
|
|
4
|
+
export type { AppChain, WalletChain } from './networks'
|
|
8
5
|
|
|
9
6
|
/**
|
|
10
7
|
* Map our app-level chain id to the wallet-toolbox `Chain` value.
|
|
11
|
-
* The app persists/displays `'teratest'`, but the toolbox
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* The app persists/displays `'teratest'` and `'scaletest'`, but the toolbox
|
|
9
|
+
* identifies them as `'ttn'` and `'regtest'`. Keep the app names for
|
|
10
|
+
* AsyncStorage keys, env var names (`EXPO_PUBLIC_TERATEST_*`) and UI; convert
|
|
11
|
+
* only at toolbox boundaries.
|
|
12
|
+
*
|
|
13
|
+
* The one cast in the chain mapping: `'regtest'` joins the toolbox's `Chain`
|
|
14
|
+
* in @bsv/wallet-toolbox 2.15.0 (bsv-blockchain/ts-stack#819). Only scaletest
|
|
15
|
+
* maps to it, and scaletest is not available (NETWORKS.scaletest.available),
|
|
16
|
+
* so the installed 2.14.x never receives it. Drop the cast when the
|
|
17
|
+
* dependency is bumped.
|
|
15
18
|
*/
|
|
16
|
-
export function toWalletChain(chain: AppChain):
|
|
17
|
-
return chain
|
|
19
|
+
export function toWalletChain(chain: AppChain): ToolboxChain {
|
|
20
|
+
return NETWORKS[chain].walletChain as ToolboxChain
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export const DEFAULT_WAB_URL = 'noWAB'
|
|
21
24
|
export const DEFAULT_STORAGE_URL = 'local'
|
|
22
|
-
|
|
25
|
+
/** Mainnet's MessageBox server. Each network has its own: see `NETWORKS`. */
|
|
26
|
+
export const DEFAULT_MESSAGEBOX_URL = NETWORKS.main.messageBoxUrl
|
|
23
27
|
/**
|
|
24
28
|
* Encrypted wallet-backup log.
|
|
25
29
|
*
|
package/core/constants.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NETWORKS, type AppChain } from './networks'
|
|
2
|
+
|
|
1
3
|
/** Auto-approve transactions below this satoshi amount without showing the spend modal */
|
|
2
4
|
export const DEFAULT_AUTO_APPROVE_THRESHOLD = 100_000
|
|
3
5
|
/** Minimum milliseconds between two auto-approved transactions from the SAME originator */
|
|
@@ -33,16 +35,37 @@ export const arcUrlStorageKey = (network: string) => `arc_custom_url_${network}`
|
|
|
33
35
|
export const arcApiTokenStorageKey = (network: string) => `arc_custom_api_token_${network}`
|
|
34
36
|
|
|
35
37
|
/** Default ARC URLs per network */
|
|
36
|
-
export const DEFAULT_ARC_URLS: Record<
|
|
37
|
-
main:
|
|
38
|
-
test:
|
|
39
|
-
teratest:
|
|
38
|
+
export const DEFAULT_ARC_URLS: Record<AppChain, string> = {
|
|
39
|
+
main: NETWORKS.main.arcadeUrl,
|
|
40
|
+
test: NETWORKS.test.arcadeUrl,
|
|
41
|
+
teratest: NETWORKS.teratest.arcadeUrl,
|
|
42
|
+
scaletest: NETWORKS.scaletest.arcadeUrl
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface KnownArcUrl {
|
|
46
|
+
label: string
|
|
47
|
+
url: string
|
|
48
|
+
requiresToken: boolean
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Known ARC endpoint presets, per network. Each list names only endpoints that
|
|
53
|
+
* serve that network: picking a mainnet ARC on a test chain posts its
|
|
54
|
+
* transactions to a network that will reject them (or, worse, accept a replay).
|
|
55
|
+
* The scaling and tera test networks have one Arcade each, so they offer no
|
|
56
|
+
* presets beyond their default.
|
|
57
|
+
*/
|
|
58
|
+
export const KNOWN_ARC_URLS: Record<AppChain, readonly KnownArcUrl[]> = {
|
|
59
|
+
main: [
|
|
60
|
+
{ label: 'Arcade v2 (default)', url: NETWORKS.main.arcadeUrl, requiresToken: false },
|
|
61
|
+
{ label: 'Arcade', url: 'https://arcade-us-1.bsvb.tech', requiresToken: false },
|
|
62
|
+
{ label: 'TAAL', url: 'https://arc.taal.com', requiresToken: true },
|
|
63
|
+
{ label: 'GorillaPool', url: 'https://arc.gorillapool.io', requiresToken: false }
|
|
64
|
+
],
|
|
65
|
+
test: [
|
|
66
|
+
{ label: 'Arcade v2 (default)', url: NETWORKS.test.arcadeUrl, requiresToken: false },
|
|
67
|
+
{ label: 'TAAL', url: 'https://arc-test.taal.com', requiresToken: true }
|
|
68
|
+
],
|
|
69
|
+
teratest: [{ label: 'Arcade v2 (default)', url: NETWORKS.teratest.arcadeUrl, requiresToken: false }],
|
|
70
|
+
scaletest: [{ label: 'Arcade (default)', url: NETWORKS.scaletest.arcadeUrl, requiresToken: false }]
|
|
71
|
+
}
|
|
@@ -118,9 +118,10 @@ export interface ContactsStore {
|
|
|
118
118
|
export function createContactsStore(db: ContactsDb): ContactsStore {
|
|
119
119
|
return {
|
|
120
120
|
async listContacts(userId) {
|
|
121
|
-
const rows = (await db.getAllAsync(
|
|
122
|
-
userId
|
|
123
|
-
|
|
121
|
+
const rows = (await db.getAllAsync(
|
|
122
|
+
'SELECT * FROM contacts WHERE userId = ? AND removedAt IS NULL ORDER BY name COLLATE NOCASE ASC',
|
|
123
|
+
[userId]
|
|
124
|
+
)) as ContactDbRow[]
|
|
124
125
|
return rows.map(toContact)
|
|
125
126
|
},
|
|
126
127
|
|