@bsv/expo-wallet-toolbox 0.2.1 → 0.3.1

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.
@@ -28,17 +28,19 @@ import { EnvelopeBlob, EnvelopeError, SECRET_NAMES, SecretName } from './types'
28
28
  * the stale ciphertext. Harmless — it was already unopenable — but don't call
29
29
  * it speculatively in a hot path.
30
30
  */
31
- export async function hasSecret(name: SecretName): Promise<boolean> {
31
+ export async function hasSecret(name: SecretName, options?: { strict?: boolean }): Promise<boolean> {
32
32
  try {
33
33
  return (await SecureStore.getItemAsync(envKey(name), envOptions)) !== null
34
- } catch {
34
+ } catch (err) {
35
+ // Creation must distinguish an unreadable keychain from an empty one.
36
+ if (options?.strict) throw err
35
37
  return false
36
38
  }
37
39
  }
38
40
 
39
- export async function hasAnySecret(): Promise<boolean> {
41
+ export async function hasAnySecret(options?: { strict?: boolean }): Promise<boolean> {
40
42
  for (const name of SECRET_NAMES) {
41
- if (await hasSecret(name)) return true
43
+ if (await hasSecret(name, options)) return true
42
44
  }
43
45
  return false
44
46
  }
@@ -18,6 +18,7 @@
18
18
  import AsyncStorage from '@react-native-async-storage/async-storage'
19
19
 
20
20
  export const ATTEST_KEY_PREFIX = 'vault_backup_attest_v1_'
21
+ export const PENDING_KEY_PREFIX = 'wallet_backup_pending_v1_'
21
22
 
22
23
  export type BackupMedium = 'phrase' | 'shares'
23
24
 
@@ -30,8 +31,21 @@ export interface BackupAttestation {
30
31
 
31
32
  /** Last 8 hex chars of the identity key — the app's established scope suffix. */
32
33
  const scopeKey = (identityKey: string): string => ATTEST_KEY_PREFIX + identityKey.slice(-8)
34
+ const pendingKey = (identityKey: string): string => PENDING_KEY_PREFIX + identityKey
33
35
 
34
36
  export const backupAttestation = {
37
+ /** Only newly generated wallets are known to need their first backup.
38
+ * A returning wallet with no record predates tracking: its backup status is
39
+ * unknown, not evidence that the owner has never saved their keys. */
40
+ async markPending(identityKey: string): Promise<void> {
41
+ await AsyncStorage.setItem(pendingKey(identityKey), '1')
42
+ },
43
+
44
+ async needsReminder(identityKey: string): Promise<boolean> {
45
+ if ((await AsyncStorage.getItem(pendingKey(identityKey))) !== '1') return false
46
+ return (await backupAttestation.get(identityKey)) === null
47
+ },
48
+
35
49
  async get(identityKey: string): Promise<BackupAttestation | null> {
36
50
  const raw = await AsyncStorage.getItem(scopeKey(identityKey))
37
51
  if (!raw) return null
@@ -46,16 +60,17 @@ export const backupAttestation = {
46
60
  async set(identityKey: string, medium: BackupMedium): Promise<void> {
47
61
  const record: BackupAttestation = { v: 1, medium, at: Date.now() }
48
62
  await AsyncStorage.setItem(scopeKey(identityKey), JSON.stringify(record))
63
+ await AsyncStorage.removeItem(pendingKey(identityKey))
49
64
  },
50
65
 
51
66
  async clear(identityKey: string): Promise<void> {
52
- await AsyncStorage.removeItem(scopeKey(identityKey))
67
+ await AsyncStorage.multiRemove([scopeKey(identityKey), pendingKey(identityKey)])
53
68
  },
54
69
 
55
70
  /** Logout has no identity key to hand, so sweep the prefix. */
56
71
  async clearAll(): Promise<void> {
57
72
  const keys = await AsyncStorage.getAllKeys()
58
- const mine = keys.filter(k => k.startsWith(ATTEST_KEY_PREFIX))
73
+ const mine = keys.filter(k => k.startsWith(ATTEST_KEY_PREFIX) || k.startsWith(PENDING_KEY_PREFIX))
59
74
  if (mine.length > 0) await AsyncStorage.multiRemove(mine)
60
75
  }
61
76
  }
@@ -103,6 +103,13 @@ export interface StorageExpoSQLiteOptions extends StorageProviderOptions {
103
103
  /** Per-connection wait before a lock contention becomes "database is locked". */
104
104
  export const BUSY_TIMEOUT_MS = 5000
105
105
 
106
+ /**
107
+ * The lowest SQLITE_MAX_VARIABLE_NUMBER a shipped SQLite still enforces. Any
108
+ * IN (...) list built from caller data is split at this size so a large page
109
+ * can never turn into "too many SQL variables".
110
+ */
111
+ const SQLITE_MAX_BOUND_VARIABLES = 999
112
+
106
113
  /**
107
114
  * The token `transaction()` hands its scope. Carrying the connection on the
108
115
  * token is what lets `getDB(trx)` route a statement to the transaction without
@@ -1687,6 +1694,36 @@ export class StorageExpoSQLite extends StorageProvider {
1687
1694
  return this.validateEntities(rows, undefined, ['isDeleted'])
1688
1695
  }
1689
1696
 
1697
+ /**
1698
+ * The payer's identity key for each of a page of transactions, keyed by
1699
+ * transactionId. The key is recorded per output, not per transaction, so this
1700
+ * reads the whole page's outputs in one round trip and keeps the lowest-vout
1701
+ * non-empty key per transaction; transactions with no keyed output are absent
1702
+ * from the map. The sentinel key the address sweep writes is deliberately NOT
1703
+ * filtered here: what counts as a real counterparty is a presentation
1704
+ * decision that belongs to the caller.
1705
+ */
1706
+ async getSenderIdentityKeysForTransactionIds(transactionIds: number[], trx?: TrxToken): Promise<Map<number, string>> {
1707
+ const keys = new Map<number, string>()
1708
+ if (transactionIds.length === 0) return keys
1709
+ const db = this.getDB(trx)
1710
+ type Row = { transactionId: number; senderIdentityKey: string }
1711
+ for (let i = 0; i < transactionIds.length; i += SQLITE_MAX_BOUND_VARIABLES) {
1712
+ const chunk = transactionIds.slice(i, i + SQLITE_MAX_BOUND_VARIABLES)
1713
+ const rows = (await db.getAllAsync(
1714
+ `SELECT transactionId, senderIdentityKey FROM outputs
1715
+ WHERE transactionId IN (${chunk.map(() => '?').join(',')})
1716
+ AND senderIdentityKey IS NOT NULL AND senderIdentityKey != ''
1717
+ ORDER BY transactionId, vout`,
1718
+ chunk
1719
+ )) as Row[]
1720
+ for (const row of rows) {
1721
+ if (!keys.has(row.transactionId)) keys.set(row.transactionId, row.senderIdentityKey)
1722
+ }
1723
+ }
1724
+ return keys
1725
+ }
1726
+
1690
1727
  async getTagsForOutputId(outputId: number, trx?: TrxToken): Promise<TableOutputTag[]> {
1691
1728
  const rows = await this.getDB(trx).getAllAsync(
1692
1729
  `SELECT t.* FROM output_tags_map m JOIN output_tags t ON t.outputTagId = m.outputTagId
@@ -109,6 +109,11 @@ export async function listActionsSql(
109
109
  await specOp.postProcess(storage, auth, vargs, specOpLabels, txs)
110
110
  }
111
111
 
112
+ // The activity list identifies who paid us from the key stored on the
113
+ // transaction's outputs. One read covers the whole page rather than a
114
+ // findOutputs round trip per row.
115
+ const senderIdentityKeys = await storage.getSenderIdentityKeysForTransactionIds(txs.map(tx => tx.transactionId))
116
+
112
117
  // Build action objects
113
118
  for (const tx of txs) {
114
119
  const wtx: any = {
@@ -126,6 +131,10 @@ export async function listActionsSql(
126
131
  // `reference` already is.
127
132
  created_at: tx.created_at
128
133
  }
134
+ // Another extra, set only when a keyed output exists so consumers can tell
135
+ // "no sender recorded" from an empty string.
136
+ const senderIdentityKey = senderIdentityKeys.get(tx.transactionId)
137
+ if (senderIdentityKey !== undefined) wtx.senderIdentityKey = senderIdentityKey
129
138
  r.actions.push(wtx)
130
139
  }
131
140
 
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Colour for a counterparty's sigil tile. Every sigil used to be drawn in the
3
+ * text colour on a neutral tile, and at 38pt the shapes alone are too alike
4
+ * to tell one row from the next. A hue per counterparty gives each face its
5
+ * own tint, so the eye can pick out "the blue one" before it reads the glyph.
6
+ *
7
+ * The hue is whatever the caller derives (see counterpartyHue); this module
8
+ * only turns it into a pair of solids that stay readable at every hue in
9
+ * both themes. Saturation and lightness are fixed per theme rather than
10
+ * varied with the hue, so the tiles read as one family and not as a random
11
+ * scatter of swatches down the list.
12
+ */
13
+
14
+ export type SigilPalette = {
15
+ /** Symbol colour, six-digit lower-case hex. */
16
+ foreground: string
17
+ /**
18
+ * Tile colour, six-digit lower-case hex. Solid on purpose: sigil-js draws
19
+ * the cut-lines inside each glyph in this colour, so alpha would leave gaps.
20
+ */
21
+ background: string
22
+ }
23
+
24
+ type Tone = { s: number; l: number }
25
+
26
+ /**
27
+ * Per-theme saturation and lightness, in percent. Light theme: a pale tint
28
+ * under a deep symbol. Dark theme: a deep tint under a bright symbol.
29
+ *
30
+ * The lightness values are pinned by the WCAG floor of 4.5:1 across all 360
31
+ * hues, which the palette test enforces. The weak spots are the hues whose
32
+ * luminance moves furthest for a given lightness: yellow (hue 60) is the
33
+ * brightest thing a light-theme symbol can be, so the foreground sits at 28%
34
+ * rather than 30% to keep 4.75:1 there; blue (hue 240) is the darkest thing a
35
+ * dark-theme symbol can be and clears 5.8:1 at 78%.
36
+ */
37
+ const LIGHT: { background: Tone; foreground: Tone } = {
38
+ background: { s: 45, l: 92 },
39
+ foreground: { s: 55, l: 28 }
40
+ }
41
+ const DARK: { background: Tone; foreground: Tone } = {
42
+ background: { s: 35, l: 24 },
43
+ foreground: { s: 65, l: 78 }
44
+ }
45
+
46
+ /** Standard HSL to sRGB (CSS Color 3, section 4.2.4), then to `#rrggbb`. */
47
+ function hslToHex(hue: number, saturation: number, lightness: number): string {
48
+ const s = saturation / 100
49
+ const l = lightness / 100
50
+ const chroma = (1 - Math.abs(2 * l - 1)) * s
51
+ const sector = hue / 60
52
+ const x = chroma * (1 - Math.abs((sector % 2) - 1))
53
+ let r = 0
54
+ let g = 0
55
+ let b = 0
56
+ if (sector < 1) [r, g, b] = [chroma, x, 0]
57
+ else if (sector < 2) [r, g, b] = [x, chroma, 0]
58
+ else if (sector < 3) [r, g, b] = [0, chroma, x]
59
+ else if (sector < 4) [r, g, b] = [0, x, chroma]
60
+ else if (sector < 5) [r, g, b] = [x, 0, chroma]
61
+ else [r, g, b] = [chroma, 0, x]
62
+ const m = l - chroma / 2
63
+ const channel = (v: number) =>
64
+ Math.round((v + m) * 255)
65
+ .toString(16)
66
+ .padStart(2, '0')
67
+ return '#' + channel(r) + channel(g) + channel(b)
68
+ }
69
+
70
+ /**
71
+ * The symbol and tile colours for a hue in degrees. Any finite number is
72
+ * accepted and wrapped onto [0, 360), so -30 and 330 are the same tint; a
73
+ * non-finite hue (a NaN from a bad upstream parse) falls back to 0 rather than
74
+ * producing `#NaNNaNNaN` and a transparent tile.
75
+ */
76
+ export function sigilPalette(hue: number, isDark: boolean): SigilPalette {
77
+ const h = Number.isFinite(hue) ? ((hue % 360) + 360) % 360 : 0
78
+ const tone = isDark ? DARK : LIGHT
79
+ return {
80
+ foreground: hslToHex(h, tone.foreground.s, tone.foreground.l),
81
+ background: hslToHex(h, tone.background.s, tone.background.l)
82
+ }
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/expo-wallet-toolbox",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
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",
@@ -25,7 +25,8 @@
25
25
  "files": [
26
26
  "core",
27
27
  "ui",
28
- "assets"
28
+ "assets",
29
+ "CHANGELOG.md"
29
30
  ],
30
31
  "peerDependencies": {
31
32
  "@bsv/air-gap": "^0.1.1",
@@ -41,6 +42,7 @@
41
42
  "@react-native-async-storage/async-storage": "^2.2.0",
42
43
  "@react-native-clipboard/clipboard": "^1.16.2",
43
44
  "@react-native-community/netinfo": "^11.5.2",
45
+ "@urbit/sigil-js": "^2.2.0",
44
46
  "date-fns": "^4.1.0",
45
47
  "expo-audio": "~55.0.16",
46
48
  "expo-blur": "~55.0.14",
@@ -51,6 +53,7 @@
51
53
  "expo-document-picker": "~55.0.13",
52
54
  "expo-file-system": "~55.0.20",
53
55
  "expo-haptics": "~55.0.14",
56
+ "expo-image": "~55.0.11",
54
57
  "expo-local-authentication": "~55.0.14",
55
58
  "expo-localization": "~55.0.15",
56
59
  "expo-print": "~55.0.15",
@@ -42,7 +42,7 @@ import { wocConfigFor } from '../../../core/pay/rails/address'
42
42
  import { makeCreditClassifier } from '../../../core/pay/creditErrors'
43
43
  import { satoshisFromToken } from '../../../core/pay/tokenAmount'
44
44
  import { userFacingPayError } from '../../../core/pay/userError'
45
- import { creditInboxOnce, INBOX_DESCRIPTION, type CreditInboxResult } from '../../../core/pay/creditInbox'
45
+ import { creditInboxOnce, type CreditInboxResult } from '../../../core/pay/creditInbox'
46
46
  import { setReceiveInboxFocused } from '../../../core/pay/receiveFocus'
47
47
  import { TaskCreditInbox } from '../../../core/monitor/TaskCreditInbox'
48
48
  import { useOnline } from '../../hooks/useOnline'
@@ -468,10 +468,10 @@ export default function HandleReceive({
468
468
  )
469
469
 
470
470
  const internalize = useCallback(
471
- async (payment: IncomingPayment, description: string) => {
471
+ async (payment: IncomingPayment) => {
472
472
  const client = peerPayClient
473
473
  if (!client || !wallet) throw new Error(t('wallet_not_ready'))
474
- await internalizeIncoming(wallet as any, client, adminOriginator, payment, description, repairBeef)
474
+ await internalizeIncoming(wallet as any, client, adminOriginator, payment, repairBeef)
475
475
  },
476
476
  [peerPayClient, wallet, adminOriginator, t, repairBeef]
477
477
  )
@@ -510,7 +510,7 @@ export default function HandleReceive({
510
510
  storage: storage ?? undefined,
511
511
  force,
512
512
  classify,
513
- accept: payment => acceptWithRetry(client, messageBoxUrl, payment, INBOX_DESCRIPTION, internalize)
513
+ accept: payment => acceptWithRetry(client, messageBoxUrl, payment, internalize)
514
514
  })
515
515
  applyCreditResult(outcome)
516
516
  return outcome
@@ -23,7 +23,15 @@ const AppLogo: React.FC<AppLogoProps> = ({ size = 150, color = '#2196F3', rotate
23
23
  toValue: 1,
24
24
  duration: 10000,
25
25
  easing: Easing.linear,
26
- useNativeDriver: true
26
+ useNativeDriver: true,
27
+ // A looped animation never ends, so without this the interaction
28
+ // handle Animated.timing registers is held for as long as this
29
+ // component is mounted — and while any handle is held,
30
+ // InteractionManager.runAfterInteractions never fires for anyone,
31
+ // process-wide. Balance renders this spinner whenever a balance is
32
+ // loading, so the deferred proof sweep in PayScreen (and any host
33
+ // that defers work the same way) would simply never run.
34
+ isInteraction: false
27
35
  })
28
36
  ).start()
29
37
  }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Urbit sigil: a deterministic glyph for an @p name such as `~sampel-palnet`.
3
+ * The wallet uses it as the avatar for a counterparty it has no name or
4
+ * picture for, so two payments to the same key are recognisably the same
5
+ * person at a glance without showing them a hex string.
6
+ */
7
+ import React, { useMemo } from 'react'
8
+ import type { StyleProp, ViewStyle } from 'react-native'
9
+ import { SvgXml } from 'react-native-svg'
10
+ // Only ever the `core` entry. The package root pulls in a DOM React renderer
11
+ // that touches `document` at import time, which does not exist on a device.
12
+ import sigil from '@urbit/sigil-js/core'
13
+
14
+ interface SigilProps {
15
+ /** A canonical @p, `~`-prefixed. */
16
+ point: string
17
+ /** Rendered edge in dp; the sigil is always square. */
18
+ size: number
19
+ /** Symbol colour. */
20
+ foreground: string
21
+ /**
22
+ * Tile colour. Must be a solid: sigil-js draws the cut-lines inside each
23
+ * glyph in this colour, so alpha would leave gaps in the shapes.
24
+ */
25
+ background: string
26
+ /**
27
+ * sigil-js's own detail switch. `none` (the default) is the icon form: the
28
+ * inner lines that `default` adds are illegible at avatar size and just
29
+ * make every glyph look equally busy.
30
+ */
31
+ detail?: 'none' | 'default'
32
+ style?: StyleProp<ViewStyle>
33
+ }
34
+
35
+ // sigil-js emits this on the root <svg> for the browser, where an inline svg
36
+ // is otherwise `inline` and picks up line-height slop. Fabric has no such
37
+ // value and logs an error for it on every render, so it is cut before parsing.
38
+ const DOM_ONLY_STYLE = ' style="display: block;"'
39
+
40
+ export default function Sigil({
41
+ point,
42
+ size,
43
+ foreground,
44
+ background,
45
+ detail = 'none',
46
+ style
47
+ }: SigilProps): React.JSX.Element | null {
48
+ const xml = useMemo(() => {
49
+ try {
50
+ return sigil({ point, size, foreground, background, detail, space: 'default' }).replace(DOM_ONLY_STYLE, '')
51
+ } catch {
52
+ // A malformed @p (unknown syllable, odd length) throws inside sigil-js.
53
+ // One bad label must not take a whole activity list down with it.
54
+ return null
55
+ }
56
+ }, [point, size, foreground, background, detail])
57
+
58
+ if (xml === null) return null
59
+ // sigil-js writes `viewbox` in lower case, which the xml parser does not map
60
+ // onto the `viewBox` prop, so the box is restated here or nothing scales.
61
+ return <SvgXml xml={xml} width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={style} />
62
+ }
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * One row of the wallet's activity list.
3
3
  *
4
- * Reading order is direction → what it was → how much, then status and time
5
- * underneath. The per-transaction utilities (status, explorer, resend, cancel)
4
+ * Reading order is who (a sigil avatar for the counterparty, with direction on
5
+ * the tile edge) → what it was → how much, then status and time underneath.
6
+ * The per-transaction utilities (status, explorer, resend, cancel)
6
7
  * are NOT on the row: they used to sit permanently on the right, four icons
7
8
  * deep, which made every row look equally busy whether or not anything needed
8
9
  * doing. They now live behind a tap, and the expanded row lifts onto its own
@@ -12,13 +13,27 @@
12
13
  * txid to a clipboard is not that — it is debugging, and it used to crowd out
13
14
  * the two chips that actually resolve a stuck payment.
14
15
  */
15
- import React, { memo, useContext } from 'react'
16
+ import React, { memo, useContext, useMemo } from 'react'
16
17
  import { View, Text, StyleSheet, ActivityIndicator } from 'react-native'
17
18
  import { useTranslation } from 'react-i18next'
18
19
  import type { WalletAction } from '@bsv/sdk'
19
- import { useTheme, spacing, radii, typography, useWallet, ExchangeRateContext, formatAmount, formatAmountParts } from '@bsv/expo-wallet-toolbox'
20
+ import {
21
+ useTheme,
22
+ spacing,
23
+ radii,
24
+ typography,
25
+ useWallet,
26
+ ExchangeRateContext,
27
+ formatAmount,
28
+ formatAmountParts,
29
+ counterpartyOf,
30
+ counterpartyHue,
31
+ sigilPointOf,
32
+ sigilPalette
33
+ } from '@bsv/expo-wallet-toolbox'
20
34
  import { txStatusView, toneColor } from '../../txStatus'
21
35
  import PressableScale from '../ui/PressableScale'
36
+ import Sigil from '../ui/Sigil'
22
37
 
23
38
  /**
24
39
  * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
@@ -48,11 +63,14 @@ function loadMaterialCommunityIcons(): MaterialCommunityIconsComponent {
48
63
  return materialCommunityIconsComponent
49
64
  }
50
65
 
51
- /** A row as storage actually returns it: `reference` and `created_at` are real
52
- * columns the SDK's WalletAction type does not declare. */
66
+ /** A row as storage actually returns it: `reference`, `created_at` and
67
+ * `senderIdentityKey` are real columns the SDK's WalletAction type does not
68
+ * declare. The sender key is what an inbound peer payment records about who
69
+ * paid, since nothing else on the row does. */
53
70
  export type ActivityAction = WalletAction & {
54
71
  reference?: string
55
72
  created_at?: string | number | Date
73
+ senderIdentityKey?: string
56
74
  }
57
75
 
58
76
  interface Props {
@@ -117,7 +135,7 @@ function ActivityRowBase({
117
135
  onCancelParked
118
136
  }: Props & { currency: string }) {
119
137
  const { t } = useTranslation()
120
- const { colors } = useTheme()
138
+ const { colors, isDark } = useTheme()
121
139
  const { satoshisPerUSD, usdToFiat = {} } = useContext(ExchangeRateContext)
122
140
  const MaterialCommunityIcons = loadMaterialCommunityIcons()
123
141
 
@@ -144,6 +162,22 @@ function ActivityRowBase({
144
162
  const amountColor = incoming ? colors.successAmount : colors.textPrimary
145
163
  const unitColor = incoming ? colors.successAmount : colors.textSecondary
146
164
 
165
+ // Keyed on the label contents rather than on `action` or `labels`: every
166
+ // poll hands the row a fresh action object with a fresh labels array for the
167
+ // same transaction, so only a scalar key keeps the @p derivation from
168
+ // re-running per poll. Newline cannot appear in a stored label, so the join
169
+ // is unambiguous.
170
+ const { labels, senderIdentityKey, txid } = action
171
+ const labelsKey = labels?.join('\n') ?? ''
172
+ const face = useMemo(() => {
173
+ const cp = counterpartyOf({ labels: labelsKey === '' ? undefined : labelsKey.split('\n'), senderIdentityKey, txid })
174
+ return cp ? { point: sigilPointOf(cp), hue: counterpartyHue(cp) } : null
175
+ }, [labelsKey, senderIdentityKey, txid])
176
+ // Resolved outside the memo: the hue is a property of the counterparty, the
177
+ // colours it maps to are a property of the theme, and the theme can flip
178
+ // under a mounted row. Two HSL conversions per render are not worth a dep.
179
+ const palette = face ? sigilPalette(face.hue, !!isDark) : null
180
+
147
181
  // A parked payment was built and shown as a code, but never released: it is
148
182
  // not on chain and no task will put it there. An explorer link would 404 and
149
183
  // a Refresh would ask the network about a transaction it has never seen, so
@@ -187,23 +221,50 @@ function ActivityRowBase({
187
221
  accessibilityState={{ expanded }}
188
222
  accessibilityLabel={action.description || t('transactions')}
189
223
  >
190
- <View
191
- style={[
192
- styles.glyph,
193
- incoming
194
- ? {
195
- backgroundColor: colors.successStrong + '1A',
196
- borderColor: colors.successStrong + '2E'
197
- }
198
- : { backgroundColor: colors.surfaceSunken, borderColor: colors.surfaceSunkenBorder }
199
- ]}
200
- >
201
- <MaterialCommunityIcons
202
- name={incoming ? 'arrow-bottom-left' : 'arrow-top-right'}
203
- size={16}
204
- color={incoming ? colors.successStrong : colors.textSecondary}
205
- />
206
- </View>
224
+ {/* The sigil fills the tile, so direction moves to the border tint
225
+ alone: the same tints as the arrow tile, so a mixed list still
226
+ reads consistently down the left edge. The tile takes the
227
+ counterparty's own colour, and the sigil is drawn in exactly that
228
+ pair: sigil-js cuts its glyph lines in the background colour, so
229
+ the fill must be the same solid or the cuts show as a halo. */}
230
+ {face !== null && palette !== null ? (
231
+ <View
232
+ style={[
233
+ styles.glyph,
234
+ styles.avatar,
235
+ {
236
+ backgroundColor: palette.background,
237
+ borderColor: incoming ? colors.successStrong + '2E' : colors.surfaceSunkenBorder
238
+ }
239
+ ]}
240
+ >
241
+ <Sigil
242
+ point={face.point}
243
+ size={38}
244
+ foreground={palette.foreground}
245
+ background={palette.background}
246
+ detail="default"
247
+ />
248
+ </View>
249
+ ) : (
250
+ <View
251
+ style={[
252
+ styles.glyph,
253
+ incoming
254
+ ? {
255
+ backgroundColor: colors.successStrong + '1A',
256
+ borderColor: colors.successStrong + '2E'
257
+ }
258
+ : { backgroundColor: colors.surfaceSunken, borderColor: colors.surfaceSunkenBorder }
259
+ ]}
260
+ >
261
+ <MaterialCommunityIcons
262
+ name={incoming ? 'arrow-bottom-left' : 'arrow-top-right'}
263
+ size={16}
264
+ color={incoming ? colors.successStrong : colors.textSecondary}
265
+ />
266
+ </View>
267
+ )}
207
268
 
208
269
  <View style={styles.middle}>
209
270
  <Text style={[styles.description, { color: colors.textPrimary }]} numberOfLines={1}>
@@ -362,6 +423,8 @@ const styles = StyleSheet.create({
362
423
  alignItems: 'center',
363
424
  justifyContent: 'center'
364
425
  },
426
+ // Clips the square sigil to the tile's rounded corners.
427
+ avatar: { overflow: 'hidden' },
365
428
  middle: { flex: 1, minWidth: 0 },
366
429
  // 14.5/500 rather than body 17/400: the row is scanned, not read, and at 17pt
367
430
  // the description crowds the amount on narrow phones.
package/ui/isImageUrl.ts CHANGED
@@ -1,9 +1,22 @@
1
- import { Image } from 'react-native'
1
+ /**
2
+ * expo-image is required lazily: its package entry is raw TypeScript that Jest
3
+ * does not transform under this package's documented config, and this helper
4
+ * is reached from the `ui` barrel. TrustScreen gives its Image the same
5
+ * treatment.
6
+ */
7
+ type ExpoImageModule = typeof import('expo-image')
8
+ let expoImage: ExpoImageModule | undefined
9
+ function loadExpoImage(): ExpoImageModule {
10
+ if (!expoImage) {
11
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
12
+ expoImage = require('expo-image') as ExpoImageModule
13
+ }
14
+ return expoImage
15
+ }
2
16
 
3
17
  export default async (url: string): Promise<boolean> => {
4
18
  try {
5
- await Image.prefetch(url)
6
- return true
19
+ return await loadExpoImage().Image.prefetch(url)
7
20
  } catch {
8
21
  return false
9
22
  }
@@ -93,7 +93,9 @@ type ParseResult = { params: PairingParams; error: null } | { params: null; erro
93
93
  function parsePairingUri(raw: string): ParseResult {
94
94
  try {
95
95
  const url = new URL(raw)
96
- if (url.protocol !== 'bsv-wallet:') return { params: null, error: 'Not a bsv-wallet:// URI' }
96
+ if (url.protocol !== 'bsv-wallet:' && url.protocol !== 'bsv-browser:') {
97
+ return { params: null, error: 'Not a bsv-wallet:// or bsv-browser:// URI' }
98
+ }
97
99
 
98
100
  const g = (k: string) => url.searchParams.get(k) ?? ''
99
101
  const topic = g('topic')
@@ -163,7 +165,15 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
163
165
  // Auto-connect when navigated here with deep link pairing params
164
166
  useEffect(() => {
165
167
  if (!deepLinkParams.topic || !managers.permissionsManager) return
166
- const uri = `bsv-wallet://pair?topic=${deepLinkParams.topic}&backendIdentityKey=${deepLinkParams.backendIdentityKey}&protocolID=${encodeURIComponent(deepLinkParams.protocolID)}&origin=${encodeURIComponent(deepLinkParams.origin)}&expiry=${deepLinkParams.expiry}&sig=${deepLinkParams.sig}`
168
+ const query = new URLSearchParams({
169
+ topic: deepLinkParams.topic,
170
+ backendIdentityKey: deepLinkParams.backendIdentityKey ?? '',
171
+ protocolID: deepLinkParams.protocolID ?? '',
172
+ origin: deepLinkParams.origin ?? '',
173
+ expiry: deepLinkParams.expiry ?? '',
174
+ sig: deepLinkParams.sig ?? ''
175
+ })
176
+ const uri = `bsv-wallet://pair?${query}`
167
177
  handleScan(uri)
168
178
  }, [deepLinkParams.topic, managers.permissionsManager]) // eslint-disable-line react-hooks/exhaustive-deps
169
179