@suilend/sui-fe-next 2.0.9 → 2.0.11

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.
@@ -51,9 +51,7 @@ export interface WalletContext {
51
51
  switchAccount: (account: WalletAccount, addressNameServiceName?: string) => void;
52
52
  address?: string;
53
53
  dryRunTransaction: (transaction: Transaction, setGasBudget?: boolean) => Promise<DevInspectResults>;
54
- signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
55
- auction?: boolean;
56
- }, onSetGasBudget?: (transaction: Transaction) => void, onSign?: (signedTransaction: SignedTransaction) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
54
+ signExecuteAndWaitForTransaction: (transaction: Transaction, onSetGasBudget?: (transaction: Transaction) => void, onSign?: (signedTransaction: SignedTransaction) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
57
55
  isUsingLedger: boolean;
58
56
  setIsUsingLedger: (isUsingLedger: boolean) => void;
59
57
  signPersonalMessage: (message: Uint8Array) => Promise<{
@@ -64,7 +64,6 @@ import { Transaction } from "@mysten/sui/transactions";
64
64
  import { SUI_DECIMALS, toBase64 } from "@mysten/sui/utils";
65
65
  import BigNumber from "bignumber.js";
66
66
  import { useLDClient } from "launchdarkly-react-client-sdk";
67
- import { executeAuction } from "shio-sdk";
68
67
  import { useLocalStorage } from "usehooks-ts";
69
68
  import { API_URL, formatAddress, isInMsafeApp } from "@suilend/sui-fe";
70
69
  import { getUniversalConnector } from "../lib/connector";
@@ -598,11 +597,33 @@ function Inner(_a) {
598
597
  });
599
598
  });
600
599
  }, [impersonatedAddress, account === null || account === void 0 ? void 0 : account.address, gasBudget, suiClient]);
601
- var signExecuteAndWaitForTransaction = useCallback(function (transaction, options, onSetGasBudget, onSign, onExecute) { return __awaiter(_this, void 0, void 0, function () {
602
- var _address, signedTransaction, txBytes, res, err_5, res1, res2, err_6;
600
+ var waitForTransactionWithCheck = useCallback(function (digest) { return __awaiter(_this, void 0, void 0, function () {
601
+ var res;
603
602
  var _a, _b;
604
603
  return __generator(this, function (_c) {
605
604
  switch (_c.label) {
605
+ case 0: return [4 /*yield*/, suiClient.waitForTransaction({
606
+ digest: digest,
607
+ options: {
608
+ showBalanceChanges: true,
609
+ showEffects: true,
610
+ showEvents: true,
611
+ showObjectChanges: true,
612
+ },
613
+ })];
614
+ case 1:
615
+ res = _c.sent();
616
+ if (((_a = res.effects) === null || _a === void 0 ? void 0 : _a.status) !== undefined &&
617
+ res.effects.status.status === "failure")
618
+ throw new Error((_b = res.effects.status.error) !== null && _b !== void 0 ? _b : "Transaction failed");
619
+ return [2 /*return*/, res];
620
+ }
621
+ });
622
+ }); }, [suiClient]);
623
+ var signExecuteAndWaitForTransaction = useCallback(function (transaction, onSetGasBudget, onSign, onExecute) { return __awaiter(_this, void 0, void 0, function () {
624
+ var _address, txBytes, res_1, usedSignOnly, signedTransaction, res1, err_5, message, res, digest, err_6;
625
+ return __generator(this, function (_a) {
626
+ switch (_a.label) {
606
627
  case 0:
607
628
  _address = impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address;
608
629
  if (_address) {
@@ -611,9 +632,9 @@ function Inner(_a) {
611
632
  }
612
633
  catch (err) { }
613
634
  }
614
- _c.label = 1;
635
+ _a.label = 1;
615
636
  case 1:
616
- _c.trys.push([1, 13, , 14]);
637
+ _a.trys.push([1, 14, , 15]);
617
638
  // Gas budget
618
639
  if (gasBudget !== "")
619
640
  transaction.setGasBudget(+new BigNumber(gasBudget)
@@ -622,72 +643,69 @@ function Inner(_a) {
622
643
  onSetGasBudget === null || onSetGasBudget === void 0 ? void 0 : onSetGasBudget(transaction);
623
644
  // Log
624
645
  console.log("[WalletContext] signExecuteAndWaitForTransaction - transaction.getData():", transaction.getData());
625
- signedTransaction = void 0;
626
- if (!(sessionAddress && universalConnector)) return [3 /*break*/, 4];
646
+ if (!(sessionAddress && universalConnector)) return [3 /*break*/, 5];
647
+ // WalletConnect: use combined sign+execute so institutional
648
+ // wallets (e.g. Fireblocks) don't drop the channel.
627
649
  transaction.setSender(sessionAddress);
628
650
  return [4 /*yield*/, transaction.build({ client: suiClient })];
629
651
  case 2:
630
- txBytes = _c.sent();
652
+ txBytes = _a.sent();
631
653
  return [4 /*yield*/, universalConnector.request({
632
- method: "sui_signTransaction",
654
+ method: "sui_signAndExecuteTransaction",
633
655
  params: {
634
656
  transaction: toBase64(txBytes),
635
657
  address: sessionAddress,
636
658
  },
637
659
  }, "sui:mainnet")];
638
660
  case 3:
639
- res = _c.sent();
640
- signedTransaction = {
641
- bytes: res.transactionBytes,
642
- signature: res.signature,
643
- };
644
- return [3 /*break*/, 6];
645
- case 4: return [4 /*yield*/, dAppKit.signTransaction({
646
- transaction: transaction,
647
- })];
661
+ res_1 = _a.sent();
662
+ return [4 /*yield*/, waitForTransactionWithCheck(res_1.digest)];
663
+ case 4: return [2 /*return*/, _a.sent()];
648
664
  case 5:
649
- signedTransaction = _c.sent();
650
- _c.label = 6;
665
+ usedSignOnly = false;
666
+ _a.label = 6;
651
667
  case 6:
652
- onSign === null || onSign === void 0 ? void 0 : onSign(signedTransaction);
653
- if (!(options === null || options === void 0 ? void 0 : options.auction)) return [3 /*break*/, 10];
654
- _c.label = 7;
668
+ _a.trys.push([6, 10, , 11]);
669
+ return [4 /*yield*/, dAppKit.signTransaction({
670
+ transaction: transaction,
671
+ })];
655
672
  case 7:
656
- _c.trys.push([7, 9, , 10]);
657
- return [4 /*yield*/, executeAuction(signedTransaction.bytes, signedTransaction.signature)];
673
+ signedTransaction = _a.sent();
674
+ usedSignOnly = true;
675
+ onSign === null || onSign === void 0 ? void 0 : onSign(signedTransaction);
676
+ return [4 /*yield*/, suiClient.executeTransactionBlock({
677
+ transactionBlock: signedTransaction.bytes,
678
+ signature: signedTransaction.signature,
679
+ })];
658
680
  case 8:
659
- _c.sent();
660
- return [3 /*break*/, 10];
661
- case 9:
662
- err_5 = _c.sent();
663
- return [3 /*break*/, 10];
664
- case 10: return [4 /*yield*/, suiClient.executeTransactionBlock({
665
- transactionBlock: signedTransaction.bytes,
666
- signature: signedTransaction.signature,
667
- })];
668
- case 11:
669
- res1 = _c.sent();
681
+ res1 = _a.sent();
670
682
  onExecute === null || onExecute === void 0 ? void 0 : onExecute(res1);
671
- return [4 /*yield*/, suiClient.waitForTransaction({
672
- digest: res1.digest,
673
- options: {
674
- showBalanceChanges: true,
675
- showEffects: true,
676
- showEvents: true,
677
- showObjectChanges: true,
678
- },
679
- })];
683
+ return [4 /*yield*/, waitForTransactionWithCheck(res1.digest)];
684
+ case 9: return [2 /*return*/, _a.sent()];
685
+ case 10:
686
+ err_5 = _a.sent();
687
+ if (usedSignOnly)
688
+ throw err_5;
689
+ message = err_5 instanceof Error ? err_5.message : String(err_5);
690
+ if (!message.includes("does not support"))
691
+ throw err_5;
692
+ console.warn("[WalletContext] Wallet does not support sign-only, falling back to signAndExecuteTransaction");
693
+ return [3 /*break*/, 11];
694
+ case 11: return [4 /*yield*/, dAppKit.signAndExecuteTransaction({
695
+ transaction: transaction,
696
+ })];
680
697
  case 12:
681
- res2 = _c.sent();
682
- if (((_a = res2.effects) === null || _a === void 0 ? void 0 : _a.status) !== undefined &&
683
- res2.effects.status.status === "failure")
684
- throw new Error((_b = res2.effects.status.error) !== null && _b !== void 0 ? _b : "Transaction failed");
685
- return [2 /*return*/, res2];
686
- case 13:
687
- err_6 = _c.sent();
698
+ res = _a.sent();
699
+ digest = res.$kind === "Transaction"
700
+ ? res.Transaction.digest
701
+ : res.FailedTransaction.digest;
702
+ return [4 /*yield*/, waitForTransactionWithCheck(digest)];
703
+ case 13: return [2 /*return*/, _a.sent()];
704
+ case 14:
705
+ err_6 = _a.sent();
688
706
  console.error(err_6);
689
707
  throw err_6;
690
- case 14: return [2 /*return*/];
708
+ case 15: return [2 /*return*/];
691
709
  }
692
710
  });
693
711
  }); }, [
@@ -699,6 +717,7 @@ function Inner(_a) {
699
717
  dryRunTransaction,
700
718
  suiClient,
701
719
  dAppKit,
720
+ waitForTransactionWithCheck,
702
721
  ]);
703
722
  // Using Ledger
704
723
  var _o = useLocalStorage("isUsingLedger-".concat(impersonatedAddress !== null && impersonatedAddress !== void 0 ? impersonatedAddress : account === null || account === void 0 ? void 0 : account.address), false), isUsingLedger = _o[0], setIsUsingLedger = _o[1];
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe-next","version":"2.0.9","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.10","@reown/appkit-common":"^1.8.10","@reown/appkit-universal-connector":"^1.8.19","@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.72.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/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.6"}}
1
+ {"name":"@suilend/sui-fe-next","version":"2.0.11","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.10","@reown/appkit-common":"^1.8.10","@reown/appkit-universal-connector":"^1.8.19","@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.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"}}