@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.
@@ -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 AsyncStorage.getItem(registryKey(keySuffix, chain))
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 AsyncStorage.setItem(registryKey(keySuffix, chain), JSON.stringify(existing))
123
+ await getAsyncStorage().setItem(registryKey(keySuffix, chain), JSON.stringify(existing))
110
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/expo-wallet-toolbox",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -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">Identity Key</div>
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>
@@ -257,7 +257,7 @@ function ActivityRowBase({
257
257
  {action.txid && !parked ? (
258
258
  <Chip
259
259
  icon="link-outline"
260
- label="WoC"
260
+ label="Explorer"
261
261
  accessibilityLabel={t('tx_action_explorer')}
262
262
  onPress={() => onExplorer(action.txid)}
263
263
  />
@@ -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 identity key is not a valid public key' }
125
+ return { params: null, error: 'Backend identifier is not valid' }
126
126
  }
127
127
 
128
128
  let proto: unknown