@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
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New Contact — four ways in: a scanned or deep-linked identity key (QR scan
|
|
3
|
+
* on the Contacts header, or `bsv-wallet://contact/add?identityKey=`), a
|
|
4
|
+
* network search hit on Contacts (`?source=search`), the "Save as a contact"
|
|
5
|
+
* offer on a payment's success screen (`?identityKey=` and `?name=` both
|
|
6
|
+
* prefilled, `?source=pay`), or the plain "New Contact" button at the bottom
|
|
7
|
+
* of the Contacts list (2026-09-18) — the only path with no identity key
|
|
8
|
+
* yet, where the Identifier row itself becomes an editable paste field.
|
|
9
|
+
*
|
|
10
|
+
* Any past activity with the key is shown below the form, so you can see who
|
|
11
|
+
* you are about to save.
|
|
12
|
+
*/
|
|
13
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
14
|
+
import { I18nManager, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'
|
|
15
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
16
|
+
import { useTranslation } from 'react-i18next'
|
|
17
|
+
import { useTheme, spacing, radii, typography, useWallet } from '@bsv/expo-wallet-toolbox'
|
|
18
|
+
import { GroupedSection } from '../components/ui/GroupedList'
|
|
19
|
+
import PressableScale from '../components/ui/PressableScale'
|
|
20
|
+
import { showToast } from '../components/ui/Toast'
|
|
21
|
+
import ContactSigil from '../components/wallet/ContactSigil'
|
|
22
|
+
import ContactActivityList from '../components/wallet/ContactActivityList'
|
|
23
|
+
import IdentifierRow from '../components/wallet/IdentifierRow'
|
|
24
|
+
import { useContactsStore } from '../hooks/useContactsStore'
|
|
25
|
+
import { abbreviateKey } from '../../core/pay/counterparty'
|
|
26
|
+
import { isCompressedIdentityKey } from '../../core/identity/contactLink'
|
|
27
|
+
import { getHandleRegistryConfig } from '../../core/toolboxConfig'
|
|
28
|
+
import { parsePaymail } from '../../core/identity/handleRegistry/rules'
|
|
29
|
+
import { createHandleRegistryClient } from '../../core/identity/handleRegistry/client'
|
|
30
|
+
import { getContactActivity, type ContactActivityItem } from '../../core/contacts/contactActivity'
|
|
31
|
+
import type { ContactSource } from '../../core/contacts/contactsStore'
|
|
32
|
+
|
|
33
|
+
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
34
|
+
let ioniconsComponent: IoniconsComponent | undefined
|
|
35
|
+
function loadIonicons(): IoniconsComponent {
|
|
36
|
+
if (!ioniconsComponent) {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
38
|
+
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
39
|
+
}
|
|
40
|
+
return ioniconsComponent
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type ExpoRouterModule = typeof import('expo-router')
|
|
44
|
+
let expoRouterMod: ExpoRouterModule | undefined
|
|
45
|
+
function loadExpoRouter(): ExpoRouterModule {
|
|
46
|
+
if (!expoRouterMod) {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
48
|
+
expoRouterMod = require('expo-router') as ExpoRouterModule
|
|
49
|
+
}
|
|
50
|
+
return expoRouterMod
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function firstParam(v: string | string[] | undefined): string | undefined {
|
|
54
|
+
return Array.isArray(v) ? v[0] : v
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const SOURCES: ReadonlySet<string> = new Set<ContactSource>(['manual', 'qr', 'pay', 'search'])
|
|
58
|
+
|
|
59
|
+
export function NewContactScreen() {
|
|
60
|
+
const { t } = useTranslation()
|
|
61
|
+
const { colors } = useTheme()
|
|
62
|
+
const insets = useSafeAreaInsets()
|
|
63
|
+
const Ionicons = loadIonicons()
|
|
64
|
+
const { router, useLocalSearchParams } = loadExpoRouter()
|
|
65
|
+
const { walletUserId, managers, adminOriginator, storage, selectedNetwork } = useWallet()
|
|
66
|
+
const store = useContactsStore()
|
|
67
|
+
const params = useLocalSearchParams<{
|
|
68
|
+
identityKey?: string | string[]
|
|
69
|
+
name?: string | string[]
|
|
70
|
+
handle?: string | string[]
|
|
71
|
+
source?: string | string[]
|
|
72
|
+
}>()
|
|
73
|
+
const prefilledIdentityKey = (firstParam(params.identityKey) ?? '').toLowerCase()
|
|
74
|
+
/**
|
|
75
|
+
* The registry's `handle@domain`, when the caller had one: Pay's "Save as a
|
|
76
|
+
* contact" is the only route that knows it today — the Contacts search tier
|
|
77
|
+
* is an overlay result, which carries no paymail — and it is the only way
|
|
78
|
+
* this column is ever populated.
|
|
79
|
+
*
|
|
80
|
+
* Validated, not trusted. `/contact/add` is a deep-linkable expo-router
|
|
81
|
+
* route, so this param is a string from outside the app — and what it becomes
|
|
82
|
+
* is rendered on ContactScreen under a shield and the words "only they can
|
|
83
|
+
* change it". Anything that is not a paymail is not a handle.
|
|
84
|
+
*
|
|
85
|
+
* Passing `parsePaymail` is only the SHAPE, though, and shape says nothing
|
|
86
|
+
* about whose handle it is: a phishing link can assert any well-formed
|
|
87
|
+
* paymail for any identity key. The registry decides that, below.
|
|
88
|
+
*/
|
|
89
|
+
const parsedHandle = parsePaymail(firstParam(params.handle) ?? '')
|
|
90
|
+
const prefilledHandle = parsedHandle ? `${parsedHandle.handle}@${parsedHandle.domain}` : ''
|
|
91
|
+
const handleDomain = parsedHandle?.domain
|
|
92
|
+
const sourceParam = firstParam(params.source)
|
|
93
|
+
const source: ContactSource = sourceParam && SOURCES.has(sourceParam) ? (sourceParam as ContactSource) : 'qr'
|
|
94
|
+
// The only path with no identity key yet: the plain "New Contact" button on
|
|
95
|
+
// the Contacts list. Everywhere else (scan, deep link, search, the payment
|
|
96
|
+
// success screen) arrives with one already known, and the row stays read-only.
|
|
97
|
+
const manualEntry = prefilledIdentityKey === ''
|
|
98
|
+
|
|
99
|
+
const [name, setName] = useState(firstParam(params.name) ?? '')
|
|
100
|
+
const [identifierInput, setIdentifierInput] = useState('')
|
|
101
|
+
const [saving, setSaving] = useState(false)
|
|
102
|
+
const [activity, setActivity] = useState<ContactActivityItem[]>([])
|
|
103
|
+
|
|
104
|
+
const identityKey = manualEntry ? identifierInput.trim().toLowerCase() : prefilledIdentityKey
|
|
105
|
+
const identityKeyValid = isCompressedIdentityKey(identityKey)
|
|
106
|
+
const nameValid = name.trim().length > 0
|
|
107
|
+
|
|
108
|
+
/** Two strings rather than the config object, which is rebuilt every call. */
|
|
109
|
+
const registry = getHandleRegistryConfig(selectedNetwork)
|
|
110
|
+
const registryDomain = registry?.domain
|
|
111
|
+
const registryUrl = registry?.url
|
|
112
|
+
const registryClient = useMemo(
|
|
113
|
+
() =>
|
|
114
|
+
registryDomain && registryUrl
|
|
115
|
+
? createHandleRegistryClient({ pinned: { domain: registryDomain, url: registryUrl } })
|
|
116
|
+
: null,
|
|
117
|
+
[registryDomain, registryUrl]
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The handle this key actually holds, as the registry answers for it — the
|
|
122
|
+
* only version of the param worth storing.
|
|
123
|
+
*
|
|
124
|
+
* `cachedHandle` is drawn on ContactScreen under a shield reading "only they
|
|
125
|
+
* can change it", and it is the line Pay's contacts tier offers this person
|
|
126
|
+
* by. An asserted string is neither of those things, so it is checked against
|
|
127
|
+
* the key it claims before it is written, on the domain it names (the same
|
|
128
|
+
* domain ContactScreen's own refresh asks). An unproven one is simply not a
|
|
129
|
+
* handle here: that refresh fills the column in later if it is real, and no
|
|
130
|
+
* screen has to un-say a shield in the meantime.
|
|
131
|
+
*/
|
|
132
|
+
const [provenFor, setProvenFor] = useState<{ identityKey: string; handle: string } | null>(null)
|
|
133
|
+
// Held against the pair it was proven for, rather than reset when either
|
|
134
|
+
// changes: the manual-entry field rewrites `identityKey` on every keystroke,
|
|
135
|
+
// and a proof carried over to the next key would be exactly the claim this
|
|
136
|
+
// is here to refuse.
|
|
137
|
+
const verifiedHandle =
|
|
138
|
+
provenFor?.identityKey === identityKey && provenFor?.handle === prefilledHandle ? prefilledHandle : ''
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!registryClient || !prefilledHandle || !identityKeyValid) return
|
|
141
|
+
let cancelled = false
|
|
142
|
+
void registryClient.lookupProfile(identityKey, handleDomain).then(seen => {
|
|
143
|
+
if (cancelled || seen.kind !== 'found' || seen.profile.paymail !== prefilledHandle) return
|
|
144
|
+
setProvenFor({ identityKey, handle: prefilledHandle })
|
|
145
|
+
})
|
|
146
|
+
return () => {
|
|
147
|
+
cancelled = true
|
|
148
|
+
}
|
|
149
|
+
}, [registryClient, prefilledHandle, handleDomain, identityKey, identityKeyValid])
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (!identityKeyValid) {
|
|
153
|
+
setActivity([])
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
let cancelled = false
|
|
157
|
+
void getContactActivity({
|
|
158
|
+
wallet: managers?.permissionsManager as never,
|
|
159
|
+
adminOriginator,
|
|
160
|
+
settlementsDb: storage?.sqliteDb as never,
|
|
161
|
+
identityKey
|
|
162
|
+
}).then(items => {
|
|
163
|
+
if (!cancelled) setActivity(items)
|
|
164
|
+
})
|
|
165
|
+
return () => {
|
|
166
|
+
cancelled = true
|
|
167
|
+
}
|
|
168
|
+
}, [identityKey, identityKeyValid, managers, adminOriginator, storage])
|
|
169
|
+
|
|
170
|
+
const onSave = useCallback(async () => {
|
|
171
|
+
if (!store || walletUserId === null || !identityKeyValid || !nameValid) return
|
|
172
|
+
setSaving(true)
|
|
173
|
+
try {
|
|
174
|
+
await store.createContact({
|
|
175
|
+
userId: walletUserId,
|
|
176
|
+
identityKey,
|
|
177
|
+
name: name.trim(),
|
|
178
|
+
...(verifiedHandle ? { cachedHandle: verifiedHandle } : {}),
|
|
179
|
+
source: manualEntry ? 'manual' : source
|
|
180
|
+
})
|
|
181
|
+
showToast(t('contact_saved'), { type: 'success' })
|
|
182
|
+
router.replace({ pathname: '/contact', params: { identityKey } } as never)
|
|
183
|
+
} finally {
|
|
184
|
+
setSaving(false)
|
|
185
|
+
}
|
|
186
|
+
}, [
|
|
187
|
+
store,
|
|
188
|
+
walletUserId,
|
|
189
|
+
identityKey,
|
|
190
|
+
identityKeyValid,
|
|
191
|
+
name,
|
|
192
|
+
nameValid,
|
|
193
|
+
verifiedHandle,
|
|
194
|
+
manualEntry,
|
|
195
|
+
source,
|
|
196
|
+
router,
|
|
197
|
+
t
|
|
198
|
+
])
|
|
199
|
+
|
|
200
|
+
const canSave = nameValid && identityKeyValid && !saving
|
|
201
|
+
const showIdentifierError = manualEntry && identifierInput.trim().length > 0 && !identityKeyValid
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<View style={[styles.container, { backgroundColor: colors.background, paddingTop: insets.top }]}>
|
|
205
|
+
<View style={[styles.header, { borderBottomColor: colors.separator }]}>
|
|
206
|
+
<PressableScale
|
|
207
|
+
onPress={() => router.back()}
|
|
208
|
+
haptic="tap"
|
|
209
|
+
style={styles.headerBtn}
|
|
210
|
+
accessibilityRole="button"
|
|
211
|
+
accessibilityLabel={t('go_back')}
|
|
212
|
+
>
|
|
213
|
+
<Ionicons
|
|
214
|
+
name={I18nManager.isRTL ? 'chevron-forward' : 'chevron-back'}
|
|
215
|
+
size={24}
|
|
216
|
+
color={colors.textSecondary}
|
|
217
|
+
/>
|
|
218
|
+
</PressableScale>
|
|
219
|
+
<Text style={[styles.headerTitle, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
220
|
+
{t('contact_new_title')}
|
|
221
|
+
</Text>
|
|
222
|
+
<View style={styles.headerBtn} />
|
|
223
|
+
</View>
|
|
224
|
+
|
|
225
|
+
<ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
|
|
226
|
+
<View style={styles.hero}>
|
|
227
|
+
<ContactSigil identityKey={identityKeyValid ? identityKey : '0'.repeat(66)} size={72} radius={24} />
|
|
228
|
+
<Text style={[styles.heroKey, { color: identityKeyValid ? colors.textPrimary : colors.textTertiary }]}>
|
|
229
|
+
{identityKeyValid ? abbreviateKey(identityKey) : t('contact_identifier')}
|
|
230
|
+
</Text>
|
|
231
|
+
{/* Only once the registry has confirmed it belongs to this key: a
|
|
232
|
+
handle shown here is the same claim the shield makes on the
|
|
233
|
+
screen this route replaces itself with. */}
|
|
234
|
+
<Text style={[styles.heroCaption, { color: colors.textTertiary }]}>
|
|
235
|
+
{verifiedHandle || t('contact_no_handle_registered')}
|
|
236
|
+
</Text>
|
|
237
|
+
</View>
|
|
238
|
+
|
|
239
|
+
<GroupedSection header={t('contact_name_section')} footer={t('contact_new_name_hint')}>
|
|
240
|
+
<View style={styles.nameRow}>
|
|
241
|
+
<View style={styles.nameLeading}>
|
|
242
|
+
<Ionicons name="pencil-outline" size={17} color={colors.textSecondary} />
|
|
243
|
+
</View>
|
|
244
|
+
<TextInput
|
|
245
|
+
value={name}
|
|
246
|
+
onChangeText={setName}
|
|
247
|
+
placeholder={t('contact_new_title')}
|
|
248
|
+
placeholderTextColor={colors.textTertiary}
|
|
249
|
+
autoFocus={!manualEntry}
|
|
250
|
+
returnKeyType="done"
|
|
251
|
+
style={[styles.nameInput, { color: colors.textPrimary }]}
|
|
252
|
+
/>
|
|
253
|
+
</View>
|
|
254
|
+
</GroupedSection>
|
|
255
|
+
|
|
256
|
+
<GroupedSection
|
|
257
|
+
header={t('contact_identifier')}
|
|
258
|
+
footer={showIdentifierError ? t('contact_identifier_invalid') : undefined}
|
|
259
|
+
>
|
|
260
|
+
{manualEntry ? (
|
|
261
|
+
<TextInput
|
|
262
|
+
value={identifierInput}
|
|
263
|
+
onChangeText={setIdentifierInput}
|
|
264
|
+
placeholder={t('contact_identifier_placeholder')}
|
|
265
|
+
placeholderTextColor={colors.textTertiary}
|
|
266
|
+
autoCapitalize="none"
|
|
267
|
+
autoCorrect={false}
|
|
268
|
+
autoFocus
|
|
269
|
+
style={[styles.identifierInput, { color: showIdentifierError ? colors.error : colors.textPrimary }]}
|
|
270
|
+
/>
|
|
271
|
+
) : (
|
|
272
|
+
<IdentifierRow identityKey={identityKey} />
|
|
273
|
+
)}
|
|
274
|
+
</GroupedSection>
|
|
275
|
+
|
|
276
|
+
{activity.length > 0 && (
|
|
277
|
+
<>
|
|
278
|
+
<Text style={[styles.sectionTitle, { color: colors.textTertiary }]}>
|
|
279
|
+
{t('contact_activity').toUpperCase()}
|
|
280
|
+
</Text>
|
|
281
|
+
<ContactActivityList items={activity} identityKey={identityKey} />
|
|
282
|
+
</>
|
|
283
|
+
)}
|
|
284
|
+
</ScrollView>
|
|
285
|
+
|
|
286
|
+
<View style={[styles.footer, { paddingBottom: Math.max(insets.bottom, spacing.lg) }]}>
|
|
287
|
+
<PressableScale
|
|
288
|
+
onPress={onSave}
|
|
289
|
+
disabled={!canSave}
|
|
290
|
+
haptic="confirm"
|
|
291
|
+
style={[styles.cta, { backgroundColor: canSave ? colors.accent : colors.fill }]}
|
|
292
|
+
accessibilityRole="button"
|
|
293
|
+
accessibilityState={{ disabled: !canSave }}
|
|
294
|
+
>
|
|
295
|
+
<Ionicons name="person-add-outline" size={18} color={canSave ? colors.textOnAccent : colors.textTertiary} />
|
|
296
|
+
<Text style={[styles.ctaText, { color: canSave ? colors.textOnAccent : colors.textTertiary }]}>
|
|
297
|
+
{t('contact_save')}
|
|
298
|
+
</Text>
|
|
299
|
+
</PressableScale>
|
|
300
|
+
</View>
|
|
301
|
+
</View>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export default NewContactScreen
|
|
306
|
+
|
|
307
|
+
const styles = StyleSheet.create({
|
|
308
|
+
container: { flex: 1 },
|
|
309
|
+
header: {
|
|
310
|
+
flexDirection: 'row',
|
|
311
|
+
alignItems: 'center',
|
|
312
|
+
justifyContent: 'space-between',
|
|
313
|
+
paddingHorizontal: spacing.sm,
|
|
314
|
+
paddingVertical: spacing.md,
|
|
315
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
316
|
+
},
|
|
317
|
+
headerBtn: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' },
|
|
318
|
+
headerTitle: { ...typography.headline, fontWeight: '600', flex: 1, textAlign: 'center' },
|
|
319
|
+
content: { paddingTop: spacing.lg, paddingBottom: spacing.lg },
|
|
320
|
+
hero: {
|
|
321
|
+
alignItems: 'center',
|
|
322
|
+
gap: spacing.sm,
|
|
323
|
+
paddingHorizontal: spacing.xl,
|
|
324
|
+
paddingTop: spacing.sm,
|
|
325
|
+
paddingBottom: spacing.xl
|
|
326
|
+
},
|
|
327
|
+
heroKey: { fontSize: 18, lineHeight: 24, fontWeight: '700', fontFamily: 'monospace', marginTop: spacing.xs },
|
|
328
|
+
heroCaption: { ...typography.footnote },
|
|
329
|
+
nameRow: {
|
|
330
|
+
flexDirection: 'row',
|
|
331
|
+
alignItems: 'center',
|
|
332
|
+
minHeight: 52,
|
|
333
|
+
paddingLeft: spacing.xs,
|
|
334
|
+
paddingRight: spacing.lg
|
|
335
|
+
},
|
|
336
|
+
nameLeading: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' },
|
|
337
|
+
nameInput: { ...typography.body, flex: 1, minWidth: 0, paddingVertical: spacing.md, paddingHorizontal: 0 },
|
|
338
|
+
identifierInput: {
|
|
339
|
+
...typography.subhead,
|
|
340
|
+
fontFamily: 'monospace',
|
|
341
|
+
minHeight: 48,
|
|
342
|
+
paddingHorizontal: spacing.lg,
|
|
343
|
+
paddingVertical: spacing.md
|
|
344
|
+
},
|
|
345
|
+
sectionTitle: {
|
|
346
|
+
fontSize: 10.5,
|
|
347
|
+
fontWeight: '700',
|
|
348
|
+
letterSpacing: 1.3,
|
|
349
|
+
paddingHorizontal: spacing.xl,
|
|
350
|
+
paddingBottom: spacing.sm
|
|
351
|
+
},
|
|
352
|
+
footer: { paddingHorizontal: spacing.lg, paddingTop: spacing.sm },
|
|
353
|
+
cta: {
|
|
354
|
+
flexDirection: 'row',
|
|
355
|
+
alignItems: 'center',
|
|
356
|
+
justifyContent: 'center',
|
|
357
|
+
gap: spacing.sm,
|
|
358
|
+
paddingVertical: spacing.md + 2,
|
|
359
|
+
borderRadius: radii.md
|
|
360
|
+
},
|
|
361
|
+
ctaText: { ...typography.subhead, fontWeight: '600' }
|
|
362
|
+
})
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
useWalletConnection,
|
|
18
18
|
guardVaultAccess,
|
|
19
19
|
capWalletArgs,
|
|
20
|
-
ADMIN_ORIGINATOR
|
|
20
|
+
ADMIN_ORIGINATOR,
|
|
21
|
+
parseExternalOrigin
|
|
21
22
|
} from '@bsv/expo-wallet-toolbox'
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -38,10 +39,6 @@ function loadExpoRouter(): ExpoRouterModule {
|
|
|
38
39
|
return expoRouterMod
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
function domainFromOrigin(origin: string): string {
|
|
42
|
-
try { return new URL(origin).hostname } catch { return origin }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
42
|
export function PairScreen() {
|
|
46
43
|
const { colors } = useTheme()
|
|
47
44
|
const { managers } = useWallet()
|
|
@@ -107,18 +104,21 @@ export function PairScreen() {
|
|
|
107
104
|
setPreConnectError('Wallet not ready — please log in first')
|
|
108
105
|
return
|
|
109
106
|
}
|
|
110
|
-
const originator = domainFromOrigin(params.origin)
|
|
111
|
-
// Guarded exactly like every sibling call site (connections.tsx): this is
|
|
112
|
-
// an external surface (the desktop/browser pairing peer dispatches
|
|
113
|
-
// BRC-100 methods by name), so it must never receive the unguarded
|
|
114
|
-
// manager — see guard.ts for what that would otherwise expose.
|
|
115
|
-
const wallet = new WalletClient(capWalletArgs(guardVaultAccess(managers.permissionsManager as any, ADMIN_ORIGINATOR)), originator)
|
|
116
107
|
try {
|
|
108
|
+
const external = parseExternalOrigin(params.origin)
|
|
109
|
+
// Guarded exactly like every sibling call site (connections.tsx): this is
|
|
110
|
+
// an external surface (the desktop/browser pairing peer dispatches
|
|
111
|
+
// BRC-100 methods by name), so it must never receive the unguarded
|
|
112
|
+
// manager — see guard.ts for what that would otherwise expose.
|
|
113
|
+
const wallet = new WalletClient(
|
|
114
|
+
capWalletArgs(guardVaultAccess(managers.permissionsManager as any, ADMIN_ORIGINATOR)),
|
|
115
|
+
external.originator
|
|
116
|
+
)
|
|
117
117
|
await connect({
|
|
118
118
|
topic: params.topic,
|
|
119
119
|
backendIdentityKey: params.backendIdentityKey,
|
|
120
120
|
protocolID: params.protocolID,
|
|
121
|
-
origin:
|
|
121
|
+
origin: external.origin,
|
|
122
122
|
expiry: params.expiry,
|
|
123
123
|
sig: params.sig,
|
|
124
124
|
}, wallet)
|
package/ui/screens/PayScreen.tsx
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* `?cell=` values survive as deep-link aliases: any `pay-*` opens the send form
|
|
12
12
|
* (`pay-nearby` with the scanner up), any `get-*` opens that method directly.
|
|
13
13
|
*/
|
|
14
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
14
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
15
15
|
import { I18nManager, InteractionManager, Modal, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
16
16
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
17
17
|
import { useTranslation } from 'react-i18next'
|
|
@@ -19,7 +19,8 @@ import { useTranslation } from 'react-i18next'
|
|
|
19
19
|
import PressableScale from '../components/ui/PressableScale'
|
|
20
20
|
import { partitionQueueByGrace } from '../../core/offline/queueGrace'
|
|
21
21
|
import PaymentQrDisplay from '../components/pay/PaymentQrDisplay'
|
|
22
|
-
import UniversalSend from '../components/pay/UniversalSend'
|
|
22
|
+
import UniversalSend, { type UniversalSendHandle } from '../components/pay/UniversalSend'
|
|
23
|
+
import type { PayStep } from '../components/pay/StepBar'
|
|
23
24
|
import RequestHub, { requestSatsFrom, type RequestMethod } from '../components/pay/RequestHub'
|
|
24
25
|
import NearbyFlow from '../components/pay/NearbyFlow'
|
|
25
26
|
import HandleReceive from '../components/pay/HandleReceive'
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
typography,
|
|
34
35
|
useWallet,
|
|
35
36
|
validatePeerPayURI,
|
|
37
|
+
peerPayValidationMessage,
|
|
36
38
|
type Session,
|
|
37
39
|
takeProofNudge,
|
|
38
40
|
findOfflineActions,
|
|
@@ -40,6 +42,8 @@ import {
|
|
|
40
42
|
TaskSendOffline
|
|
41
43
|
} from '@bsv/expo-wallet-toolbox'
|
|
42
44
|
import { getPendingCorruptNotice, readUnprocessedPending } from '../../core/localpay/pending'
|
|
45
|
+
import { useAssetStatus, useMandala } from '../hooks/useMandala'
|
|
46
|
+
import { formatTokenAmountWithUnit } from '../tokenFormat'
|
|
43
47
|
import { nearbyAdvisory } from '../../core/localpay/nearbyAdvisory'
|
|
44
48
|
import { NearbyAdvisoryModal } from '../components/pay/NearbyAdvisoryModal'
|
|
45
49
|
import type { DismissTarget } from '../dismissTarget'
|
|
@@ -139,19 +143,25 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
|
|
|
139
143
|
identityKey?: string | string[]
|
|
140
144
|
sats?: string | string[]
|
|
141
145
|
peerpay?: string | string[]
|
|
146
|
+
asset?: string | string[]
|
|
142
147
|
}>()
|
|
143
148
|
|
|
144
149
|
const peerpay = firstParam(params.peerpay)
|
|
145
150
|
const peerPayValidation = useMemo(() => (peerpay ? validatePeerPayURI(peerpay) : null), [peerpay])
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
const peerPayInvalid = peerPayValidationMessage(peerPayValidation)
|
|
152
|
+
// A link's money and figure are adopted only from a link with no error at
|
|
153
|
+
// all: one that mixes `sats` with a token request must not be read as either.
|
|
154
|
+
const linkSats = peerPayValidation && !peerPayInvalid ? peerPayValidation.sats : undefined
|
|
155
|
+
const linkAsset = peerPayValidation && !peerPayInvalid ? peerPayValidation.asset : undefined
|
|
156
|
+
const linkAmount = peerPayValidation && !peerPayInvalid ? peerPayValidation.amount : undefined
|
|
151
157
|
|
|
152
158
|
const initialIdentityKey = peerPayValidation?.identityKey ?? firstParam(params.identityKey)
|
|
153
|
-
const satsParam =
|
|
159
|
+
const satsParam = linkSats ?? Number(firstParam(params.sats))
|
|
154
160
|
const initialSats = Number.isFinite(satsParam) && satsParam > 0 ? Number(satsParam) : undefined
|
|
161
|
+
const initialTokenAmount = useMemo(
|
|
162
|
+
() => (linkAsset && linkAmount ? { assetId: linkAsset, baseUnits: linkAmount } : undefined),
|
|
163
|
+
[linkAsset, linkAmount]
|
|
164
|
+
)
|
|
155
165
|
// Memoized: useRecipientInput re-adopts initialTarget whenever its identity changes.
|
|
156
166
|
const initialTarget = useMemo(
|
|
157
167
|
() =>
|
|
@@ -182,7 +192,89 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
|
|
|
182
192
|
)
|
|
183
193
|
/** Get side: the hub's raw amount, carried into the method. */
|
|
184
194
|
const [requestSats, setRequestSats] = useState('')
|
|
185
|
-
|
|
195
|
+
|
|
196
|
+
// ── the asset axis ──────────────────────────────────────────────────
|
|
197
|
+
// One piece of state for the whole screen, so the choice survives the hop
|
|
198
|
+
// from the hub into a method and back. `null` is BSV, and a wallet holding no
|
|
199
|
+
// token never leaves that value.
|
|
200
|
+
const mandala = useMandala()
|
|
201
|
+
const balances = mandala.balances ?? []
|
|
202
|
+
// A token request in a peerpay link selects its asset the way `?asset=` does,
|
|
203
|
+
// and a `sats=` link selects BSV. The choice is remembered against the link
|
|
204
|
+
// it was made under, so a second link arriving while this screen is mounted
|
|
205
|
+
// names its own money — the way its figure already does — while a choice
|
|
206
|
+
// made after the link (the picker) stands until the next link.
|
|
207
|
+
// Every term of the request, so two links for the same asset (a new payee,
|
|
208
|
+
// a new figure) are two links, not one.
|
|
209
|
+
const linkKey = `${initialIdentityKey ?? ''}|${linkAsset ?? ''}|${linkAmount ?? ''}|${linkSats ?? ''}`
|
|
210
|
+
const [choice, setChoice] = useState<{ forLink: string; assetId: string | null }>(() => ({
|
|
211
|
+
forLink: linkKey,
|
|
212
|
+
assetId: linkAsset ?? firstParam(params.asset) ?? null
|
|
213
|
+
}))
|
|
214
|
+
const selectedAssetId =
|
|
215
|
+
choice.forLink === linkKey ? choice.assetId : (linkAsset ?? (linkSats !== undefined ? null : choice.assetId))
|
|
216
|
+
const setSelectedAssetId = useCallback((id: string | null) => setChoice({ forLink: linkKey, assetId: id }), [linkKey])
|
|
217
|
+
const holding = balances.find(b => b.asset.assetId === selectedAssetId) ?? null
|
|
218
|
+
const asset = holding?.asset ?? null
|
|
219
|
+
/**
|
|
220
|
+
* The banner over the send form: a malformed link, or a valid token request
|
|
221
|
+
* for an asset this wallet does not hold — which the effect below turns
|
|
222
|
+
* back into BSV, and which must not do so silently: the payer would
|
|
223
|
+
* otherwise pay a different money than the one asked for, with no figure
|
|
224
|
+
* and no idea why.
|
|
225
|
+
*/
|
|
226
|
+
// No runtime on a BUILT wallet is a settled fact — the runtime is published
|
|
227
|
+
// at build, only on a chain with Mandala endpoints — where no runtime on a
|
|
228
|
+
// wallet still building is merely unknown and decides nothing yet.
|
|
229
|
+
const tokensNever = walletBuilt && !mandala.available
|
|
230
|
+
const peerPayNotice = useMemo(() => {
|
|
231
|
+
if (peerPayInvalid) return peerPayInvalid
|
|
232
|
+
if (
|
|
233
|
+
linkAsset &&
|
|
234
|
+
(tokensNever || (mandala.balances && !mandala.balances.some(b => b.asset.assetId === linkAsset)))
|
|
235
|
+
) {
|
|
236
|
+
return t('pay_asset_link_not_held')
|
|
237
|
+
}
|
|
238
|
+
return null
|
|
239
|
+
}, [peerPayInvalid, linkAsset, tokensNever, mandala.balances, t])
|
|
240
|
+
// Regulatory/registry facts for whichever asset is selected — RequestHub
|
|
241
|
+
// stays a plain prop-driven view, so this screen is the one that asks.
|
|
242
|
+
const selectedAssetStatus = useAssetStatus(asset?.assetId ?? null).status
|
|
243
|
+
// A deep link naming an asset this wallet does not hold selects BSV rather
|
|
244
|
+
// than a denomination with no balance behind it.
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
if (selectedAssetId && (tokensNever || (mandala.balances && !holding))) setSelectedAssetId(null)
|
|
247
|
+
}, [selectedAssetId, tokensNever, mandala.balances, holding, setSelectedAssetId])
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The request, in the unit it was actually typed in.
|
|
251
|
+
*
|
|
252
|
+
* `requestSatsFrom(requestSats)` would read base units as satoshis the moment
|
|
253
|
+
* an asset is selected — a 25.00 USDX request rendering as "2,500 satoshis"
|
|
254
|
+
* on the payee's own screen and binding the payer to that figure. The
|
|
255
|
+
* discriminated shape makes the unit impossible to lose.
|
|
256
|
+
*/
|
|
257
|
+
const request: { kind: 'bsv'; sats?: number } | { kind: 'token'; baseUnits?: number; assetId: string } = asset
|
|
258
|
+
? { kind: 'token', baseUnits: requestSatsFrom(requestSats), assetId: asset.assetId }
|
|
259
|
+
: { kind: 'bsv', sats: requestSatsFrom(requestSats) }
|
|
260
|
+
const initialNearbyRequest = useMemo(
|
|
261
|
+
() => ({
|
|
262
|
+
sats: requestSatsFrom(requestSats),
|
|
263
|
+
...(asset
|
|
264
|
+
? {
|
|
265
|
+
asset: {
|
|
266
|
+
id: asset.assetId,
|
|
267
|
+
label: asset.label,
|
|
268
|
+
ticker: asset.ticker,
|
|
269
|
+
decimals: asset.decimals,
|
|
270
|
+
overlayUrl: asset.overlayUrl,
|
|
271
|
+
overlayIdentityKey: asset.overlayIdentityKey
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
: {})
|
|
275
|
+
}),
|
|
276
|
+
[requestSats, asset]
|
|
277
|
+
)
|
|
186
278
|
// One camera raise per deep link; a cancelled advisory must not re-open it.
|
|
187
279
|
const [scanOnMount, setScanOnMount] = useState(paramCell === 'pay-nearby')
|
|
188
280
|
|
|
@@ -332,7 +424,13 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
|
|
|
332
424
|
* trying to leave behind, which puts them one edge-swipe away instead of
|
|
333
425
|
* discarding them.
|
|
334
426
|
*/
|
|
427
|
+
// The three-step send form owns its own step; the header's one back
|
|
428
|
+
// chevron walks it back a step before it leaves the screen (no second back
|
|
429
|
+
// control inside the form — 2026-09-18 design).
|
|
430
|
+
const sendRef = useRef<UniversalSendHandle>(null)
|
|
431
|
+
const [payStep, setPayStep] = useState<PayStep>('who')
|
|
335
432
|
const goBack = useCallback(() => {
|
|
433
|
+
if (sendRef.current?.back()) return
|
|
336
434
|
router.dismissTo(dismissTo)
|
|
337
435
|
}, [dismissTo])
|
|
338
436
|
|
|
@@ -375,24 +473,45 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
|
|
|
375
473
|
<>
|
|
376
474
|
{offlineNotice}
|
|
377
475
|
<UniversalSend
|
|
476
|
+
ref={sendRef}
|
|
477
|
+
onStepChange={setPayStep}
|
|
378
478
|
initialTarget={initialTarget}
|
|
379
479
|
initialSats={initialSats}
|
|
480
|
+
initialTokenAmount={initialTokenAmount}
|
|
380
481
|
initialNotice={peerPayNotice}
|
|
381
482
|
openScannerOnMount={scanOnMount}
|
|
382
483
|
onNearbySession={onNearbySession}
|
|
484
|
+
selectedAssetId={selectedAssetId}
|
|
485
|
+
onSelectAsset={setSelectedAssetId}
|
|
383
486
|
dismissTo={dismissTo}
|
|
384
487
|
/>
|
|
385
488
|
</>
|
|
386
489
|
)
|
|
387
490
|
}
|
|
388
|
-
|
|
491
|
+
// Satoshis ONLY on the BSV branch. On the token branch the same digits are
|
|
492
|
+
// base units, and every satoshi-shaped prop below must not see them.
|
|
493
|
+
const sats = request.kind === 'bsv' ? request.sats : undefined
|
|
494
|
+
const requestedAmountText =
|
|
495
|
+
asset && request.kind === 'token' && request.baseUnits !== undefined
|
|
496
|
+
? (formatTokenAmountWithUnit(request.baseUnits, asset) ?? undefined)
|
|
497
|
+
: undefined
|
|
389
498
|
switch (method) {
|
|
390
499
|
case 'get-nearby':
|
|
391
500
|
return nearbyAdvisorySeen ? (
|
|
392
501
|
<NearbyFlow role="payee" initialRequest={initialNearbyRequest} onExit={goBack} dismissTo={dismissTo} />
|
|
393
502
|
) : null
|
|
394
503
|
case 'get-handle':
|
|
395
|
-
return
|
|
504
|
+
return (
|
|
505
|
+
<HandleReceive
|
|
506
|
+
initialSats={sats}
|
|
507
|
+
asset={asset ? { assetId: asset.assetId, ticker: asset.ticker, issuerName: asset.issuerName } : null}
|
|
508
|
+
requestedBaseUnits={request.kind === 'token' ? request.baseUnits : undefined}
|
|
509
|
+
requestedAmountText={requestedAmountText}
|
|
510
|
+
assetMessageBoxUrl={selectedAssetStatus?.messageBoxUrl ?? null}
|
|
511
|
+
onBsvInstead={() => setSelectedAssetId(null)}
|
|
512
|
+
dismissTo={dismissTo}
|
|
513
|
+
/>
|
|
514
|
+
)
|
|
396
515
|
case 'get-address':
|
|
397
516
|
return <AddressReceive initialSats={sats} dismissTo={dismissTo} />
|
|
398
517
|
default:
|
|
@@ -404,6 +523,10 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
|
|
|
404
523
|
onChangeRequestSats={setRequestSats}
|
|
405
524
|
onPick={setMethod}
|
|
406
525
|
online={online}
|
|
526
|
+
balances={balances}
|
|
527
|
+
selectedAssetId={selectedAssetId}
|
|
528
|
+
onSelectAsset={setSelectedAssetId}
|
|
529
|
+
assetStatus={selectedAssetStatus}
|
|
407
530
|
/>
|
|
408
531
|
</>
|
|
409
532
|
)
|
|
@@ -429,7 +552,17 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
|
|
|
429
552
|
<Text style={[styles.headerTitle, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
430
553
|
{/* The screen names what it is doing: the direction, or the rail/method once one is live. */}
|
|
431
554
|
{direction === 'pay'
|
|
432
|
-
?
|
|
555
|
+
? nearbySession
|
|
556
|
+
? t('pay_cell_nearby_pay')
|
|
557
|
+
: payStep === 'review'
|
|
558
|
+
? // The last step is named for what it is: a review, before the
|
|
559
|
+
// button that names the exact figure and asset being sent.
|
|
560
|
+
t('pay_review_title')
|
|
561
|
+
: asset
|
|
562
|
+
? // The coin was chosen on Home; this is the one place the
|
|
563
|
+
// Pay screen says which one it is armed with.
|
|
564
|
+
t('pay_direction_pay_asset', { ticker: asset.ticker })
|
|
565
|
+
: t('pay_direction_pay')
|
|
433
566
|
: t(method ? METHOD_TITLE_KEYS[method] : 'local_pay_request')}
|
|
434
567
|
</Text>
|
|
435
568
|
<View style={styles.headerBtn} />
|