@suilend/sui-fe-next 2.0.16 → 2.0.18

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.
@@ -61,7 +61,7 @@ import { createDAppKit } from "@mysten/dapp-kit-core";
61
61
  import { DAppKitProvider, useCurrentAccount, useCurrentWallet, useDAppKit, useWalletConnection, useWallets, } from "@mysten/dapp-kit-react";
62
62
  import { SuiJsonRpcClient, } from "@mysten/sui/jsonRpc";
63
63
  import { Transaction } from "@mysten/sui/transactions";
64
- import { SUI_DECIMALS, toBase64 } from "@mysten/sui/utils";
64
+ import { SUI_DECIMALS, isValidSuiAddress, normalizeSuiAddress, toBase64, } from "@mysten/sui/utils";
65
65
  import { getWallets } from "@wallet-standard/app";
66
66
  import BigNumber from "bignumber.js";
67
67
  import { useLDClient } from "launchdarkly-react-client-sdk";
@@ -225,7 +225,13 @@ function Inner(_a) {
225
225
  var sessionAddress = useMemo(function () {
226
226
  var _a, _b, _c;
227
227
  var raw = (_c = (_b = (_a = wcSession === null || wcSession === void 0 ? void 0 : wcSession.namespaces) === null || _a === void 0 ? void 0 : _a.sui) === null || _b === void 0 ? void 0 : _b.accounts) === null || _c === void 0 ? void 0 : _c[0];
228
- return raw ? raw.split(":").pop() : undefined;
228
+ if (!raw)
229
+ return undefined;
230
+ var addr = raw.split(":").pop();
231
+ if (!addr)
232
+ return undefined;
233
+ var normalized = normalizeSuiAddress(addr);
234
+ return isValidSuiAddress(normalized) ? normalized : undefined;
229
235
  }, [wcSession]);
230
236
  useEffect(function () {
231
237
  (function () { return __awaiter(_this, void 0, void 0, function () {
@@ -667,8 +673,9 @@ function Inner(_a) {
667
673
  }); }, [suiClient]);
668
674
  var signExecuteAndWaitForTransaction = useCallback(function (transaction, onSetGasBudget, onSign, onExecute) { return __awaiter(_this, void 0, void 0, function () {
669
675
  var _address, provider, txBytes, txBase64, params, res_1, signAndExecErr_1, signRes, execRes, msafeWallet, msafeFeature, msafeAccount, usedSignOnly, signedTransaction, res1, err_5, message, res, digest, err_6;
670
- return __generator(this, function (_a) {
671
- switch (_a.label) {
676
+ var _a, _b;
677
+ return __generator(this, function (_c) {
678
+ switch (_c.label) {
672
679
  case 0:
673
680
  _address = impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address;
674
681
  if (_address) {
@@ -677,9 +684,9 @@ function Inner(_a) {
677
684
  }
678
685
  catch (err) { }
679
686
  }
680
- _a.label = 1;
687
+ _c.label = 1;
681
688
  case 1:
682
- _a.trys.push([1, 24, , 25]);
689
+ _c.trys.push([1, 24, , 25]);
683
690
  // Gas budget
684
691
  if (gasBudget !== "")
685
692
  transaction.setGasBudget(+new BigNumber(gasBudget)
@@ -691,31 +698,34 @@ function Inner(_a) {
691
698
  if (!sessionAddress) return [3 /*break*/, 12];
692
699
  return [4 /*yield*/, getWalletConnectProvider()];
693
700
  case 2:
694
- provider = _a.sent();
701
+ provider = _c.sent();
695
702
  transaction.setSender(sessionAddress);
696
703
  return [4 /*yield*/, transaction.build({ client: suiClient })];
697
704
  case 3:
698
- txBytes = _a.sent();
705
+ txBytes = _c.sent();
699
706
  txBase64 = toBase64(txBytes);
700
707
  params = {
701
708
  transaction: txBase64,
702
709
  address: sessionAddress,
703
710
  };
704
- _a.label = 4;
711
+ console.log("[WalletContext] WalletConnect — session topic:", (_a = provider.session) === null || _a === void 0 ? void 0 : _a.topic);
712
+ console.log("[WalletContext] WalletConnect — session namespaces:", JSON.stringify((_b = provider.session) === null || _b === void 0 ? void 0 : _b.namespaces));
713
+ console.log("[WalletContext] WalletConnect — request params:", params);
714
+ _c.label = 4;
705
715
  case 4:
706
- _a.trys.push([4, 7, , 8]);
716
+ _c.trys.push([4, 7, , 8]);
707
717
  console.log("[WalletContext] WalletConnect — trying sui_signAndExecuteTransaction");
708
718
  return [4 /*yield*/, provider.request({
709
719
  method: WC_SUI_METHODS.SIGN_AND_EXECUTE_TRANSACTION,
710
720
  params: params,
711
721
  }, "sui:mainnet")];
712
722
  case 5:
713
- res_1 = _a.sent();
723
+ res_1 = _c.sent();
714
724
  console.log("[WalletContext] WalletConnect — sui_signAndExecuteTransaction succeeded, digest:", res_1.digest);
715
725
  return [4 /*yield*/, waitForTransactionWithCheck(res_1.digest)];
716
- case 6: return [2 /*return*/, _a.sent()];
726
+ case 6: return [2 /*return*/, _c.sent()];
717
727
  case 7:
718
- signAndExecErr_1 = _a.sent();
728
+ signAndExecErr_1 = _c.sent();
719
729
  console.warn("[WalletContext] WalletConnect — sui_signAndExecuteTransaction failed:", signAndExecErr_1);
720
730
  return [3 /*break*/, 8];
721
731
  case 8:
@@ -723,16 +733,16 @@ function Inner(_a) {
723
733
  console.log("[WalletContext] WalletConnect — trying sui_signTransaction (sign-only fallback)");
724
734
  return [4 /*yield*/, provider.request({ method: WC_SUI_METHODS.SIGN_TRANSACTION, params: params }, "sui:mainnet")];
725
735
  case 9:
726
- signRes = _a.sent();
736
+ signRes = _c.sent();
727
737
  console.log("[WalletContext] WalletConnect — sui_signTransaction succeeded, executing on-chain");
728
738
  return [4 /*yield*/, suiClient.executeTransactionBlock({
729
739
  transactionBlock: signRes.transactionBytes,
730
740
  signature: signRes.signature,
731
741
  })];
732
742
  case 10:
733
- execRes = _a.sent();
743
+ execRes = _c.sent();
734
744
  return [4 /*yield*/, waitForTransactionWithCheck(execRes.digest)];
735
- case 11: return [2 /*return*/, _a.sent()];
745
+ case 11: return [2 /*return*/, _c.sent()];
736
746
  case 12:
737
747
  if (!isInMsafeApp()) return [3 /*break*/, 15];
738
748
  msafeWallet = getWallets()
@@ -749,7 +759,7 @@ function Inner(_a) {
749
759
  chain: "sui:mainnet",
750
760
  })];
751
761
  case 13:
752
- _a.sent();
762
+ _c.sent();
753
763
  // MSafe proposes the transaction to the multisig queue;
754
764
  // the promise never resolves (only rejects on cancel).
755
765
  // If we reach here the proposal was accepted.
@@ -757,14 +767,14 @@ function Inner(_a) {
757
767
  case 14: throw new Error("MSafe wallet not found. Please reload the page inside MSafe.");
758
768
  case 15:
759
769
  usedSignOnly = false;
760
- _a.label = 16;
770
+ _c.label = 16;
761
771
  case 16:
762
- _a.trys.push([16, 20, , 21]);
772
+ _c.trys.push([16, 20, , 21]);
763
773
  return [4 /*yield*/, dAppKit.signTransaction({
764
774
  transaction: transaction,
765
775
  })];
766
776
  case 17:
767
- signedTransaction = _a.sent();
777
+ signedTransaction = _c.sent();
768
778
  usedSignOnly = true;
769
779
  onSign === null || onSign === void 0 ? void 0 : onSign(signedTransaction);
770
780
  return [4 /*yield*/, suiClient.executeTransactionBlock({
@@ -772,12 +782,12 @@ function Inner(_a) {
772
782
  signature: signedTransaction.signature,
773
783
  })];
774
784
  case 18:
775
- res1 = _a.sent();
785
+ res1 = _c.sent();
776
786
  onExecute === null || onExecute === void 0 ? void 0 : onExecute(res1);
777
787
  return [4 /*yield*/, waitForTransactionWithCheck(res1.digest)];
778
- case 19: return [2 /*return*/, _a.sent()];
788
+ case 19: return [2 /*return*/, _c.sent()];
779
789
  case 20:
780
- err_5 = _a.sent();
790
+ err_5 = _c.sent();
781
791
  if (usedSignOnly)
782
792
  throw err_5;
783
793
  message = err_5 instanceof Error ? err_5.message : String(err_5);
@@ -789,14 +799,14 @@ function Inner(_a) {
789
799
  transaction: transaction,
790
800
  })];
791
801
  case 22:
792
- res = _a.sent();
802
+ res = _c.sent();
793
803
  digest = res.$kind === "Transaction"
794
804
  ? res.Transaction.digest
795
805
  : res.FailedTransaction.digest;
796
806
  return [4 /*yield*/, waitForTransactionWithCheck(digest)];
797
- case 23: return [2 /*return*/, _a.sent()];
807
+ case 23: return [2 /*return*/, _c.sent()];
798
808
  case 24:
799
- err_6 = _a.sent();
809
+ err_6 = _c.sent();
800
810
  console.error(err_6);
801
811
  throw err_6;
802
812
  case 25: return [2 /*return*/];
@@ -827,7 +837,13 @@ function Inner(_a) {
827
837
  accounts: accounts,
828
838
  account: account,
829
839
  switchAccount: switchAccountWrapper,
830
- address: impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address,
840
+ address: (function () {
841
+ var raw = impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address;
842
+ if (!raw)
843
+ return undefined;
844
+ var normalized = normalizeSuiAddress(raw);
845
+ return isValidSuiAddress(normalized) ? normalized : undefined;
846
+ })(),
831
847
  dryRunTransaction: dryRunTransaction,
832
848
  signExecuteAndWaitForTransaction: signExecuteAndWaitForTransaction,
833
849
  isUsingLedger: isUsingLedger,
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe-next","version":"2.0.16","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"}}
1
+ {"name":"@suilend/sui-fe-next","version":"2.0.18","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"}}