@suilend/sui-fe-next 0.1.73 → 0.1.76
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.
|
@@ -54,12 +54,12 @@ export interface WalletContext {
|
|
|
54
54
|
signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
|
|
55
55
|
auction?: boolean;
|
|
56
56
|
}, onSetGasBudget?: (transaction: Transaction) => void, onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
|
|
57
|
+
isUsingLedger: boolean;
|
|
58
|
+
setIsUsingLedger: (isUsingLedger: boolean) => void;
|
|
57
59
|
signPersonalMessage: (message: Uint8Array) => Promise<{
|
|
58
60
|
bytes: string;
|
|
59
61
|
signature: string;
|
|
60
62
|
}>;
|
|
61
|
-
isUsingLedger: boolean;
|
|
62
|
-
setIsUsingLedger: (isUsingLedger: boolean) => void;
|
|
63
63
|
}
|
|
64
64
|
export declare const useWalletContext: () => WalletContext;
|
|
65
65
|
interface WalletContextProviderProps extends PropsWithChildren {
|
|
@@ -69,8 +69,8 @@ import { executeAuction } from "shio-sdk";
|
|
|
69
69
|
import { useLocalStorage } from "usehooks-ts";
|
|
70
70
|
import { API_URL, formatAddress, isInMsafeApp } from "@suilend/sui-fe";
|
|
71
71
|
import { showErrorToast, showInfoToast } from "../lib";
|
|
72
|
-
import { useSettingsContext } from "./SettingsContext";
|
|
73
72
|
import { getUniversalConnector } from "../lib/connector";
|
|
73
|
+
import { useSettingsContext } from "./SettingsContext";
|
|
74
74
|
export var WalletType;
|
|
75
75
|
(function (WalletType) {
|
|
76
76
|
WalletType["EXTENSION"] = "extension";
|
|
@@ -170,11 +170,6 @@ export var WalletContextQueryParams;
|
|
|
170
170
|
WalletContextQueryParams["WALLET"] = "wallet";
|
|
171
171
|
})(WalletContextQueryParams || (WalletContextQueryParams = {}));
|
|
172
172
|
var WalletContext = createContext({
|
|
173
|
-
signPersonalMessage: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
-
return __generator(this, function (_a) {
|
|
175
|
-
throw new Error("WalletContextProvider not initialized");
|
|
176
|
-
});
|
|
177
|
-
}); },
|
|
178
173
|
isImpersonating: false,
|
|
179
174
|
isConnectWalletDropdownOpen: false,
|
|
180
175
|
setIsConnectWalletDropdownOpen: function () {
|
|
@@ -208,6 +203,11 @@ var WalletContext = createContext({
|
|
|
208
203
|
setIsUsingLedger: function () {
|
|
209
204
|
throw new Error("WalletContextProvider not initialized");
|
|
210
205
|
},
|
|
206
|
+
signPersonalMessage: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
throw new Error("WalletContextProvider not initialized");
|
|
209
|
+
});
|
|
210
|
+
}); },
|
|
211
211
|
});
|
|
212
212
|
export var useWalletContext = function () { return useContext(WalletContext); };
|
|
213
213
|
function Inner(_a) {
|
|
@@ -312,9 +312,11 @@ function Inner(_a) {
|
|
|
312
312
|
var wallets__extension_installed_default = useMemo(function () {
|
|
313
313
|
return wallets__extension_default
|
|
314
314
|
.filter(function (w) {
|
|
315
|
-
return w.name ===
|
|
316
|
-
?
|
|
317
|
-
:
|
|
315
|
+
return w.name === WALLET_CONNECT_WALLET.name
|
|
316
|
+
? true
|
|
317
|
+
: w.name === WalletName.MSAFE_WALLET
|
|
318
|
+
? isInMsafeApp()
|
|
319
|
+
: !!getInstalledWallet(w.name);
|
|
318
320
|
})
|
|
319
321
|
.map(function (w) { return (__assign(__assign({}, w), { isInstalled: true, raw: getInstalledWallet(w.name) })); });
|
|
320
322
|
}, [wallets__extension_default, getInstalledWallet]);
|
|
@@ -386,9 +388,6 @@ function Inner(_a) {
|
|
|
386
388
|
}
|
|
387
389
|
});
|
|
388
390
|
}); }, [sessionAddress, universalConnector]);
|
|
389
|
-
var signPersonalMessage = sessionAddress
|
|
390
|
-
? walletConnectSignPersonalMessage
|
|
391
|
-
: function (message) { return signPersonalMessageRaw({ message: message, account: account }); };
|
|
392
391
|
var connectWalletWrapper = useCallback(function (_wallet) {
|
|
393
392
|
try {
|
|
394
393
|
if (_wallet === null || _wallet === void 0 ? void 0 : _wallet.walletConnect) {
|
|
@@ -420,43 +419,63 @@ function Inner(_a) {
|
|
|
420
419
|
}, [connectWallet, disconnectWallet, universalConnector]);
|
|
421
420
|
var disconnectWalletWrapper = useCallback(function () {
|
|
422
421
|
try {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
422
|
+
if (sessionAddress) {
|
|
423
|
+
universalConnector.disconnect();
|
|
424
|
+
setSession(null);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
disconnectWallet(undefined, {
|
|
428
|
+
onSuccess: function () {
|
|
429
|
+
showInfoToast("Disconnected wallet");
|
|
430
|
+
},
|
|
431
|
+
onError: function (err) {
|
|
432
|
+
showErrorToast("Failed to disconnect wallet", err);
|
|
433
|
+
console.error(err);
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}
|
|
432
437
|
}
|
|
433
438
|
catch (err) {
|
|
434
439
|
showErrorToast("Failed to disconnect wallet", err);
|
|
435
440
|
console.error(err);
|
|
436
441
|
}
|
|
437
|
-
}, [disconnectWallet]);
|
|
442
|
+
}, [sessionAddress, universalConnector, disconnectWallet]);
|
|
438
443
|
// Accounts
|
|
439
444
|
var accountsRes = useAccounts();
|
|
440
445
|
var accountRes = (_f = useCurrentAccount()) !== null && _f !== void 0 ? _f : undefined;
|
|
441
446
|
var switchAccount = useSwitchAccount().mutate;
|
|
442
|
-
var account =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
publicKey: new Uint8Array(),
|
|
446
|
-
chains: ["sui:mainnet"],
|
|
447
|
-
features: [],
|
|
448
|
-
}
|
|
449
|
-
: accountRes;
|
|
450
|
-
var accounts = sessionAddress
|
|
451
|
-
? [
|
|
452
|
-
{
|
|
447
|
+
var account = useMemo(function () {
|
|
448
|
+
return sessionAddress
|
|
449
|
+
? {
|
|
453
450
|
address: sessionAddress,
|
|
454
451
|
publicKey: new Uint8Array(),
|
|
455
452
|
chains: ["sui:mainnet"],
|
|
456
453
|
features: [],
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
}
|
|
455
|
+
: accountRes;
|
|
456
|
+
}, [sessionAddress, accountRes]);
|
|
457
|
+
var accounts = useMemo(function () {
|
|
458
|
+
return sessionAddress
|
|
459
|
+
? [
|
|
460
|
+
{
|
|
461
|
+
address: sessionAddress,
|
|
462
|
+
publicKey: new Uint8Array(),
|
|
463
|
+
chains: ["sui:mainnet"],
|
|
464
|
+
features: [],
|
|
465
|
+
},
|
|
466
|
+
]
|
|
467
|
+
: accountsRes;
|
|
468
|
+
}, [sessionAddress, accountsRes]);
|
|
469
|
+
var signPersonalMessage = useMemo(function () {
|
|
470
|
+
return sessionAddress
|
|
471
|
+
? walletConnectSignPersonalMessage
|
|
472
|
+
: function (message) { return signPersonalMessageRaw({ message: message, account: account }); };
|
|
473
|
+
}, [
|
|
474
|
+
sessionAddress,
|
|
475
|
+
walletConnectSignPersonalMessage,
|
|
476
|
+
signPersonalMessageRaw,
|
|
477
|
+
account,
|
|
478
|
+
]);
|
|
460
479
|
var switchAccountWrapper = useCallback(function (_account, addressNameServiceName) {
|
|
461
480
|
var _a, _b, _c;
|
|
462
481
|
var accountLabel = (_b = (_a = _account === null || _account === void 0 ? void 0 : _account.label) !== null && _a !== void 0 ? _a : addressNameServiceName) !== null && _b !== void 0 ? _b : formatAddress(_account.address);
|
|
@@ -728,7 +747,6 @@ function Inner(_a) {
|
|
|
728
747
|
signPersonalMessage: signPersonalMessage,
|
|
729
748
|
};
|
|
730
749
|
}, [
|
|
731
|
-
session,
|
|
732
750
|
impersonatedAddress,
|
|
733
751
|
isConnectWalletDropdownOpen,
|
|
734
752
|
wallets,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sui-fe-next","version":"0.1.
|
|
1
|
+
{"name":"@suilend/sui-fe-next","version":"0.1.76","private":false,"description":"A collection of TypeScript frontend components and hooks","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./contexts/SettingsContext":"./contexts/SettingsContext.jsx","./contexts/WalletContext":"./contexts/WalletContext.jsx","./contexts":"./contexts/index.js","./fetchers":"./fetchers/index.js","./fetchers/useFetchBalances":"./fetchers/useFetchBalances.js","./hooks":"./hooks/index.js","./hooks/keypair":"./hooks/keypair.js","./hooks/useCoinMetadataMap":"./hooks/useCoinMetadataMap.js","./hooks/useIsAndroid":"./hooks/useIsAndroid.jsx","./hooks/useIsTouchscreen":"./hooks/useIsTouchscreen.jsx","./hooks/useIsiOS":"./hooks/useIsiOS.jsx","./hooks/useLedgerHashDialog":"./hooks/useLedgerHashDialog.js","./hooks/useRefreshOnBalancesChange":"./hooks/useRefreshOnBalancesChange.js","./lib/connector":"./lib/connector.js","./lib":"./lib/index.js","./lib/router":"./lib/router.js","./lib/toasts":"./lib/toasts.jsx"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ts-node ./release.ts && 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.10","@reown/appkit-common":"^1.8.10","@reown/appkit-universal-connector":"^1.8.10","@sentry/nextjs":"^8.38.0","@tanstack/react-query":"^5.60.2","bignumber.js":"^9.1.2","launchdarkly-react-client-sdk":"^3.6.0","lodash":"^4.17.21","next":"^15.0.3","react":"18.3.1","react-dom":"18.3.1","react-responsive":"^10.0.0","shio-sdk":"^1.0.8","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":"0.19.4","@mysten/sui":"1.42.0","@mysten/wallet-standard":"0.19.2","@suilend/sui-fe":"^0.3.36"}}
|