@suilend/sui-fe-next 2.0.26 → 2.0.27
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/contexts/WalletContext.jsx +28 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -489,6 +489,7 @@ function Inner(_a) {
|
|
|
489
489
|
}
|
|
490
490
|
});
|
|
491
491
|
}); }, [rpc.url, connectWallet, disconnectWallet]);
|
|
492
|
+
var PREFERRED_ACCOUNT_KEY = "suilend:preferred-account-address";
|
|
492
493
|
var disconnectWalletWrapper = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
493
494
|
var provider, err_2;
|
|
494
495
|
return __generator(this, function (_a) {
|
|
@@ -509,7 +510,12 @@ function Inner(_a) {
|
|
|
509
510
|
_a.sent();
|
|
510
511
|
showInfoToast("Disconnected wallet");
|
|
511
512
|
_a.label = 5;
|
|
512
|
-
case 5:
|
|
513
|
+
case 5:
|
|
514
|
+
try {
|
|
515
|
+
localStorage.removeItem(PREFERRED_ACCOUNT_KEY);
|
|
516
|
+
}
|
|
517
|
+
catch (_b) { }
|
|
518
|
+
return [3 /*break*/, 7];
|
|
513
519
|
case 6:
|
|
514
520
|
err_2 = _a.sent();
|
|
515
521
|
showErrorToast("Failed to disconnect wallet", err_2);
|
|
@@ -548,6 +554,10 @@ function Inner(_a) {
|
|
|
548
554
|
if (!matchingAccount)
|
|
549
555
|
throw new Error("Account not found");
|
|
550
556
|
dAppKit.switchAccount({ account: matchingAccount });
|
|
557
|
+
try {
|
|
558
|
+
localStorage.setItem(PREFERRED_ACCOUNT_KEY, _account.address);
|
|
559
|
+
}
|
|
560
|
+
catch (_d) { }
|
|
551
561
|
showInfoToast("Switched to ".concat(accountLabel), {
|
|
552
562
|
description: (_account === null || _account === void 0 ? void 0 : _account.label)
|
|
553
563
|
? (addressNameServiceName !== null && addressNameServiceName !== void 0 ? addressNameServiceName : formatAddress(_account.address))
|
|
@@ -559,6 +569,23 @@ function Inner(_a) {
|
|
|
559
569
|
console.error(err);
|
|
560
570
|
}
|
|
561
571
|
}, [dAppKit, (_e = walletConnection.wallet) === null || _e === void 0 ? void 0 : _e.accounts]);
|
|
572
|
+
// After autoconnect restores the wallet, check if the user had previously
|
|
573
|
+
// selected a different account and switch to it.
|
|
574
|
+
var hasRestoredPreferredAccount = useRef(false);
|
|
575
|
+
useEffect(function () {
|
|
576
|
+
if (hasRestoredPreferredAccount.current)
|
|
577
|
+
return;
|
|
578
|
+
if (!walletConnection.wallet || !accountRes)
|
|
579
|
+
return;
|
|
580
|
+
var preferred = localStorage.getItem(PREFERRED_ACCOUNT_KEY);
|
|
581
|
+
if (!preferred || preferred === accountRes.address)
|
|
582
|
+
return;
|
|
583
|
+
var match = walletConnection.wallet.accounts.find(function (a) { return a.address === preferred; });
|
|
584
|
+
if (!match)
|
|
585
|
+
return;
|
|
586
|
+
hasRestoredPreferredAccount.current = true;
|
|
587
|
+
dAppKit.switchAccount({ account: match });
|
|
588
|
+
}, [walletConnection.wallet, accountRes, dAppKit]);
|
|
562
589
|
// LaunchDarkly
|
|
563
590
|
var ldClient = useLDClient();
|
|
564
591
|
var ldKeyRef = useRef(undefined);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sui-fe-next","version":"2.0.
|
|
1
|
+
{"name":"@suilend/sui-fe-next","version":"2.0.27","private":false,"description":"A collection of TypeScript frontend components and hooks","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./contexts/WalletContext":"./contexts/WalletContext.jsx","./contexts/SettingsContext":"./contexts/SettingsContext.jsx","./contexts":"./contexts/index.js","./fetchers":"./fetchers/index.js","./fetchers/useFetchBalances":"./fetchers/useFetchBalances.js","./hooks/useRefreshOnBalancesChange":"./hooks/useRefreshOnBalancesChange.js","./hooks/useLedgerHashDialog":"./hooks/useLedgerHashDialog.js","./hooks/useIsAndroid":"./hooks/useIsAndroid.jsx","./hooks/useCoinMetadataMap":"./hooks/useCoinMetadataMap.js","./hooks":"./hooks/index.js","./hooks/useIsTouchscreen":"./hooks/useIsTouchscreen.jsx","./hooks/useIsiOS":"./hooks/useIsiOS.jsx","./hooks/keypair":"./hooks/keypair.js","./lib/track":"./lib/track.js","./lib":"./lib/index.js","./lib/router":"./lib/router.js","./lib/toasts":"./lib/toasts.jsx","./lib/connector":"./lib/connector.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix src/","prettier":"prettier --write src/","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/sui-fe.git"},"bugs":{"url":"https://github.com/suilend/sui-fe/issues"},"dependencies":{"@reown/appkit":"1.8.2","@tanstack/react-query":"^5.60.2","@wallet-standard/app":"^1.1.0","@walletconnect/universal-provider":"2.21.1","bignumber.js":"^9.1.2","launchdarkly-react-client-sdk":"^3.6.0","lodash":"^4.17.21","mixpanel-browser":"^2.72.0","next":"^15.0.3","react":"18.3.1","react-dom":"18.3.1","react-responsive":"^10.0.0","sonner":"1.4.41","swr":"^2.2.5","tailwind-merge":"^2.5.4","usehooks-ts":"^3.1.1"},"devDependencies":{"@tsconfig/next":"^2.0.3","@types/lodash":"^4.17.13","@types/node":"^22.9.0","@types/react":"^18.3.12","@types/react-dom":"^18.3.1","@typescript-eslint/eslint-plugin":"^8.14.0","@typescript-eslint/parser":"^8.14.0","eslint":"^9.14.0","eslint-config-next":"^15.0.3","eslint-config-prettier":"^9.1.0","eslint-plugin-import":"^2.31.0","eslint-plugin-prettier":"^5.2.1","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^5.6.3"},"peerDependencies":{"@mysten/dapp-kit-core":"1.0.3","@mysten/dapp-kit-react":"1.0.1","@mysten/sui":"2.3.1","@mysten/wallet-standard":"0.20.0","@suilend/sui-fe":"^2.0.10"}}
|