@suilend/sui-fe-next 2.0.10 → 2.0.12
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.
- package/contexts/WalletContext.jsx +70 -36
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -621,7 +621,7 @@ function Inner(_a) {
|
|
|
621
621
|
});
|
|
622
622
|
}); }, [suiClient]);
|
|
623
623
|
var signExecuteAndWaitForTransaction = useCallback(function (transaction, onSetGasBudget, onSign, onExecute) { return __awaiter(_this, void 0, void 0, function () {
|
|
624
|
-
var _address, txBytes,
|
|
624
|
+
var _address, txBytes, txBase64, params, res_1, signAndExecErr_1, signRes, execRes, usedSignOnly, signedTransaction, res1, err_5, message, res, digest, err_6;
|
|
625
625
|
return __generator(this, function (_a) {
|
|
626
626
|
switch (_a.label) {
|
|
627
627
|
case 0:
|
|
@@ -634,7 +634,7 @@ function Inner(_a) {
|
|
|
634
634
|
}
|
|
635
635
|
_a.label = 1;
|
|
636
636
|
case 1:
|
|
637
|
-
_a.trys.push([1,
|
|
637
|
+
_a.trys.push([1, 20, , 21]);
|
|
638
638
|
// Gas budget
|
|
639
639
|
if (gasBudget !== "")
|
|
640
640
|
transaction.setGasBudget(+new BigNumber(gasBudget)
|
|
@@ -643,65 +643,99 @@ function Inner(_a) {
|
|
|
643
643
|
onSetGasBudget === null || onSetGasBudget === void 0 ? void 0 : onSetGasBudget(transaction);
|
|
644
644
|
// Log
|
|
645
645
|
console.log("[WalletContext] signExecuteAndWaitForTransaction - transaction.getData():", transaction.getData());
|
|
646
|
-
if (!(sessionAddress && universalConnector)) return [3 /*break*/,
|
|
647
|
-
// WalletConnect
|
|
648
|
-
//
|
|
646
|
+
if (!(sessionAddress && universalConnector)) return [3 /*break*/, 11];
|
|
647
|
+
// WalletConnect Sui spec defines two transaction methods:
|
|
648
|
+
// 1. sui_signAndExecuteTransaction — wallet signs + submits, returns { digest }
|
|
649
|
+
// 2. sui_signTransaction — wallet signs only, returns { transactionBytes, signature }
|
|
650
|
+
// Fireblocks and most institutional wallets prefer (1).
|
|
651
|
+
// Ref: https://docs.walletconnect.network/wallet-sdk/chain-support/sui
|
|
652
|
+
// https://github.com/WalletConnect/react-core-up-sui
|
|
649
653
|
transaction.setSender(sessionAddress);
|
|
650
654
|
return [4 /*yield*/, transaction.build({ client: suiClient })];
|
|
651
655
|
case 2:
|
|
652
656
|
txBytes = _a.sent();
|
|
657
|
+
txBase64 = toBase64(txBytes);
|
|
658
|
+
params = {
|
|
659
|
+
transaction: txBase64,
|
|
660
|
+
address: sessionAddress,
|
|
661
|
+
};
|
|
662
|
+
_a.label = 3;
|
|
663
|
+
case 3:
|
|
664
|
+
_a.trys.push([3, 6, , 7]);
|
|
665
|
+
console.log("[WalletContext] WalletConnect — trying sui_signAndExecuteTransaction");
|
|
653
666
|
return [4 /*yield*/, universalConnector.request({
|
|
654
667
|
method: "sui_signAndExecuteTransaction",
|
|
655
|
-
params:
|
|
656
|
-
transaction: toBase64(txBytes),
|
|
657
|
-
address: sessionAddress,
|
|
658
|
-
},
|
|
668
|
+
params: params,
|
|
659
669
|
}, "sui:mainnet")];
|
|
660
|
-
case
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
case 5:
|
|
665
|
-
|
|
670
|
+
case 4:
|
|
671
|
+
res_1 = _a.sent();
|
|
672
|
+
console.log("[WalletContext] WalletConnect — sui_signAndExecuteTransaction succeeded, digest:", res_1.digest);
|
|
673
|
+
return [4 /*yield*/, waitForTransactionWithCheck(res_1.digest)];
|
|
674
|
+
case 5: return [2 /*return*/, _a.sent()];
|
|
675
|
+
case 6:
|
|
676
|
+
signAndExecErr_1 = _a.sent();
|
|
677
|
+
console.warn("[WalletContext] WalletConnect — sui_signAndExecuteTransaction failed:", signAndExecErr_1);
|
|
678
|
+
return [3 /*break*/, 7];
|
|
679
|
+
case 7:
|
|
680
|
+
// Fallback: sign-only, then dApp-side execute
|
|
681
|
+
console.log("[WalletContext] WalletConnect — trying sui_signTransaction (sign-only fallback)");
|
|
682
|
+
return [4 /*yield*/, universalConnector.request({ method: "sui_signTransaction", params: params }, "sui:mainnet")];
|
|
683
|
+
case 8:
|
|
684
|
+
signRes = _a.sent();
|
|
685
|
+
console.log("[WalletContext] WalletConnect — sui_signTransaction succeeded, executing on-chain");
|
|
686
|
+
return [4 /*yield*/, suiClient.executeTransactionBlock({
|
|
687
|
+
transactionBlock: signRes.transactionBytes,
|
|
688
|
+
signature: signRes.signature,
|
|
689
|
+
})];
|
|
690
|
+
case 9:
|
|
691
|
+
execRes = _a.sent();
|
|
692
|
+
return [4 /*yield*/, waitForTransactionWithCheck(execRes.digest)];
|
|
693
|
+
case 10: return [2 /*return*/, _a.sent()];
|
|
694
|
+
case 11:
|
|
695
|
+
usedSignOnly = false;
|
|
696
|
+
_a.label = 12;
|
|
697
|
+
case 12:
|
|
698
|
+
_a.trys.push([12, 16, , 17]);
|
|
666
699
|
return [4 /*yield*/, dAppKit.signTransaction({
|
|
667
700
|
transaction: transaction,
|
|
668
701
|
})];
|
|
669
|
-
case
|
|
702
|
+
case 13:
|
|
670
703
|
signedTransaction = _a.sent();
|
|
704
|
+
usedSignOnly = true;
|
|
671
705
|
onSign === null || onSign === void 0 ? void 0 : onSign(signedTransaction);
|
|
672
706
|
return [4 /*yield*/, suiClient.executeTransactionBlock({
|
|
673
707
|
transactionBlock: signedTransaction.bytes,
|
|
674
708
|
signature: signedTransaction.signature,
|
|
675
709
|
})];
|
|
676
|
-
case
|
|
710
|
+
case 14:
|
|
677
711
|
res1 = _a.sent();
|
|
678
712
|
onExecute === null || onExecute === void 0 ? void 0 : onExecute(res1);
|
|
679
713
|
return [4 /*yield*/, waitForTransactionWithCheck(res1.digest)];
|
|
680
|
-
case
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
message =
|
|
686
|
-
if (!message.includes("does not support
|
|
687
|
-
throw
|
|
714
|
+
case 15: return [2 /*return*/, _a.sent()];
|
|
715
|
+
case 16:
|
|
716
|
+
err_5 = _a.sent();
|
|
717
|
+
if (usedSignOnly)
|
|
718
|
+
throw err_5;
|
|
719
|
+
message = err_5 instanceof Error ? err_5.message : String(err_5);
|
|
720
|
+
if (!message.includes("does not support"))
|
|
721
|
+
throw err_5;
|
|
688
722
|
console.warn("[WalletContext] Wallet does not support sign-only, falling back to signAndExecuteTransaction");
|
|
689
|
-
return [
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
723
|
+
return [3 /*break*/, 17];
|
|
724
|
+
case 17: return [4 /*yield*/, dAppKit.signAndExecuteTransaction({
|
|
725
|
+
transaction: transaction,
|
|
726
|
+
})];
|
|
727
|
+
case 18:
|
|
693
728
|
res = _a.sent();
|
|
694
729
|
digest = res.$kind === "Transaction"
|
|
695
730
|
? res.Transaction.digest
|
|
696
731
|
: res.FailedTransaction.digest;
|
|
697
732
|
return [4 /*yield*/, waitForTransactionWithCheck(digest)];
|
|
698
|
-
case
|
|
699
|
-
case
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
case 14: return [2 /*return*/];
|
|
733
|
+
case 19: return [2 /*return*/, _a.sent()];
|
|
734
|
+
case 20:
|
|
735
|
+
err_6 = _a.sent();
|
|
736
|
+
console.error(err_6);
|
|
737
|
+
throw err_6;
|
|
738
|
+
case 21: return [2 /*return*/];
|
|
705
739
|
}
|
|
706
740
|
});
|
|
707
741
|
}); }, [
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sui-fe-next","version":"2.0.
|
|
1
|
+
{"name":"@suilend/sui-fe-next","version":"2.0.12","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"}}
|