@bsv/expo-wallet-toolbox 0.4.0 → 0.7.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 +547 -0
- package/README.md +19 -1
- package/assets/sounds/vault-deposit.wav +0 -0
- package/assets/sounds/vault-withdraw.wav +0 -0
- package/core/amountFormatHelpers.ts +238 -34
- package/core/backup/RemoteSyncReader.ts +2 -5
- package/core/backup/codec.ts +2 -2
- package/core/backup/push.ts +1 -1
- package/core/config.tsx +16 -1
- package/core/contacts/contactActivity.ts +153 -0
- package/core/contacts/contactCache.ts +41 -0
- package/core/contacts/contactsStore.ts +183 -0
- package/core/context/VaultContext.tsx +8 -11
- package/core/context/WalletConnectionContext.tsx +137 -52
- package/core/context/WalletContext.tsx +464 -30
- package/core/demo/demoAssets.ts +60 -0
- package/core/demo/demoLedger.ts +240 -0
- package/core/demo/demoMandalaRuntime.ts +96 -0
- package/core/demo/demoMode.ts +38 -0
- package/core/demo/demoWallet.ts +25 -0
- package/core/demo/index.ts +26 -0
- package/core/demo/useDemo.ts +59 -0
- package/core/headers/OfflineFirstChaintracks.ts +52 -14
- package/core/headers/headerStore.ts +7 -10
- package/core/hooks/useConfirmationSound.ts +14 -8
- package/core/i18n/translations.tsx +4562 -986
- package/core/identity/contactLink.ts +36 -0
- package/core/identity/handleRegistry/client.ts +285 -0
- package/core/identity/handleRegistry/profileCert.ts +254 -0
- package/core/identity/handleRegistry/registration.ts +559 -0
- package/core/identity/handleRegistry/resolver.ts +247 -0
- package/core/identity/handleRegistry/rules.ts +104 -0
- package/core/index.ts +116 -15
- package/core/localpay/build.ts +674 -37
- package/core/localpay/codec.ts +68 -5
- package/core/localpay/pending.ts +240 -22
- package/core/localpay/pendingAborts.ts +5 -1
- package/core/localpay/settlementAck.ts +149 -0
- package/core/localpay/types.ts +14 -1
- package/core/localpay/verify.ts +118 -69
- package/core/mandala/abortGuard.ts +134 -0
- package/core/mandala/basketMigration.ts +166 -0
- package/core/mandala/bundle.ts +244 -0
- package/core/mandala/createRuntime.ts +2437 -0
- package/core/mandala/drain.ts +670 -0
- package/core/mandala/permissionModule.ts +642 -0
- package/core/mandala/resendTransfer.ts +175 -0
- package/core/mandala/runtime.ts +357 -0
- package/core/mandala/settlementStore.ts +412 -0
- package/core/mandala/types.ts +290 -0
- package/core/monitor/MonitorSupervisor.ts +121 -0
- package/core/monitor/TaskBackupPush.ts +1 -1
- package/core/monitor/TaskCreditInbox.ts +1 -1
- package/core/monitor/TaskDrainOutbox.ts +1 -1
- package/core/monitor/TaskSendOffline.ts +1 -1
- package/core/net/online.ts +49 -0
- package/core/numberFormat.ts +19 -0
- package/core/offline/cancelParked.ts +94 -1
- package/core/offline/payerHold.ts +152 -12
- package/core/offline/plan.ts +1 -1
- package/core/offline/tokenFrames.ts +197 -0
- package/core/parsePeerPayURI.ts +70 -17
- package/core/pay/rails/address.ts +51 -3
- package/core/pay/rails/handle.ts +88 -9
- package/core/pay/rails/index.ts +16 -6
- package/core/pay/rails/nearby.ts +114 -4
- package/core/pay/recordProof.ts +2 -6
- package/core/services/arcadeBroadcastProvider.ts +1 -4
- package/core/services/capWalletArgs.ts +8 -9
- package/core/services/exchangeRate.ts +1 -1
- package/core/services/externalOrigin.ts +42 -0
- package/core/services/vault/VaultKeyService.ts +912 -251
- package/core/services/vault/ceremony.ts +435 -367
- package/core/services/vault/ceremonyHost.ts +27 -21
- package/core/services/vault/devMock.ts +30 -7
- package/core/services/vault/driver.ts +95 -41
- package/core/services/vault/guard.ts +514 -56
- package/core/services/vault/hardwareLease.ts +22 -0
- package/core/services/vault/mockYubiKey.ts +258 -90
- package/core/services/vault/pivReset.ts +145 -0
- package/core/services/vault/r1comb.ts +976 -0
- package/core/services/vault/session.ts +93 -26
- package/core/services/vault/transfers.ts +2617 -747
- package/core/services/vault/types.ts +100 -43
- package/core/services/vault/vaultStore.ts +991 -74
- package/core/services/walletConnectionValidation.ts +293 -0
- package/core/services/walletServiceConfig.ts +31 -20
- package/core/storage/StorageExpoSQLite.ts +420 -87
- package/core/storage/dbImage.ts +48 -0
- package/core/storage/methods/findSql.ts +3 -54
- package/core/storage/methods/listActionsSql.ts +8 -5
- package/core/storage/methods/listOutputsSql.ts +9 -5
- package/core/storage/methods/offlineActions.ts +15 -0
- package/core/storage/methods/processOfflineActions.ts +265 -9
- package/core/storage/methods/reviewStatusSql.ts +7 -2
- package/core/storage/methods/walletBalanceSql.ts +16 -4
- package/core/storage/schema/createTables.ts +152 -0
- package/core/storage/sqlUpdateValue.ts +24 -0
- package/core/toolboxConfig.ts +182 -1
- package/core/toolboxTypes.ts +40 -0
- package/core/userAvatar.ts +79 -0
- package/core/walletMonitor.ts +8 -3
- package/core/walletRepair/runWalletCheck.ts +19 -2
- package/package.json +31 -30
- package/ui/activityFilter.ts +115 -0
- package/ui/components/QRScanner.tsx +1 -1
- package/ui/components/pay/AdmissionNotice.tsx +99 -0
- package/ui/components/pay/AssetPicker.tsx +184 -0
- package/ui/components/pay/AvailableBalance.tsx +33 -2
- package/ui/components/pay/HandleReceive.tsx +213 -50
- package/ui/components/pay/NearbyFlow.tsx +616 -69
- package/ui/components/pay/PayForm.tsx +73 -8
- package/ui/components/pay/PaymentSuccessOverlay.tsx +89 -8
- package/ui/components/pay/RecipientField.tsx +132 -73
- package/ui/components/pay/RequestHub.tsx +68 -8
- package/ui/components/pay/ResultBanner.tsx +41 -4
- package/ui/components/pay/StepBar.tsx +32 -0
- package/ui/components/pay/UniversalSend.tsx +1118 -86
- package/ui/components/pay/tokenSendCopy.ts +116 -0
- package/ui/components/pay/useRecipientInput.ts +36 -7
- package/ui/components/ui/PencilEditField.tsx +109 -0
- package/ui/components/ui/PermissionSheet.tsx +65 -4
- package/ui/components/ui/Sheet.tsx +9 -2
- package/ui/components/ui/SlideOverFromRight.tsx +86 -0
- package/ui/components/vault/EnrollWizard.tsx +1432 -488
- package/ui/components/vault/KeyChooser.tsx +96 -0
- package/ui/components/vault/VaultCeremonySheet.tsx +107 -43
- package/ui/components/vault/vaultErrorCopy.ts +145 -0
- package/ui/components/wallet/ActivityRow.tsx +283 -97
- package/ui/components/wallet/AmountInput.tsx +92 -28
- package/ui/components/wallet/AssetAmount.tsx +95 -0
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +261 -0
- package/ui/components/wallet/ContactActivityList.tsx +149 -0
- package/ui/components/wallet/ContactSigil.tsx +49 -0
- package/ui/components/wallet/EditPictureSheet.tsx +99 -0
- package/ui/components/wallet/FitAmount.tsx +148 -0
- package/ui/components/wallet/IconPickerSheet.tsx +168 -0
- package/ui/components/wallet/IdentifierRow.tsx +69 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +35 -13
- package/ui/components/wallet/ProfileButton.tsx +62 -0
- package/ui/components/wallet/UserAvatar.tsx +85 -0
- package/ui/components/wallet/avatarIcons.ts +122 -0
- package/ui/components/wallet/tokenEviction.ts +65 -0
- package/ui/hooks/useContactsStore.ts +10 -0
- package/ui/hooks/useExportWalletData.ts +39 -0
- package/ui/hooks/useMandala.ts +320 -0
- package/ui/hooks/useOnline.ts +65 -20
- package/ui/hooks/useVaultBalance.ts +105 -7
- package/ui/hooks/useVaultCoverage.ts +52 -0
- package/ui/importDatabases.ts +7 -3
- package/ui/index.ts +75 -7
- package/ui/screens/ConnectionsScreen.tsx +46 -29
- package/ui/screens/ContactScreen.tsx +289 -0
- package/ui/screens/ContactsScreen.tsx +373 -0
- package/ui/screens/IdentifierScreen.tsx +234 -0
- package/ui/screens/NewContactScreen.tsx +362 -0
- package/ui/screens/PairScreen.tsx +12 -12
- package/ui/screens/PayScreen.tsx +145 -12
- package/ui/screens/ProfileScreen.tsx +783 -0
- package/ui/screens/SettingsScreen.tsx +18 -9
- package/ui/screens/TransactionDetailScreen.tsx +419 -0
- package/ui/screens/TrustScreen.tsx +1 -1
- package/ui/screens/VaultScreen.tsx +925 -171
- package/ui/screens/VaultTransferScreen.tsx +376 -123
- package/ui/screens/WalletCheckScreen.tsx +10 -1
- package/ui/screens/WalletConfigScreen.tsx +80 -16
- package/ui/screens/WalletHomeScreen.tsx +915 -139
- package/ui/screens/homeBadges.ts +9 -1
- package/ui/screens/tokenRowTitle.ts +68 -0
- package/ui/tokenFormat.ts +108 -0
- package/ui/tokenSeen.ts +75 -0
- package/ui/tokenStatus.ts +100 -0
- package/ui/txStatus.ts +43 -5
- package/assets/sounds/vault-close.wav +0 -0
- package/assets/sounds/vault-open.wav +0 -0
- package/core/services/vault/k1.ts +0 -75
- package/core/services/vault/sealing.ts +0 -84
- package/core/services/vault/vaultDerivation.ts +0 -152
- package/core/services/vault/vaultPassphrase.ts +0 -287
- package/ui/components/vault/PassphraseField.tsx +0 -306
- package/ui/components/vault/PhraseBackupSheet.tsx +0 -227
- package/ui/screens/VaultRecoverScreen.tsx +0 -226
|
@@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'
|
|
|
17
17
|
|
|
18
18
|
import AvailableBalance from './AvailableBalance'
|
|
19
19
|
import { useTheme, radii, spacing, typography } from '@bsv/expo-wallet-toolbox'
|
|
20
|
-
import { AmountInput } from '../wallet/AmountInput'
|
|
20
|
+
import { AmountInput, type AmountInputAsset } from '../wallet/AmountInput'
|
|
21
21
|
import PressableScale from '../ui/PressableScale'
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -59,31 +59,85 @@ export function PayAmountField({
|
|
|
59
59
|
value,
|
|
60
60
|
onChangeText,
|
|
61
61
|
showMax = true,
|
|
62
|
-
showBalance = true
|
|
62
|
+
showBalance = true,
|
|
63
|
+
asset,
|
|
64
|
+
maxValue,
|
|
65
|
+
availableText,
|
|
66
|
+
availableNote
|
|
63
67
|
}: {
|
|
64
68
|
value: string
|
|
65
69
|
onChangeText: (text: string) => void
|
|
66
70
|
showMax?: boolean
|
|
67
71
|
showBalance?: boolean
|
|
72
|
+
/** Token mode: the field takes and emits base units of this asset. */
|
|
73
|
+
asset?: AmountInputAsset
|
|
74
|
+
/** Token mode: what Max writes (the real spendable figure, not a sentinel). */
|
|
75
|
+
maxValue?: string
|
|
76
|
+
/**
|
|
77
|
+
* Token mode: the available figure, already formatted. `AvailableBalance`
|
|
78
|
+
* sources its own BSV figure and takes no balance prop, so this is the only
|
|
79
|
+
* way a token figure can appear under the field.
|
|
80
|
+
*/
|
|
81
|
+
availableText?: string
|
|
82
|
+
/** A second line under the available figure — today, the frozen subtotal. */
|
|
83
|
+
availableNote?: string
|
|
68
84
|
}) {
|
|
69
85
|
return (
|
|
70
86
|
<PayField labelKey="amount">
|
|
71
|
-
<AmountInput value={value} onChangeText={onChangeText} showMax={showMax} />
|
|
72
|
-
{showBalance && <AvailableBalance />}
|
|
87
|
+
<AmountInput value={value} onChangeText={onChangeText} showMax={showMax} asset={asset} maxValue={maxValue} />
|
|
88
|
+
{showBalance && <AvailableBalance text={availableText} note={availableNote} />}
|
|
73
89
|
</PayField>
|
|
74
90
|
)
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
/** The consequence, before the button — not after. Boxed so it reads as fact,
|
|
78
94
|
* not fine print. */
|
|
79
|
-
export function ConsequenceNote({
|
|
95
|
+
export function ConsequenceNote({
|
|
96
|
+
textKey,
|
|
97
|
+
values,
|
|
98
|
+
text,
|
|
99
|
+
action
|
|
100
|
+
}: {
|
|
101
|
+
textKey: string
|
|
102
|
+
/**
|
|
103
|
+
* An already-resolved sentence that wins over the key — for a reason that
|
|
104
|
+
* comes from somewhere other than this app's own string table (today: the
|
|
105
|
+
* Mandala runtime's plain refusals).
|
|
106
|
+
*/
|
|
107
|
+
text?: string
|
|
108
|
+
/**
|
|
109
|
+
* Interpolation values. Every token note carries `{{ticker}}` or
|
|
110
|
+
* `{{issuer}}`, and `t(key)` with no options renders the placeholders raw.
|
|
111
|
+
*/
|
|
112
|
+
values?: Record<string, string | number>
|
|
113
|
+
/**
|
|
114
|
+
* The one inline affordance a note may carry — "Get BSV", "Check again".
|
|
115
|
+
* Its hit area is padded to the 44pt minimum because the note's own text is
|
|
116
|
+
* a footnote and a footnote-sized target is not a target.
|
|
117
|
+
*/
|
|
118
|
+
action?: { label: string; onPress: () => void }
|
|
119
|
+
}) {
|
|
80
120
|
const { t } = useTranslation()
|
|
81
121
|
const { colors } = useTheme()
|
|
82
122
|
const Ionicons = loadIonicons()
|
|
83
123
|
return (
|
|
84
124
|
<View style={[styles.consequence, { backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}>
|
|
85
125
|
<Ionicons name="information-circle-outline" size={16} color={colors.textSecondary} />
|
|
86
|
-
<Text style={[styles.consequenceText, { color: colors.textSecondary }]}>{t(textKey)}</Text>
|
|
126
|
+
<Text style={[styles.consequenceText, { color: colors.textSecondary }]}>{text ?? t(textKey, values)}</Text>
|
|
127
|
+
{action && (
|
|
128
|
+
<PressableScale
|
|
129
|
+
onPress={action.onPress}
|
|
130
|
+
haptic="tap"
|
|
131
|
+
hitSlop={{ top: 14, bottom: 14, left: 12, right: 12 }}
|
|
132
|
+
style={styles.consequenceAction}
|
|
133
|
+
accessibilityRole="button"
|
|
134
|
+
accessibilityLabel={action.label}
|
|
135
|
+
>
|
|
136
|
+
<Text style={[styles.consequenceActionText, { color: colors.accent }]} numberOfLines={1}>
|
|
137
|
+
{action.label}
|
|
138
|
+
</Text>
|
|
139
|
+
</PressableScale>
|
|
140
|
+
)}
|
|
87
141
|
</View>
|
|
88
142
|
)
|
|
89
143
|
}
|
|
@@ -94,18 +148,27 @@ export function PayCta({
|
|
|
94
148
|
disabled,
|
|
95
149
|
busy,
|
|
96
150
|
labelKey = 'pay',
|
|
151
|
+
label,
|
|
97
152
|
icon = 'arrow-up'
|
|
98
153
|
}: {
|
|
99
154
|
onPress: () => void
|
|
100
155
|
disabled: boolean
|
|
101
156
|
busy: boolean
|
|
102
157
|
labelKey?: string
|
|
158
|
+
/**
|
|
159
|
+
* A raw, already-interpolated label, which wins over `labelKey`. The token
|
|
160
|
+
* CTA names the exact figure and asset ("Send 25.00 USDX") and is the
|
|
161
|
+
* confirmation this flow has instead of a review screen — and `t(labelKey)`
|
|
162
|
+
* takes no options, so it could never produce that sentence from a key.
|
|
163
|
+
*/
|
|
164
|
+
label?: string
|
|
103
165
|
icon?: keyof IoniconsComponent['glyphMap']
|
|
104
166
|
}) {
|
|
105
167
|
const { t } = useTranslation()
|
|
106
168
|
const { colors } = useTheme()
|
|
107
169
|
const Ionicons = loadIonicons()
|
|
108
170
|
const enabled = !disabled
|
|
171
|
+
const text = label ?? t(labelKey)
|
|
109
172
|
return (
|
|
110
173
|
<PressableScale
|
|
111
174
|
onPress={onPress}
|
|
@@ -113,7 +176,7 @@ export function PayCta({
|
|
|
113
176
|
haptic="confirm"
|
|
114
177
|
style={[styles.cta, { backgroundColor: enabled ? colors.accent : colors.fill }]}
|
|
115
178
|
accessibilityRole="button"
|
|
116
|
-
accessibilityLabel={
|
|
179
|
+
accessibilityLabel={text}
|
|
117
180
|
accessibilityState={{ disabled }}
|
|
118
181
|
>
|
|
119
182
|
{busy ? (
|
|
@@ -122,7 +185,7 @@ export function PayCta({
|
|
|
122
185
|
<>
|
|
123
186
|
<Ionicons name={icon} size={20} color={enabled ? colors.textOnAccent : colors.textTertiary} />
|
|
124
187
|
<Text style={[styles.ctaText, { color: enabled ? colors.textOnAccent : colors.textTertiary }]}>
|
|
125
|
-
{
|
|
188
|
+
{text}
|
|
126
189
|
</Text>
|
|
127
190
|
</>
|
|
128
191
|
)}
|
|
@@ -187,6 +250,8 @@ const styles = StyleSheet.create({
|
|
|
187
250
|
marginBottom: spacing.lg
|
|
188
251
|
},
|
|
189
252
|
consequenceText: { ...typography.footnote, flex: 1 },
|
|
253
|
+
consequenceAction: { paddingVertical: spacing.xs, paddingHorizontal: spacing.xs },
|
|
254
|
+
consequenceActionText: { ...typography.footnote, fontWeight: '600' },
|
|
190
255
|
cta: {
|
|
191
256
|
flexDirection: 'row',
|
|
192
257
|
alignItems: 'center',
|
|
@@ -71,12 +71,38 @@ export interface ReceivedOverlayProps {
|
|
|
71
71
|
direction?: 'received' | 'sent'
|
|
72
72
|
/** Sent only: the resolved counterparty (name, handle, or abbreviated address). */
|
|
73
73
|
recipientName?: string
|
|
74
|
+
/**
|
|
75
|
+
* Token mode: the figure in the asset's own units, already formatted
|
|
76
|
+
* ("25.00 USDX"). It replaces the satoshi figure entirely — `AmountDisplay`
|
|
77
|
+
* would read `settings.currency` and print a token amount as satoshis or,
|
|
78
|
+
* worse, cross it into fiat at the BSV rate.
|
|
79
|
+
*/
|
|
80
|
+
amountText?: string
|
|
81
|
+
/**
|
|
82
|
+
* One already-interpolated line about what has and has not happened yet:
|
|
83
|
+
* "Settling with Acme Bank", "not yet confirmed by Acme Bank", "we couldn't
|
|
84
|
+
* tell them yet". Never a claim of settlement the wallet does not have.
|
|
85
|
+
*/
|
|
86
|
+
statusNote?: string
|
|
87
|
+
/**
|
|
88
|
+
* First time this wallet has ever held this asset: who issues it and what
|
|
89
|
+
* they can do. Disclosure at the one moment the user is definitely looking.
|
|
90
|
+
*/
|
|
91
|
+
firstHoldNote?: string
|
|
74
92
|
/**
|
|
75
93
|
* Where acknowledging the overlay sends the user. Defaults to `/`, the
|
|
76
94
|
* wallet's own home route. A host that embeds the wallet as a sub-screen
|
|
77
95
|
* (rather than as the app root) should pass its own wallet-home route here.
|
|
78
96
|
*/
|
|
79
97
|
dismissTo?: DismissTarget
|
|
98
|
+
/**
|
|
99
|
+
* Sent only, and only when the recipient resolved to an identity key that
|
|
100
|
+
* is not already a saved contact: offers a "Save as a contact" text
|
|
101
|
+
* action under the recipient's name. The caller owns the whole action (cleanup and
|
|
102
|
+
* navigation both) — this component stays presentational and only decides
|
|
103
|
+
* whether to show the button at all.
|
|
104
|
+
*/
|
|
105
|
+
onAddContact?: () => void
|
|
80
106
|
/**
|
|
81
107
|
* Acknowledged. The only way this screen closes. Clean up local state here —
|
|
82
108
|
* the overlay itself then returns the user to the wallet, so the updated
|
|
@@ -91,7 +117,11 @@ export default function PaymentSuccessOverlay({
|
|
|
91
117
|
broadcast = true,
|
|
92
118
|
direction = 'received',
|
|
93
119
|
recipientName,
|
|
120
|
+
amountText,
|
|
121
|
+
statusNote,
|
|
122
|
+
firstHoldNote,
|
|
94
123
|
dismissTo = '/',
|
|
124
|
+
onAddContact,
|
|
95
125
|
onDismiss
|
|
96
126
|
}: ReceivedOverlayProps) {
|
|
97
127
|
const sent = direction === 'sent'
|
|
@@ -178,24 +208,59 @@ export default function PaymentSuccessOverlay({
|
|
|
178
208
|
adjustsFontSizeToFit
|
|
179
209
|
accessibilityRole="text"
|
|
180
210
|
>
|
|
181
|
-
<AmountDisplay>{amount}</AmountDisplay>
|
|
211
|
+
{amountText ?? <AmountDisplay>{amount}</AmountDisplay>}
|
|
182
212
|
</Text>
|
|
183
213
|
</Animated.View>
|
|
184
214
|
|
|
185
215
|
{sent ? (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
216
|
+
<>
|
|
217
|
+
{!!recipientName && (
|
|
218
|
+
<Text
|
|
219
|
+
style={[styles.support, { color: colors.textSecondary }]}
|
|
220
|
+
numberOfLines={1}
|
|
221
|
+
ellipsizeMode="middle"
|
|
222
|
+
>
|
|
223
|
+
{t('pay_sent_to', { name: recipientName })}
|
|
224
|
+
</Text>
|
|
225
|
+
)}
|
|
226
|
+
{/* A text button under the name, not a second filled control: Done
|
|
227
|
+
stays the one accent-filled control on this screen. */}
|
|
228
|
+
{!!onAddContact && (
|
|
229
|
+
<PressableScale
|
|
230
|
+
onPress={onAddContact}
|
|
231
|
+
haptic="tap"
|
|
232
|
+
style={styles.saveContact}
|
|
233
|
+
accessibilityRole="button"
|
|
234
|
+
accessibilityLabel={t('pay_save_as_contact')}
|
|
235
|
+
>
|
|
236
|
+
<Text style={[styles.saveContactText, { color: colors.accent }]}>{t('pay_save_as_contact')}</Text>
|
|
237
|
+
</PressableScale>
|
|
238
|
+
)}
|
|
239
|
+
</>
|
|
191
240
|
) : (
|
|
192
241
|
<Text style={[styles.support, { color: colors.success }]} textBreakStrategy="balanced">
|
|
193
242
|
{count > 1 ? t('local_pay_added_multiple', { count }) : t('local_pay_added')}
|
|
194
243
|
</Text>
|
|
195
244
|
)}
|
|
196
245
|
|
|
246
|
+
{/* `pay_received_not_broadcast` is the RECEIVED-side sentence and was
|
|
247
|
+
rendered ungated by direction; a sent payment gets its own, because
|
|
248
|
+
"Received offline" over an outgoing payment is simply wrong. */}
|
|
197
249
|
{!broadcast && (
|
|
198
|
-
<Text style={[styles.pending, { color: colors.textSecondary }]}>
|
|
250
|
+
<Text style={[styles.pending, { color: colors.textSecondary }]}>
|
|
251
|
+
{t(sent ? 'pay_sent_not_broadcast' : 'pay_received_not_broadcast')}
|
|
252
|
+
</Text>
|
|
253
|
+
)}
|
|
254
|
+
|
|
255
|
+
{!!statusNote && <Text style={[styles.pending, { color: colors.textSecondary }]}>{statusNote}</Text>}
|
|
256
|
+
|
|
257
|
+
{!!firstHoldNote && (
|
|
258
|
+
<Text
|
|
259
|
+
style={[styles.pending, styles.firstHold, { color: colors.textSecondary }]}
|
|
260
|
+
textBreakStrategy="balanced"
|
|
261
|
+
>
|
|
262
|
+
{firstHoldNote}
|
|
263
|
+
</Text>
|
|
199
264
|
)}
|
|
200
265
|
</View>
|
|
201
266
|
|
|
@@ -257,8 +322,13 @@ const styles = StyleSheet.create({
|
|
|
257
322
|
textAlign: 'center',
|
|
258
323
|
marginTop: spacing.xs
|
|
259
324
|
},
|
|
325
|
+
firstHold: {
|
|
326
|
+
marginTop: spacing.lg,
|
|
327
|
+
maxWidth: 300
|
|
328
|
+
},
|
|
260
329
|
footer: {
|
|
261
|
-
paddingBottom: spacing.md
|
|
330
|
+
paddingBottom: spacing.md,
|
|
331
|
+
gap: spacing.sm
|
|
262
332
|
},
|
|
263
333
|
button: {
|
|
264
334
|
flexDirection: 'row',
|
|
@@ -270,5 +340,16 @@ const styles = StyleSheet.create({
|
|
|
270
340
|
buttonText: {
|
|
271
341
|
...typography.headline,
|
|
272
342
|
fontWeight: '600'
|
|
343
|
+
},
|
|
344
|
+
saveContact: {
|
|
345
|
+
minHeight: 44,
|
|
346
|
+
paddingHorizontal: spacing.lg,
|
|
347
|
+
paddingVertical: spacing.md,
|
|
348
|
+
alignItems: 'center',
|
|
349
|
+
justifyContent: 'center'
|
|
350
|
+
},
|
|
351
|
+
saveContactText: {
|
|
352
|
+
...typography.footnote,
|
|
353
|
+
fontWeight: '600'
|
|
273
354
|
}
|
|
274
355
|
})
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* useRecipientInput; this file only renders that state.
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react'
|
|
10
|
-
import { ActivityIndicator,
|
|
10
|
+
import { ActivityIndicator, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'
|
|
11
11
|
import type { DisplayableIdentity } from '@bsv/sdk'
|
|
12
12
|
import Animated, { FadeInDown, useReducedMotion } from 'react-native-reanimated'
|
|
13
13
|
import { spacing, typography, radii, springs } from '@bsv/expo-wallet-toolbox'
|
|
14
|
+
import ContactSigil from '../wallet/ContactSigil'
|
|
14
15
|
import type { RecipientInlineError, RecipientTarget } from './useRecipientInput'
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -30,19 +31,56 @@ function loadIonicons(): IoniconsComponent {
|
|
|
30
31
|
return ioniconsComponent
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* A dropdown row. `DisplayableIdentity` is a fixed seven-string SDK interface
|
|
36
|
+
* with nowhere to put a handle, so the one line this list needs that it does
|
|
37
|
+
* not carry is added here — supplied by the caller, because only the caller
|
|
38
|
+
* knows whether a row came from a contact, the registry or the overlay.
|
|
39
|
+
*/
|
|
40
|
+
export interface RecipientRow extends DisplayableIdentity {
|
|
41
|
+
/** Drawn under the name: a registry row's full `handle@domain`, a contact's
|
|
42
|
+
* `cachedHandle`. Falls back to the abbreviated identity key. */
|
|
43
|
+
readonly secondaryLine?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
interface RecipientFieldProps {
|
|
34
47
|
readonly selectedIdentity: DisplayableIdentity | null
|
|
35
48
|
readonly inputText: string
|
|
36
49
|
readonly target: RecipientTarget | null
|
|
37
50
|
readonly inlineError: RecipientInlineError | null
|
|
38
51
|
readonly isSearching: boolean
|
|
39
|
-
readonly searchResults:
|
|
52
|
+
readonly searchResults: RecipientRow[]
|
|
40
53
|
readonly colors: ReturnType<typeof import('@bsv/expo-wallet-toolbox').useTheme>['colors']
|
|
41
54
|
readonly t: ReturnType<typeof import('react-i18next').useTranslation>['t']
|
|
42
55
|
readonly onChangeText: (v: string) => void
|
|
43
|
-
readonly onSelectIdentity: (i:
|
|
56
|
+
readonly onSelectIdentity: (i: RecipientRow) => void
|
|
44
57
|
readonly onClear: () => void
|
|
45
58
|
readonly onOpenScanner: () => void
|
|
59
|
+
/**
|
|
60
|
+
* Token mode. When an asset is selected, an address is not a recipient this
|
|
61
|
+
* payment can have: the output locks to an ECDH product of the recipient's
|
|
62
|
+
* identity key, so there is nothing an address could be turned into (D4).
|
|
63
|
+
*
|
|
64
|
+
* The refusal is INLINE and NON-DESTRUCTIVE — the typed text stays exactly
|
|
65
|
+
* where it is, in a warning tone with a plain reason, and switching the
|
|
66
|
+
* picker back to BSV makes it valid again with no retyping. Deleting the
|
|
67
|
+
* user's input to enforce a rule they have not been told about yet would be
|
|
68
|
+
* the wallet punishing them for a choice it made.
|
|
69
|
+
*/
|
|
70
|
+
readonly assetTicker?: string
|
|
71
|
+
/**
|
|
72
|
+
* A status line the caller owns, for facts this component cannot know —
|
|
73
|
+
* today the recipient's standing with the issuer (blocked, unregistered).
|
|
74
|
+
* Rendered in place of the resolved-target line.
|
|
75
|
+
*/
|
|
76
|
+
readonly statusOverride?: { readonly text: string; readonly tone: 'warning' | 'error' }
|
|
77
|
+
/**
|
|
78
|
+
* A heading shown above the dropdown when it is showing local contacts on
|
|
79
|
+
* an empty query rather than overlay search hits (Pay's "Recent" tier,
|
|
80
|
+
* 2026-09 design). The caller merges local contacts into `searchResults`
|
|
81
|
+
* itself — this component only draws the label they ask for.
|
|
82
|
+
*/
|
|
83
|
+
readonly recentLabel?: string
|
|
46
84
|
}
|
|
47
85
|
|
|
48
86
|
export default function RecipientField({
|
|
@@ -57,10 +95,15 @@ export default function RecipientField({
|
|
|
57
95
|
onChangeText,
|
|
58
96
|
onSelectIdentity,
|
|
59
97
|
onClear,
|
|
60
|
-
onOpenScanner
|
|
98
|
+
onOpenScanner,
|
|
99
|
+
assetTicker,
|
|
100
|
+
statusOverride,
|
|
101
|
+
recentLabel
|
|
61
102
|
}: RecipientFieldProps) {
|
|
62
103
|
const Ionicons = loadIonicons()
|
|
63
104
|
const reducedMotion = useReducedMotion()
|
|
105
|
+
/** An address typed while a token is selected: refused, but not erased. */
|
|
106
|
+
const addressRefused = !!assetTicker && (target?.kind === 'address' || inlineError === 'invalid_bsv_address')
|
|
64
107
|
if (selectedIdentity) {
|
|
65
108
|
const identityEntering = reducedMotion
|
|
66
109
|
? undefined
|
|
@@ -70,13 +113,14 @@ export default function RecipientField({
|
|
|
70
113
|
entering={identityEntering}
|
|
71
114
|
style={[styles.selectedRecipient, { backgroundColor: colors.backgroundSecondary }]}
|
|
72
115
|
>
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
116
|
+
{/* Their avatar, else their sigil — never an initials/person placeholder
|
|
117
|
+
(2026-09-18 ruling): the same face Contacts and the review card draw. */}
|
|
118
|
+
<ContactSigil
|
|
119
|
+
identityKey={selectedIdentity.identityKey}
|
|
120
|
+
avatarUrl={selectedIdentity.avatarURL || undefined}
|
|
121
|
+
size={36}
|
|
122
|
+
radius={18}
|
|
123
|
+
/>
|
|
80
124
|
<View style={styles.selectedInfo}>
|
|
81
125
|
<Text style={[styles.selectedName, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
82
126
|
{selectedIdentity.name || t('unknown')}
|
|
@@ -92,8 +136,17 @@ export default function RecipientField({
|
|
|
92
136
|
)
|
|
93
137
|
}
|
|
94
138
|
const showDropdown = (isSearching || searchResults.length > 0) && !target && !inlineError
|
|
95
|
-
const
|
|
96
|
-
const
|
|
139
|
+
const overrideColor = statusOverride?.tone === 'error' ? colors.error : colors.warning
|
|
140
|
+
const borderColor = addressRefused
|
|
141
|
+
? colors.warning
|
|
142
|
+
: statusOverride
|
|
143
|
+
? overrideColor
|
|
144
|
+
: inlineError
|
|
145
|
+
? colors.error
|
|
146
|
+
: target
|
|
147
|
+
? colors.success
|
|
148
|
+
: colors.separator
|
|
149
|
+
const borderWidth = addressRefused || statusOverride || inlineError || target ? 1 : StyleSheet.hairlineWidth
|
|
97
150
|
return (
|
|
98
151
|
<>
|
|
99
152
|
<View style={[styles.inputRow, { backgroundColor: colors.backgroundSecondary, borderColor, borderWidth }]}>
|
|
@@ -110,7 +163,21 @@ export default function RecipientField({
|
|
|
110
163
|
<Ionicons name="qr-code-outline" size={20} color={colors.accent} />
|
|
111
164
|
</TouchableOpacity>
|
|
112
165
|
</View>
|
|
113
|
-
{
|
|
166
|
+
{addressRefused ? (
|
|
167
|
+
// A sentence, not just a colour: no state in this app is communicated
|
|
168
|
+
// by colour alone.
|
|
169
|
+
<View style={styles.statusRow}>
|
|
170
|
+
<Ionicons name="alert-circle-outline" size={14} color={colors.warning} />
|
|
171
|
+
<Text style={[styles.statusText, { color: colors.warning }]}>
|
|
172
|
+
{t('pay_asset_address_status', { ticker: assetTicker })}
|
|
173
|
+
</Text>
|
|
174
|
+
</View>
|
|
175
|
+
) : statusOverride ? (
|
|
176
|
+
<View style={styles.statusRow}>
|
|
177
|
+
<Ionicons name="alert-circle-outline" size={14} color={overrideColor} />
|
|
178
|
+
<Text style={[styles.statusText, { color: overrideColor }]}>{statusOverride.text}</Text>
|
|
179
|
+
</View>
|
|
180
|
+
) : inlineError ? (
|
|
114
181
|
<View style={styles.statusRow}>
|
|
115
182
|
<Ionicons name="close-circle-outline" size={14} color={colors.error} />
|
|
116
183
|
<Text style={[styles.statusText, { color: colors.error }]}>{t(inlineError)}</Text>
|
|
@@ -130,46 +197,52 @@ export default function RecipientField({
|
|
|
130
197
|
<View
|
|
131
198
|
style={[styles.searchResults, { backgroundColor: colors.backgroundSecondary, borderColor: colors.separator }]}
|
|
132
199
|
>
|
|
133
|
-
{
|
|
200
|
+
{!!recentLabel && inputText.trim() === '' && (
|
|
201
|
+
<Text style={[styles.recentLabel, { color: colors.textTertiary }]}>{recentLabel}</Text>
|
|
202
|
+
)}
|
|
203
|
+
{searchResults.map((identity, idx) => (
|
|
204
|
+
<TouchableOpacity
|
|
205
|
+
key={identity.identityKey + idx}
|
|
206
|
+
onPress={() => onSelectIdentity(identity)}
|
|
207
|
+
style={[
|
|
208
|
+
styles.searchResultRow,
|
|
209
|
+
(idx < searchResults.length - 1 || isSearching) && {
|
|
210
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
211
|
+
borderBottomColor: colors.separator
|
|
212
|
+
}
|
|
213
|
+
]}
|
|
214
|
+
>
|
|
215
|
+
<View style={styles.searchAvatar}>
|
|
216
|
+
<ContactSigil
|
|
217
|
+
identityKey={identity.identityKey}
|
|
218
|
+
avatarUrl={identity.avatarURL || undefined}
|
|
219
|
+
size={32}
|
|
220
|
+
radius={16}
|
|
221
|
+
/>
|
|
222
|
+
</View>
|
|
223
|
+
<View style={styles.searchResultInfo}>
|
|
224
|
+
<Text style={[styles.searchResultName, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
225
|
+
{identity.name || t('unknown')}
|
|
226
|
+
</Text>
|
|
227
|
+
<Text style={[styles.searchResultKey, { color: colors.textSecondary }]} numberOfLines={1}>
|
|
228
|
+
{identity.secondaryLine || identity.abbreviatedKey || `${identity.identityKey.slice(0, 20)}...`}
|
|
229
|
+
</Text>
|
|
230
|
+
</View>
|
|
231
|
+
{identity.badgeLabel ? (
|
|
232
|
+
<View style={[styles.badge, { backgroundColor: colors.fill }]}>
|
|
233
|
+
<Text style={[styles.badgeText, { color: colors.accent }]}>{identity.badgeLabel}</Text>
|
|
234
|
+
</View>
|
|
235
|
+
) : null}
|
|
236
|
+
</TouchableOpacity>
|
|
237
|
+
))}
|
|
238
|
+
{/* A footer, not a replacement: the instant tier is already on screen
|
|
239
|
+
and hiding it for the remote tier's whole debounce made "instant"
|
|
240
|
+
a claim the user never saw. */}
|
|
241
|
+
{isSearching && (
|
|
134
242
|
<View style={styles.searchLoading}>
|
|
135
243
|
<ActivityIndicator size="small" color={colors.accent} />
|
|
136
244
|
<Text style={[styles.searchLoadingText, { color: colors.textSecondary }]}>{t('searching')}</Text>
|
|
137
245
|
</View>
|
|
138
|
-
) : (
|
|
139
|
-
searchResults.map((identity, idx) => (
|
|
140
|
-
<TouchableOpacity
|
|
141
|
-
key={identity.identityKey + idx}
|
|
142
|
-
onPress={() => onSelectIdentity(identity)}
|
|
143
|
-
style={[
|
|
144
|
-
styles.searchResultRow,
|
|
145
|
-
idx < searchResults.length - 1 && {
|
|
146
|
-
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
147
|
-
borderBottomColor: colors.separator
|
|
148
|
-
}
|
|
149
|
-
]}
|
|
150
|
-
>
|
|
151
|
-
{identity.avatarURL ? (
|
|
152
|
-
<Image source={{ uri: identity.avatarURL }} style={styles.searchAvatar} />
|
|
153
|
-
) : (
|
|
154
|
-
<View style={[styles.searchAvatarPlaceholder, { backgroundColor: colors.accent }]}>
|
|
155
|
-
<Ionicons name="person" size={18} color={colors.background} />
|
|
156
|
-
</View>
|
|
157
|
-
)}
|
|
158
|
-
<View style={styles.searchResultInfo}>
|
|
159
|
-
<Text style={[styles.searchResultName, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
160
|
-
{identity.name || t('unknown')}
|
|
161
|
-
</Text>
|
|
162
|
-
<Text style={[styles.searchResultKey, { color: colors.textSecondary }]} numberOfLines={1}>
|
|
163
|
-
{identity.abbreviatedKey || `${identity.identityKey.slice(0, 20)}...`}
|
|
164
|
-
</Text>
|
|
165
|
-
</View>
|
|
166
|
-
{identity.badgeLabel ? (
|
|
167
|
-
<View style={[styles.badge, { backgroundColor: colors.fill }]}>
|
|
168
|
-
<Text style={[styles.badgeText, { color: colors.accent }]}>{identity.badgeLabel}</Text>
|
|
169
|
-
</View>
|
|
170
|
-
) : null}
|
|
171
|
-
</TouchableOpacity>
|
|
172
|
-
))
|
|
173
246
|
)}
|
|
174
247
|
</View>
|
|
175
248
|
)}
|
|
@@ -185,18 +258,6 @@ const styles = StyleSheet.create({
|
|
|
185
258
|
padding: spacing.md,
|
|
186
259
|
borderRadius: radii.md
|
|
187
260
|
},
|
|
188
|
-
avatar: {
|
|
189
|
-
width: 36,
|
|
190
|
-
height: 36,
|
|
191
|
-
borderRadius: 18
|
|
192
|
-
},
|
|
193
|
-
avatarPlaceholder: {
|
|
194
|
-
width: 36,
|
|
195
|
-
height: 36,
|
|
196
|
-
borderRadius: 18,
|
|
197
|
-
alignItems: 'center',
|
|
198
|
-
justifyContent: 'center'
|
|
199
|
-
},
|
|
200
261
|
selectedInfo: {
|
|
201
262
|
flex: 1,
|
|
202
263
|
marginLeft: spacing.md
|
|
@@ -242,23 +303,21 @@ const styles = StyleSheet.create({
|
|
|
242
303
|
searchLoadingText: {
|
|
243
304
|
...typography.subhead
|
|
244
305
|
},
|
|
306
|
+
recentLabel: {
|
|
307
|
+
...typography.caption2,
|
|
308
|
+
fontWeight: '700',
|
|
309
|
+
letterSpacing: 0.8,
|
|
310
|
+
textTransform: 'uppercase',
|
|
311
|
+
paddingHorizontal: spacing.md,
|
|
312
|
+
paddingTop: spacing.sm,
|
|
313
|
+
paddingBottom: spacing.xs
|
|
314
|
+
},
|
|
245
315
|
searchResultRow: {
|
|
246
316
|
flexDirection: 'row',
|
|
247
317
|
alignItems: 'center',
|
|
248
318
|
padding: spacing.md
|
|
249
319
|
},
|
|
250
320
|
searchAvatar: {
|
|
251
|
-
width: 32,
|
|
252
|
-
height: 32,
|
|
253
|
-
borderRadius: 16,
|
|
254
|
-
marginRight: spacing.md
|
|
255
|
-
},
|
|
256
|
-
searchAvatarPlaceholder: {
|
|
257
|
-
width: 32,
|
|
258
|
-
height: 32,
|
|
259
|
-
borderRadius: 16,
|
|
260
|
-
alignItems: 'center',
|
|
261
|
-
justifyContent: 'center',
|
|
262
321
|
marginRight: spacing.md
|
|
263
322
|
},
|
|
264
323
|
searchResultInfo: {
|