@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
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import React from 'react'
|
|
14
14
|
import { StyleSheet, Text, View } from 'react-native'
|
|
15
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
16
15
|
import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
|
|
17
16
|
import PressableScale from '../ui/PressableScale'
|
|
18
17
|
|
|
@@ -34,14 +33,15 @@ export const ImportFromBackupPrompt: React.FC<{
|
|
|
34
33
|
}> = ({ visible, onImport }) => {
|
|
35
34
|
const { colors } = useTheme()
|
|
36
35
|
const Ionicons = loadIonicons()
|
|
37
|
-
const insets = useSafeAreaInsets()
|
|
38
36
|
|
|
39
37
|
if (!visible) return null
|
|
40
38
|
|
|
41
39
|
return (
|
|
42
|
-
<View style={[styles.wrapper, { paddingBottom:
|
|
40
|
+
<View style={[styles.wrapper, { paddingBottom: CARD_INSET }]} pointerEvents="box-none">
|
|
43
41
|
<View style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.separator }]}>
|
|
44
|
-
<
|
|
42
|
+
<View style={[styles.iconCircle, { backgroundColor: colors.fill }]}>
|
|
43
|
+
<Ionicons name="download-outline" size={22} color={colors.accent} />
|
|
44
|
+
</View>
|
|
45
45
|
<View style={styles.textGroup}>
|
|
46
46
|
<Text style={[styles.title, { color: colors.textPrimary }]}>{t('import_prompt_title')}</Text>
|
|
47
47
|
<Text style={[styles.body, { color: colors.textSecondary }]}>{t('import_prompt_body')}</Text>
|
|
@@ -54,6 +54,19 @@ export const ImportFromBackupPrompt: React.FC<{
|
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The card hugs the bottom of the screen, so its corners have to agree with the
|
|
59
|
+
* screen's own. Concentric rounding means the inner radius is the outer one
|
|
60
|
+
* less the gap between them — anything else and the two curves visibly fight.
|
|
61
|
+
*
|
|
62
|
+
* The display corner is a constant because no RN API reports it. 55pt is the
|
|
63
|
+
* modern iPhone notch-era radius; on a device that differs (an iPad, most
|
|
64
|
+
* Android hardware) the card is merely a little rounder or flatter than its
|
|
65
|
+
* housing, which is a far smaller error than not following it at all.
|
|
66
|
+
*/
|
|
67
|
+
const SCREEN_CORNER = 55
|
|
68
|
+
const CARD_INSET = spacing.lg
|
|
69
|
+
|
|
57
70
|
const styles = StyleSheet.create({
|
|
58
71
|
wrapper: {
|
|
59
72
|
position: 'absolute',
|
|
@@ -62,30 +75,39 @@ const styles = StyleSheet.create({
|
|
|
62
75
|
bottom: 0,
|
|
63
76
|
zIndex: 30,
|
|
64
77
|
alignItems: 'center',
|
|
65
|
-
paddingHorizontal:
|
|
78
|
+
paddingHorizontal: CARD_INSET
|
|
66
79
|
},
|
|
67
80
|
card: {
|
|
68
81
|
width: '100%',
|
|
69
82
|
maxWidth: 380,
|
|
70
|
-
borderRadius:
|
|
83
|
+
borderRadius: SCREEN_CORNER - CARD_INSET,
|
|
71
84
|
borderWidth: StyleSheet.hairlineWidth,
|
|
72
|
-
padding: spacing.
|
|
85
|
+
padding: spacing.xxl,
|
|
73
86
|
alignItems: 'center',
|
|
74
|
-
gap: spacing.
|
|
87
|
+
gap: spacing.md,
|
|
75
88
|
shadowColor: '#000',
|
|
76
89
|
shadowOffset: { width: 0, height: 4 },
|
|
77
90
|
shadowOpacity: 0.15,
|
|
78
91
|
shadowRadius: 12,
|
|
79
92
|
elevation: 6
|
|
80
93
|
},
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
iconCircle: {
|
|
95
|
+
width: 44,
|
|
96
|
+
height: 44,
|
|
97
|
+
borderRadius: 22,
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
justifyContent: 'center',
|
|
100
|
+
marginBottom: spacing.xs
|
|
101
|
+
},
|
|
102
|
+
textGroup: { alignItems: 'center', gap: spacing.xs },
|
|
83
103
|
title: { ...typography.subhead, fontWeight: '600', textAlign: 'center' },
|
|
84
104
|
body: { ...typography.footnote, textAlign: 'center' },
|
|
85
105
|
button: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
// Set apart from the copy it acts on, and given enough height that a pill
|
|
107
|
+
// border reads as a control rather than as a caption in a box.
|
|
108
|
+
marginTop: spacing.sm,
|
|
109
|
+
paddingVertical: spacing.md,
|
|
110
|
+
paddingHorizontal: spacing.xl,
|
|
89
111
|
borderRadius: radii.pill,
|
|
90
112
|
borderWidth: StyleSheet.hairlineWidth
|
|
91
113
|
},
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 34pt chrome-disc profile button, top-left of Home. Wears whatever avatar
|
|
3
|
+
* icon the user picked in Profile — the same `core/userAvatar.ts` choice the
|
|
4
|
+
* profile hero draws, so the two can never disagree.
|
|
5
|
+
*
|
|
6
|
+
* Original note: 34pt chrome-disc profile button, top-left of Home — passed through
|
|
7
|
+
* `WalletHomeScreen`'s existing (previously unused) `topLeft` prop from the
|
|
8
|
+
* host app's `app/index.tsx`, so this needed no package API change. Same disc
|
|
9
|
+
* as the settings button on the right (surfaceRaised + hairline), so the two
|
|
10
|
+
* bookend the header as a matched pair.
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react'
|
|
13
|
+
import { StyleSheet } from 'react-native'
|
|
14
|
+
import { useTheme, useUserAvatarIcon } from '@bsv/expo-wallet-toolbox'
|
|
15
|
+
import { useTranslation } from 'react-i18next'
|
|
16
|
+
import PressableScale from '../ui/PressableScale'
|
|
17
|
+
import { AvatarGlyph } from './UserAvatar'
|
|
18
|
+
|
|
19
|
+
type ExpoRouterModule = typeof import('expo-router')
|
|
20
|
+
let expoRouterMod: ExpoRouterModule | undefined
|
|
21
|
+
function loadExpoRouter(): ExpoRouterModule {
|
|
22
|
+
if (!expoRouterMod) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
24
|
+
expoRouterMod = require('expo-router') as ExpoRouterModule
|
|
25
|
+
}
|
|
26
|
+
return expoRouterMod
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function ProfileButton() {
|
|
30
|
+
const { colors } = useTheme()
|
|
31
|
+
const { t } = useTranslation()
|
|
32
|
+
const { router } = loadExpoRouter()
|
|
33
|
+
const avatar = useUserAvatarIcon()
|
|
34
|
+
return (
|
|
35
|
+
<PressableScale
|
|
36
|
+
onPress={() => router.push('/profile' as never)}
|
|
37
|
+
haptic="tap"
|
|
38
|
+
hitSlop={5}
|
|
39
|
+
style={[styles.disc, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
|
|
40
|
+
accessibilityRole="button"
|
|
41
|
+
accessibilityLabel={t('profile')}
|
|
42
|
+
>
|
|
43
|
+
<AvatarGlyph
|
|
44
|
+
family={avatar?.family ?? 'ionicons'}
|
|
45
|
+
name={avatar?.name ?? 'person-outline'}
|
|
46
|
+
size={17}
|
|
47
|
+
color={colors.textSecondary}
|
|
48
|
+
/>
|
|
49
|
+
</PressableScale>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const styles = StyleSheet.create({
|
|
54
|
+
disc: {
|
|
55
|
+
width: 34,
|
|
56
|
+
height: 34,
|
|
57
|
+
borderRadius: 17,
|
|
58
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center'
|
|
61
|
+
}
|
|
62
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user's own face, wherever "you" is drawn.
|
|
3
|
+
*
|
|
4
|
+
* One component so the home button and the profile hero can never disagree
|
|
5
|
+
* about what the user picked. With no choice stored it falls back to the
|
|
6
|
+
* plain person glyph those surfaces have always shown, so an install that
|
|
7
|
+
* never opens the picker looks exactly as it did.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react'
|
|
10
|
+
import { StyleSheet, View } from 'react-native'
|
|
11
|
+
import { useTheme, useUserAvatarIcon, type AvatarIconFamily } from '@bsv/expo-wallet-toolbox'
|
|
12
|
+
|
|
13
|
+
type VectorIcons = typeof import('@expo/vector-icons')
|
|
14
|
+
let vectorIcons: VectorIcons | undefined
|
|
15
|
+
function loadIcons(): VectorIcons {
|
|
16
|
+
if (!vectorIcons) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
|
+
vectorIcons = require('@expo/vector-icons') as VectorIcons
|
|
19
|
+
}
|
|
20
|
+
return vectorIcons
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Draw one catalogue entry, whichever family it came from. */
|
|
24
|
+
export function AvatarGlyph({
|
|
25
|
+
family,
|
|
26
|
+
name,
|
|
27
|
+
size,
|
|
28
|
+
color
|
|
29
|
+
}: {
|
|
30
|
+
family: AvatarIconFamily
|
|
31
|
+
name: string
|
|
32
|
+
size: number
|
|
33
|
+
color: string
|
|
34
|
+
}) {
|
|
35
|
+
const { Ionicons, MaterialCommunityIcons } = loadIcons()
|
|
36
|
+
const Icon = family === 'ionicons' ? Ionicons : MaterialCommunityIcons
|
|
37
|
+
return <Icon name={name as never} size={size} color={color} />
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function UserAvatar({
|
|
41
|
+
size = 34,
|
|
42
|
+
/** Glyph size; defaults to roughly half the disc, as the 34pt button does. */
|
|
43
|
+
glyphSize,
|
|
44
|
+
color,
|
|
45
|
+
background,
|
|
46
|
+
borderColor,
|
|
47
|
+
style
|
|
48
|
+
}: {
|
|
49
|
+
size?: number
|
|
50
|
+
glyphSize?: number
|
|
51
|
+
color?: string
|
|
52
|
+
background?: string
|
|
53
|
+
borderColor?: string
|
|
54
|
+
style?: object
|
|
55
|
+
}) {
|
|
56
|
+
const { colors } = useTheme()
|
|
57
|
+
const chosen = useUserAvatarIcon()
|
|
58
|
+
const glyph = glyphSize ?? Math.round(size * 0.5)
|
|
59
|
+
return (
|
|
60
|
+
<View
|
|
61
|
+
style={[
|
|
62
|
+
styles.disc,
|
|
63
|
+
{
|
|
64
|
+
width: size,
|
|
65
|
+
height: size,
|
|
66
|
+
borderRadius: size / 2,
|
|
67
|
+
backgroundColor: background ?? colors.surfaceRaised,
|
|
68
|
+
borderColor: borderColor ?? colors.surfaceRaisedBorder
|
|
69
|
+
},
|
|
70
|
+
style
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
<AvatarGlyph
|
|
74
|
+
family={chosen?.family ?? 'ionicons'}
|
|
75
|
+
name={chosen?.name ?? 'person-outline'}
|
|
76
|
+
size={glyph}
|
|
77
|
+
color={color ?? colors.textSecondary}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const styles = StyleSheet.create({
|
|
84
|
+
disc: { alignItems: 'center', justifyContent: 'center', borderWidth: StyleSheet.hairlineWidth, overflow: 'hidden' }
|
|
85
|
+
})
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icons offered as an avatar, grouped the way the picker shows them.
|
|
3
|
+
*
|
|
4
|
+
* Only families this app already ships (see `@expo/vector-icons`): Ionicons
|
|
5
|
+
* for people, nature and objects, MaterialCommunityIcons for the animals,
|
|
6
|
+
* which Ionicons has almost none of. Nothing here adds a dependency.
|
|
7
|
+
*
|
|
8
|
+
* Chosen for being something a person would actually WEAR — creatures and
|
|
9
|
+
* characters, not UI furniture. Every name below was checked against the
|
|
10
|
+
* shipped glyph maps; a name that is not in them renders as a blank square,
|
|
11
|
+
* which is why this list is explicit rather than generated from a prefix.
|
|
12
|
+
*/
|
|
13
|
+
import type { AvatarIconFamily } from '@bsv/expo-wallet-toolbox'
|
|
14
|
+
|
|
15
|
+
export interface AvatarIconOption {
|
|
16
|
+
family: AvatarIconFamily
|
|
17
|
+
name: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AvatarIconGroup {
|
|
21
|
+
/** i18n key for the section heading, with an English fallback. */
|
|
22
|
+
labelKey: string
|
|
23
|
+
labelFallback: string
|
|
24
|
+
icons: AvatarIconOption[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const mc = (name: string): AvatarIconOption => ({ family: 'material-community', name })
|
|
28
|
+
const io = (name: string): AvatarIconOption => ({ family: 'ionicons', name })
|
|
29
|
+
|
|
30
|
+
export const AVATAR_ICON_GROUPS: AvatarIconGroup[] = [
|
|
31
|
+
{
|
|
32
|
+
labelKey: 'avatar_group_animals',
|
|
33
|
+
labelFallback: 'Animals',
|
|
34
|
+
icons: [
|
|
35
|
+
mc('cat'),
|
|
36
|
+
mc('dog'),
|
|
37
|
+
mc('rabbit'),
|
|
38
|
+
mc('owl'),
|
|
39
|
+
mc('panda'),
|
|
40
|
+
mc('koala'),
|
|
41
|
+
mc('penguin'),
|
|
42
|
+
mc('bird'),
|
|
43
|
+
mc('duck'),
|
|
44
|
+
mc('horse'),
|
|
45
|
+
mc('elephant'),
|
|
46
|
+
mc('kangaroo'),
|
|
47
|
+
mc('cow'),
|
|
48
|
+
mc('pig'),
|
|
49
|
+
mc('sheep'),
|
|
50
|
+
mc('turtle'),
|
|
51
|
+
mc('tortoise'),
|
|
52
|
+
mc('snake'),
|
|
53
|
+
mc('dolphin'),
|
|
54
|
+
mc('shark'),
|
|
55
|
+
mc('fish'),
|
|
56
|
+
mc('jellyfish'),
|
|
57
|
+
mc('butterfly'),
|
|
58
|
+
mc('bee'),
|
|
59
|
+
mc('ladybug'),
|
|
60
|
+
mc('snail'),
|
|
61
|
+
mc('spider'),
|
|
62
|
+
mc('bat'),
|
|
63
|
+
mc('unicorn')
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
labelKey: 'avatar_group_characters',
|
|
68
|
+
labelFallback: 'Characters',
|
|
69
|
+
icons: [
|
|
70
|
+
mc('emoticon-happy-outline'),
|
|
71
|
+
mc('emoticon-cool-outline'),
|
|
72
|
+
mc('robot'),
|
|
73
|
+
mc('alien'),
|
|
74
|
+
mc('ghost'),
|
|
75
|
+
mc('account'),
|
|
76
|
+
mc('human'),
|
|
77
|
+
mc('sunglasses'),
|
|
78
|
+
io('happy-outline'),
|
|
79
|
+
io('person-outline'),
|
|
80
|
+
io('people-outline'),
|
|
81
|
+
io('skull-outline')
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
labelKey: 'avatar_group_nature',
|
|
86
|
+
labelFallback: 'Nature',
|
|
87
|
+
icons: [
|
|
88
|
+
io('leaf-outline'),
|
|
89
|
+
io('flower-outline'),
|
|
90
|
+
io('paw-outline'),
|
|
91
|
+
io('planet-outline'),
|
|
92
|
+
io('moon-outline'),
|
|
93
|
+
io('sunny-outline'),
|
|
94
|
+
io('snow-outline'),
|
|
95
|
+
io('flame-outline'),
|
|
96
|
+
io('star-outline'),
|
|
97
|
+
io('heart-outline'),
|
|
98
|
+
io('diamond-outline'),
|
|
99
|
+
io('flash-outline')
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
labelKey: 'avatar_group_things',
|
|
104
|
+
labelFallback: 'Things',
|
|
105
|
+
icons: [
|
|
106
|
+
io('rocket-outline'),
|
|
107
|
+
io('game-controller-outline'),
|
|
108
|
+
io('musical-note-outline'),
|
|
109
|
+
io('headset-outline'),
|
|
110
|
+
io('camera-outline'),
|
|
111
|
+
io('bicycle-outline'),
|
|
112
|
+
io('football-outline'),
|
|
113
|
+
io('basketball-outline'),
|
|
114
|
+
io('pizza-outline'),
|
|
115
|
+
io('ice-cream-outline'),
|
|
116
|
+
io('cafe-outline'),
|
|
117
|
+
io('balloon-outline'),
|
|
118
|
+
io('gift-outline'),
|
|
119
|
+
io('glasses-outline')
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one modal this design spends (ux §6.3).
|
|
3
|
+
*
|
|
4
|
+
* When an issuer withdraws coins, the balance simply drops. On a phone, money
|
|
5
|
+
* disappearing without a sentence is the worst failure in the system — worse
|
|
6
|
+
* than a refusal, which at least names itself — so this is the single place the
|
|
7
|
+
* design chooses interruption over quiet: one alert, once per transaction,
|
|
8
|
+
* naming the actor and the figure.
|
|
9
|
+
*
|
|
10
|
+
* `showAlert` rather than a toast: a toast is the FYI channel and can be missed
|
|
11
|
+
* entirely, while an alert must be acknowledged. No Activity row is fabricated
|
|
12
|
+
* to go with it — there is no transaction of the user's to show.
|
|
13
|
+
*/
|
|
14
|
+
import type { TokenActivityRow } from '../../../core/mandala/runtime'
|
|
15
|
+
import { showAlert } from '../ui/AlertCard'
|
|
16
|
+
import { formatTokenAmount } from '../../tokenFormat'
|
|
17
|
+
|
|
18
|
+
/** The `t` every component in this package already holds. */
|
|
19
|
+
type Translate = ReturnType<typeof import('react-i18next').useTranslation>['t']
|
|
20
|
+
|
|
21
|
+
export interface EvictionNotice {
|
|
22
|
+
txid: string
|
|
23
|
+
ticker: string
|
|
24
|
+
issuer?: string
|
|
25
|
+
/** Base units the holder lost. */
|
|
26
|
+
baseUnits: number
|
|
27
|
+
decimals: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Money that was credited to this wallet and is no longer there.
|
|
32
|
+
*
|
|
33
|
+
* A `reversed` row is exactly that and nothing else: a `refused` SENT payment
|
|
34
|
+
* never left, so the holder's balance is unchanged and there is nothing to
|
|
35
|
+
* announce; a `refused` RECEIVED payment is the settlement spec's row 1
|
|
36
|
+
* (reversed credit) and belongs here too.
|
|
37
|
+
*/
|
|
38
|
+
export function evictionsFrom(rows: readonly TokenActivityRow[] | null, alreadySeen: readonly string[]): EvictionNotice[] {
|
|
39
|
+
if (!rows) return []
|
|
40
|
+
return rows
|
|
41
|
+
.filter(r => r.role === 'received' && (r.status === 'reversed' || r.status === 'refused'))
|
|
42
|
+
.filter(r => !alreadySeen.includes(r.txid))
|
|
43
|
+
.map(r => ({
|
|
44
|
+
txid: r.txid,
|
|
45
|
+
ticker: r.asset.ticker,
|
|
46
|
+
issuer: r.asset.issuerName,
|
|
47
|
+
baseUnits: r.baseUnits,
|
|
48
|
+
decimals: r.asset.decimals
|
|
49
|
+
}))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Raises the alert and resolves once it has been acknowledged. */
|
|
53
|
+
export async function announceEviction(t: Translate, notice: EvictionNotice): Promise<void> {
|
|
54
|
+
const issuer = notice.issuer || t('token_issuer_fallback')
|
|
55
|
+
const amount = formatTokenAmount(notice.baseUnits, notice.decimals)
|
|
56
|
+
await showAlert({
|
|
57
|
+
title: t('token_evicted_title', { ticker: notice.ticker }),
|
|
58
|
+
// Without a figure the sentence would be "some money left" — true, useless,
|
|
59
|
+
// and the reason the alert exists. If the figure cannot be formatted the
|
|
60
|
+
// alert still fires, because the withdrawal happened either way.
|
|
61
|
+
message: amount
|
|
62
|
+
? t('token_evicted_body', { issuer, amount, ticker: notice.ticker })
|
|
63
|
+
: t('token_recv_reversed', { issuer })
|
|
64
|
+
})
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useWallet } from '@bsv/expo-wallet-toolbox'
|
|
3
|
+
import { createContactsStore, type ContactsDb, type ContactsStore } from '../../core/contacts/contactsStore'
|
|
4
|
+
|
|
5
|
+
/** The contacts store for the open wallet, or null before its database is ready. */
|
|
6
|
+
export function useContactsStore(): ContactsStore | null {
|
|
7
|
+
const { storage } = useWallet()
|
|
8
|
+
const db = storage?.sqliteDb
|
|
9
|
+
return useMemo(() => (db ? createContactsStore(db as unknown as ContactsDb) : null), [db])
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export the wallet database through the OS share sheet — the action behind
|
|
3
|
+
* Settings › "Export Wallet Data" and the Vault screen's row of the same name
|
|
4
|
+
* (spec §3.4: the vault screen is where the user is thinking about recovery,
|
|
5
|
+
* and encrypted export preserves the recovery metadata/history mirrored by
|
|
6
|
+
* each output. The salt in v6 custom instructions is rederived through the
|
|
7
|
+
* wallet HMAC and used to rebuild the lock's salted commitments).
|
|
8
|
+
*
|
|
9
|
+
* Lifted from WalletConfigScreen.handleExportData so both screens share one
|
|
10
|
+
* implementation: one export at a time, `exporting` for the spinner, failures
|
|
11
|
+
* logged rather than surfaced (a dismissed share sheet is not an error).
|
|
12
|
+
*/
|
|
13
|
+
import { useCallback, useRef, useState } from 'react'
|
|
14
|
+
import { useWallet } from '@bsv/expo-wallet-toolbox'
|
|
15
|
+
import { exportAllWalletDatabases } from '../exportDatabases'
|
|
16
|
+
|
|
17
|
+
export function useExportWalletData(): { exportData: () => Promise<void>; exporting: boolean } {
|
|
18
|
+
const { storage } = useWallet()
|
|
19
|
+
const [exporting, setExporting] = useState(false)
|
|
20
|
+
// A ref, not the state: two taps in the same tick both see `exporting ===
|
|
21
|
+
// false` in their closure, and the second must still be refused.
|
|
22
|
+
const inFlightRef = useRef(false)
|
|
23
|
+
|
|
24
|
+
const exportData = useCallback(async () => {
|
|
25
|
+
if (inFlightRef.current) return
|
|
26
|
+
inFlightRef.current = true
|
|
27
|
+
setExporting(true)
|
|
28
|
+
try {
|
|
29
|
+
await exportAllWalletDatabases(storage)
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.warn('[exportWalletData] Export failed:', e)
|
|
32
|
+
} finally {
|
|
33
|
+
inFlightRef.current = false
|
|
34
|
+
setExporting(false)
|
|
35
|
+
}
|
|
36
|
+
}, [storage])
|
|
37
|
+
|
|
38
|
+
return { exportData, exporting }
|
|
39
|
+
}
|