@suilend/sui-fe-next 0.1.54 → 0.1.56

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.
@@ -9,8 +9,6 @@ interface SettingsContext {
9
9
  setExplorerId: (id: ExplorerId) => void;
10
10
  gasBudget: string;
11
11
  setGasBudget: (value: string) => void;
12
- isUsingLedger: boolean;
13
- setIsUsingLedger: (value: boolean) => void;
14
12
  suiClient: SuiClient;
15
13
  }
16
14
  declare const SettingsContext: import("react").Context<SettingsContext>;
@@ -29,10 +29,6 @@ var defaultContextValue = {
29
29
  setGasBudget: function () {
30
30
  throw Error("SettingsContextProvider not initialized");
31
31
  },
32
- isUsingLedger: false,
33
- setIsUsingLedger: function () {
34
- throw Error("SettingsContextProvider not initialized");
35
- },
36
32
  suiClient: new SuiClient({ url: getFullnodeUrl("mainnet") }),
37
33
  };
38
34
  var SettingsContext = createContext(defaultContextValue);
@@ -55,8 +51,6 @@ export function SettingsContextProvider(_a) {
55
51
  }, [explorerId]);
56
52
  // Gas budget
57
53
  var _e = useLocalStorage("gasBudget", defaultContextValue.gasBudget), gasBudget = _e[0], setGasBudget = _e[1];
58
- // Using Ledger
59
- var _f = useLocalStorage("isUsingLedger", false), isUsingLedger = _f[0], setIsUsingLedger = _f[1];
60
54
  // Sui client
61
55
  var suiClient = useMemo(function () { return new SuiClient({ url: rpc.url }); }, [rpc.url]);
62
56
  // Context
@@ -68,8 +62,6 @@ export function SettingsContextProvider(_a) {
68
62
  setExplorerId: setExplorerId,
69
63
  gasBudget: gasBudget,
70
64
  setGasBudget: setGasBudget,
71
- isUsingLedger: isUsingLedger,
72
- setIsUsingLedger: setIsUsingLedger,
73
65
  suiClient: suiClient,
74
66
  }); }, [
75
67
  rpc,
@@ -79,8 +71,6 @@ export function SettingsContextProvider(_a) {
79
71
  setExplorerId,
80
72
  gasBudget,
81
73
  setGasBudget,
82
- isUsingLedger,
83
- setIsUsingLedger,
84
74
  suiClient,
85
75
  ]);
86
76
  return (<SettingsContext.Provider value={contextValue}>
@@ -47,6 +47,8 @@ export interface WalletContext {
47
47
  signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
48
48
  auction?: boolean;
49
49
  }, onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
50
+ isUsingLedger: boolean;
51
+ setIsUsingLedger: (isUsingLedger: boolean) => void;
50
52
  }
51
53
  export declare const useWalletContext: () => WalletContext;
52
54
  interface WalletContextProviderProps extends PropsWithChildren {
@@ -65,6 +65,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
65
65
  import BigNumber from "bignumber.js";
66
66
  import { useLDClient } from "launchdarkly-react-client-sdk";
67
67
  import { executeAuction } from "shio-sdk";
68
+ import { useLocalStorage } from "usehooks-ts";
68
69
  import { API_URL, formatAddress, isInMsafeApp } from "@suilend/sui-fe";
69
70
  import { showErrorToast, showInfoToast } from "../lib";
70
71
  import { useSettingsContext } from "./SettingsContext";
@@ -189,6 +190,10 @@ var WalletContext = createContext({
189
190
  throw new Error("WalletContextProvider not initialized");
190
191
  });
191
192
  }); },
193
+ isUsingLedger: false,
194
+ setIsUsingLedger: function () {
195
+ throw new Error("WalletContextProvider not initialized");
196
+ },
192
197
  });
193
198
  export var useWalletContext = function () { return useContext(WalletContext); };
194
199
  function Inner(_a) {
@@ -573,6 +578,8 @@ function Inner(_a) {
573
578
  suiClient,
574
579
  signTransaction,
575
580
  ]);
581
+ // Using Ledger
582
+ var _e = useLocalStorage("isUsingLedger-".concat(impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address), false), isUsingLedger = _e[0], setIsUsingLedger = _e[1];
576
583
  // Context
577
584
  var contextValue = useMemo(function () { return ({
578
585
  isImpersonating: !!impersonatedAddress,
@@ -588,6 +595,8 @@ function Inner(_a) {
588
595
  address: impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address,
589
596
  dryRunTransaction: dryRunTransaction,
590
597
  signExecuteAndWaitForTransaction: signExecuteAndWaitForTransaction,
598
+ isUsingLedger: isUsingLedger,
599
+ setIsUsingLedger: setIsUsingLedger,
591
600
  }); }, [
592
601
  impersonatedAddress,
593
602
  isConnectWalletDropdownOpen,
@@ -600,6 +609,8 @@ function Inner(_a) {
600
609
  switchAccountWrapper,
601
610
  dryRunTransaction,
602
611
  signExecuteAndWaitForTransaction,
612
+ isUsingLedger,
613
+ setIsUsingLedger,
603
614
  ]);
604
615
  return (<WalletContext.Provider value={contextValue}>
605
616
  {children}
@@ -2,7 +2,6 @@ import { Transaction } from "@mysten/sui/transactions";
2
2
  declare const useLedgerHashDialog: () => {
3
3
  ledgerHash: string | undefined;
4
4
  isLedgerHashDialogOpen: boolean;
5
- doNotShowLedgerHashDialogAgain: () => void;
6
5
  openLedgerHashDialog: (transaction: Transaction) => Promise<void>;
7
6
  closeLedgerHashDialog: () => void;
8
7
  };
@@ -35,15 +35,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import { useCallback, useState } from "react";
38
- import { useLocalStorage } from "usehooks-ts";
39
38
  import { getLedgerHash } from "@suilend/sui-fe";
40
39
  import { useSettingsContext, useWalletContext } from "../contexts";
41
40
  var useLedgerHashDialog = function () {
42
41
  var suiClient = useSettingsContext().suiClient;
43
- var address = useWalletContext().address;
44
- var _a = useState(undefined), ledgerHash = _a[0], setLedgerHash = _a[1];
45
- var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
46
- var _c = useLocalStorage("useLedgerHashDialog_doNotShowAgain", false), doNotShowAgain = _c[0], setDoNotShowAgain = _c[1];
42
+ var _a = useWalletContext(), address = _a.address, isUsingLedger = _a.isUsingLedger;
43
+ var _b = useState(undefined), ledgerHash = _b[0], setLedgerHash = _b[1];
44
+ var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
47
45
  var open = useCallback(function (transaction) { return __awaiter(void 0, void 0, void 0, function () {
48
46
  var transactionLedgerHash;
49
47
  return __generator(this, function (_a) {
@@ -51,7 +49,7 @@ var useLedgerHashDialog = function () {
51
49
  case 0:
52
50
  if (!address)
53
51
  return [2 /*return*/];
54
- if (doNotShowAgain)
52
+ if (!isUsingLedger)
55
53
  return [2 /*return*/];
56
54
  return [4 /*yield*/, getLedgerHash(address, transaction, suiClient)];
57
55
  case 1:
@@ -61,14 +59,13 @@ var useLedgerHashDialog = function () {
61
59
  return [2 /*return*/];
62
60
  }
63
61
  });
64
- }); }, [address, doNotShowAgain, suiClient]);
62
+ }); }, [address, isUsingLedger, suiClient]);
65
63
  var close = useCallback(function () {
66
64
  setIsOpen(false);
67
65
  }, []);
68
66
  return {
69
67
  ledgerHash: ledgerHash,
70
68
  isLedgerHashDialogOpen: isOpen,
71
- doNotShowLedgerHashDialogAgain: function () { return setDoNotShowAgain(true); },
72
69
  openLedgerHashDialog: open,
73
70
  closeLedgerHashDialog: close,
74
71
  };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe-next","version":"0.1.54","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":"./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":{"@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","mixpanel-browser":"^2.56.0","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/mixpanel-browser":"^2.50.2","@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.16.0","@mysten/sui":"1.28.2","@mysten/wallet-standard":"0.14.7","@suilend/sui-fe":"^0.3.9"}}
1
+ {"name":"@suilend/sui-fe-next","version":"0.1.56","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":"./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":{"@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","mixpanel-browser":"^2.56.0","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/mixpanel-browser":"^2.50.2","@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.16.0","@mysten/sui":"1.28.2","@mysten/wallet-standard":"0.14.7","@suilend/sui-fe":"^0.3.9"}}