@bsv/expo-wallet-toolbox 0.12.0 → 0.13.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 +71 -0
- package/core/backup/erase.ts +7 -1
- package/core/backup/preference.ts +12 -4
- package/core/backup/push.ts +8 -1
- package/core/backup/status.ts +6 -2
- package/core/context/WalletContext.tsx +841 -236
- package/core/i18n/translations.tsx +376 -0
- package/core/identity/handleRegistry/registration.ts +57 -3
- package/core/index.ts +24 -1
- package/core/mandala/createRuntime.ts +3 -3
- package/core/mandala/runtime.ts +7 -2
- package/core/mnemonicWallet.ts +46 -40
- package/core/monitor/MonitorSupervisor.ts +35 -1
- package/core/monitor/TaskCreditInbox.ts +24 -0
- package/core/pay/rails/handle.ts +4 -2
- package/core/peerpay/outbox.ts +11 -1
- package/core/profiles/assertProfileEmpty.ts +287 -0
- package/core/profiles/discovery.ts +84 -0
- package/core/profiles/profileLabel.ts +13 -0
- package/core/profiles/profileStore.ts +265 -0
- package/core/profiles/purgeProfile.ts +76 -0
- package/core/profiles/removeProfile.ts +257 -0
- package/core/push/events.ts +52 -5
- package/core/push/identities.ts +55 -0
- package/core/push/profilePush.ts +143 -0
- package/core/push/registration.ts +362 -24
- package/core/push/types.ts +5 -1
- package/core/services/arcTokenStorage.ts +17 -2
- package/core/services/vault/transfers.ts +6 -1
- package/core/services/vault/vaultStore.ts +16 -3
- package/core/stores/ConnectionStore.ts +11 -7
- package/core/toolboxConfig.ts +7 -3
- package/core/userAvatar.ts +12 -5
- package/core/walletDbRegistry.ts +73 -0
- package/package.json +1 -1
- package/ui/backupShares.ts +2 -3
- package/ui/components/pay/MessageBoxConfig.tsx +6 -5
- package/ui/components/ui/PencilEditField.tsx +5 -2
- package/ui/components/wallet/Balance.tsx +3 -1
- package/ui/components/wallet/ProfileButton.tsx +92 -18
- package/ui/components/wallet/ProfileSwitcherPopover.tsx +247 -0
- package/ui/hooks/useOfflineNoticeActions.ts +2 -1
- package/ui/hooks/useSpendableBalance.ts +3 -1
- package/ui/printRecoveryShares.ts +6 -7
- package/ui/screens/PairScreen.tsx +2 -1
- package/ui/screens/ProfileScreen.tsx +195 -4
- package/ui/screens/SettingsScreen.tsx +8 -4
- package/ui/screens/VaultScreen.tsx +31 -2
- package/ui/screens/VaultTransferScreen.tsx +25 -2
- package/ui/screens/WalletCheckScreen.tsx +2 -1
- package/ui/screens/WalletConfigScreen.tsx +51 -21
- package/ui/screens/WalletHomeScreen.tsx +6 -3
- package/ui/tokenSeen.ts +13 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- **The privileged key is no longer the BIP32 master.** A mnemonic wallet's
|
|
8
|
+
`PrivilegedKeyManager` now gets profile *n*'s own key at `m/1'/n'` (`m/1'/0'`
|
|
9
|
+
for the default profile) instead of the master key `m`, so no two profiles
|
|
10
|
+
share key material. Anything a host derived with `privileged: true` under an
|
|
11
|
+
existing wallet derives differently after upgrading. A recovered-key (WIF)
|
|
12
|
+
wallet is unchanged.
|
|
13
|
+
- `generateMnemonicWallet()` / `recoverMnemonicWallet()` no longer return
|
|
14
|
+
`rootKey`; they return `privilegedKey` (the `m/1'/n'` key) next to
|
|
15
|
+
`primaryKey` and `identityKey`, and `recoverMnemonicWallet` takes an optional
|
|
16
|
+
third argument, `profileIndex` (default 0).
|
|
17
|
+
- `isVaultAvailable(chain, profileIndex)` takes the active profile index; the
|
|
18
|
+
vault exists only on profile 0. Pass `useActiveProfileIndex()` (or
|
|
19
|
+
`useWallet().activeProfile`).
|
|
20
|
+
- Per-profile device state: for profile 1 and above, the AsyncStorage keys for
|
|
21
|
+
the balance cache, avatar, paired connections, ARC and MessageBox overrides,
|
|
22
|
+
auto-approve threshold and ledger, seen-token markers and the remote-backup
|
|
23
|
+
preference gain a `__p<n>` suffix (`profileScopedKey`). Profile 0 keeps the
|
|
24
|
+
existing keys, so a single-profile host sees no change.
|
|
25
|
+
- The push registration marker (`push_registration_v1`) now holds one entry per
|
|
26
|
+
registered identity, so an existing install registers once more after
|
|
27
|
+
upgrading.
|
|
28
|
+
|
|
29
|
+
- **Recovery shares print as one three-page job again (XR-110 reverted).**
|
|
30
|
+
`printRecoveryShares()` had sent each share as its own `Print.printAsync`
|
|
31
|
+
job. Users saw one dialog with one page and did not know two more would
|
|
32
|
+
follow (on Android the three dialogs stacked at once), so they kept only one
|
|
33
|
+
share. Every share is now a page of a single job, so the user gets one
|
|
34
|
+
dialog and, when saving, one PDF. The owner accepts the risk that a
|
|
35
|
+
retained print job holds the full 2-of-3 threshold: these sheets are
|
|
36
|
+
printed on home hardware the user controls. `generatePrintHTML()` keeps its
|
|
37
|
+
optional `only` parameter; the package no longer calls it.
|
|
38
|
+
|
|
39
|
+
### Wallet profiles
|
|
40
|
+
|
|
41
|
+
One mnemonic now backs any number of independent wallet profiles, each with its
|
|
42
|
+
own identity key, balance, history, contacts, handle and network (the primary
|
|
43
|
+
key is `m/0'/n'` and the privileged key `m/1'/n'`). A recovered-key wallet has
|
|
44
|
+
no profiles. Switching profiles is a full wallet teardown and rebuild under a
|
|
45
|
+
full-screen cover.
|
|
46
|
+
|
|
47
|
+
- `useWallet()` gains `profiles`, `activeProfile`, `profilesSupported`,
|
|
48
|
+
`switchProfile(n)`, `addProfile()`, `switchingProfile`, `removingProfile`,
|
|
49
|
+
`checkProfileRemoval()` and `removeProfile()`.
|
|
50
|
+
- New exports: `getActiveProfile`, `getActiveProfileIndex`, `getProfilesState`,
|
|
51
|
+
`liveProfiles`, `profileScopedKey`, `subscribeProfiles`, `useActiveProfileIndex`,
|
|
52
|
+
`useProfiles`, `PROFILES_STORAGE_KEY`, `profileLabel`, `deriveProfileKeys`,
|
|
53
|
+
`hdFromMnemonic`, `profilePaths`, and the types `ProfileRecord`,
|
|
54
|
+
`ProfilesState`, `RemovalBlocker`, `ProfileRemovalCheck`, `RemoveProfileResult`
|
|
55
|
+
and `RemoveRefusal`.
|
|
56
|
+
- A profile can be given a private name (at most 24 characters, kept only on the
|
|
57
|
+
device); `profileLabel(record, t)` is the label to show, the name or
|
|
58
|
+
`profile<N>`. The remote-backup preference is now per profile.
|
|
59
|
+
- A profile can be removed once it is provably empty: no spendable output in any
|
|
60
|
+
basket, no unfinished transaction, queued payment or token settlement, nothing
|
|
61
|
+
waiting to be credited from either MessageBox box, and nothing in its databases
|
|
62
|
+
for any other network. Removing releases the profile's handle, switches to
|
|
63
|
+
profile 0, then tombstones the record (its index is never reused) and purges
|
|
64
|
+
its databases and keys; a purge that did not finish is repeated at every
|
|
65
|
+
startup. Profile 0 can never be removed.
|
|
66
|
+
- Push: every live profile registers the install's FCM token under its own
|
|
67
|
+
identity and at its own MessageBox host, and a tap on a push for another profile
|
|
68
|
+
switches to it. Removing a profile and Delete Wallet withdraw the registration
|
|
69
|
+
(`POST /unregisterDevice`, which needs a server with the multi-identity change;
|
|
70
|
+
an older server answers 404 and is tolerated). A withdrawal that did not get
|
|
71
|
+
through is retried at the next build.
|
|
72
|
+
- Delete Wallet erases every profile, tombstoned ones included.
|
|
73
|
+
|
|
3
74
|
## 0.12.0
|
|
4
75
|
|
|
5
76
|
### Payment push notifications
|
package/core/backup/erase.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface EraseDeps {
|
|
|
36
36
|
/** Supply exactly one of these. */
|
|
37
37
|
baseUrl?: string
|
|
38
38
|
client?: BackupClient
|
|
39
|
+
/**
|
|
40
|
+
* The profile whose backup is erased: only ITS opt-out is written, so erasing one
|
|
41
|
+
* profile's server copy never turns off another profile's backup. Defaults to the
|
|
42
|
+
* active profile.
|
|
43
|
+
*/
|
|
44
|
+
profileIndex?: number
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export interface EraseResult {
|
|
@@ -47,7 +53,7 @@ export async function eraseRemoteBackup (deps: EraseDeps): Promise<EraseResult>
|
|
|
47
53
|
const client = resolveClient(deps)
|
|
48
54
|
|
|
49
55
|
// Step 1 — before anything is deleted. See the module doc.
|
|
50
|
-
await setBackupPushEnabled(false)
|
|
56
|
+
await setBackupPushEnabled(false, deps.profileIndex)
|
|
51
57
|
|
|
52
58
|
// Step 2 — throws on any server refusal, leaving the local cursors intact.
|
|
53
59
|
const { deleted } = await client.deleteAccount()
|
|
@@ -10,24 +10,32 @@
|
|
|
10
10
|
* The opt-out stops pushing only. Restoring on a new device still works: a log already on
|
|
11
11
|
* the server stays readable, and `restoreOnImport` never consults this.
|
|
12
12
|
*
|
|
13
|
+
* Per profile: each profile pushes to its own server account, so the flag goes through
|
|
14
|
+
* `profileScopedKey` (profile 0 keeps the bare key, profile n appends `__p<n>`). Opting one
|
|
15
|
+
* profile out, or erasing its server copy, must never silence another profile's backup.
|
|
16
|
+
* Callers that hold a specific profile's key pass its index; anything else means "what the
|
|
17
|
+
* user is looking at" and takes the active profile.
|
|
18
|
+
*
|
|
13
19
|
* Not stored in wallet settings: those live in the wallet database, which is itself what
|
|
14
20
|
* gets backed up, and the flag has to be readable by a push pass that runs before/without
|
|
15
21
|
* the settings manager.
|
|
16
22
|
*/
|
|
17
23
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
24
|
+
import { profileScopedKey } from '../profiles/profileStore'
|
|
18
25
|
|
|
26
|
+
/** Profile 0's key; other profiles append `__p<n>` (see `profileScopedKey`). */
|
|
19
27
|
export const BACKUP_PUSH_ENABLED_KEY = 'backupPushEnabled'
|
|
20
28
|
|
|
21
29
|
/** True unless the user has explicitly opted out. Never throws. */
|
|
22
|
-
export async function isBackupPushEnabled (): Promise<boolean> {
|
|
30
|
+
export async function isBackupPushEnabled (profileIndex?: number): Promise<boolean> {
|
|
23
31
|
try {
|
|
24
|
-
return (await AsyncStorage.getItem(BACKUP_PUSH_ENABLED_KEY)) !== 'false'
|
|
32
|
+
return (await AsyncStorage.getItem(profileScopedKey(BACKUP_PUSH_ENABLED_KEY, profileIndex))) !== 'false'
|
|
25
33
|
} catch {
|
|
26
34
|
// Fail towards backing up. The alternative silently abandons the user's history.
|
|
27
35
|
return true
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
export async function setBackupPushEnabled (enabled: boolean): Promise<void> {
|
|
32
|
-
await AsyncStorage.setItem(BACKUP_PUSH_ENABLED_KEY, enabled ? 'true' : 'false')
|
|
39
|
+
export async function setBackupPushEnabled (enabled: boolean, profileIndex?: number): Promise<void> {
|
|
40
|
+
await AsyncStorage.setItem(profileScopedKey(BACKUP_PUSH_ENABLED_KEY, profileIndex), enabled ? 'true' : 'false')
|
|
33
41
|
}
|
package/core/backup/push.ts
CHANGED
|
@@ -51,6 +51,13 @@ export interface PushDeps {
|
|
|
51
51
|
baseUrl?: string
|
|
52
52
|
client?: BackupClient
|
|
53
53
|
deviceId?: string
|
|
54
|
+
/**
|
|
55
|
+
* The profile this pass belongs to; its opt-out is the one consulted. Pass the index the
|
|
56
|
+
* wallet was built for, so a pass that outlives a profile switch still reads the
|
|
57
|
+
* departing profile's flag rather than whichever is active by then. Defaults to the
|
|
58
|
+
* active profile.
|
|
59
|
+
*/
|
|
60
|
+
profileIndex?: number
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
export interface PushResult {
|
|
@@ -80,7 +87,7 @@ export async function pushOnce (deps: PushDeps): Promise<PushResult> {
|
|
|
80
87
|
// data leaves this device, and the cheapest way to guarantee that is to do nothing at
|
|
81
88
|
// all. The cursor is left untouched, so opting back in resumes from where the log
|
|
82
89
|
// stopped instead of skipping everything written while it was off.
|
|
83
|
-
if (!(await isBackupPushEnabled())) {
|
|
90
|
+
if (!(await isBackupPushEnabled(deps.profileIndex))) {
|
|
84
91
|
return { pushed: 0, bytes: 0, windowClosed: false, rotated: false, optedOut: true }
|
|
85
92
|
}
|
|
86
93
|
|
package/core/backup/status.ts
CHANGED
|
@@ -26,8 +26,12 @@ export type BackupUploadState = {
|
|
|
26
26
|
uploaded: boolean
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export async function getBackupUploadState(
|
|
30
|
-
|
|
29
|
+
export async function getBackupUploadState(
|
|
30
|
+
chain: BackupChain,
|
|
31
|
+
pseudonym: string,
|
|
32
|
+
profileIndex?: number
|
|
33
|
+
): Promise<BackupUploadState> {
|
|
34
|
+
const enabled = await isBackupPushEnabled(profileIndex)
|
|
31
35
|
let uploaded = false
|
|
32
36
|
try {
|
|
33
37
|
const prefix = cursorKeyPrefix(chain, pseudonym)
|