@bsv/expo-wallet-toolbox 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/core/i18n/translations.tsx +2603 -1105
- package/core/walletDbRegistry.ts +18 -4
- package/package.json +1 -1
- package/ui/backupShares.ts +1 -1
- package/ui/components/wallet/ActivityRow.tsx +1 -1
- package/ui/screens/ConnectionsScreen.tsx +1 -1
package/core/walletDbRegistry.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Wallet database filename registry.
|
|
5
3
|
*
|
|
@@ -81,6 +79,22 @@ export function selectLatestDb(filenames: string[]): string {
|
|
|
81
79
|
|
|
82
80
|
// ── AsyncStorage-backed registry ────────────────────────────────────────────
|
|
83
81
|
|
|
82
|
+
// Required lazily, on first call, rather than imported statically — this
|
|
83
|
+
// file is barrel-exported from the package root, and a static top-level
|
|
84
|
+
// `import` of a native module gets eagerly evaluated for every consumer of
|
|
85
|
+
// the barrel, which breaks a plain `jest` host that never touches the
|
|
86
|
+
// registry (no native module to resolve). Same class of issue documented on
|
|
87
|
+
// useHaptics.ts and services/vault/driver.ts/random.ts's lazy requires.
|
|
88
|
+
type AsyncStorageModule = typeof import('@react-native-async-storage/async-storage')['default']
|
|
89
|
+
let asyncStorage: AsyncStorageModule | undefined
|
|
90
|
+
function getAsyncStorage(): AsyncStorageModule {
|
|
91
|
+
if (!asyncStorage) {
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
93
|
+
asyncStorage = require('@react-native-async-storage/async-storage').default as AsyncStorageModule
|
|
94
|
+
}
|
|
95
|
+
return asyncStorage
|
|
96
|
+
}
|
|
97
|
+
|
|
84
98
|
function registryKey(keySuffix: string, chain: string): string {
|
|
85
99
|
return `walletDbs-${keySuffix}-${chain}net`
|
|
86
100
|
}
|
|
@@ -89,7 +103,7 @@ function registryKey(keySuffix: string, chain: string): string {
|
|
|
89
103
|
* Return all registered wallet DB filenames for the given identity + chain.
|
|
90
104
|
*/
|
|
91
105
|
export async function getRegisteredDbs(keySuffix: string, chain: string): Promise<string[]> {
|
|
92
|
-
const raw = await
|
|
106
|
+
const raw = await getAsyncStorage().getItem(registryKey(keySuffix, chain))
|
|
93
107
|
if (!raw) return []
|
|
94
108
|
try {
|
|
95
109
|
const arr = JSON.parse(raw)
|
|
@@ -106,5 +120,5 @@ export async function registerDb(keySuffix: string, chain: string, filename: str
|
|
|
106
120
|
const existing = await getRegisteredDbs(keySuffix, chain)
|
|
107
121
|
if (existing.includes(filename)) return
|
|
108
122
|
existing.push(filename)
|
|
109
|
-
await
|
|
123
|
+
await getAsyncStorage().setItem(registryKey(keySuffix, chain), JSON.stringify(existing))
|
|
110
124
|
}
|
package/package.json
CHANGED
package/ui/backupShares.ts
CHANGED
|
@@ -217,7 +217,7 @@ export async function generatePrintHTML(
|
|
|
217
217
|
<div class="qr-container identity-qr">
|
|
218
218
|
${identityQR}
|
|
219
219
|
</div>
|
|
220
|
-
<div class="data-label">
|
|
220
|
+
<div class="data-label">Identifier</div>
|
|
221
221
|
<div class="data-value">${identityKey}</div>
|
|
222
222
|
<div class="identity-caption">Scan this QR code to send BSV payments to this wallet.</div>
|
|
223
223
|
</div>
|
|
@@ -122,7 +122,7 @@ function parsePairingUri(raw: string): ParseResult {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (!/^0[23][0-9a-fA-F]{64}$/.test(backendIdentityKey)) {
|
|
125
|
-
return { params: null, error: 'Backend
|
|
125
|
+
return { params: null, error: 'Backend identifier is not valid' }
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
let proto: unknown
|