@suilend/sui-fe-next 2.0.18 → 2.0.20

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.
@@ -222,17 +222,24 @@ function Inner(_a) {
222
222
  // WalletConnect via @walletconnect/universal-provider
223
223
  // Matches the reference implementation: https://github.com/WalletConnect/react-core-up-sui
224
224
  var _g = useState(), wcSession = _g[0], setWcSession = _g[1];
225
- var sessionAddress = useMemo(function () {
225
+ // Raw address as returned by the wallet (e.g. Fireblocks returns an
226
+ // EVM-length address). We must send this back in WalletConnect request
227
+ // params so the wallet recognises it as its own account.
228
+ var wcRawAddress = useMemo(function () {
226
229
  var _a, _b, _c;
227
230
  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
231
  if (!raw)
229
232
  return undefined;
230
- var addr = raw.split(":").pop();
231
- if (!addr)
233
+ return raw.split(":").pop();
234
+ }, [wcSession]);
235
+ // Normalised Sui address (zero-padded to 32 bytes) for on-chain use:
236
+ // transaction sender, RPC queries, etc.
237
+ var sessionAddress = useMemo(function () {
238
+ if (!wcRawAddress)
232
239
  return undefined;
233
- var normalized = normalizeSuiAddress(addr);
240
+ var normalized = normalizeSuiAddress(wcRawAddress);
234
241
  return isValidSuiAddress(normalized) ? normalized : undefined;
235
- }, [wcSession]);
242
+ }, [wcRawAddress]);
236
243
  useEffect(function () {
237
244
  (function () { return __awaiter(_this, void 0, void 0, function () {
238
245
  var provider;
@@ -387,7 +394,10 @@ function Inner(_a) {
387
394
  provider = _a.sent();
388
395
  return [4 /*yield*/, provider.request({
389
396
  method: WC_SUI_METHODS.SIGN_PERSONAL_MESSAGE,
390
- params: { message: message.toString(), address: sessionAddress },
397
+ params: {
398
+ message: message.toString(),
399
+ address: wcRawAddress !== null && wcRawAddress !== void 0 ? wcRawAddress : sessionAddress,
400
+ },
391
401
  }, "sui:mainnet")];
392
402
  case 2:
393
403
  res = _a.sent();
@@ -397,7 +407,7 @@ function Inner(_a) {
397
407
  }];
398
408
  }
399
409
  });
400
- }); }, [sessionAddress]);
410
+ }); }, [sessionAddress, wcRawAddress]);
401
411
  var connectWalletWrapper = useCallback(function (_wallet) { return __awaiter(_this, void 0, void 0, function () {
402
412
  var provider, modal, _a, provider, _b, err_1;
403
413
  return __generator(this, function (_c) {
@@ -672,7 +682,7 @@ function Inner(_a) {
672
682
  });
673
683
  }); }, [suiClient]);
674
684
  var signExecuteAndWaitForTransaction = useCallback(function (transaction, onSetGasBudget, onSign, onExecute) { return __awaiter(_this, void 0, void 0, function () {
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;
685
+ var _address, provider, txBytes, txBase64, params, topic, signClient, res_1, signAndExecErr_1, signRes, execRes, msafeWallet, msafeFeature, msafeAccount, usedSignOnly, signedTransaction, res1, err_5, message, res, digest, err_6;
676
686
  var _a, _b;
677
687
  return __generator(this, function (_c) {
678
688
  switch (_c.label) {
@@ -706,19 +716,27 @@ function Inner(_a) {
706
716
  txBase64 = toBase64(txBytes);
707
717
  params = {
708
718
  transaction: txBase64,
709
- address: sessionAddress,
719
+ address: wcRawAddress !== null && wcRawAddress !== void 0 ? wcRawAddress : sessionAddress,
710
720
  };
711
- console.log("[WalletContext] WalletConnect — session topic:", (_a = provider.session) === null || _a === void 0 ? void 0 : _a.topic);
721
+ topic = (_a = provider.session) === null || _a === void 0 ? void 0 : _a.topic;
722
+ console.log("[WalletContext] WalletConnect — session topic:", topic);
712
723
  console.log("[WalletContext] WalletConnect — session namespaces:", JSON.stringify((_b = provider.session) === null || _b === void 0 ? void 0 : _b.namespaces));
713
724
  console.log("[WalletContext] WalletConnect — request params:", params);
725
+ if (!topic)
726
+ throw new Error("WalletConnect session not found");
727
+ signClient = provider.client;
714
728
  _c.label = 4;
715
729
  case 4:
716
730
  _c.trys.push([4, 7, , 8]);
717
- console.log("[WalletContext] WalletConnect — trying sui_signAndExecuteTransaction");
718
- return [4 /*yield*/, provider.request({
719
- method: WC_SUI_METHODS.SIGN_AND_EXECUTE_TRANSACTION,
720
- params: params,
721
- }, "sui:mainnet")];
731
+ console.log("[WalletContext] WalletConnect — trying sui_signAndExecuteTransaction via SignClient");
732
+ return [4 /*yield*/, signClient.request({
733
+ topic: topic,
734
+ chainId: "sui:mainnet",
735
+ request: {
736
+ method: WC_SUI_METHODS.SIGN_AND_EXECUTE_TRANSACTION,
737
+ params: params,
738
+ },
739
+ })];
722
740
  case 5:
723
741
  res_1 = _c.sent();
724
742
  console.log("[WalletContext] WalletConnect — sui_signAndExecuteTransaction succeeded, digest:", res_1.digest);
@@ -731,7 +749,14 @@ function Inner(_a) {
731
749
  case 8:
732
750
  // Fallback: sign-only, then dApp-side execute
733
751
  console.log("[WalletContext] WalletConnect — trying sui_signTransaction (sign-only fallback)");
734
- return [4 /*yield*/, provider.request({ method: WC_SUI_METHODS.SIGN_TRANSACTION, params: params }, "sui:mainnet")];
752
+ return [4 /*yield*/, signClient.request({
753
+ topic: topic,
754
+ chainId: "sui:mainnet",
755
+ request: {
756
+ method: WC_SUI_METHODS.SIGN_TRANSACTION,
757
+ params: params,
758
+ },
759
+ })];
735
760
  case 9:
736
761
  signRes = _c.sent();
737
762
  console.log("[WalletContext] WalletConnect — sui_signTransaction succeeded, executing on-chain");
@@ -814,6 +839,7 @@ function Inner(_a) {
814
839
  });
815
840
  }); }, [
816
841
  sessionAddress,
842
+ wcRawAddress,
817
843
  gasBudget,
818
844
  impersonatedAddress,
819
845
  account,
@@ -837,13 +863,7 @@ function Inner(_a) {
837
863
  accounts: accounts,
838
864
  account: account,
839
865
  switchAccount: switchAccountWrapper,
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
- })(),
866
+ address: impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address,
847
867
  dryRunTransaction: dryRunTransaction,
848
868
  signExecuteAndWaitForTransaction: signExecuteAndWaitForTransaction,
849
869
  isUsingLedger: isUsingLedger,
package/package.json CHANGED
@@ -1 +1 @@
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"}}
1
+ {"name":"@suilend/sui-fe-next","version":"2.0.20","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"}}