@suilend/sui-fe-next 0.1.64 → 0.1.66

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.
@@ -2,17 +2,13 @@ import { Dispatch, PropsWithChildren, SetStateAction } from "react";
2
2
  import { DevInspectResults, SuiTransactionBlockResponse } from "@mysten/sui/client";
3
3
  import { SignatureWithBytes } from "@mysten/sui/cryptography";
4
4
  import { Transaction } from "@mysten/sui/transactions";
5
- import { IdentifierArray, WalletIcon, WalletWithRequiredFeatures } from "@mysten/wallet-standard";
5
+ import { ReadonlyUint8Array, WalletIcon, WalletAccount as WalletStandardWalletAccount, WalletWithRequiredFeatures } from "@mysten/wallet-standard";
6
6
  export declare enum WalletType {
7
7
  EXTENSION = "extension",
8
8
  WEB = "web"
9
9
  }
10
- export type WalletAccount = {
11
- address: string;
12
- label?: string;
13
- icon?: WalletIcon;
14
- chains: IdentifierArray;
15
- features: IdentifierArray;
10
+ export type WalletAccount = Omit<WalletStandardWalletAccount, 'publicKey'> & {
11
+ publicKey?: ReadonlyUint8Array;
16
12
  };
17
13
  type WalletPlatform = "iOS" | "android" | "extension";
18
14
  export type Wallet = {
@@ -56,6 +52,10 @@ export interface WalletContext {
56
52
  signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
57
53
  auction?: boolean;
58
54
  }, onSetGasBudget?: (transaction: Transaction) => void, onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
55
+ signPersonalMessage: (message: Uint8Array) => Promise<{
56
+ bytes: string;
57
+ signature: string;
58
+ }>;
59
59
  isUsingLedger: boolean;
60
60
  setIsUsingLedger: (isUsingLedger: boolean) => void;
61
61
  }
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  var _a, _b;
58
58
  import { useRouter } from "next/router";
59
59
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
60
- import { WalletProvider as MystenWalletProvider, SuiClientProvider, createNetworkConfig, } from "@mysten/dapp-kit";
60
+ import { WalletProvider as MystenWalletProvider, SuiClientProvider, createNetworkConfig, useSignPersonalMessage, } from "@mysten/dapp-kit";
61
61
  import { useAccounts, useConnectWallet, useCurrentAccount, useCurrentWallet, useDisconnectWallet, useSignTransaction, useSwitchAccount, useWallets, } from "@mysten/dapp-kit";
62
62
  import { Transaction } from "@mysten/sui/transactions";
63
63
  import { SUI_DECIMALS, toBase64 } from "@mysten/sui/utils";
@@ -163,6 +163,11 @@ export var WalletContextQueryParams;
163
163
  WalletContextQueryParams["WALLET"] = "wallet";
164
164
  })(WalletContextQueryParams || (WalletContextQueryParams = {}));
165
165
  var WalletContext = createContext({
166
+ signPersonalMessage: function () { return __awaiter(void 0, void 0, void 0, function () {
167
+ return __generator(this, function (_a) {
168
+ throw new Error("WalletContextProvider not initialized");
169
+ });
170
+ }); },
166
171
  isImpersonating: false,
167
172
  isConnectWalletDropdownOpen: false,
168
173
  setIsConnectWalletDropdownOpen: function () {
@@ -345,6 +350,28 @@ function Inner(_a) {
345
350
  }, [rawWallet, wallets]);
346
351
  var connectWallet = useConnectWallet().mutate;
347
352
  var disconnectWallet = useDisconnectWallet().mutate;
353
+ var signPersonalMessageRaw = useSignPersonalMessage().mutateAsync;
354
+ var walletConnectSignPersonalMessage = useCallback(function (message) { return __awaiter(_this, void 0, void 0, function () {
355
+ var res;
356
+ return __generator(this, function (_a) {
357
+ switch (_a.label) {
358
+ case 0:
359
+ if (!sessionAddress || !universalConnector)
360
+ throw new Error("Wallet not connected");
361
+ return [4 /*yield*/, universalConnector.request({
362
+ method: "sui_signPersonalMessage",
363
+ params: { message: message.toString() },
364
+ }, "sui:mainnet")];
365
+ case 1:
366
+ res = _a.sent();
367
+ return [2 /*return*/, {
368
+ signature: res.signature,
369
+ bytes: res.transactionBytes,
370
+ }];
371
+ }
372
+ });
373
+ }); }, [sessionAddress, universalConnector]);
374
+ var signPersonalMessage = sessionAddress ? walletConnectSignPersonalMessage : function (message) { return signPersonalMessageRaw({ message: message, account: account }); };
348
375
  var connectWalletWrapper = useCallback(function (_wallet) {
349
376
  try {
350
377
  if (!_wallet.raw)
@@ -663,6 +690,7 @@ function Inner(_a) {
663
690
  signExecuteAndWaitForTransaction: signExecuteAndWaitForTransaction,
664
691
  isUsingLedger: isUsingLedger,
665
692
  setIsUsingLedger: setIsUsingLedger,
693
+ signPersonalMessage: signPersonalMessage
666
694
  });
667
695
  }, [
668
696
  session,
@@ -679,6 +707,7 @@ function Inner(_a) {
679
707
  signExecuteAndWaitForTransaction,
680
708
  isUsingLedger,
681
709
  setIsUsingLedger,
710
+ signPersonalMessage
682
711
  ]);
683
712
  return (<WalletContext.Provider value={contextValue}>
684
713
  {children}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe-next","version":"0.1.64","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":{"@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.16.0","@mysten/sui":"1.28.2","@mysten/wallet-standard":"0.14.7","@suilend/sui-fe":"^0.3.31"}}
1
+ {"name":"@suilend/sui-fe-next","version":"0.1.66","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":{"@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.16.0","@mysten/sui":"1.28.2","@mysten/wallet-standard":"0.14.7","@suilend/sui-fe":"^0.3.31"}}