@bsv/expo-wallet-toolbox 0.30.0 → 1.0.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 +8 -0
- package/core/context/WalletContext.tsx +36 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
The first stable release. It adds one fix to 0.30.0: Delete Wallet no longer builds the departing wallet again. No native change: hosts do not rebuild. No API changes, so no host action is necessary.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **No wallet build during `logout()`.** `logout()` resets `configStatus` and `walletBuilt` long before it erases the recovery phrase, its last step. It awaits the push unregistration (a network call) and several storage sweeps in between. In that window, the startup config effect set `configStatus` to `configured` again, and the auto-build effect then built the departing wallet from the phrase that was still in the keychain, on top of the teardown. A new `loggingOutRef` is set at the start of `logout()`. The auto-build effect, `buildWalletFromMnemonic` and `buildWalletFromRecoveredKey` do nothing while it is set. When `logout()` ends, it clears the ref and requests one build. With the phrase gone, that build finds no wallet. After a failed erasure, it opens the wallet that is still there.
|
|
12
|
+
|
|
5
13
|
## 0.30.0
|
|
6
14
|
|
|
7
15
|
The BSV Wallet app's last patch of the toolbox, upstreamed: a backup carries the wallet's look, and the vault chain check shows its progress and can be skipped. No native change: hosts do not rebuild. Every new prop and option is optional, so no host action is necessary.
|
|
@@ -854,6 +854,16 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
854
854
|
* handing anything to React. See core/context/buildGeneration.ts.
|
|
855
855
|
*/
|
|
856
856
|
const buildGenRef = useRef(makeBuildGeneration())
|
|
857
|
+
/**
|
|
858
|
+
* True from the first line of logout() until it returns. Logout resets
|
|
859
|
+
* configStatus and walletBuilt long before it erases the secrets (it awaits
|
|
860
|
+
* the push unregistration, a network call, in between). Without this, the
|
|
861
|
+
* auto-build effect saw "configured, not built" in that window and could
|
|
862
|
+
* build the departing wallet again from the secrets still in the keychain,
|
|
863
|
+
* on top of the teardown (a second database, monitor and key prompt for a
|
|
864
|
+
* wallet being deleted).
|
|
865
|
+
*/
|
|
866
|
+
const loggingOutRef = useRef(false)
|
|
857
867
|
const [settings, setSettings] = useState(DEFAULT_SETTINGS)
|
|
858
868
|
const [txStatusVersion, setTxStatusVersion] = useState(0)
|
|
859
869
|
// The active user's storage id, for scoping `offline_actions` reads (see
|
|
@@ -2921,6 +2931,8 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
2921
2931
|
if (walletBuiltRef.current || walletBuildingRef.current) {
|
|
2922
2932
|
return
|
|
2923
2933
|
}
|
|
2934
|
+
// Never during Delete Wallet: see loggingOutRef.
|
|
2935
|
+
if (loggingOutRef.current) return
|
|
2924
2936
|
const buildToken = buildGenRef.current.current()
|
|
2925
2937
|
|
|
2926
2938
|
// Only build if wallet is properly configured
|
|
@@ -3085,6 +3097,8 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
3085
3097
|
async (wif: string, opts?: WalletBuildOptions) => {
|
|
3086
3098
|
if (walletBuiltRef.current || walletBuildingRef.current) return
|
|
3087
3099
|
if (configStatus !== 'configured') return
|
|
3100
|
+
// Never during Delete Wallet: see loggingOutRef.
|
|
3101
|
+
if (loggingOutRef.current) return
|
|
3088
3102
|
|
|
3089
3103
|
walletBuildingRef.current = true
|
|
3090
3104
|
setWalletBuilding(true)
|
|
@@ -3587,6 +3601,11 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
3587
3601
|
useEffect(() => {
|
|
3588
3602
|
// A profile switch is mid-way: it requests the build itself once ready.
|
|
3589
3603
|
if (profileTransitionRef.current) return
|
|
3604
|
+
// Delete Wallet is mid-way and the secrets may still be there: building now
|
|
3605
|
+
// would bring the departing wallet back. Logout requests a build when it
|
|
3606
|
+
// ends (see loggingOutRef), which finds no wallet, or the one a failed
|
|
3607
|
+
// erasure left.
|
|
3608
|
+
if (loggingOutRef.current) return
|
|
3590
3609
|
if (configStatus !== 'configured' || walletBuilt) return
|
|
3591
3610
|
// Signal that a build attempt is starting. buildWalletFromMnemonic /
|
|
3592
3611
|
// buildWalletFromRecoveredKey will clear this flag on completion or error.
|
|
@@ -4069,6 +4088,22 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
4069
4088
|
// comment warned about — everything above this point already ran
|
|
4070
4089
|
// synchronously before any promise existed to await.
|
|
4071
4090
|
return (async () => {
|
|
4091
|
+
try {
|
|
4092
|
+
// No build may start until this logout has ended. Set here, in the
|
|
4093
|
+
// try, so the finally always clears it; nothing above has yielded, so
|
|
4094
|
+
// no effect can have run in between.
|
|
4095
|
+
loggingOutRef.current = true
|
|
4096
|
+
return await runLogout()
|
|
4097
|
+
} finally {
|
|
4098
|
+
// The auto-build effect was held off for the whole logout, so ask it
|
|
4099
|
+
// once now: with the secrets gone it finds no wallet and settles; if
|
|
4100
|
+
// the erasure failed, it opens the wallet that is still there.
|
|
4101
|
+
loggingOutRef.current = false
|
|
4102
|
+
setAutoBuildRequest(r => r + 1)
|
|
4103
|
+
}
|
|
4104
|
+
})()
|
|
4105
|
+
|
|
4106
|
+
async function runLogout(): Promise<boolean> {
|
|
4072
4107
|
// Push listeners and the registration sync belong to the wallet being
|
|
4073
4108
|
// torn down; nothing may fire them against it from here on.
|
|
4074
4109
|
pushDetachRef.current?.()
|
|
@@ -4241,7 +4276,7 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
4241
4276
|
router.dismissAll()
|
|
4242
4277
|
router.replace('/')
|
|
4243
4278
|
return true
|
|
4244
|
-
}
|
|
4279
|
+
}
|
|
4245
4280
|
}, [deleteAllWalletKeys, storage])
|
|
4246
4281
|
|
|
4247
4282
|
/**
|
package/package.json
CHANGED