@kimafinance/kima-transaction-widget 1.5.19 → 1.5.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.
- package/dist/index.cjs +686 -489
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -4
- package/dist/index.js +619 -422
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3042,6 +3042,9 @@ var isAddressCompatible = (address, shortName) => {
|
|
|
3042
3042
|
return false;
|
|
3043
3043
|
};
|
|
3044
3044
|
|
|
3045
|
+
// src/shared/lib/fees.ts
|
|
3046
|
+
var getFeeSideValues = (feeDeduct, transactionValues) => feeDeduct ? transactionValues.feeFromTarget : transactionValues.feeFromOrigin;
|
|
3047
|
+
|
|
3045
3048
|
// src/features/allowances/evm/useApproveErc20.ts
|
|
3046
3049
|
var import_viem2 = require("viem");
|
|
3047
3050
|
|
|
@@ -3068,7 +3071,7 @@ var useApproveErc20 = () => {
|
|
|
3068
3071
|
const tokenOptions = (0, import_react_redux.useSelector)(selectTokenOptions);
|
|
3069
3072
|
const { transactionValues } = (0, import_react_redux.useSelector)(selectServiceFee);
|
|
3070
3073
|
const feeDeduct = (0, import_react_redux.useSelector)(selectFeeDeduct);
|
|
3071
|
-
const txValues = feeDeduct
|
|
3074
|
+
const txValues = getFeeSideValues(feeDeduct, transactionValues);
|
|
3072
3075
|
const allowanceNeeded = BigInt(txValues.allowanceAmount.value);
|
|
3073
3076
|
const { pools } = useGetPools_default(
|
|
3074
3077
|
(0, import_react_redux.useSelector)(selectBackendUrl),
|
|
@@ -3237,7 +3240,7 @@ var useEvmSignMessage = () => {
|
|
|
3237
3240
|
const { address: appkitAddress } = (0, import_react7.useAppKitAccount)() || {};
|
|
3238
3241
|
const { walletProvider: appkitProvider } = (0, import_react7.useAppKitProvider)("eip155");
|
|
3239
3242
|
const userAddress = useEvmAddress(mode);
|
|
3240
|
-
const { message } = feeDeduct
|
|
3243
|
+
const { message } = getFeeSideValues(feeDeduct, transactionValues);
|
|
3241
3244
|
const signMessage = (0, import_react6.useCallback)(async () => {
|
|
3242
3245
|
try {
|
|
3243
3246
|
const eip1193 = appkitProvider?.provider ?? globalThis.ethereum;
|
|
@@ -3275,7 +3278,7 @@ var useAllowance = () => {
|
|
|
3275
3278
|
const { signMessage } = useEvmSignMessage();
|
|
3276
3279
|
const { transactionValues } = (0, import_react_redux4.useSelector)(selectServiceFee);
|
|
3277
3280
|
const feeDeduct = (0, import_react_redux4.useSelector)(selectFeeDeduct);
|
|
3278
|
-
const txValues = feeDeduct
|
|
3281
|
+
const txValues = getFeeSideValues(feeDeduct, transactionValues);
|
|
3279
3282
|
const allowanceNeeded = (0, import_react8.useMemo)(
|
|
3280
3283
|
() => BigInt(txValues.allowanceAmount.value),
|
|
3281
3284
|
[txValues.allowanceAmount.value]
|
|
@@ -4127,7 +4130,7 @@ var useApproveSPL = () => {
|
|
|
4127
4130
|
const tokenOptions = (0, import_react_redux13.useSelector)(selectTokenOptions);
|
|
4128
4131
|
const { transactionValues } = (0, import_react_redux13.useSelector)(selectServiceFee);
|
|
4129
4132
|
const feeDeduct = (0, import_react_redux13.useSelector)(selectFeeDeduct);
|
|
4130
|
-
const { allowanceAmount } = feeDeduct
|
|
4133
|
+
const { allowanceAmount } = getFeeSideValues(feeDeduct, transactionValues);
|
|
4131
4134
|
const allowanceNumber = BigInt(allowanceAmount.value);
|
|
4132
4135
|
const ownerPk = mode === "light" /* light */ ? new import_web37.PublicKey(lightDemoAccounts.SOL) : publicKey ? new import_web37.PublicKey(publicKey) : void 0;
|
|
4133
4136
|
const { pools } = useGetPools_default(backendUrl, networkOption);
|
|
@@ -4217,7 +4220,7 @@ var useSolSignMessage = () => {
|
|
|
4217
4220
|
const { signMessage } = useSolProvider();
|
|
4218
4221
|
const { transactionValues } = (0, import_react_redux14.useSelector)(selectServiceFee);
|
|
4219
4222
|
const feeDeduct = (0, import_react_redux14.useSelector)(selectFeeDeduct);
|
|
4220
|
-
const { message } = feeDeduct
|
|
4223
|
+
const { message } = getFeeSideValues(feeDeduct, transactionValues);
|
|
4221
4224
|
const sign = (0, import_react23.useCallback)(async () => {
|
|
4222
4225
|
if (!signMessage) {
|
|
4223
4226
|
logger_default.warn("useSolSignMessage: signMessage not available");
|
|
@@ -4244,7 +4247,7 @@ var useAllowance2 = () => {
|
|
|
4244
4247
|
const { transactionValues } = (0, import_react_redux15.useSelector)(selectServiceFee);
|
|
4245
4248
|
const feeDeduct = (0, import_react_redux15.useSelector)(selectFeeDeduct);
|
|
4246
4249
|
const needed = BigInt(
|
|
4247
|
-
(feeDeduct
|
|
4250
|
+
getFeeSideValues(feeDeduct, transactionValues).allowanceAmount.value
|
|
4248
4251
|
);
|
|
4249
4252
|
const current = read?.allowance ?? 0n;
|
|
4250
4253
|
const isApproved = current >= needed;
|
|
@@ -4922,7 +4925,7 @@ var useApproveTrc20 = () => {
|
|
|
4922
4925
|
const tokenOptions = (0, import_react_redux21.useSelector)(selectTokenOptions);
|
|
4923
4926
|
const { transactionValues } = (0, import_react_redux21.useSelector)(selectServiceFee);
|
|
4924
4927
|
const feeDeduct = (0, import_react_redux21.useSelector)(selectFeeDeduct);
|
|
4925
|
-
const txValues = feeDeduct
|
|
4928
|
+
const txValues = getFeeSideValues(feeDeduct, transactionValues);
|
|
4926
4929
|
const allowanceNeeded = BigInt(txValues.allowanceAmount.value);
|
|
4927
4930
|
const { tronWeb, signTransaction } = useTronProvider();
|
|
4928
4931
|
const address = useTronAddress(mode);
|
|
@@ -5077,7 +5080,7 @@ var useAllowance3 = () => {
|
|
|
5077
5080
|
const { sign } = useTronSignMessage();
|
|
5078
5081
|
const { transactionValues } = (0, import_react_redux23.useSelector)(selectServiceFee);
|
|
5079
5082
|
const feeDeduct = (0, import_react_redux23.useSelector)(selectFeeDeduct);
|
|
5080
|
-
const txValues = feeDeduct
|
|
5083
|
+
const txValues = getFeeSideValues(feeDeduct, transactionValues);
|
|
5081
5084
|
const allowanceNeeded = (0, import_react31.useMemo)(
|
|
5082
5085
|
() => BigInt(txValues.allowanceAmount.value),
|
|
5083
5086
|
[txValues.allowanceAmount.value]
|
|
@@ -5482,7 +5485,7 @@ var KimaProvider = ({
|
|
|
5482
5485
|
var KimaProvider_default = KimaProvider;
|
|
5483
5486
|
|
|
5484
5487
|
// src/widgets/common/KimaTransactionWidget.tsx
|
|
5485
|
-
var
|
|
5488
|
+
var import_react69 = require("react");
|
|
5486
5489
|
var import_react_redux58 = require("react-redux");
|
|
5487
5490
|
|
|
5488
5491
|
// src/assets/loading/180-ring.tsx
|
|
@@ -6387,6 +6390,13 @@ var sumBigAmts = (amts) => {
|
|
|
6387
6390
|
);
|
|
6388
6391
|
return { value: total, decimals: maxDec };
|
|
6389
6392
|
};
|
|
6393
|
+
var uiSymbol = (symbol) => {
|
|
6394
|
+
if (!symbol) return symbol ?? "";
|
|
6395
|
+
const s = symbol.toUpperCase();
|
|
6396
|
+
if (s === "WETH") return "ETH";
|
|
6397
|
+
if (s === "WSOL") return "SOL";
|
|
6398
|
+
return symbol;
|
|
6399
|
+
};
|
|
6390
6400
|
var ConfirmDetails = ({
|
|
6391
6401
|
isApproved,
|
|
6392
6402
|
feeOptionDisabled
|
|
@@ -6425,6 +6435,14 @@ var ConfirmDetails = ({
|
|
|
6425
6435
|
);
|
|
6426
6436
|
const sourceCurrency = (0, import_react_redux32.useSelector)(selectSourceCurrency);
|
|
6427
6437
|
const targetCurrency = (0, import_react_redux32.useSelector)(selectTargetCurrency);
|
|
6438
|
+
const uiSourceCurrency = (0, import_react47.useMemo)(
|
|
6439
|
+
() => uiSymbol(sourceCurrency),
|
|
6440
|
+
[sourceCurrency]
|
|
6441
|
+
);
|
|
6442
|
+
const uiTargetCurrency = (0, import_react47.useMemo)(
|
|
6443
|
+
() => uiSymbol(targetCurrency),
|
|
6444
|
+
[targetCurrency]
|
|
6445
|
+
);
|
|
6428
6446
|
const { width, updateWidth } = useWidth_default();
|
|
6429
6447
|
const isSwap = (0, import_react47.useMemo)(
|
|
6430
6448
|
() => !isSamePeggedToken(
|
|
@@ -6490,8 +6508,8 @@ var ConfirmDetails = ({
|
|
|
6490
6508
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("p", { children: [
|
|
6491
6509
|
"Step ",
|
|
6492
6510
|
isApproved ? "2" : "1",
|
|
6493
|
-
"\xA0of 2
|
|
6494
|
-
isApproved ? "Submit
|
|
6511
|
+
"\xA0of 2:\xA0\xA0\xA0",
|
|
6512
|
+
isApproved ? isSwap ? "Submit Swap Transaction" : "Submit Transfer Transaction" : originNetwork.shortName === "FIAT" /* FIAT */ ? "Bank Details" : "Approval"
|
|
6495
6513
|
] }),
|
|
6496
6514
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "detail-item", children: [
|
|
6497
6515
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "label", children: [
|
|
@@ -6513,7 +6531,7 @@ var ConfirmDetails = ({
|
|
|
6513
6531
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "coin-details", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("p", { children: [
|
|
6514
6532
|
formatBigInt(amountToTransferBig),
|
|
6515
6533
|
" ",
|
|
6516
|
-
|
|
6534
|
+
uiSourceCurrency
|
|
6517
6535
|
] }) })
|
|
6518
6536
|
] }),
|
|
6519
6537
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "amount-details", children: [
|
|
@@ -6538,7 +6556,7 @@ var ConfirmDetails = ({
|
|
|
6538
6556
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6539
6557
|
formatBigInt(totalFee),
|
|
6540
6558
|
" ",
|
|
6541
|
-
|
|
6559
|
+
uiSourceCurrency
|
|
6542
6560
|
] })
|
|
6543
6561
|
]
|
|
6544
6562
|
}
|
|
@@ -6550,7 +6568,7 @@ var ConfirmDetails = ({
|
|
|
6550
6568
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6551
6569
|
formatBigInt(combinedSwapFees),
|
|
6552
6570
|
" ",
|
|
6553
|
-
|
|
6571
|
+
uiSourceCurrency
|
|
6554
6572
|
] })
|
|
6555
6573
|
] }),
|
|
6556
6574
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "amount-details", children: [
|
|
@@ -6558,7 +6576,7 @@ var ConfirmDetails = ({
|
|
|
6558
6576
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6559
6577
|
formatBigInt(kimaFee),
|
|
6560
6578
|
" ",
|
|
6561
|
-
|
|
6579
|
+
uiSourceCurrency
|
|
6562
6580
|
] })
|
|
6563
6581
|
] })
|
|
6564
6582
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
|
|
@@ -6567,7 +6585,7 @@ var ConfirmDetails = ({
|
|
|
6567
6585
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6568
6586
|
formatBigInt(sourceFee),
|
|
6569
6587
|
" ",
|
|
6570
|
-
|
|
6588
|
+
uiSourceCurrency
|
|
6571
6589
|
] })
|
|
6572
6590
|
] }),
|
|
6573
6591
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "amount-details", children: [
|
|
@@ -6579,7 +6597,7 @@ var ConfirmDetails = ({
|
|
|
6579
6597
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6580
6598
|
formatBigInt(targetFee),
|
|
6581
6599
|
" ",
|
|
6582
|
-
|
|
6600
|
+
uiTargetCurrency
|
|
6583
6601
|
] })
|
|
6584
6602
|
] }),
|
|
6585
6603
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "amount-details", children: [
|
|
@@ -6587,7 +6605,7 @@ var ConfirmDetails = ({
|
|
|
6587
6605
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6588
6606
|
formatBigInt(kimaFee),
|
|
6589
6607
|
" ",
|
|
6590
|
-
|
|
6608
|
+
uiSourceCurrency
|
|
6591
6609
|
] })
|
|
6592
6610
|
] })
|
|
6593
6611
|
] }) }),
|
|
@@ -6596,7 +6614,7 @@ var ConfirmDetails = ({
|
|
|
6596
6614
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "service-fee", children: [
|
|
6597
6615
|
formatBigInt(targetTransferBig),
|
|
6598
6616
|
" ",
|
|
6599
|
-
|
|
6617
|
+
uiTargetCurrency
|
|
6600
6618
|
] })
|
|
6601
6619
|
] })
|
|
6602
6620
|
] }) }),
|
|
@@ -6680,29 +6698,20 @@ var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
|
6680
6698
|
var import_react49 = require("react");
|
|
6681
6699
|
var import_react_redux35 = require("react-redux");
|
|
6682
6700
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
6683
|
-
var
|
|
6684
|
-
{
|
|
6685
|
-
|
|
6686
|
-
},
|
|
6687
|
-
{
|
|
6688
|
-
|
|
6689
|
-
},
|
|
6690
|
-
{
|
|
6691
|
-
title: "Validation"
|
|
6692
|
-
},
|
|
6693
|
-
{
|
|
6694
|
-
title: "Target Transfer"
|
|
6695
|
-
},
|
|
6696
|
-
{
|
|
6697
|
-
title: "Finalize"
|
|
6698
|
-
}
|
|
6701
|
+
var DEFAULT_STEPS = [
|
|
6702
|
+
{ title: "Initialize" },
|
|
6703
|
+
{ title: "Source Transfer" },
|
|
6704
|
+
{ title: "Validation" },
|
|
6705
|
+
{ title: "Target Transfer" },
|
|
6706
|
+
{ title: "Finalize" }
|
|
6699
6707
|
];
|
|
6700
|
-
var StepBox = ({ step, errorStep, loadingStep, data }) => {
|
|
6708
|
+
var StepBox = ({ step, errorStep, loadingStep, data, steps }) => {
|
|
6701
6709
|
const theme = (0, import_react_redux35.useSelector)(selectTheme);
|
|
6702
6710
|
const explorerUrl = (0, import_react_redux35.useSelector)(selectKimaExplorer);
|
|
6703
6711
|
const networkOption = (0, import_react_redux35.useSelector)(selectNetworkOption);
|
|
6704
6712
|
const networks = (0, import_react_redux35.useSelector)(selectNetworks);
|
|
6705
6713
|
const { width: windowWidth } = useWidth_default();
|
|
6714
|
+
const stepInfo = steps ?? DEFAULT_STEPS;
|
|
6706
6715
|
const sourceChain = (0, import_react49.useMemo)(() => {
|
|
6707
6716
|
const sourceKey = data?.sourceChain === "FIAT" ? "CC" : data?.sourceChain;
|
|
6708
6717
|
return networks.find((network) => network.shortName === sourceKey);
|
|
@@ -6801,7 +6810,7 @@ var StepBox = ({ step, errorStep, loadingStep, data }) => {
|
|
|
6801
6810
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CopyButton_default, { text: data?.tssReleaseHash || "" })
|
|
6802
6811
|
] })
|
|
6803
6812
|
] }) : null
|
|
6804
|
-
] }, item.title)) }) });
|
|
6813
|
+
] }, `${item.title}-${index}`)) }) });
|
|
6805
6814
|
};
|
|
6806
6815
|
var StepBox_default = StepBox;
|
|
6807
6816
|
|
|
@@ -6929,45 +6938,49 @@ var useDebugCode = (sequence = ["D", "E", "B", "U", "G"]) => {
|
|
|
6929
6938
|
};
|
|
6930
6939
|
|
|
6931
6940
|
// src/widgets/common/KimaWidgetWrapper.tsx
|
|
6932
|
-
var
|
|
6933
|
-
var
|
|
6941
|
+
var import_react67 = require("@reown/appkit/react");
|
|
6942
|
+
var import_react68 = require("react");
|
|
6934
6943
|
var import_react_redux57 = require("react-redux");
|
|
6935
6944
|
|
|
6936
6945
|
// src/widgets/transaction/components/TransactionWidget.tsx
|
|
6937
|
-
var
|
|
6946
|
+
var import_react54 = require("react");
|
|
6938
6947
|
|
|
6939
6948
|
// src/components/reusable/Progressbar.tsx
|
|
6949
|
+
var import_react51 = require("react");
|
|
6940
6950
|
var import_react_redux37 = require("react-redux");
|
|
6941
6951
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
6942
|
-
var
|
|
6943
|
-
{
|
|
6944
|
-
|
|
6945
|
-
},
|
|
6946
|
-
{
|
|
6947
|
-
|
|
6948
|
-
},
|
|
6949
|
-
{
|
|
6950
|
-
title: "Validation"
|
|
6951
|
-
},
|
|
6952
|
-
{
|
|
6953
|
-
title: "Target Transfer"
|
|
6954
|
-
},
|
|
6955
|
-
{
|
|
6956
|
-
title: "Finalize"
|
|
6957
|
-
}
|
|
6952
|
+
var DEFAULT_STEPS2 = [
|
|
6953
|
+
{ title: "Initialize" },
|
|
6954
|
+
{ title: "Source Transfer" },
|
|
6955
|
+
{ title: "Validation" },
|
|
6956
|
+
{ title: "Target Transfer" },
|
|
6957
|
+
{ title: "Finalize" }
|
|
6958
6958
|
];
|
|
6959
|
-
var Progressbar = ({
|
|
6959
|
+
var Progressbar = ({
|
|
6960
|
+
step,
|
|
6961
|
+
errorStep,
|
|
6962
|
+
setFocus,
|
|
6963
|
+
loadingStep,
|
|
6964
|
+
steps
|
|
6965
|
+
}) => {
|
|
6960
6966
|
const theme = (0, import_react_redux37.useSelector)(selectTheme);
|
|
6967
|
+
const stepInfo = steps ?? DEFAULT_STEPS2;
|
|
6968
|
+
const lastIndex = stepInfo.length - 1;
|
|
6969
|
+
const pct = (0, import_react51.useMemo)(() => {
|
|
6970
|
+
if (lastIndex <= 0) return 0;
|
|
6971
|
+
const clamped = Math.max(0, Math.min(step, lastIndex));
|
|
6972
|
+
return clamped * 100 / lastIndex;
|
|
6973
|
+
}, [step, lastIndex]);
|
|
6961
6974
|
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "kima-progressbar", children: [
|
|
6962
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className:
|
|
6963
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "step-indicators", children:
|
|
6975
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "value", style: { width: `${pct}%` } }),
|
|
6976
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "step-indicators", children: stepInfo.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
6964
6977
|
"div",
|
|
6965
6978
|
{
|
|
6966
6979
|
className: `step ${step === index && "active"}
|
|
6967
6980
|
${step >= index ? index === errorStep ? "error" : "completed" : ""}
|
|
6968
6981
|
${step < index && "locked"} ${theme.colorMode}`,
|
|
6969
6982
|
onClick: () => {
|
|
6970
|
-
if (index <
|
|
6983
|
+
if (index < lastIndex) setFocus(index);
|
|
6971
6984
|
},
|
|
6972
6985
|
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "step-info", children: [
|
|
6973
6986
|
step < index && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Lock_default, {}),
|
|
@@ -6975,7 +6988,7 @@ var Progressbar = ({ step, errorStep, setFocus, loadingStep }) => {
|
|
|
6975
6988
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { children: item.title })
|
|
6976
6989
|
] })
|
|
6977
6990
|
},
|
|
6978
|
-
item.title
|
|
6991
|
+
`${item.title}-${index}`
|
|
6979
6992
|
)) })
|
|
6980
6993
|
] });
|
|
6981
6994
|
};
|
|
@@ -6988,7 +7001,7 @@ var import_react_redux42 = require("react-redux");
|
|
|
6988
7001
|
var import_react_hot_toast2 = require("react-hot-toast");
|
|
6989
7002
|
|
|
6990
7003
|
// src/widgets/transaction/hooks/useTxData.ts
|
|
6991
|
-
var
|
|
7004
|
+
var import_react52 = require("react");
|
|
6992
7005
|
var import_react_query17 = require("@tanstack/react-query");
|
|
6993
7006
|
|
|
6994
7007
|
// src/services/transactionApi.ts
|
|
@@ -7087,7 +7100,7 @@ var getTxData = async ({
|
|
|
7087
7100
|
// src/widgets/transaction/hooks/useTxData.ts
|
|
7088
7101
|
var POLLING_INTERVAL_MS = 1e3 * 10;
|
|
7089
7102
|
var useTxData = (txId, dAppOption, backendUrl, isSwap) => {
|
|
7090
|
-
const refPollForUpdates = (0,
|
|
7103
|
+
const refPollForUpdates = (0, import_react52.useRef)(false);
|
|
7091
7104
|
const isLP = dAppOption === "LPAdd" /* LPAdd */ || dAppOption === "LPDrain" /* LPDrain */;
|
|
7092
7105
|
const validTxId = typeof txId === "number" ? txId > 0 : txId.toString().length > 0;
|
|
7093
7106
|
return (0, import_react_query17.useQuery)({
|
|
@@ -7128,7 +7141,7 @@ var TransactionStatusMessage = ({
|
|
|
7128
7141
|
var TransactionStatusMessage_default = TransactionStatusMessage;
|
|
7129
7142
|
|
|
7130
7143
|
// src/components/reusable/TransactionSearch.tsx
|
|
7131
|
-
var
|
|
7144
|
+
var import_react53 = require("react");
|
|
7132
7145
|
var import_react_redux38 = require("react-redux");
|
|
7133
7146
|
var import_react_redux39 = require("react-redux");
|
|
7134
7147
|
var import_react_hot_toast = __toESM(require("react-hot-toast"), 1);
|
|
@@ -7137,8 +7150,8 @@ var TransactionSearch = () => {
|
|
|
7137
7150
|
const theme = (0, import_react_redux38.useSelector)(selectTheme);
|
|
7138
7151
|
const backendUrl = (0, import_react_redux38.useSelector)(selectBackendUrl);
|
|
7139
7152
|
const dispatch = (0, import_react_redux39.useDispatch)();
|
|
7140
|
-
const [transactionId, setTransactionId] = (0,
|
|
7141
|
-
const refPollForUpdates = (0,
|
|
7153
|
+
const [transactionId, setTransactionId] = (0, import_react53.useState)("");
|
|
7154
|
+
const refPollForUpdates = (0, import_react53.useRef)(false);
|
|
7142
7155
|
const handleSearch = async () => {
|
|
7143
7156
|
if (transactionId.length <= 0)
|
|
7144
7157
|
return import_react_hot_toast.default.error("You must provide a valid transaction id", {
|
|
@@ -7186,14 +7199,63 @@ var TransactionSearch_default = TransactionSearch;
|
|
|
7186
7199
|
|
|
7187
7200
|
// src/widgets/transaction/components/TransactionWidget.tsx
|
|
7188
7201
|
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
7202
|
+
var TRANSFER_STEPS = [
|
|
7203
|
+
{ title: "Initialize" },
|
|
7204
|
+
{ title: "Source Transfer" },
|
|
7205
|
+
{ title: "Validation" },
|
|
7206
|
+
{ title: "Target Transfer" },
|
|
7207
|
+
{ title: "Finalize" }
|
|
7208
|
+
];
|
|
7209
|
+
var SWAP_STEPS = [
|
|
7210
|
+
{ title: "Initialize" },
|
|
7211
|
+
{ title: "Source Transfer" },
|
|
7212
|
+
{ title: "Swap" },
|
|
7213
|
+
{ title: "Target Transfer" },
|
|
7214
|
+
{ title: "Finalize" }
|
|
7215
|
+
];
|
|
7216
|
+
var normalizeStatus = (s) => (s ?? "").toString().trim().toUpperCase().replace(/[\s-]+/g, "_");
|
|
7217
|
+
var compact = (s) => s.replace(/_/g, "");
|
|
7218
|
+
var displaySymbol2 = (sym) => {
|
|
7219
|
+
const s = (sym ?? "").toString().trim();
|
|
7220
|
+
const up = s.toUpperCase();
|
|
7221
|
+
if (up === "WETH") return "ETH";
|
|
7222
|
+
if (up === "WSOL") return "SOL";
|
|
7223
|
+
return s;
|
|
7224
|
+
};
|
|
7225
|
+
var formatTruncMaxDecimals = (value, maxDecimals = 4, maxExtraDecimals = 12) => {
|
|
7226
|
+
const n = Number(value);
|
|
7227
|
+
if (!Number.isFinite(n)) return "";
|
|
7228
|
+
const abs = Math.abs(n);
|
|
7229
|
+
const baseFactor = 10 ** maxDecimals;
|
|
7230
|
+
const baseTrunc = Math.trunc(n * baseFactor) / baseFactor;
|
|
7231
|
+
if (abs === 0 || baseTrunc !== 0) {
|
|
7232
|
+
const fixed2 = baseTrunc.toFixed(maxDecimals);
|
|
7233
|
+
return fixed2.replace(/\.?0+$/, "");
|
|
7234
|
+
}
|
|
7235
|
+
let d = maxDecimals + 1;
|
|
7236
|
+
const maxD = maxDecimals + maxExtraDecimals;
|
|
7237
|
+
while (d <= maxD) {
|
|
7238
|
+
const factor = 10 ** d;
|
|
7239
|
+
const trunc = Math.trunc(n * factor) / factor;
|
|
7240
|
+
if (trunc !== 0) {
|
|
7241
|
+
const fixed2 = trunc.toFixed(d);
|
|
7242
|
+
return fixed2.replace(/\.?0+$/, "");
|
|
7243
|
+
}
|
|
7244
|
+
d += 1;
|
|
7245
|
+
}
|
|
7246
|
+
const capFactor = 10 ** maxD;
|
|
7247
|
+
const capTrunc = Math.trunc(n * capFactor) / capFactor;
|
|
7248
|
+
const fixed = capTrunc.toFixed(maxD);
|
|
7249
|
+
return fixed.replace(/\.?0+$/, "");
|
|
7250
|
+
};
|
|
7189
7251
|
var TransactionWidget = ({ theme }) => {
|
|
7190
|
-
const [step, setStep] = (0,
|
|
7191
|
-
const [focus, setFocus] = (0,
|
|
7192
|
-
const [errorStep, setErrorStep] = (0,
|
|
7193
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
7194
|
-
const [loadingStep, setLoadingStep] = (0,
|
|
7195
|
-
const [minimized, setMinimized] = (0,
|
|
7196
|
-
const [isComplete, setIsComplete] = (0,
|
|
7252
|
+
const [step, setStep] = (0, import_react54.useState)(0);
|
|
7253
|
+
const [focus, setFocus] = (0, import_react54.useState)(-1);
|
|
7254
|
+
const [errorStep, setErrorStep] = (0, import_react54.useState)(-1);
|
|
7255
|
+
const [errorMessage, setErrorMessage] = (0, import_react54.useState)("");
|
|
7256
|
+
const [loadingStep, setLoadingStep] = (0, import_react54.useState)(-1);
|
|
7257
|
+
const [minimized, setMinimized] = (0, import_react54.useState)(false);
|
|
7258
|
+
const [isComplete, setIsComplete] = (0, import_react54.useState)(false);
|
|
7197
7259
|
const dispatch = (0, import_react_redux42.useDispatch)();
|
|
7198
7260
|
const explorerUrl = (0, import_react_redux41.useSelector)(selectKimaExplorer);
|
|
7199
7261
|
const mode = (0, import_react_redux41.useSelector)(selectMode);
|
|
@@ -7220,8 +7282,12 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7220
7282
|
);
|
|
7221
7283
|
const isSwapBy3Letters = three(sourceSymbol) !== three(targetSymbol);
|
|
7222
7284
|
const widgetIsSwap = mode === "status" /* status */ ? isSwapBy3Letters : isSwapByPegged;
|
|
7285
|
+
const steps = (0, import_react54.useMemo)(
|
|
7286
|
+
() => widgetIsSwap ? SWAP_STEPS : TRANSFER_STEPS,
|
|
7287
|
+
[widgetIsSwap]
|
|
7288
|
+
);
|
|
7223
7289
|
const { width: windowWidth, updateWidth } = useWidth_default();
|
|
7224
|
-
(0,
|
|
7290
|
+
(0, import_react54.useEffect)(() => {
|
|
7225
7291
|
windowWidth === 0 && updateWidth(window.innerWidth);
|
|
7226
7292
|
}, [windowWidth, updateWidth]);
|
|
7227
7293
|
const safeTxId = typeof txId === "string" || typeof txId === "number" ? txId : -1;
|
|
@@ -7231,80 +7297,93 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7231
7297
|
backendUrl,
|
|
7232
7298
|
widgetIsSwap
|
|
7233
7299
|
);
|
|
7234
|
-
const transactionSourceChain = (0,
|
|
7300
|
+
const transactionSourceChain = (0, import_react54.useMemo)(
|
|
7235
7301
|
() => networks.find(
|
|
7236
7302
|
(network) => network.shortName === (mode === "status" /* status */ ? data?.sourceChain === "FIAT" ? "CC" : data?.sourceChain : sourceChain.shortName)
|
|
7237
7303
|
),
|
|
7238
7304
|
[data, mode, sourceChain, networks]
|
|
7239
7305
|
);
|
|
7240
|
-
const transactionTargetChain = (0,
|
|
7306
|
+
const transactionTargetChain = (0, import_react54.useMemo)(
|
|
7241
7307
|
() => networks.find(
|
|
7242
7308
|
(network) => network.shortName === (mode === "status" /* status */ ? data?.targetChain : targetChain.shortName)
|
|
7243
7309
|
),
|
|
7244
7310
|
[data, mode, targetChain, networks]
|
|
7245
7311
|
);
|
|
7246
|
-
const isValidTxId = (0,
|
|
7312
|
+
const isValidTxId = (0, import_react54.useMemo)(() => {
|
|
7247
7313
|
return !(safeTxId === -1 || typeof safeTxId === "string" && safeTxId.length === 0);
|
|
7248
7314
|
}, [safeTxId]);
|
|
7249
|
-
const isEmptyStatus = (0,
|
|
7315
|
+
const isEmptyStatus = (0, import_react54.useMemo)(() => {
|
|
7250
7316
|
if (!data) return true;
|
|
7251
7317
|
return data?.amount === "";
|
|
7252
7318
|
}, [data]);
|
|
7253
7319
|
const showFetchingTitle = isValidTxId && isEmptyStatus;
|
|
7254
|
-
(0,
|
|
7320
|
+
(0, import_react54.useEffect)(() => {
|
|
7255
7321
|
if (!data || data.status !== "Completed" /* COMPLETED */) return;
|
|
7256
7322
|
successHandler && successHandler({
|
|
7257
7323
|
txId: safeTxId
|
|
7258
7324
|
});
|
|
7259
7325
|
}, [data, successHandler, safeTxId]);
|
|
7260
|
-
(0,
|
|
7326
|
+
(0, import_react54.useEffect)(() => {
|
|
7261
7327
|
if (!data) return;
|
|
7262
7328
|
if (data.status === "Completed" /* COMPLETED */) {
|
|
7263
7329
|
setIsComplete(true);
|
|
7264
7330
|
}
|
|
7265
7331
|
}, [data]);
|
|
7266
|
-
(0,
|
|
7332
|
+
(0, import_react54.useEffect)(() => {
|
|
7267
7333
|
if (error)
|
|
7268
7334
|
import_react_hot_toast2.toast.error(
|
|
7269
7335
|
"The provided transaction id is not valid, please use a different one or contact support for further assistance",
|
|
7270
7336
|
{ icon: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Error_default, {}) }
|
|
7271
7337
|
);
|
|
7272
7338
|
}, [error]);
|
|
7273
|
-
(0,
|
|
7274
|
-
const
|
|
7275
|
-
const s =
|
|
7276
|
-
|
|
7339
|
+
(0, import_react54.useEffect)(() => {
|
|
7340
|
+
const raw = normalizeStatus(data?.status);
|
|
7341
|
+
const s = compact(raw);
|
|
7342
|
+
const is = (candidate) => {
|
|
7343
|
+
const cRaw = normalizeStatus(candidate);
|
|
7344
|
+
return raw === cRaw || s === compact(cRaw);
|
|
7345
|
+
};
|
|
7346
|
+
if (!data || !raw) {
|
|
7277
7347
|
setStep(0);
|
|
7278
7348
|
setLoadingStep(0);
|
|
7279
7349
|
return;
|
|
7280
7350
|
}
|
|
7281
|
-
logger_default.debug("
|
|
7351
|
+
logger_default.debug("[TransactionWidget] status", { raw, widgetIsSwap, errorMessage });
|
|
7282
7352
|
setErrorStep(-1);
|
|
7283
|
-
if (
|
|
7284
|
-
setStep(
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
if (s === "CONFIRMED") {
|
|
7289
|
-
setStep(2);
|
|
7290
|
-
setLoadingStep(2);
|
|
7353
|
+
if (is("DECLINED_INVALID") || is("DECLINEDINVALID")) {
|
|
7354
|
+
setStep(0);
|
|
7355
|
+
setErrorStep(0);
|
|
7356
|
+
setLoadingStep(-1);
|
|
7357
|
+
import_react_hot_toast2.toast.error("Invalid signature!");
|
|
7291
7358
|
return;
|
|
7292
7359
|
}
|
|
7293
|
-
if (
|
|
7360
|
+
if (raw.startsWith("UNAVAILABLE")) {
|
|
7294
7361
|
setStep(1);
|
|
7295
7362
|
setErrorStep(1);
|
|
7296
7363
|
setLoadingStep(-1);
|
|
7297
|
-
logger_default.error("transaction failed:", data?.failReason);
|
|
7298
7364
|
import_react_hot_toast2.toast.error("Unavailable", { icon: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Error_default, {}) });
|
|
7299
7365
|
setErrorMessage("Unavailable");
|
|
7300
7366
|
return;
|
|
7301
7367
|
}
|
|
7302
|
-
if (
|
|
7368
|
+
if (is("FAILED_TO_PULL") || is("FAILEDTOPULL")) {
|
|
7369
|
+
setStep(1);
|
|
7370
|
+
setErrorStep(1);
|
|
7371
|
+
setLoadingStep(-1);
|
|
7372
|
+
import_react_hot_toast2.toast.error("Failed to pull tokens from source!", { icon: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Error_default, {}) });
|
|
7373
|
+
setErrorMessage("Failed to pull tokens from source!");
|
|
7374
|
+
return;
|
|
7375
|
+
}
|
|
7376
|
+
if (is("FAILED_TO_PAY") || is("FAILEDTOPAY")) {
|
|
7303
7377
|
setStep(3);
|
|
7304
|
-
|
|
7378
|
+
setErrorStep(3);
|
|
7379
|
+
setLoadingStep(-1);
|
|
7380
|
+
import_react_hot_toast2.toast.error("Failed to release tokens to target!", {
|
|
7381
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Error_default, {})
|
|
7382
|
+
});
|
|
7383
|
+
setErrorMessage("Failed to release tokens to target!");
|
|
7305
7384
|
return;
|
|
7306
7385
|
}
|
|
7307
|
-
if (
|
|
7386
|
+
if (is("REFUND_START") || is("REFUND_STARTED") || is("REFUNDSTART") || is("REFUNDSTARTED")) {
|
|
7308
7387
|
setStep(3);
|
|
7309
7388
|
setLoadingStep(3);
|
|
7310
7389
|
import_react_hot_toast2.toast.error(
|
|
@@ -7316,7 +7395,7 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7316
7395
|
);
|
|
7317
7396
|
return;
|
|
7318
7397
|
}
|
|
7319
|
-
if (
|
|
7398
|
+
if (is("REFUND_FAILED") || is("REFUNDFAILED")) {
|
|
7320
7399
|
setStep(3);
|
|
7321
7400
|
setErrorStep(3);
|
|
7322
7401
|
setLoadingStep(-1);
|
|
@@ -7324,7 +7403,7 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7324
7403
|
setErrorMessage("Failed to refund tokens to source!");
|
|
7325
7404
|
return;
|
|
7326
7405
|
}
|
|
7327
|
-
if (
|
|
7406
|
+
if (is("REFUND_COMPLETED") || is("REFUNDCOMPLETED")) {
|
|
7328
7407
|
setStep(4);
|
|
7329
7408
|
setErrorStep(3);
|
|
7330
7409
|
setLoadingStep(-1);
|
|
@@ -7332,48 +7411,60 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7332
7411
|
setErrorMessage("Refund completed!");
|
|
7333
7412
|
return;
|
|
7334
7413
|
}
|
|
7335
|
-
if (
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7414
|
+
if (widgetIsSwap) {
|
|
7415
|
+
if (is("AVAILABLE") || is("PULLED") || is("PULL_CONFIRMED") || is("CONFIRMED")) {
|
|
7416
|
+
setStep(1);
|
|
7417
|
+
setLoadingStep(1);
|
|
7418
|
+
return;
|
|
7419
|
+
}
|
|
7420
|
+
if (is("SWAP_APPROVED") || is("SWAP_APPROVE_CONFIRMED") || is("SWAPPED") || is("SWAP_CONFIRMED")) {
|
|
7421
|
+
setStep(2);
|
|
7422
|
+
setLoadingStep(2);
|
|
7423
|
+
return;
|
|
7424
|
+
}
|
|
7425
|
+
if (is("PAID")) {
|
|
7426
|
+
setStep(3);
|
|
7427
|
+
setLoadingStep(3);
|
|
7428
|
+
return;
|
|
7429
|
+
}
|
|
7430
|
+
if (is("COMPLETED")) {
|
|
7431
|
+
setStep(4);
|
|
7432
|
+
setLoadingStep(-1);
|
|
7433
|
+
return;
|
|
7434
|
+
}
|
|
7435
|
+
setStep((prev) => Math.max(prev, 1));
|
|
7436
|
+
setLoadingStep((prev) => Math.max(prev, 1));
|
|
7344
7437
|
return;
|
|
7345
7438
|
}
|
|
7346
|
-
if (
|
|
7439
|
+
if (is("AVAILABLE") || is("PULLED")) {
|
|
7347
7440
|
setStep(1);
|
|
7348
|
-
|
|
7349
|
-
setLoadingStep(-1);
|
|
7350
|
-
logger_default.error("transaction failed:", data?.failReason);
|
|
7351
|
-
import_react_hot_toast2.toast.error("Failed to pull tokens from source!", { icon: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Error_default, {}) });
|
|
7352
|
-
setErrorMessage("Failed to pull tokens from source!");
|
|
7441
|
+
setLoadingStep(1);
|
|
7353
7442
|
return;
|
|
7354
7443
|
}
|
|
7355
|
-
if (
|
|
7356
|
-
setStep(
|
|
7357
|
-
setLoadingStep(
|
|
7444
|
+
if (is("CONFIRMED")) {
|
|
7445
|
+
setStep(2);
|
|
7446
|
+
setLoadingStep(2);
|
|
7358
7447
|
return;
|
|
7359
7448
|
}
|
|
7360
|
-
if (
|
|
7361
|
-
setStep(
|
|
7362
|
-
|
|
7449
|
+
if (is("PAID")) {
|
|
7450
|
+
setStep(3);
|
|
7451
|
+
setLoadingStep(3);
|
|
7452
|
+
return;
|
|
7453
|
+
}
|
|
7454
|
+
if (is("COMPLETED")) {
|
|
7455
|
+
setStep(4);
|
|
7363
7456
|
setLoadingStep(-1);
|
|
7364
|
-
import_react_hot_toast2.toast.error("Invalid signature!");
|
|
7365
7457
|
return;
|
|
7366
7458
|
}
|
|
7367
|
-
}, [data?.status]);
|
|
7368
|
-
const
|
|
7369
|
-
const verb = (0, import_react53.useMemo)(() => {
|
|
7459
|
+
}, [data?.status, widgetIsSwap, errorMessage]);
|
|
7460
|
+
const verb = (0, import_react54.useMemo)(() => {
|
|
7370
7461
|
if (mode === "status" /* status */) {
|
|
7371
7462
|
if (isEmptyStatus) return "Fetching transaction status ";
|
|
7372
7463
|
return data?.status?.toUpperCase?.() === "Completed" /* COMPLETED */ ? widgetIsSwap ? "Swapped " : "Transferred " : widgetIsSwap ? "Swapping " : "Transfering ";
|
|
7373
7464
|
}
|
|
7374
7465
|
return data?.status?.toUpperCase?.() === "Completed" /* COMPLETED */ ? widgetIsSwap ? "Swapped " : "Transferred " : widgetIsSwap ? "Swapping " : "Transfering ";
|
|
7375
7466
|
}, [mode, data?.status, isEmptyStatus, widgetIsSwap]);
|
|
7376
|
-
const originChargeAmount = (0,
|
|
7467
|
+
const originChargeAmount = (0, import_react54.useMemo)(() => {
|
|
7377
7468
|
const submit = txValues.submitAmount;
|
|
7378
7469
|
const feeInSubmitDec = bigIntChangeDecimals({
|
|
7379
7470
|
...totalFee,
|
|
@@ -7382,37 +7473,39 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7382
7473
|
const val = feeDeduct ? submit.value : submit.value + feeInSubmitDec.value;
|
|
7383
7474
|
return { value: val, decimals: submit.decimals };
|
|
7384
7475
|
}, [txValues.submitAmount, totalFee, feeDeduct]);
|
|
7385
|
-
const { leftAmt, rightAmt, leftSym, rightSym } = (0,
|
|
7476
|
+
const { leftAmt, rightAmt, leftSym, rightSym } = (0, import_react54.useMemo)(() => {
|
|
7386
7477
|
if (mode === "status" /* status */) {
|
|
7387
7478
|
if (widgetIsSwap) {
|
|
7388
7479
|
const amountIn = data?.amountIn;
|
|
7389
7480
|
const amountOut = data?.amount ?? "";
|
|
7481
|
+
const left2 = amountIn != null ? amountIn : amountOut !== "" ? amountOut : "";
|
|
7482
|
+
const right2 = amountOut !== "" ? amountOut : "";
|
|
7390
7483
|
return {
|
|
7391
|
-
leftAmt:
|
|
7392
|
-
rightAmt:
|
|
7393
|
-
leftSym: data?.sourceSymbol ?? "",
|
|
7394
|
-
rightSym: data?.targetSymbol ?? ""
|
|
7484
|
+
leftAmt: left2 !== "" ? formatTruncMaxDecimals(left2, 4) : "",
|
|
7485
|
+
rightAmt: right2 !== "" ? formatTruncMaxDecimals(right2, 4) : "",
|
|
7486
|
+
leftSym: displaySymbol2(data?.sourceSymbol ?? ""),
|
|
7487
|
+
rightSym: displaySymbol2(data?.targetSymbol ?? "")
|
|
7395
7488
|
};
|
|
7396
7489
|
}
|
|
7397
7490
|
const amt = data?.amount ?? "";
|
|
7398
7491
|
return {
|
|
7399
7492
|
leftAmt: amt,
|
|
7400
7493
|
rightAmt: amt,
|
|
7401
|
-
leftSym: data?.sourceSymbol ?? "",
|
|
7402
|
-
rightSym: data?.targetSymbol ?? ""
|
|
7494
|
+
leftSym: displaySymbol2(data?.sourceSymbol ?? ""),
|
|
7495
|
+
rightSym: displaySymbol2(data?.targetSymbol ?? "")
|
|
7403
7496
|
};
|
|
7404
7497
|
}
|
|
7405
7498
|
const isFiatSrc = (transactionSourceChain?.shortName ?? "") === "CC" || (transactionSourceChain?.shortName ?? "") === "BANK";
|
|
7406
7499
|
let left = Number(amount) !== 0 ? isFiatSrc ? bigIntToNumber(originChargeAmount).toFixed(2) : formatBigInt(txValues.allowanceAmount) : "";
|
|
7407
7500
|
let right = Number(amount) !== 0 ? isFiatSrc ? bigIntToNumber(txValues.submitAmount).toFixed(2) : formatBigInt(txValues.submitAmount) : "";
|
|
7408
|
-
let leftSymbol = sourceSymbol;
|
|
7409
|
-
let rightSymbol = targetSymbol;
|
|
7501
|
+
let leftSymbol = displaySymbol2(sourceSymbol);
|
|
7502
|
+
let rightSymbol = displaySymbol2(targetSymbol);
|
|
7410
7503
|
if (widgetIsSwap && data && data?.amount != null && data?.amount !== "") {
|
|
7411
|
-
right =
|
|
7412
|
-
rightSymbol = data?.targetSymbol ?? rightSymbol;
|
|
7504
|
+
right = formatTruncMaxDecimals(data.amount, 4);
|
|
7505
|
+
rightSymbol = displaySymbol2(data?.targetSymbol ?? rightSymbol);
|
|
7413
7506
|
if (data?.amountIn != null) {
|
|
7414
|
-
left =
|
|
7415
|
-
leftSymbol = data?.sourceSymbol ?? leftSymbol;
|
|
7507
|
+
left = formatTruncMaxDecimals(data.amountIn, 4);
|
|
7508
|
+
leftSymbol = displaySymbol2(data?.sourceSymbol ?? leftSymbol);
|
|
7416
7509
|
}
|
|
7417
7510
|
}
|
|
7418
7511
|
return {
|
|
@@ -7471,7 +7564,7 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7471
7564
|
dispatch(setTxId(-1));
|
|
7472
7565
|
dispatch(setSubmitted(false));
|
|
7473
7566
|
} catch (e) {
|
|
7474
|
-
logger_default.
|
|
7567
|
+
logger_default.debug("[TransactionWidget] reset failed", e);
|
|
7475
7568
|
import_react_hot_toast2.toast.error(
|
|
7476
7569
|
"Unable to reset the transaction view. Please contact support for assistance.",
|
|
7477
7570
|
{ icon: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Error_default, {}) }
|
|
@@ -7480,6 +7573,10 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7480
7573
|
};
|
|
7481
7574
|
const swapSrcAmt = data?.amountIn ?? amount;
|
|
7482
7575
|
const swapDstAmt = data?.amount;
|
|
7576
|
+
const swapSrcAmtLabel = formatTruncMaxDecimals(swapSrcAmt, 4);
|
|
7577
|
+
const swapDstAmtLabel = formatTruncMaxDecimals(swapDstAmt, 4);
|
|
7578
|
+
const swapSrcSymLabel = displaySymbol2(data?.sourceSymbol ?? sourceSymbol);
|
|
7579
|
+
const swapDstSymLabel = displaySymbol2(data?.targetSymbol ?? targetSymbol);
|
|
7483
7580
|
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_react_redux40.Provider, { store: store_default, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
|
|
7484
7581
|
"div",
|
|
7485
7582
|
{
|
|
@@ -7575,7 +7672,8 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7575
7672
|
focus,
|
|
7576
7673
|
errorStep,
|
|
7577
7674
|
setFocus,
|
|
7578
|
-
loadingStep
|
|
7675
|
+
loadingStep,
|
|
7676
|
+
steps
|
|
7579
7677
|
}
|
|
7580
7678
|
),
|
|
7581
7679
|
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
@@ -7584,7 +7682,8 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7584
7682
|
step,
|
|
7585
7683
|
errorStep,
|
|
7586
7684
|
loadingStep,
|
|
7587
|
-
data
|
|
7685
|
+
data,
|
|
7686
|
+
steps
|
|
7588
7687
|
}
|
|
7589
7688
|
)
|
|
7590
7689
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "transaction-content transaction-complete", children: [
|
|
@@ -7597,18 +7696,19 @@ var TransactionWidget = ({ theme }) => {
|
|
|
7597
7696
|
children: [
|
|
7598
7697
|
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { children: widgetIsSwap ? /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
|
|
7599
7698
|
"You just swapped ",
|
|
7600
|
-
|
|
7699
|
+
swapSrcAmtLabel,
|
|
7601
7700
|
" ",
|
|
7602
|
-
|
|
7603
|
-
" for ",
|
|
7604
|
-
fmt3(swapDstAmt),
|
|
7701
|
+
swapSrcSymLabel,
|
|
7605
7702
|
" ",
|
|
7606
|
-
|
|
7703
|
+
"for ",
|
|
7704
|
+
swapDstAmtLabel,
|
|
7705
|
+
" ",
|
|
7706
|
+
swapDstSymLabel
|
|
7607
7707
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
|
|
7608
7708
|
"You just transferred ",
|
|
7609
7709
|
data?.amount,
|
|
7610
7710
|
" ",
|
|
7611
|
-
data?.sourceSymbol
|
|
7711
|
+
displaySymbol2(data?.sourceSymbol)
|
|
7612
7712
|
] }) }),
|
|
7613
7713
|
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "header-network-labels", children: [
|
|
7614
7714
|
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
|
|
@@ -8035,7 +8135,7 @@ var useSubmitTransaction = (isSubmitting, setIsSubmitting) => {
|
|
|
8035
8135
|
var useSubmitTransaction_default = useSubmitTransaction;
|
|
8036
8136
|
|
|
8037
8137
|
// src/widgets/transfer/hooks/useValidateTransaction.tsx
|
|
8038
|
-
var
|
|
8138
|
+
var import_react55 = require("react");
|
|
8039
8139
|
var import_viem7 = require("viem");
|
|
8040
8140
|
var import_react_redux45 = require("react-redux");
|
|
8041
8141
|
var useValidateTransaction = (inputs) => {
|
|
@@ -8066,11 +8166,11 @@ var useValidateTransaction = (inputs) => {
|
|
|
8066
8166
|
const tgtNet = (0, import_react_redux45.useSelector)(selectTargetChain);
|
|
8067
8167
|
const srcCur = (0, import_react_redux45.useSelector)(selectSourceCurrency);
|
|
8068
8168
|
const tgtCur = (0, import_react_redux45.useSelector)(selectTargetCurrency);
|
|
8069
|
-
const isSwap = (0,
|
|
8169
|
+
const isSwap = (0, import_react55.useMemo)(
|
|
8070
8170
|
() => !isSamePeggedToken(srcNet, srcCur, tgtNet, tgtCur),
|
|
8071
8171
|
[srcNet, srcCur, tgtNet, tgtCur]
|
|
8072
8172
|
);
|
|
8073
|
-
const maxValue = (0,
|
|
8173
|
+
const maxValue = (0, import_react55.useMemo)(() => {
|
|
8074
8174
|
logger_default.debug("useValidateTransaction: maxValue: ", inputs);
|
|
8075
8175
|
if (!balance) return 0n;
|
|
8076
8176
|
if (totalFee <= 0n) return balance;
|
|
@@ -8185,8 +8285,8 @@ var useValidateTransaction = (inputs) => {
|
|
|
8185
8285
|
var useValidateTransaction_default = useValidateTransaction;
|
|
8186
8286
|
|
|
8187
8287
|
// src/widgets/transfer/components/TransferWidget.tsx
|
|
8188
|
-
var
|
|
8189
|
-
var
|
|
8288
|
+
var import_react66 = require("react");
|
|
8289
|
+
var import_react_hot_toast10 = __toESM(require("react-hot-toast"), 1);
|
|
8190
8290
|
var import_react_redux56 = require("react-redux");
|
|
8191
8291
|
var import_viem9 = require("viem");
|
|
8192
8292
|
|
|
@@ -8226,12 +8326,12 @@ var WarningModal_default = WarningModal;
|
|
|
8226
8326
|
|
|
8227
8327
|
// src/components/reusable/SingleForm.tsx
|
|
8228
8328
|
var import_viem8 = require("viem");
|
|
8229
|
-
var
|
|
8329
|
+
var import_react57 = require("react");
|
|
8230
8330
|
var import_react_hot_toast3 = require("react-hot-toast");
|
|
8231
8331
|
var import_react_redux47 = require("react-redux");
|
|
8232
8332
|
|
|
8233
8333
|
// src/components/primary/NetworkSelector.tsx
|
|
8234
|
-
var
|
|
8334
|
+
var import_react56 = __toESM(require("react"), 1);
|
|
8235
8335
|
var import_react_redux46 = require("react-redux");
|
|
8236
8336
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
8237
8337
|
var NetworkSelector = ({
|
|
@@ -8239,8 +8339,8 @@ var NetworkSelector = ({
|
|
|
8239
8339
|
initialSelection,
|
|
8240
8340
|
setInitialSelection
|
|
8241
8341
|
}) => {
|
|
8242
|
-
const [collapsed, setCollapsed] = (0,
|
|
8243
|
-
const ref = (0,
|
|
8342
|
+
const [collapsed, setCollapsed] = (0, import_react56.useState)(true);
|
|
8343
|
+
const ref = (0, import_react56.useRef)(null);
|
|
8244
8344
|
const dispatch = (0, import_react_redux46.useDispatch)();
|
|
8245
8345
|
const theme = (0, import_react_redux46.useSelector)(selectTheme);
|
|
8246
8346
|
const networkOptions = (0, import_react_redux46.useSelector)(selectNetworks);
|
|
@@ -8254,7 +8354,7 @@ var NetworkSelector = ({
|
|
|
8254
8354
|
const currentTargetAddr = (0, import_react_redux46.useSelector)(selectTargetAddress);
|
|
8255
8355
|
const { switchChainHandler } = useKimaContext();
|
|
8256
8356
|
const isOriginSelector = type === "origin";
|
|
8257
|
-
(0,
|
|
8357
|
+
(0, import_react56.useEffect)(() => {
|
|
8258
8358
|
logger_default.info("[NetworkSelector] mount", {
|
|
8259
8359
|
type,
|
|
8260
8360
|
mode,
|
|
@@ -8263,7 +8363,7 @@ var NetworkSelector = ({
|
|
|
8263
8363
|
targetShort: targetNetwork?.shortName
|
|
8264
8364
|
});
|
|
8265
8365
|
}, []);
|
|
8266
|
-
const networks = (0,
|
|
8366
|
+
const networks = (0, import_react56.useMemo)(() => {
|
|
8267
8367
|
const result = networkOptions.filter((network) => {
|
|
8268
8368
|
if (dAppOption !== "none" /* None */ && network.shortName === "CC")
|
|
8269
8369
|
return false;
|
|
@@ -8288,7 +8388,7 @@ var NetworkSelector = ({
|
|
|
8288
8388
|
isOriginSelector
|
|
8289
8389
|
]);
|
|
8290
8390
|
const shouldLockSourceNetwork = isOriginSelector && mode === "payment" /* payment */ && dAppOption !== "none" /* None */ && !!transactionOption?.targetChain;
|
|
8291
|
-
const selectedNetwork = (0,
|
|
8391
|
+
const selectedNetwork = (0, import_react56.useMemo)(() => {
|
|
8292
8392
|
if (shouldLockSourceNetwork) {
|
|
8293
8393
|
const forced = networks.find(
|
|
8294
8394
|
(n) => n.shortName === transactionOption.targetChain
|
|
@@ -8327,8 +8427,8 @@ var NetworkSelector = ({
|
|
|
8327
8427
|
shouldLockSourceNetwork,
|
|
8328
8428
|
transactionOption?.targetChain
|
|
8329
8429
|
]);
|
|
8330
|
-
const lastForcedShort = (0,
|
|
8331
|
-
(0,
|
|
8430
|
+
const lastForcedShort = (0, import_react56.useRef)();
|
|
8431
|
+
(0, import_react56.useEffect)(() => {
|
|
8332
8432
|
if (!shouldLockSourceNetwork || !isOriginSelector || !transactionOption?.targetChain)
|
|
8333
8433
|
return;
|
|
8334
8434
|
const forcedNetwork = networks.find(
|
|
@@ -8443,7 +8543,7 @@ var NetworkSelector = ({
|
|
|
8443
8543
|
}
|
|
8444
8544
|
setCollapsed(true);
|
|
8445
8545
|
};
|
|
8446
|
-
(0,
|
|
8546
|
+
(0, import_react56.useEffect)(() => {
|
|
8447
8547
|
const handleOutsideClick = (e) => {
|
|
8448
8548
|
if (ref.current && !ref.current.contains(e.target)) {
|
|
8449
8549
|
setCollapsed(true);
|
|
@@ -8452,7 +8552,7 @@ var NetworkSelector = ({
|
|
|
8452
8552
|
document.addEventListener("mousedown", handleOutsideClick);
|
|
8453
8553
|
return () => document.removeEventListener("mousedown", handleOutsideClick);
|
|
8454
8554
|
}, []);
|
|
8455
|
-
(0,
|
|
8555
|
+
(0, import_react56.useEffect)(() => {
|
|
8456
8556
|
if (mode !== "light" /* light */) return;
|
|
8457
8557
|
let srcDemo = "";
|
|
8458
8558
|
if (isEVMChain(sourceNetwork.shortName)) srcDemo = lightDemoAccounts.EVM;
|
|
@@ -8524,7 +8624,7 @@ var NetworkSelector = ({
|
|
|
8524
8624
|
}
|
|
8525
8625
|
);
|
|
8526
8626
|
};
|
|
8527
|
-
var NetworkSelector_default =
|
|
8627
|
+
var NetworkSelector_default = import_react56.default.memo(NetworkSelector);
|
|
8528
8628
|
|
|
8529
8629
|
// src/components/reusable/SingleForm.tsx
|
|
8530
8630
|
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
@@ -8546,7 +8646,7 @@ var SingleForm = ({
|
|
|
8546
8646
|
const targetNetwork = (0, import_react_redux47.useSelector)(selectTargetChain);
|
|
8547
8647
|
const targetAddress = (0, import_react_redux47.useSelector)(selectTargetAddress);
|
|
8548
8648
|
const { isReady } = useIsWalletReady_default();
|
|
8549
|
-
const [amountValue, setAmountValue] = (0,
|
|
8649
|
+
const [amountValue, setAmountValue] = (0, import_react57.useState)("");
|
|
8550
8650
|
const amount = (0, import_react_redux47.useSelector)(selectAmount);
|
|
8551
8651
|
const sourceCurrency = (0, import_react_redux47.useSelector)(selectSourceCurrency);
|
|
8552
8652
|
const targetCurrency = (0, import_react_redux47.useSelector)(selectTargetCurrency);
|
|
@@ -8554,11 +8654,11 @@ var SingleForm = ({
|
|
|
8554
8654
|
const { balance, decimals } = useBalance_default();
|
|
8555
8655
|
const { kimaBackendUrl } = useKimaContext();
|
|
8556
8656
|
const { data: envOptions } = useGetEnvOptions({ kimaBackendUrl });
|
|
8557
|
-
const errorMessage = (0,
|
|
8657
|
+
const errorMessage = (0, import_react57.useMemo)(
|
|
8558
8658
|
() => compliantOption && targetCompliant !== null && !targetCompliant?.isCompliant ? `Target address has ${targetCompliant.results?.[0].result.risk_score} risk` : "",
|
|
8559
8659
|
[compliantOption, targetCompliant]
|
|
8560
8660
|
);
|
|
8561
|
-
const maxValue = (0,
|
|
8661
|
+
const maxValue = (0, import_react57.useMemo)(() => {
|
|
8562
8662
|
if (mode === "light" /* light */) {
|
|
8563
8663
|
const limit = envOptions?.transferLimitMaxUSDT ? parseFloat(envOptions.transferLimitMaxUSDT) : 1e3;
|
|
8564
8664
|
return BigInt(limit);
|
|
@@ -8568,13 +8668,13 @@ var SingleForm = ({
|
|
|
8568
8668
|
const intAmount = (0, import_viem8.parseUnits)(amount || "0", totalFee.decimals);
|
|
8569
8669
|
return balance - intAmount;
|
|
8570
8670
|
}, [mode, envOptions?.transferLimitMaxUSDT, balance, totalFee, amount]);
|
|
8571
|
-
const feeCurrency = (0,
|
|
8671
|
+
const feeCurrency = (0, import_react57.useMemo)(() => {
|
|
8572
8672
|
const srcToken = sourceNetwork.supportedTokens.find(
|
|
8573
8673
|
(t) => t.symbol === sourceCurrency
|
|
8574
8674
|
);
|
|
8575
8675
|
return srcToken?.peggedTo ?? "USD";
|
|
8576
8676
|
}, [sourceNetwork, sourceCurrency]);
|
|
8577
|
-
const canQuoteFees = (0,
|
|
8677
|
+
const canQuoteFees = (0, import_react57.useMemo)(() => {
|
|
8578
8678
|
const haveBasics = !!backendUrl && !!amount && !!sourceNetwork?.shortName && !!sourceCurrency && !!targetNetwork?.shortName && !!targetCurrency;
|
|
8579
8679
|
if (!haveBasics) return false;
|
|
8580
8680
|
const requiresSourceAddress = !["BANK", "CC"].includes(
|
|
@@ -8593,11 +8693,11 @@ var SingleForm = ({
|
|
|
8593
8693
|
sourceAddress,
|
|
8594
8694
|
targetAddress
|
|
8595
8695
|
]);
|
|
8596
|
-
(0,
|
|
8696
|
+
(0, import_react57.useEffect)(() => {
|
|
8597
8697
|
if (!errorMessage) return;
|
|
8598
8698
|
import_react_hot_toast3.toast.error(errorMessage);
|
|
8599
8699
|
}, [errorMessage]);
|
|
8600
|
-
(0,
|
|
8700
|
+
(0, import_react57.useEffect)(() => {
|
|
8601
8701
|
if (amountValue && amount !== "") return;
|
|
8602
8702
|
setAmountValue(amount);
|
|
8603
8703
|
}, [amount, amountValue]);
|
|
@@ -8636,7 +8736,7 @@ var SingleForm = ({
|
|
|
8636
8736
|
);
|
|
8637
8737
|
}
|
|
8638
8738
|
};
|
|
8639
|
-
const demoSourceAddress = (0,
|
|
8739
|
+
const demoSourceAddress = (0, import_react57.useMemo)(() => {
|
|
8640
8740
|
if (mode !== "light" /* light */) return "";
|
|
8641
8741
|
const short = sourceNetwork?.shortName;
|
|
8642
8742
|
if (!short) return "";
|
|
@@ -8645,7 +8745,7 @@ var SingleForm = ({
|
|
|
8645
8745
|
if (lightDemoNetworks.includes(short)) return lightDemoAccounts.EVM;
|
|
8646
8746
|
return "";
|
|
8647
8747
|
}, [mode, sourceNetwork?.shortName]);
|
|
8648
|
-
const isConnectedSourceWrapper = (0,
|
|
8748
|
+
const isConnectedSourceWrapper = (0, import_react57.useMemo)(() => {
|
|
8649
8749
|
if (mode === "light" /* light */) {
|
|
8650
8750
|
const on2 = !!demoSourceAddress;
|
|
8651
8751
|
logger_default.debug("[SingleForm] source wrapper connected (LIGHT)?", {
|
|
@@ -8678,7 +8778,7 @@ var SingleForm = ({
|
|
|
8678
8778
|
demoSourceAddress,
|
|
8679
8779
|
sourceNetwork?.shortName
|
|
8680
8780
|
]);
|
|
8681
|
-
const isConnectedTargetWrapper = (0,
|
|
8781
|
+
const isConnectedTargetWrapper = (0, import_react57.useMemo)(() => {
|
|
8682
8782
|
if (mode !== "light" /* light */) return false;
|
|
8683
8783
|
const on = !!targetAddress;
|
|
8684
8784
|
logger_default.debug("[SingleForm] target wrapper connected (LIGHT)?", {
|
|
@@ -8688,13 +8788,13 @@ var SingleForm = ({
|
|
|
8688
8788
|
});
|
|
8689
8789
|
return on;
|
|
8690
8790
|
}, [mode, targetAddress, targetNetwork?.shortName]);
|
|
8691
|
-
const isConnected = (0,
|
|
8791
|
+
const isConnected = (0, import_react57.useMemo)(() => {
|
|
8692
8792
|
if (mode === "payment" /* payment */ && dAppOption !== "none" /* None */) {
|
|
8693
8793
|
return isReady;
|
|
8694
8794
|
}
|
|
8695
8795
|
return isReady && !initialSelection.sourceSelection;
|
|
8696
8796
|
}, [isReady, initialSelection, mode, dAppOption]);
|
|
8697
|
-
(0,
|
|
8797
|
+
(0, import_react57.useEffect)(() => {
|
|
8698
8798
|
logger_default.debug("[SingleForm] snapshot", {
|
|
8699
8799
|
mode,
|
|
8700
8800
|
srcShort: sourceNetwork?.shortName,
|
|
@@ -8842,7 +8942,7 @@ var SingleForm = ({
|
|
|
8842
8942
|
var SingleForm_default = SingleForm;
|
|
8843
8943
|
|
|
8844
8944
|
// src/components/reusable/FiatWidget.tsx
|
|
8845
|
-
var
|
|
8945
|
+
var import_react58 = require("react");
|
|
8846
8946
|
var import_react_redux48 = require("react-redux");
|
|
8847
8947
|
var import_uuid = require("uuid");
|
|
8848
8948
|
|
|
@@ -8880,8 +8980,8 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8880
8980
|
const sourceCurrency = (0, import_react_redux48.useSelector)(selectSourceCurrency);
|
|
8881
8981
|
const sourceChain = (0, import_react_redux48.useSelector)(selectSourceChain);
|
|
8882
8982
|
const { transactionValues } = (0, import_react_redux48.useSelector)(selectServiceFee);
|
|
8883
|
-
const ccTransactionIdSeedRef = (0,
|
|
8884
|
-
const ccTransactionSubmittedRef = (0,
|
|
8983
|
+
const ccTransactionIdSeedRef = (0, import_react58.useRef)((0, import_uuid.v4)());
|
|
8984
|
+
const ccTransactionSubmittedRef = (0, import_react58.useRef)(false);
|
|
8885
8985
|
const { data: envOptions, isLoading: isEnvLoading } = useGetEnvOptions({
|
|
8886
8986
|
kimaBackendUrl: backendUrl
|
|
8887
8987
|
});
|
|
@@ -8891,25 +8991,25 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8891
8991
|
isLoading: isTransactionIdLoading,
|
|
8892
8992
|
error
|
|
8893
8993
|
} = useCCTransactionId(backendUrl, ccTransactionIdSeedRef.current);
|
|
8894
|
-
(0,
|
|
8994
|
+
(0, import_react58.useEffect)(() => {
|
|
8895
8995
|
dispatch(setCCTransactionIdSeed(ccTransactionIdSeedRef.current));
|
|
8896
8996
|
dispatch(setCCTransactionId(data?.transactionId));
|
|
8897
8997
|
}, [dispatch, data, isTransactionIdLoading]);
|
|
8898
8998
|
const txValues = feeDeduct ? transactionValues.feeFromTarget : transactionValues.feeFromOrigin;
|
|
8899
|
-
const allowanceAmount = (0,
|
|
8999
|
+
const allowanceAmount = (0, import_react58.useMemo)(
|
|
8900
9000
|
() => formatBigInt(txValues.allowanceAmount),
|
|
8901
9001
|
[txValues]
|
|
8902
9002
|
);
|
|
8903
|
-
const [isLoading, setIsLoading] = (0,
|
|
8904
|
-
const baseUrl = (0,
|
|
9003
|
+
const [isLoading, setIsLoading] = (0, import_react58.useState)(true);
|
|
9004
|
+
const baseUrl = (0, import_react58.useMemo)(
|
|
8905
9005
|
() => `https://widget2${networkOption === "testnet" /* testnet */ ? "-sandbox" : ""}.depa.wtf`,
|
|
8906
9006
|
[networkOption]
|
|
8907
9007
|
);
|
|
8908
|
-
const scenario = (0,
|
|
9008
|
+
const scenario = (0, import_react58.useMemo)(
|
|
8909
9009
|
() => sourceChain.shortName === "CC" ? "direct_card_payment" : "direct_bank_payment",
|
|
8910
9010
|
[sourceChain]
|
|
8911
9011
|
);
|
|
8912
|
-
(0,
|
|
9012
|
+
(0, import_react58.useEffect)(() => {
|
|
8913
9013
|
const handleMessage = (event) => {
|
|
8914
9014
|
if (event.origin !== baseUrl) {
|
|
8915
9015
|
return;
|
|
@@ -8938,7 +9038,7 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8938
9038
|
window.addEventListener("message", handleMessage);
|
|
8939
9039
|
return () => window.removeEventListener("message", handleMessage);
|
|
8940
9040
|
}, []);
|
|
8941
|
-
(0,
|
|
9041
|
+
(0, import_react58.useEffect)(() => {
|
|
8942
9042
|
if (error) dispatch(setCCTransactionStatus("error-id"));
|
|
8943
9043
|
}, [dispatch, error]);
|
|
8944
9044
|
return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: `cc-widget ${isLoading ? "loading" : ""}`, children: [
|
|
@@ -9038,23 +9138,79 @@ var useDisconnectWallet6 = () => {
|
|
|
9038
9138
|
var useDisconnectWallet_default = useDisconnectWallet6;
|
|
9039
9139
|
|
|
9040
9140
|
// src/widgets/transfer/components/solana/SolanaConnectModal.tsx
|
|
9041
|
-
var
|
|
9141
|
+
var import_react62 = __toESM(require("react"), 1);
|
|
9042
9142
|
var import_react_redux52 = require("react-redux");
|
|
9043
9143
|
var import_wallet_adapter_react8 = require("@solana/wallet-adapter-react");
|
|
9144
|
+
var import_react_hot_toast6 = __toESM(require("react-hot-toast"), 1);
|
|
9145
|
+
|
|
9146
|
+
// src/shared/lib/wallet.ts
|
|
9147
|
+
var isUserRejected = (err) => {
|
|
9148
|
+
if (!err) return false;
|
|
9149
|
+
if (err._kimaUserRejected) return true;
|
|
9150
|
+
if (err.code === 4001) return true;
|
|
9151
|
+
const msg = String(err?.message ?? err);
|
|
9152
|
+
return /UserRejected|denied|canceled|cancelled/i.test(msg);
|
|
9153
|
+
};
|
|
9044
9154
|
|
|
9045
9155
|
// src/widgets/transfer/components/solana/SolanaWalletSelect.tsx
|
|
9046
|
-
var
|
|
9156
|
+
var import_react60 = require("react");
|
|
9047
9157
|
var import_react_redux49 = require("react-redux");
|
|
9048
9158
|
var import_wallet_adapter_react6 = require("@solana/wallet-adapter-react");
|
|
9049
9159
|
var import_wallet_adapter_base = require("@solana/wallet-adapter-base");
|
|
9160
|
+
|
|
9161
|
+
// src/shared/lib/hooks/useHorizontalDragScroll.ts
|
|
9162
|
+
var import_react59 = require("react");
|
|
9163
|
+
var useHorizontalDragScroll = (ref) => {
|
|
9164
|
+
(0, import_react59.useEffect)(() => {
|
|
9165
|
+
const el = ref.current;
|
|
9166
|
+
if (!el) return;
|
|
9167
|
+
let isDown = false;
|
|
9168
|
+
let startX = 0;
|
|
9169
|
+
let scrollLeft = 0;
|
|
9170
|
+
const onMouseDown = (e) => {
|
|
9171
|
+
isDown = true;
|
|
9172
|
+
el.classList.add("active");
|
|
9173
|
+
startX = e.pageX - el.offsetLeft;
|
|
9174
|
+
scrollLeft = el.scrollLeft;
|
|
9175
|
+
};
|
|
9176
|
+
const onMouseLeave = () => {
|
|
9177
|
+
isDown = false;
|
|
9178
|
+
el.classList.remove("active");
|
|
9179
|
+
};
|
|
9180
|
+
const onMouseUp = () => {
|
|
9181
|
+
isDown = false;
|
|
9182
|
+
el.classList.remove("active");
|
|
9183
|
+
};
|
|
9184
|
+
const onMouseMove = (e) => {
|
|
9185
|
+
if (!isDown) return;
|
|
9186
|
+
e.preventDefault();
|
|
9187
|
+
const x = e.pageX - el.offsetLeft;
|
|
9188
|
+
const walk = (x - startX) * 1;
|
|
9189
|
+
el.scrollLeft = scrollLeft - walk;
|
|
9190
|
+
};
|
|
9191
|
+
el.addEventListener("mousedown", onMouseDown);
|
|
9192
|
+
el.addEventListener("mouseleave", onMouseLeave);
|
|
9193
|
+
el.addEventListener("mouseup", onMouseUp);
|
|
9194
|
+
el.addEventListener("mousemove", onMouseMove);
|
|
9195
|
+
return () => {
|
|
9196
|
+
el.removeEventListener("mousedown", onMouseDown);
|
|
9197
|
+
el.removeEventListener("mouseleave", onMouseLeave);
|
|
9198
|
+
el.removeEventListener("mouseup", onMouseUp);
|
|
9199
|
+
el.removeEventListener("mousemove", onMouseMove);
|
|
9200
|
+
};
|
|
9201
|
+
}, [ref]);
|
|
9202
|
+
};
|
|
9203
|
+
|
|
9204
|
+
// src/widgets/transfer/components/solana/SolanaWalletSelect.tsx
|
|
9205
|
+
var import_react_hot_toast4 = __toESM(require("react-hot-toast"), 1);
|
|
9050
9206
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
9051
9207
|
var SolanaWalletSelect = () => {
|
|
9052
9208
|
const theme = (0, import_react_redux49.useSelector)(selectTheme);
|
|
9053
9209
|
const sourceChain = (0, import_react_redux49.useSelector)(selectSourceChain);
|
|
9054
9210
|
const dispatch = (0, import_react_redux49.useDispatch)();
|
|
9055
|
-
const sliderRef = (0,
|
|
9211
|
+
const sliderRef = (0, import_react60.useRef)(null);
|
|
9056
9212
|
const { wallet, wallets, select, connect, connected } = (0, import_wallet_adapter_react6.useWallet)();
|
|
9057
|
-
const [detected, undetected] = (0,
|
|
9213
|
+
const [detected, undetected] = (0, import_react60.useMemo)(() => {
|
|
9058
9214
|
const detected2 = [];
|
|
9059
9215
|
const undetected2 = [];
|
|
9060
9216
|
for (const wallet2 of wallets) {
|
|
@@ -9066,39 +9222,14 @@ var SolanaWalletSelect = () => {
|
|
|
9066
9222
|
}
|
|
9067
9223
|
return [detected2, undetected2];
|
|
9068
9224
|
}, [wallets]);
|
|
9069
|
-
(
|
|
9070
|
-
|
|
9071
|
-
let startX;
|
|
9072
|
-
let scrollLeft;
|
|
9073
|
-
sliderRef.current?.addEventListener("mousedown", (e) => {
|
|
9074
|
-
isDown = true;
|
|
9075
|
-
sliderRef.current?.classList.add("active");
|
|
9076
|
-
startX = e.pageX - sliderRef.current?.offsetLeft;
|
|
9077
|
-
scrollLeft = sliderRef.current?.scrollLeft;
|
|
9078
|
-
});
|
|
9079
|
-
sliderRef.current?.addEventListener("mouseleave", () => {
|
|
9080
|
-
isDown = false;
|
|
9081
|
-
sliderRef.current.classList.remove("active");
|
|
9082
|
-
});
|
|
9083
|
-
sliderRef.current?.addEventListener("mouseup", () => {
|
|
9084
|
-
isDown = false;
|
|
9085
|
-
sliderRef.current.classList.remove("active");
|
|
9086
|
-
});
|
|
9087
|
-
sliderRef.current?.addEventListener("mousemove", (e) => {
|
|
9088
|
-
if (!isDown) return;
|
|
9089
|
-
e.preventDefault();
|
|
9090
|
-
const x = e.pageX - sliderRef.current.offsetLeft;
|
|
9091
|
-
const walk = (x - startX) * 1;
|
|
9092
|
-
sliderRef.current.scrollLeft = scrollLeft - walk;
|
|
9093
|
-
});
|
|
9094
|
-
}, []);
|
|
9095
|
-
const handleWalletClick = (0, import_react58.useCallback)(
|
|
9225
|
+
useHorizontalDragScroll(sliderRef);
|
|
9226
|
+
const handleWalletClick = (0, import_react60.useCallback)(
|
|
9096
9227
|
(walletName) => {
|
|
9097
9228
|
select(walletName);
|
|
9098
9229
|
},
|
|
9099
9230
|
[select]
|
|
9100
9231
|
);
|
|
9101
|
-
(0,
|
|
9232
|
+
(0, import_react60.useEffect)(() => {
|
|
9102
9233
|
if (!wallet) return;
|
|
9103
9234
|
if (sourceChain.shortName !== "SOL") {
|
|
9104
9235
|
return;
|
|
@@ -9108,7 +9239,14 @@ var SolanaWalletSelect = () => {
|
|
|
9108
9239
|
"SolanaWalletSelect: Wallet exists but not connected, connecting wallet:",
|
|
9109
9240
|
wallet
|
|
9110
9241
|
);
|
|
9111
|
-
connect().catch((err) =>
|
|
9242
|
+
connect().catch((err) => {
|
|
9243
|
+
if (isUserRejected(err)) {
|
|
9244
|
+
(0, import_react_hot_toast4.default)("Wallet connection was cancelled.");
|
|
9245
|
+
} else {
|
|
9246
|
+
import_react_hot_toast4.default.error("Failed to connect wallet.");
|
|
9247
|
+
}
|
|
9248
|
+
logger_default.error("Solana connect error:", err);
|
|
9249
|
+
});
|
|
9112
9250
|
}
|
|
9113
9251
|
dispatch(setSolanaConnectModal(false));
|
|
9114
9252
|
}, [wallet, sourceChain]);
|
|
@@ -9145,10 +9283,20 @@ var SolanaWalletSelect = () => {
|
|
|
9145
9283
|
var SolanaWalletSelect_default = SolanaWalletSelect;
|
|
9146
9284
|
|
|
9147
9285
|
// src/widgets/transfer/components/solana/AccountDetailsModal.tsx
|
|
9148
|
-
var
|
|
9286
|
+
var import_react61 = require("react");
|
|
9149
9287
|
var import_react_redux51 = require("react-redux");
|
|
9150
9288
|
var import_wallet_adapter_react7 = require("@solana/wallet-adapter-react");
|
|
9151
9289
|
|
|
9290
|
+
// src/shared/lib/explorers.ts
|
|
9291
|
+
var getSolanaAccountExplorerUrl = (address, networkOption) => {
|
|
9292
|
+
const cluster = networkOption === "mainnet" /* mainnet */ ? "mainnet" : "devnet";
|
|
9293
|
+
return `https://solscan.io/account/${address}?cluster=${cluster}`;
|
|
9294
|
+
};
|
|
9295
|
+
var getTronAccountExplorerUrl = (address, networkOption) => {
|
|
9296
|
+
const sub = networkOption === "testnet" /* testnet */ ? "nile." : "";
|
|
9297
|
+
return `https://${sub}tronscan.io/#/address/${address}`;
|
|
9298
|
+
};
|
|
9299
|
+
|
|
9152
9300
|
// src/widgets/transfer/components/WalletModalShell.tsx
|
|
9153
9301
|
var import_react_redux50 = require("react-redux");
|
|
9154
9302
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
@@ -9181,8 +9329,55 @@ var WalletModalShell = ({
|
|
|
9181
9329
|
};
|
|
9182
9330
|
var WalletModalShell_default = WalletModalShell;
|
|
9183
9331
|
|
|
9184
|
-
// src/widgets/transfer/components/
|
|
9332
|
+
// src/widgets/transfer/components/AccountDetailsModalBase.tsx
|
|
9185
9333
|
var import_jsx_runtime83 = require("react/jsx-runtime");
|
|
9334
|
+
var AccountDetailsModalBase = ({
|
|
9335
|
+
isOpen,
|
|
9336
|
+
onClose,
|
|
9337
|
+
themeMode,
|
|
9338
|
+
address,
|
|
9339
|
+
balance,
|
|
9340
|
+
symbol,
|
|
9341
|
+
explorerUrl,
|
|
9342
|
+
onDisconnect,
|
|
9343
|
+
disableDisconnect = false,
|
|
9344
|
+
closeButtonClassName = "cross-icon-button"
|
|
9345
|
+
}) => {
|
|
9346
|
+
const isLight = themeMode ? themeMode === "light" : true;
|
|
9347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
|
|
9348
|
+
WalletModalShell_default,
|
|
9349
|
+
{
|
|
9350
|
+
isOpen: !!isOpen,
|
|
9351
|
+
title: "Account Details",
|
|
9352
|
+
onClose,
|
|
9353
|
+
rightHeader: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("button", { className: closeButtonClassName, onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Cross_default, { fill: isLight ? "black" : "white" }) }),
|
|
9354
|
+
children: [
|
|
9355
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "summary", children: [
|
|
9356
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "address", children: [
|
|
9357
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)("h2", { children: address ? getShortenedAddress(address) : "\u2014" }),
|
|
9358
|
+
address && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(CopyButton_default, { text: address })
|
|
9359
|
+
] }),
|
|
9360
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("h3", { children: [
|
|
9361
|
+
formatterFloat.format(Number(balance || 0)),
|
|
9362
|
+
" ",
|
|
9363
|
+
symbol
|
|
9364
|
+
] })
|
|
9365
|
+
] }),
|
|
9366
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SecondaryButton_default, { className: "block-explorer", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(ExternalLink_default, { className: "link", to: explorerUrl, children: [
|
|
9367
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Explorer_default, { fill: "#778DA3" }),
|
|
9368
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: "Block explorer" }),
|
|
9369
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ExternalUrl_default, { fill: "#778DA3" })
|
|
9370
|
+
] }) }),
|
|
9371
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(PrimaryButton_default, { clickHandler: onDisconnect, disabled: disableDisconnect, children: "Disconnect" })
|
|
9372
|
+
]
|
|
9373
|
+
}
|
|
9374
|
+
);
|
|
9375
|
+
};
|
|
9376
|
+
var AccountDetailsModalBase_default = AccountDetailsModalBase;
|
|
9377
|
+
|
|
9378
|
+
// src/widgets/transfer/components/solana/AccountDetailsModal.tsx
|
|
9379
|
+
var import_react_hot_toast5 = __toESM(require("react-hot-toast"), 1);
|
|
9380
|
+
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
9186
9381
|
var AccountDetailsModal = () => {
|
|
9187
9382
|
const dispatch = (0, import_react_redux51.useDispatch)();
|
|
9188
9383
|
const theme = (0, import_react_redux51.useSelector)(selectTheme);
|
|
@@ -9195,10 +9390,10 @@ var AccountDetailsModal = () => {
|
|
|
9195
9390
|
const { balance: solBalance } = useSolNativeBalance();
|
|
9196
9391
|
const isSol = sourceChain.shortName === "SOL" /* SOLANA */;
|
|
9197
9392
|
if (!isSol) return null;
|
|
9198
|
-
const explorerUrl = (0,
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9393
|
+
const explorerUrl = (0, import_react61.useMemo)(
|
|
9394
|
+
() => getSolanaAccountExplorerUrl(sourceAddress, networkOption),
|
|
9395
|
+
[sourceAddress, networkOption]
|
|
9396
|
+
);
|
|
9202
9397
|
const close = () => dispatch(setAccountDetailsModal(false));
|
|
9203
9398
|
const handleDisconnect = async () => {
|
|
9204
9399
|
if (mode === "light" /* light */) {
|
|
@@ -9208,50 +9403,36 @@ var AccountDetailsModal = () => {
|
|
|
9208
9403
|
}
|
|
9209
9404
|
try {
|
|
9210
9405
|
await solanaWalletDisconnect();
|
|
9406
|
+
(0, import_react_hot_toast5.default)("Wallet disconnected.");
|
|
9211
9407
|
} catch (e) {
|
|
9408
|
+
if (isUserRejected(e)) {
|
|
9409
|
+
(0, import_react_hot_toast5.default)("Wallet disconnect was cancelled.");
|
|
9410
|
+
} else {
|
|
9411
|
+
import_react_hot_toast5.default.error("Failed to disconnect wallet.", { icon: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Error_default, {}) });
|
|
9412
|
+
}
|
|
9212
9413
|
} finally {
|
|
9213
9414
|
close();
|
|
9214
9415
|
}
|
|
9215
9416
|
};
|
|
9216
|
-
return /* @__PURE__ */ (0,
|
|
9217
|
-
|
|
9417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
9418
|
+
AccountDetailsModalBase_default,
|
|
9218
9419
|
{
|
|
9219
9420
|
isOpen: !!isOpen,
|
|
9220
|
-
title: "Account Details",
|
|
9221
9421
|
onClose: close,
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("h3", { children: [
|
|
9230
|
-
formatterFloat.format(Number(solBalance || 0)),
|
|
9231
|
-
" SOL"
|
|
9232
|
-
] })
|
|
9233
|
-
] }),
|
|
9234
|
-
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SecondaryButton_default, { className: "block-explorer", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(ExternalLink_default, { className: "link", to: explorerUrl, children: [
|
|
9235
|
-
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Explorer_default, { fill: "#778DA3" }),
|
|
9236
|
-
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: "Block explorer" }),
|
|
9237
|
-
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ExternalUrl_default, { fill: "#778DA3" })
|
|
9238
|
-
] }) }),
|
|
9239
|
-
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
9240
|
-
PrimaryButton_default,
|
|
9241
|
-
{
|
|
9242
|
-
clickHandler: handleDisconnect,
|
|
9243
|
-
disabled: mode === "light" /* light */,
|
|
9244
|
-
children: "Disconnect"
|
|
9245
|
-
}
|
|
9246
|
-
)
|
|
9247
|
-
]
|
|
9422
|
+
themeMode: theme.colorMode,
|
|
9423
|
+
address: sourceAddress,
|
|
9424
|
+
balance: solBalance,
|
|
9425
|
+
symbol: "SOL",
|
|
9426
|
+
explorerUrl,
|
|
9427
|
+
onDisconnect: handleDisconnect,
|
|
9428
|
+
disableDisconnect: mode === "light" /* light */
|
|
9248
9429
|
}
|
|
9249
9430
|
);
|
|
9250
9431
|
};
|
|
9251
9432
|
var AccountDetailsModal_default = AccountDetailsModal;
|
|
9252
9433
|
|
|
9253
9434
|
// src/widgets/transfer/components/solana/SolanaConnectModal.tsx
|
|
9254
|
-
var
|
|
9435
|
+
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
9255
9436
|
var SolanaWalletConnectModal = () => {
|
|
9256
9437
|
const dispatch = (0, import_react_redux52.useDispatch)();
|
|
9257
9438
|
const theme = (0, import_react_redux52.useSelector)(selectTheme);
|
|
@@ -9260,17 +9441,17 @@ var SolanaWalletConnectModal = () => {
|
|
|
9260
9441
|
const sourceChain = (0, import_react_redux52.useSelector)(selectSourceChain);
|
|
9261
9442
|
const { connect, connecting, connected, publicKey } = (0, import_wallet_adapter_react8.useWallet)();
|
|
9262
9443
|
const isSol = sourceChain.shortName === "SOL" /* SOLANA */;
|
|
9263
|
-
const close = (0,
|
|
9444
|
+
const close = (0, import_react62.useCallback)(() => {
|
|
9264
9445
|
dispatch(setSolanaConnectModal(false));
|
|
9265
9446
|
}, [dispatch]);
|
|
9266
|
-
|
|
9447
|
+
import_react62.default.useEffect(() => {
|
|
9267
9448
|
logger_default.debug("[SolanaConnectModal] wallet-adapter state", {
|
|
9268
9449
|
connecting,
|
|
9269
9450
|
connected,
|
|
9270
9451
|
publicKey: publicKey?.toBase58?.()
|
|
9271
9452
|
});
|
|
9272
9453
|
}, [connecting, connected, publicKey]);
|
|
9273
|
-
const onConnect = (0,
|
|
9454
|
+
const onConnect = (0, import_react62.useCallback)(async () => {
|
|
9274
9455
|
if (!isSol) return;
|
|
9275
9456
|
if (mode === "light" /* light */) {
|
|
9276
9457
|
logger_default.debug("[SolanaConnectModal] LIGHT mode \u2192 skip connect, open details");
|
|
@@ -9282,24 +9463,30 @@ var SolanaWalletConnectModal = () => {
|
|
|
9282
9463
|
await connect();
|
|
9283
9464
|
dispatch(setSolanaConnectModal(false));
|
|
9284
9465
|
dispatch(setAccountDetailsModal(true));
|
|
9466
|
+
(0, import_react_hot_toast6.default)("Wallet connected.");
|
|
9285
9467
|
} catch (e) {
|
|
9468
|
+
if (isUserRejected(e)) {
|
|
9469
|
+
(0, import_react_hot_toast6.default)("Wallet connection was cancelled.");
|
|
9470
|
+
} else {
|
|
9471
|
+
import_react_hot_toast6.default.error("Failed to connect wallet.", { icon: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Error_default, {}) });
|
|
9472
|
+
}
|
|
9286
9473
|
logger_default.error("[SolanaConnectModal] connect error", e);
|
|
9287
9474
|
}
|
|
9288
9475
|
}, [isSol, mode, connect, dispatch]);
|
|
9289
|
-
const demoMsg = (0,
|
|
9476
|
+
const demoMsg = (0, import_react62.useMemo)(
|
|
9290
9477
|
() => mode === "light" /* light */ ? `Light mode uses a demo Solana address (${lightDemoAccounts.SOL}).` : "",
|
|
9291
9478
|
[mode]
|
|
9292
9479
|
);
|
|
9293
|
-
return /* @__PURE__ */ (0,
|
|
9294
|
-
/* @__PURE__ */ (0,
|
|
9295
|
-
/* @__PURE__ */ (0,
|
|
9480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
|
|
9481
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(AccountDetailsModal_default, {}),
|
|
9482
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
|
|
9296
9483
|
WalletModalShell_default,
|
|
9297
9484
|
{
|
|
9298
9485
|
isOpen: !!isOpen,
|
|
9299
9486
|
title: "Connect Wallet",
|
|
9300
9487
|
onClose: close,
|
|
9301
9488
|
className: "wallet-connect",
|
|
9302
|
-
rightHeader: /* @__PURE__ */ (0,
|
|
9489
|
+
rightHeader: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("button", { className: "cross-icon-button", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
9303
9490
|
Cross_default,
|
|
9304
9491
|
{
|
|
9305
9492
|
width: 30,
|
|
@@ -9308,10 +9495,10 @@ var SolanaWalletConnectModal = () => {
|
|
|
9308
9495
|
}
|
|
9309
9496
|
) }),
|
|
9310
9497
|
children: [
|
|
9311
|
-
demoMsg && /* @__PURE__ */ (0,
|
|
9312
|
-
mode !== "light" /* light */ ? /* @__PURE__ */ (0,
|
|
9313
|
-
/* @__PURE__ */ (0,
|
|
9314
|
-
/* @__PURE__ */ (0,
|
|
9498
|
+
demoMsg && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { className: "muted", children: demoMsg }),
|
|
9499
|
+
mode !== "light" /* light */ ? /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
|
|
9500
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(SolanaWalletSelect_default, {}),
|
|
9501
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
9315
9502
|
"button",
|
|
9316
9503
|
{
|
|
9317
9504
|
className: "primary",
|
|
@@ -9320,8 +9507,8 @@ var SolanaWalletConnectModal = () => {
|
|
|
9320
9507
|
children: connecting ? "Connecting\u2026" : connected ? "Connected" : "Connect"
|
|
9321
9508
|
}
|
|
9322
9509
|
) })
|
|
9323
|
-
] }) : /* @__PURE__ */ (0,
|
|
9324
|
-
/* @__PURE__ */ (0,
|
|
9510
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)("div", { style: { display: "flex", gap: 8 }, children: [
|
|
9511
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
9325
9512
|
"button",
|
|
9326
9513
|
{
|
|
9327
9514
|
className: "secondary",
|
|
@@ -9329,7 +9516,7 @@ var SolanaWalletConnectModal = () => {
|
|
|
9329
9516
|
children: "View Account"
|
|
9330
9517
|
}
|
|
9331
9518
|
),
|
|
9332
|
-
/* @__PURE__ */ (0,
|
|
9519
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)("button", { className: "primary", onClick: close, children: "Close" })
|
|
9333
9520
|
] })
|
|
9334
9521
|
]
|
|
9335
9522
|
}
|
|
@@ -9339,15 +9526,17 @@ var SolanaWalletConnectModal = () => {
|
|
|
9339
9526
|
var SolanaConnectModal_default = SolanaWalletConnectModal;
|
|
9340
9527
|
|
|
9341
9528
|
// src/widgets/transfer/components/tron/TronWalletConnectModal.tsx
|
|
9342
|
-
var
|
|
9529
|
+
var import_react65 = require("react");
|
|
9343
9530
|
var import_react_redux55 = require("react-redux");
|
|
9344
9531
|
var import_tronwallet_adapter_react_hooks8 = require("@tronweb3/tronwallet-adapter-react-hooks");
|
|
9532
|
+
var import_react_hot_toast9 = __toESM(require("react-hot-toast"), 1);
|
|
9345
9533
|
|
|
9346
9534
|
// src/widgets/transfer/components/tron/AccountDetailsModal.tsx
|
|
9347
|
-
var
|
|
9535
|
+
var import_react63 = require("react");
|
|
9348
9536
|
var import_react_redux53 = require("react-redux");
|
|
9349
9537
|
var import_tronwallet_adapter_react_hooks6 = require("@tronweb3/tronwallet-adapter-react-hooks");
|
|
9350
|
-
var
|
|
9538
|
+
var import_react_hot_toast7 = __toESM(require("react-hot-toast"), 1);
|
|
9539
|
+
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
9351
9540
|
var AccountDetailsModal2 = () => {
|
|
9352
9541
|
const dispatch = (0, import_react_redux53.useDispatch)();
|
|
9353
9542
|
const theme = (0, import_react_redux53.useSelector)(selectTheme);
|
|
@@ -9360,10 +9549,10 @@ var AccountDetailsModal2 = () => {
|
|
|
9360
9549
|
const { balance: tronBalance } = useTronNativeBalance();
|
|
9361
9550
|
const isTrx = sourceChain.shortName === "TRX" /* TRON */;
|
|
9362
9551
|
if (!isTrx) return null;
|
|
9363
|
-
const explorerUrl = (0,
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9552
|
+
const explorerUrl = (0, import_react63.useMemo)(
|
|
9553
|
+
() => getTronAccountExplorerUrl(sourceAddress, networkOption),
|
|
9554
|
+
[sourceAddress, networkOption]
|
|
9555
|
+
);
|
|
9367
9556
|
const close = () => dispatch(setAccountDetailsModal(false));
|
|
9368
9557
|
const handleDisconnect = async () => {
|
|
9369
9558
|
if (mode === "light" /* light */) {
|
|
@@ -9373,57 +9562,44 @@ var AccountDetailsModal2 = () => {
|
|
|
9373
9562
|
}
|
|
9374
9563
|
try {
|
|
9375
9564
|
await tronWalletDisconnect();
|
|
9565
|
+
(0, import_react_hot_toast7.default)("Wallet disconnected.");
|
|
9376
9566
|
} catch (e) {
|
|
9567
|
+
if (isUserRejected(e)) {
|
|
9568
|
+
(0, import_react_hot_toast7.default)("Wallet disconnect was cancelled.");
|
|
9569
|
+
} else {
|
|
9570
|
+
import_react_hot_toast7.default.error("Failed to disconnect wallet.", { icon: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Error_default, {}) });
|
|
9571
|
+
}
|
|
9377
9572
|
} finally {
|
|
9378
9573
|
close();
|
|
9379
9574
|
}
|
|
9380
9575
|
};
|
|
9381
|
-
return /* @__PURE__ */ (0,
|
|
9382
|
-
|
|
9576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
|
|
9577
|
+
AccountDetailsModalBase_default,
|
|
9383
9578
|
{
|
|
9384
9579
|
isOpen: !!isOpen,
|
|
9385
|
-
title: "Account Details",
|
|
9386
9580
|
onClose: close,
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsxs)("h3", { children: [
|
|
9395
|
-
formatterFloat.format(Number(tronBalance || 0)),
|
|
9396
|
-
" TRX"
|
|
9397
|
-
] })
|
|
9398
|
-
] }),
|
|
9399
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(SecondaryButton_default, { className: "block-explorer", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(ExternalLink_default, { className: "link", to: explorerUrl, children: [
|
|
9400
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Explorer_default, { fill: "#778DA3" }),
|
|
9401
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { children: "Block explorer" }),
|
|
9402
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ExternalUrl_default, { fill: "#778DA3" })
|
|
9403
|
-
] }) }),
|
|
9404
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
9405
|
-
PrimaryButton_default,
|
|
9406
|
-
{
|
|
9407
|
-
clickHandler: handleDisconnect,
|
|
9408
|
-
disabled: mode === "light" /* light */,
|
|
9409
|
-
children: "Disconnect"
|
|
9410
|
-
}
|
|
9411
|
-
)
|
|
9412
|
-
]
|
|
9581
|
+
themeMode: theme.colorMode,
|
|
9582
|
+
address: sourceAddress,
|
|
9583
|
+
balance: tronBalance,
|
|
9584
|
+
symbol: "TRX",
|
|
9585
|
+
explorerUrl,
|
|
9586
|
+
onDisconnect: handleDisconnect,
|
|
9587
|
+
disableDisconnect: mode === "light" /* light */
|
|
9413
9588
|
}
|
|
9414
9589
|
);
|
|
9415
9590
|
};
|
|
9416
9591
|
var AccountDetailsModal_default2 = AccountDetailsModal2;
|
|
9417
9592
|
|
|
9418
9593
|
// src/widgets/transfer/components/tron/TronWalletSelect.tsx
|
|
9419
|
-
var
|
|
9594
|
+
var import_react64 = require("react");
|
|
9420
9595
|
var import_react_redux54 = require("react-redux");
|
|
9421
9596
|
var import_tronwallet_adapter_react_hooks7 = require("@tronweb3/tronwallet-adapter-react-hooks");
|
|
9422
9597
|
var import_tronwallet_abstract_adapter = require("@tronweb3/tronwallet-abstract-adapter");
|
|
9423
|
-
var
|
|
9598
|
+
var import_react_hot_toast8 = __toESM(require("react-hot-toast"), 1);
|
|
9599
|
+
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
9424
9600
|
var TronWalletSelect = () => {
|
|
9425
9601
|
const theme = (0, import_react_redux54.useSelector)(selectTheme);
|
|
9426
|
-
const sliderRef = (0,
|
|
9602
|
+
const sliderRef = (0, import_react64.useRef)(null);
|
|
9427
9603
|
const dispatch = (0, import_react_redux54.useDispatch)();
|
|
9428
9604
|
const {
|
|
9429
9605
|
wallets,
|
|
@@ -9432,7 +9608,7 @@ var TronWalletSelect = () => {
|
|
|
9432
9608
|
connect,
|
|
9433
9609
|
connected
|
|
9434
9610
|
} = (0, import_tronwallet_adapter_react_hooks7.useWallet)();
|
|
9435
|
-
const [detected, undetected] = (0,
|
|
9611
|
+
const [detected, undetected] = (0, import_react64.useMemo)(() => {
|
|
9436
9612
|
const detected2 = [];
|
|
9437
9613
|
const undetected2 = [];
|
|
9438
9614
|
for (const wallet of wallets) {
|
|
@@ -9444,59 +9620,46 @@ var TronWalletSelect = () => {
|
|
|
9444
9620
|
}
|
|
9445
9621
|
return [detected2, undetected2];
|
|
9446
9622
|
}, [wallets]);
|
|
9447
|
-
(
|
|
9448
|
-
|
|
9449
|
-
let startX;
|
|
9450
|
-
let scrollLeft;
|
|
9451
|
-
sliderRef.current?.addEventListener("mousedown", (e) => {
|
|
9452
|
-
isDown = true;
|
|
9453
|
-
sliderRef.current?.classList.add("active");
|
|
9454
|
-
startX = e.pageX - sliderRef.current?.offsetLeft;
|
|
9455
|
-
scrollLeft = sliderRef.current?.scrollLeft;
|
|
9456
|
-
});
|
|
9457
|
-
sliderRef.current?.addEventListener("mouseleave", () => {
|
|
9458
|
-
isDown = false;
|
|
9459
|
-
sliderRef.current.classList.remove("active");
|
|
9460
|
-
});
|
|
9461
|
-
sliderRef.current?.addEventListener("mouseup", () => {
|
|
9462
|
-
isDown = false;
|
|
9463
|
-
sliderRef.current.classList.remove("active");
|
|
9464
|
-
});
|
|
9465
|
-
sliderRef.current?.addEventListener("mousemove", (e) => {
|
|
9466
|
-
if (!isDown) return;
|
|
9467
|
-
e.preventDefault();
|
|
9468
|
-
const x = e.pageX - sliderRef.current.offsetLeft;
|
|
9469
|
-
const walk = (x - startX) * 1;
|
|
9470
|
-
sliderRef.current.scrollLeft = scrollLeft - walk;
|
|
9471
|
-
});
|
|
9472
|
-
}, []);
|
|
9473
|
-
(0, import_react62.useEffect)(() => {
|
|
9623
|
+
useHorizontalDragScroll(sliderRef);
|
|
9624
|
+
(0, import_react64.useEffect)(() => {
|
|
9474
9625
|
connected && dispatch(setTronConnectModal(false));
|
|
9475
9626
|
}, [connected]);
|
|
9476
9627
|
const connectWallet = async (walletName) => {
|
|
9477
|
-
|
|
9628
|
+
try {
|
|
9629
|
+
if (currentWallet?.adapter.name === walletName) {
|
|
9630
|
+
await connect();
|
|
9631
|
+
} else {
|
|
9632
|
+
select(walletName);
|
|
9633
|
+
}
|
|
9634
|
+
} catch (err) {
|
|
9635
|
+
if (isUserRejected(err)) {
|
|
9636
|
+
(0, import_react_hot_toast8.default)("Wallet connection was cancelled.");
|
|
9637
|
+
} else {
|
|
9638
|
+
import_react_hot_toast8.default.error("Failed to connect wallet.");
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9478
9641
|
};
|
|
9479
|
-
return /* @__PURE__ */ (0,
|
|
9480
|
-
detected.map((wallet, index) => /* @__PURE__ */ (0,
|
|
9642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: `wallet-select`, children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "slide-area hide-scrollbar", ref: sliderRef, children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "wallet-container", children: [
|
|
9643
|
+
detected.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
9481
9644
|
"div",
|
|
9482
9645
|
{
|
|
9483
9646
|
className: `card-item ${theme.colorMode}`,
|
|
9484
9647
|
onClick: () => connectWallet(wallet.adapter.name),
|
|
9485
|
-
children: /* @__PURE__ */ (0,
|
|
9486
|
-
/* @__PURE__ */ (0,
|
|
9487
|
-
/* @__PURE__ */ (0,
|
|
9648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "wallet-item", children: [
|
|
9649
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)("img", { src: wallet.adapter.icon, alt: wallet.adapter.name }),
|
|
9650
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { children: wallet.adapter.name })
|
|
9488
9651
|
] })
|
|
9489
9652
|
},
|
|
9490
9653
|
`${wallet.adapter.name}-${index}`
|
|
9491
9654
|
)),
|
|
9492
|
-
undetected.map((wallet, index) => /* @__PURE__ */ (0,
|
|
9655
|
+
undetected.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
9493
9656
|
ExternalLink_default,
|
|
9494
9657
|
{
|
|
9495
9658
|
to: wallet.adapter.url,
|
|
9496
9659
|
className: `card-item ${theme.colorMode}`,
|
|
9497
|
-
children: /* @__PURE__ */ (0,
|
|
9498
|
-
/* @__PURE__ */ (0,
|
|
9499
|
-
/* @__PURE__ */ (0,
|
|
9660
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "wallet-item", children: [
|
|
9661
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)("img", { src: wallet.adapter.icon, alt: wallet.adapter.name }),
|
|
9662
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("span", { children: [
|
|
9500
9663
|
"Install ",
|
|
9501
9664
|
wallet.adapter.name
|
|
9502
9665
|
] })
|
|
@@ -9509,7 +9672,7 @@ var TronWalletSelect = () => {
|
|
|
9509
9672
|
var TronWalletSelect_default = TronWalletSelect;
|
|
9510
9673
|
|
|
9511
9674
|
// src/widgets/transfer/components/tron/TronWalletConnectModal.tsx
|
|
9512
|
-
var
|
|
9675
|
+
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
9513
9676
|
var TronWalletConnectModal = () => {
|
|
9514
9677
|
const dispatch = (0, import_react_redux55.useDispatch)();
|
|
9515
9678
|
const theme = (0, import_react_redux55.useSelector)(selectTheme);
|
|
@@ -9518,10 +9681,10 @@ var TronWalletConnectModal = () => {
|
|
|
9518
9681
|
const sourceChain = (0, import_react_redux55.useSelector)(selectSourceChain);
|
|
9519
9682
|
const { connect, connected, connecting } = (0, import_tronwallet_adapter_react_hooks8.useWallet)();
|
|
9520
9683
|
const isTrx = sourceChain.shortName === "TRX" /* TRON */;
|
|
9521
|
-
const close = (0,
|
|
9684
|
+
const close = (0, import_react65.useCallback)(() => {
|
|
9522
9685
|
dispatch(setTronConnectModal(false));
|
|
9523
9686
|
}, [dispatch]);
|
|
9524
|
-
const onConnect = (0,
|
|
9687
|
+
const onConnect = (0, import_react65.useCallback)(async () => {
|
|
9525
9688
|
if (!isTrx) return;
|
|
9526
9689
|
if (mode === "light" /* light */) {
|
|
9527
9690
|
logger_default.debug("[TronConnectModal] LIGHT mode \u2192 skip connect, open details");
|
|
@@ -9533,29 +9696,35 @@ var TronWalletConnectModal = () => {
|
|
|
9533
9696
|
await connect();
|
|
9534
9697
|
dispatch(setTronConnectModal(false));
|
|
9535
9698
|
dispatch(setAccountDetailsModal(true));
|
|
9699
|
+
(0, import_react_hot_toast9.default)("Wallet connected.");
|
|
9536
9700
|
} catch (e) {
|
|
9701
|
+
if (isUserRejected(e)) {
|
|
9702
|
+
(0, import_react_hot_toast9.default)("Wallet connection was cancelled.");
|
|
9703
|
+
} else {
|
|
9704
|
+
import_react_hot_toast9.default.error("Failed to connect wallet.", { icon: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Error_default, {}) });
|
|
9705
|
+
}
|
|
9537
9706
|
logger_default.error("[TronConnectModal] connect error", e);
|
|
9538
9707
|
}
|
|
9539
9708
|
}, [isTrx, mode, connect, dispatch]);
|
|
9540
|
-
const demoMsg = (0,
|
|
9709
|
+
const demoMsg = (0, import_react65.useMemo)(
|
|
9541
9710
|
() => mode === "light" /* light */ ? `Light mode uses a demo Tron address (${lightDemoAccounts.TRX}).` : "",
|
|
9542
9711
|
[mode]
|
|
9543
9712
|
);
|
|
9544
|
-
return /* @__PURE__ */ (0,
|
|
9545
|
-
/* @__PURE__ */ (0,
|
|
9546
|
-
/* @__PURE__ */ (0,
|
|
9713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
|
|
9714
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(AccountDetailsModal_default2, {}),
|
|
9715
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
|
|
9547
9716
|
WalletModalShell_default,
|
|
9548
9717
|
{
|
|
9549
9718
|
isOpen: !!isOpen,
|
|
9550
9719
|
title: "Connect Wallet",
|
|
9551
9720
|
onClose: close,
|
|
9552
9721
|
className: "wallet-connect",
|
|
9553
|
-
rightHeader: /* @__PURE__ */ (0,
|
|
9722
|
+
rightHeader: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("button", { className: "icon-button", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Cross_default, { fill: theme.colorMode === "light" ? "black" : "white" }) }),
|
|
9554
9723
|
children: [
|
|
9555
|
-
demoMsg && /* @__PURE__ */ (0,
|
|
9556
|
-
mode !== "light" /* light */ ? /* @__PURE__ */ (0,
|
|
9557
|
-
/* @__PURE__ */ (0,
|
|
9558
|
-
/* @__PURE__ */ (0,
|
|
9724
|
+
demoMsg && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { className: "muted", children: demoMsg }),
|
|
9725
|
+
mode !== "light" /* light */ ? /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
|
|
9726
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TronWalletSelect_default, {}),
|
|
9727
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
9559
9728
|
"button",
|
|
9560
9729
|
{
|
|
9561
9730
|
className: "primary",
|
|
@@ -9564,8 +9733,8 @@ var TronWalletConnectModal = () => {
|
|
|
9564
9733
|
children: connecting ? "Connecting\u2026" : connected ? "Connected" : "Connect"
|
|
9565
9734
|
}
|
|
9566
9735
|
) })
|
|
9567
|
-
] }) : /* @__PURE__ */ (0,
|
|
9568
|
-
/* @__PURE__ */ (0,
|
|
9736
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { style: { display: "flex", gap: 8 }, children: [
|
|
9737
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
9569
9738
|
"button",
|
|
9570
9739
|
{
|
|
9571
9740
|
className: "secondary",
|
|
@@ -9573,7 +9742,7 @@ var TronWalletConnectModal = () => {
|
|
|
9573
9742
|
children: "View Account"
|
|
9574
9743
|
}
|
|
9575
9744
|
),
|
|
9576
|
-
/* @__PURE__ */ (0,
|
|
9745
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)("button", { className: "primary", onClick: close, children: "Close" })
|
|
9577
9746
|
] })
|
|
9578
9747
|
]
|
|
9579
9748
|
}
|
|
@@ -9583,7 +9752,7 @@ var TronWalletConnectModal = () => {
|
|
|
9583
9752
|
var TronWalletConnectModal_default = TronWalletConnectModal;
|
|
9584
9753
|
|
|
9585
9754
|
// src/widgets/transfer/components/TransferWidget.tsx
|
|
9586
|
-
var
|
|
9755
|
+
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
9587
9756
|
var TransferWidget = ({
|
|
9588
9757
|
theme,
|
|
9589
9758
|
helpURL,
|
|
@@ -9592,16 +9761,16 @@ var TransferWidget = ({
|
|
|
9592
9761
|
}) => {
|
|
9593
9762
|
logger_default.debug("[TransferWidget] mount");
|
|
9594
9763
|
const dispatch = (0, import_react_redux56.useDispatch)();
|
|
9595
|
-
const mainRef = (0,
|
|
9596
|
-
const [signature, setSignature2] = (0,
|
|
9597
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
9598
|
-
const [formStep, setFormStep] = (0,
|
|
9599
|
-
const [warningModalOpen, setWarningModalOpen] = (0,
|
|
9600
|
-
const [resetModalOpen, setResetModalOpen] = (0,
|
|
9601
|
-
const [isCancellingApprove, setCancellingApprove] = (0,
|
|
9602
|
-
const [isApproving, setApproving] = (0,
|
|
9603
|
-
const [isSigning, setSigning] = (0,
|
|
9604
|
-
const [feeOptionDisabled, setFeeOptionDisabled] = (0,
|
|
9764
|
+
const mainRef = (0, import_react66.useRef)(null);
|
|
9765
|
+
const [signature, setSignature2] = (0, import_react66.useState)("");
|
|
9766
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react66.useState)(false);
|
|
9767
|
+
const [formStep, setFormStep] = (0, import_react66.useState)(0);
|
|
9768
|
+
const [warningModalOpen, setWarningModalOpen] = (0, import_react66.useState)(null);
|
|
9769
|
+
const [resetModalOpen, setResetModalOpen] = (0, import_react66.useState)(false);
|
|
9770
|
+
const [isCancellingApprove, setCancellingApprove] = (0, import_react66.useState)(false);
|
|
9771
|
+
const [isApproving, setApproving] = (0, import_react66.useState)(false);
|
|
9772
|
+
const [isSigning, setSigning] = (0, import_react66.useState)(false);
|
|
9773
|
+
const [feeOptionDisabled, setFeeOptionDisabled] = (0, import_react66.useState)(false);
|
|
9605
9774
|
const networkOption = (0, import_react_redux56.useSelector)(selectNetworkOption);
|
|
9606
9775
|
const dAppOption = (0, import_react_redux56.useSelector)(selectDappOption);
|
|
9607
9776
|
const mode = (0, import_react_redux56.useSelector)(selectMode);
|
|
@@ -9649,7 +9818,16 @@ var TransferWidget = ({
|
|
|
9649
9818
|
targetSymbol: targetCurrency,
|
|
9650
9819
|
backendUrl
|
|
9651
9820
|
});
|
|
9652
|
-
(0,
|
|
9821
|
+
const isSwap = (0, import_react66.useMemo)(
|
|
9822
|
+
() => !isSamePeggedToken(
|
|
9823
|
+
sourceChain,
|
|
9824
|
+
sourceCurrency,
|
|
9825
|
+
targetChain,
|
|
9826
|
+
targetCurrency
|
|
9827
|
+
),
|
|
9828
|
+
[sourceChain, sourceCurrency, targetChain, targetCurrency]
|
|
9829
|
+
);
|
|
9830
|
+
(0, import_react66.useEffect)(() => {
|
|
9653
9831
|
setSignature2("");
|
|
9654
9832
|
setFeeOptionDisabled(false);
|
|
9655
9833
|
setApproving(false);
|
|
@@ -9660,7 +9838,7 @@ var TransferWidget = ({
|
|
|
9660
9838
|
targetChain.shortName,
|
|
9661
9839
|
targetCurrency
|
|
9662
9840
|
]);
|
|
9663
|
-
(0,
|
|
9841
|
+
(0, import_react66.useEffect)(() => {
|
|
9664
9842
|
try {
|
|
9665
9843
|
if (fees) dispatch(setServiceFee(fees));
|
|
9666
9844
|
if (transactionOption?.sourceChain) {
|
|
@@ -9674,13 +9852,13 @@ var TransferWidget = ({
|
|
|
9674
9852
|
"[TransferWidget] failed to apply fees/update initial selection",
|
|
9675
9853
|
e
|
|
9676
9854
|
);
|
|
9677
|
-
|
|
9855
|
+
import_react_hot_toast10.default.error(
|
|
9678
9856
|
"An unexpected error occurred while preparing the transfer. Please contact support for assistance.",
|
|
9679
|
-
{ icon: /* @__PURE__ */ (0,
|
|
9857
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9680
9858
|
);
|
|
9681
9859
|
}
|
|
9682
9860
|
}, [fees, mode, transactionOption, dispatch]);
|
|
9683
|
-
const isBackButtonEnabled = (0,
|
|
9861
|
+
const isBackButtonEnabled = (0, import_react66.useMemo)(() => {
|
|
9684
9862
|
if (formStep !== 0) {
|
|
9685
9863
|
if (["BANK", "CC"].includes(sourceChain.shortName)) {
|
|
9686
9864
|
return ccTransactionStatus === "idle" || ccTransactionStatus === "failed";
|
|
@@ -9689,14 +9867,14 @@ var TransferWidget = ({
|
|
|
9689
9867
|
}
|
|
9690
9868
|
return false;
|
|
9691
9869
|
}, [ccTransactionStatus, sourceChain, formStep]);
|
|
9692
|
-
const isSubmitButtonEnabled = (0,
|
|
9870
|
+
const isSubmitButtonEnabled = (0, import_react66.useMemo)(() => {
|
|
9693
9871
|
if (submitted) return false;
|
|
9694
9872
|
if (["BANK", "CC"].includes(sourceChain.shortName)) {
|
|
9695
9873
|
return ccTransactionStatus === "idle";
|
|
9696
9874
|
}
|
|
9697
9875
|
return true;
|
|
9698
9876
|
}, [sourceChain, ccTransactionStatus, submitted]);
|
|
9699
|
-
const [initialSelection, setInitialSelection] = (0,
|
|
9877
|
+
const [initialSelection, setInitialSelection] = (0, import_react66.useState)({
|
|
9700
9878
|
sourceSelection: true,
|
|
9701
9879
|
targetSelection: true
|
|
9702
9880
|
});
|
|
@@ -9727,22 +9905,61 @@ var TransferWidget = ({
|
|
|
9727
9905
|
isSubmitting,
|
|
9728
9906
|
setIsSubmitting
|
|
9729
9907
|
);
|
|
9730
|
-
const submit = (0,
|
|
9908
|
+
const submit = (0, import_react66.useCallback)(async () => {
|
|
9731
9909
|
try {
|
|
9732
9910
|
await submitTransaction(signature);
|
|
9733
9911
|
} catch (err) {
|
|
9734
9912
|
logger_default.error("[TransferWidget] submit failed", err);
|
|
9735
|
-
|
|
9913
|
+
import_react_hot_toast10.default.error(
|
|
9736
9914
|
"Failed to submit your transaction. Please contact support for assistance.",
|
|
9737
|
-
{ icon: /* @__PURE__ */ (0,
|
|
9915
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9738
9916
|
);
|
|
9739
9917
|
dispatch(setCCTransactionStatus("error-generic"));
|
|
9740
9918
|
}
|
|
9741
9919
|
}, [signature, submitTransaction, dispatch]);
|
|
9920
|
+
const requestSignature = (0, import_react66.useCallback)(async () => {
|
|
9921
|
+
let sig;
|
|
9922
|
+
setSigning(true);
|
|
9923
|
+
setFeeOptionDisabled(true);
|
|
9924
|
+
try {
|
|
9925
|
+
sig = await signMessage?.({
|
|
9926
|
+
targetAddress,
|
|
9927
|
+
targetChain: targetChain.shortName,
|
|
9928
|
+
originSymbol: sourceCurrency,
|
|
9929
|
+
originChain: sourceChain.shortName
|
|
9930
|
+
});
|
|
9931
|
+
if (!sig) {
|
|
9932
|
+
(0, import_react_hot_toast10.default)("Signature request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9933
|
+
return void 0;
|
|
9934
|
+
}
|
|
9935
|
+
setSignature2(sig);
|
|
9936
|
+
return sig;
|
|
9937
|
+
} catch (err) {
|
|
9938
|
+
if (isUserRejected(err)) {
|
|
9939
|
+
(0, import_react_hot_toast10.default)("Signature request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9940
|
+
} else {
|
|
9941
|
+
logger_default.error("[TransferWidget] signing failed", err);
|
|
9942
|
+
import_react_hot_toast10.default.error(
|
|
9943
|
+
"Failed to sign the message. Please contact support for assistance.",
|
|
9944
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9945
|
+
);
|
|
9946
|
+
}
|
|
9947
|
+
return void 0;
|
|
9948
|
+
} finally {
|
|
9949
|
+
setSigning(false);
|
|
9950
|
+
if (!sig) setFeeOptionDisabled(false);
|
|
9951
|
+
}
|
|
9952
|
+
}, [
|
|
9953
|
+
signMessage,
|
|
9954
|
+
targetAddress,
|
|
9955
|
+
targetChain.shortName,
|
|
9956
|
+
sourceCurrency,
|
|
9957
|
+
sourceChain.shortName
|
|
9958
|
+
]);
|
|
9742
9959
|
const handleSubmit = async () => {
|
|
9743
9960
|
const { error, message: validationMessage } = validate(true);
|
|
9744
9961
|
if (error === "ValidationError" /* Error */) {
|
|
9745
|
-
|
|
9962
|
+
import_react_hot_toast10.default.error(validationMessage, { icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) });
|
|
9746
9963
|
return;
|
|
9747
9964
|
}
|
|
9748
9965
|
if (["BANK", "CC"].includes(sourceChain.shortName)) {
|
|
@@ -9752,44 +9969,34 @@ var TransferWidget = ({
|
|
|
9752
9969
|
if (error === "ApprovalNeeded" /* ApprovalNeeded */ && mode !== "light" /* light */ && dAppOption === "none" /* None */) {
|
|
9753
9970
|
try {
|
|
9754
9971
|
if (!signature) {
|
|
9755
|
-
|
|
9756
|
-
setFeeOptionDisabled(true);
|
|
9757
|
-
const sig = await signMessage?.({
|
|
9758
|
-
targetAddress,
|
|
9759
|
-
targetChain: targetChain.shortName,
|
|
9760
|
-
originSymbol: sourceCurrency,
|
|
9761
|
-
originChain: sourceChain.shortName
|
|
9762
|
-
});
|
|
9763
|
-
setSigning(false);
|
|
9972
|
+
const sig = await requestSignature();
|
|
9764
9973
|
if (!sig) {
|
|
9765
|
-
(0, import_react_hot_toast4.default)("Signature request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9766
9974
|
return;
|
|
9767
9975
|
}
|
|
9768
|
-
setSignature2(sig);
|
|
9769
9976
|
return;
|
|
9770
9977
|
}
|
|
9771
9978
|
setApproving(true);
|
|
9772
9979
|
await approve();
|
|
9773
|
-
setApproving(false);
|
|
9774
9980
|
} catch (err) {
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
(0, import_react_hot_toast4.default)("Approval request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9981
|
+
if (isUserRejected(err)) {
|
|
9982
|
+
(0, import_react_hot_toast10.default)("Approval request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9778
9983
|
return;
|
|
9779
9984
|
}
|
|
9780
9985
|
const msg = String(err?.message ?? err);
|
|
9781
9986
|
if (msg.includes("ChainMismatch")) {
|
|
9782
|
-
|
|
9987
|
+
import_react_hot_toast10.default.error(
|
|
9783
9988
|
`Your wallet is on the wrong network. Please switch to ${sourceChain.name} and try again.`,
|
|
9784
|
-
{ icon: /* @__PURE__ */ (0,
|
|
9989
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9785
9990
|
);
|
|
9786
9991
|
return;
|
|
9787
9992
|
}
|
|
9788
9993
|
logger_default.error("[TransferWidget] approval failed", err);
|
|
9789
|
-
|
|
9994
|
+
import_react_hot_toast10.default.error(
|
|
9790
9995
|
"Failed to approve the token allowance. Please contact support for assistance.",
|
|
9791
|
-
{ icon: /* @__PURE__ */ (0,
|
|
9996
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9792
9997
|
);
|
|
9998
|
+
} finally {
|
|
9999
|
+
setApproving(false);
|
|
9793
10000
|
}
|
|
9794
10001
|
return;
|
|
9795
10002
|
}
|
|
@@ -9800,30 +10007,20 @@ var TransferWidget = ({
|
|
|
9800
10007
|
return;
|
|
9801
10008
|
}
|
|
9802
10009
|
if (!signature && mode !== "light" /* light */ && dAppOption === "none" /* None */) {
|
|
9803
|
-
|
|
9804
|
-
setFeeOptionDisabled(true);
|
|
9805
|
-
const sig = await signMessage?.({
|
|
9806
|
-
targetAddress,
|
|
9807
|
-
targetChain: targetChain.shortName,
|
|
9808
|
-
originSymbol: sourceCurrency,
|
|
9809
|
-
originChain: sourceChain.shortName
|
|
9810
|
-
});
|
|
9811
|
-
setSigning(false);
|
|
10010
|
+
const sig = await requestSignature();
|
|
9812
10011
|
if (!sig) {
|
|
9813
|
-
(0, import_react_hot_toast4.default)("Signature request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9814
10012
|
setIsSubmitting(false);
|
|
9815
10013
|
return;
|
|
9816
10014
|
}
|
|
9817
|
-
setSignature2(sig);
|
|
9818
10015
|
return;
|
|
9819
10016
|
}
|
|
9820
10017
|
setIsSubmitting(true);
|
|
9821
10018
|
await submitTransaction(signature);
|
|
9822
10019
|
} catch (err) {
|
|
9823
10020
|
logger_default.error("[TransferWidget] handleSubmit failed", err);
|
|
9824
|
-
|
|
10021
|
+
import_react_hot_toast10.default.error(
|
|
9825
10022
|
"An unexpected error occurred while submitting. Please contact support for assistance.",
|
|
9826
|
-
{ icon: /* @__PURE__ */ (0,
|
|
10023
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9827
10024
|
);
|
|
9828
10025
|
setIsSubmitting(false);
|
|
9829
10026
|
}
|
|
@@ -9843,7 +10040,7 @@ var TransferWidget = ({
|
|
|
9843
10040
|
void handleSubmit();
|
|
9844
10041
|
return;
|
|
9845
10042
|
}
|
|
9846
|
-
|
|
10043
|
+
import_react_hot_toast10.default.error(validationMessage, { icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) });
|
|
9847
10044
|
mainRef.current?.click();
|
|
9848
10045
|
};
|
|
9849
10046
|
const onBack = () => {
|
|
@@ -9863,15 +10060,15 @@ var TransferWidget = ({
|
|
|
9863
10060
|
try {
|
|
9864
10061
|
setCancellingApprove(true);
|
|
9865
10062
|
await approve(true);
|
|
9866
|
-
(0,
|
|
10063
|
+
(0, import_react_hot_toast10.default)("Approval successfully cancelled.", { icon: "\u2139\uFE0F" });
|
|
9867
10064
|
} catch (err) {
|
|
9868
|
-
if (err
|
|
9869
|
-
(0,
|
|
10065
|
+
if (isUserRejected(err)) {
|
|
10066
|
+
(0, import_react_hot_toast10.default)("Cancel-approval request was cancelled.", { icon: "\u2139\uFE0F" });
|
|
9870
10067
|
} else {
|
|
9871
10068
|
logger_default.error("[TransferWidget] cancel approve failed", err);
|
|
9872
|
-
|
|
10069
|
+
import_react_hot_toast10.default.error(
|
|
9873
10070
|
"Unable to cancel the approval. Please contact support for assistance.",
|
|
9874
|
-
{ icon: /* @__PURE__ */ (0,
|
|
10071
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9875
10072
|
);
|
|
9876
10073
|
}
|
|
9877
10074
|
} finally {
|
|
@@ -9917,13 +10114,13 @@ var TransferWidget = ({
|
|
|
9917
10114
|
await disconnectWallet();
|
|
9918
10115
|
} catch (e) {
|
|
9919
10116
|
logger_default.error("[TransferWidget] reset failed", e);
|
|
9920
|
-
|
|
10117
|
+
import_react_hot_toast10.default.error(
|
|
9921
10118
|
"Unable to reset the form. Please contact support for assistance.",
|
|
9922
|
-
{ icon: /* @__PURE__ */ (0,
|
|
10119
|
+
{ icon: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Error_default, {}) }
|
|
9923
10120
|
);
|
|
9924
10121
|
}
|
|
9925
10122
|
};
|
|
9926
|
-
return /* @__PURE__ */ (0,
|
|
10123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
|
|
9927
10124
|
"div",
|
|
9928
10125
|
{
|
|
9929
10126
|
className: `kima-card ${theme.colorMode}`,
|
|
@@ -9931,7 +10128,7 @@ var TransferWidget = ({
|
|
|
9931
10128
|
background: theme.colorMode === "light" /* light */ ? theme.backgroundColorLight : theme.backgroundColorDark
|
|
9932
10129
|
},
|
|
9933
10130
|
children: [
|
|
9934
|
-
resetModalOpen && /* @__PURE__ */ (0,
|
|
10131
|
+
resetModalOpen && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9935
10132
|
WarningModal_default,
|
|
9936
10133
|
{
|
|
9937
10134
|
message: "Are you sure you want to reset the widget?",
|
|
@@ -9943,7 +10140,7 @@ var TransferWidget = ({
|
|
|
9943
10140
|
onCancel: () => setResetModalOpen(false)
|
|
9944
10141
|
}
|
|
9945
10142
|
),
|
|
9946
|
-
warningModalOpen && /* @__PURE__ */ (0,
|
|
10143
|
+
warningModalOpen && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9947
10144
|
WarningModal_default,
|
|
9948
10145
|
{
|
|
9949
10146
|
message: warningModalOpen.message,
|
|
@@ -9957,21 +10154,21 @@ var TransferWidget = ({
|
|
|
9957
10154
|
}
|
|
9958
10155
|
}
|
|
9959
10156
|
),
|
|
9960
|
-
mode === "payment" /* payment */ && !transactionOption && /* @__PURE__ */ (0,
|
|
9961
|
-
/* @__PURE__ */ (0,
|
|
9962
|
-
/* @__PURE__ */ (0,
|
|
9963
|
-
/* @__PURE__ */ (0,
|
|
9964
|
-
/* @__PURE__ */ (0,
|
|
9965
|
-
/* @__PURE__ */ (0,
|
|
9966
|
-
/* @__PURE__ */ (0,
|
|
10157
|
+
mode === "payment" /* payment */ && !transactionOption && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("h2", { className: "invalid-option-banner", children: "We're unable to process your payment. Please ensure the necessary transaction details are provided. Contact support if the issue persists." }),
|
|
10158
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "transfer-card", children: [
|
|
10159
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "kima-card-header", children: [
|
|
10160
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "topbar", children: [
|
|
10161
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "title", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("h3", { style: { marginRight: "5px" }, children: formStep === 0 ? titleOption?.initialTitle ?? (mode === "payment" /* payment */ ? "New Purchase" : "New Transfer") : titleOption?.confirmTitle ?? (mode === "payment" /* payment */ ? "Confirm Purchase" : isSwap ? "Swap Details" : "Transfer Details") }) }),
|
|
10162
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "control-buttons", children: [
|
|
10163
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9967
10164
|
ExternalLink_default,
|
|
9968
10165
|
{
|
|
9969
10166
|
to: helpURL ? helpURL : networkOption === "testnet" /* testnet */ ? "https://docs.kima.network/kima-network/try-kima-with-the-demo-app" : "https://support.kima.network",
|
|
9970
|
-
children: /* @__PURE__ */ (0,
|
|
10167
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "menu-button", children: "I need help" })
|
|
9971
10168
|
}
|
|
9972
10169
|
),
|
|
9973
|
-
["BANK", "CC"].includes(sourceChain.shortName) && formStep > 0 && /* @__PURE__ */ (0,
|
|
9974
|
-
formStep === 0 && mode !== "payment" /* payment */ && /* @__PURE__ */ (0,
|
|
10170
|
+
["BANK", "CC"].includes(sourceChain.shortName) && formStep > 0 && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ExternalLink_default, { to: "https://docs.kima.network/kima-network/supported-fiat#unsupported-countries-credit-cards", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "menu-button", children: "Unsupported Countries" }) }),
|
|
10171
|
+
formStep === 0 && mode !== "payment" /* payment */ && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9975
10172
|
"button",
|
|
9976
10173
|
{
|
|
9977
10174
|
className: "reset-button",
|
|
@@ -9980,7 +10177,7 @@ var TransferWidget = ({
|
|
|
9980
10177
|
children: "Reset"
|
|
9981
10178
|
}
|
|
9982
10179
|
),
|
|
9983
|
-
closeHandler && /* @__PURE__ */ (0,
|
|
10180
|
+
closeHandler && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9984
10181
|
"button",
|
|
9985
10182
|
{
|
|
9986
10183
|
className: "cross-icon-button",
|
|
@@ -9988,14 +10185,14 @@ var TransferWidget = ({
|
|
|
9988
10185
|
resetForm();
|
|
9989
10186
|
closeHandler(0);
|
|
9990
10187
|
},
|
|
9991
|
-
children: /* @__PURE__ */ (0,
|
|
10188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Cross_default, {})
|
|
9992
10189
|
}
|
|
9993
10190
|
)
|
|
9994
10191
|
] })
|
|
9995
10192
|
] }),
|
|
9996
|
-
mode === "payment" /* payment */ && paymentTitleOption?.title && /* @__PURE__ */ (0,
|
|
10193
|
+
mode === "payment" /* payment */ && paymentTitleOption?.title && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("h4", { className: "subtitle", children: paymentTitleOption.title })
|
|
9997
10194
|
] }),
|
|
9998
|
-
/* @__PURE__ */ (0,
|
|
10195
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "kima-card-content", ref: mainRef, children: formStep === 0 ? /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9999
10196
|
SingleForm_default,
|
|
10000
10197
|
{
|
|
10001
10198
|
...{
|
|
@@ -10008,7 +10205,7 @@ var TransferWidget = ({
|
|
|
10008
10205
|
setInitialSelection
|
|
10009
10206
|
}
|
|
10010
10207
|
}
|
|
10011
|
-
) : ccTransactionStatus !== "idle" ? /* @__PURE__ */ (0,
|
|
10208
|
+
) : ccTransactionStatus !== "idle" ? /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(FiatWidget_default, { submitCallback: submit }) : /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
10012
10209
|
ConfirmDetails_default,
|
|
10013
10210
|
{
|
|
10014
10211
|
...{
|
|
@@ -10017,12 +10214,12 @@ var TransferWidget = ({
|
|
|
10017
10214
|
}
|
|
10018
10215
|
}
|
|
10019
10216
|
) }),
|
|
10020
|
-
/* @__PURE__ */ (0,
|
|
10217
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
10021
10218
|
"div",
|
|
10022
10219
|
{
|
|
10023
10220
|
className: `kima-card-footer ${mode === "bridge" /* bridge */ && formStep !== 0 && "confirm"}`,
|
|
10024
|
-
children: /* @__PURE__ */ (0,
|
|
10025
|
-
isBackButtonEnabled && /* @__PURE__ */ (0,
|
|
10221
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "button-group", children: [
|
|
10222
|
+
isBackButtonEnabled && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
10026
10223
|
SecondaryButton_default,
|
|
10027
10224
|
{
|
|
10028
10225
|
clickHandler: onBack,
|
|
@@ -10032,7 +10229,7 @@ var TransferWidget = ({
|
|
|
10032
10229
|
}
|
|
10033
10230
|
),
|
|
10034
10231
|
!!allowance && allowance > 0n && formStep !== 0 && !["BANK", "CC"].includes(sourceChain.shortName) && // EVM path
|
|
10035
|
-
mode !== "light" /* light */ && /* @__PURE__ */ (0,
|
|
10232
|
+
mode !== "light" /* light */ && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
10036
10233
|
SecondaryButton_default,
|
|
10037
10234
|
{
|
|
10038
10235
|
clickHandler: onCancelApprove,
|
|
@@ -10042,7 +10239,7 @@ var TransferWidget = ({
|
|
|
10042
10239
|
children: isCancellingApprove ? "Cancelling Approval" : "Cancel Approve"
|
|
10043
10240
|
}
|
|
10044
10241
|
),
|
|
10045
|
-
isSubmitButtonEnabled && /* @__PURE__ */ (0,
|
|
10242
|
+
isSubmitButtonEnabled && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
10046
10243
|
PrimaryButton_default,
|
|
10047
10244
|
{
|
|
10048
10245
|
clickHandler: onNext,
|
|
@@ -10054,10 +10251,10 @@ var TransferWidget = ({
|
|
|
10054
10251
|
] })
|
|
10055
10252
|
}
|
|
10056
10253
|
),
|
|
10057
|
-
/* @__PURE__ */ (0,
|
|
10058
|
-
/* @__PURE__ */ (0,
|
|
10059
|
-
/* @__PURE__ */ (0,
|
|
10060
|
-
|
|
10254
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(SolanaConnectModal_default, {}),
|
|
10255
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(TronWalletConnectModal_default, {}),
|
|
10256
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
10257
|
+
import_react_hot_toast10.Toaster,
|
|
10061
10258
|
{
|
|
10062
10259
|
position: "top-right",
|
|
10063
10260
|
reverseOrder: false,
|
|
@@ -10080,9 +10277,9 @@ var TransferWidget = ({
|
|
|
10080
10277
|
}
|
|
10081
10278
|
}
|
|
10082
10279
|
),
|
|
10083
|
-
/* @__PURE__ */ (0,
|
|
10084
|
-
/* @__PURE__ */ (0,
|
|
10085
|
-
/* @__PURE__ */ (0,
|
|
10280
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "floating-footer", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: `items ${theme.colorMode}`, children: [
|
|
10281
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { children: "Powered by" }),
|
|
10282
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(KimaNetwork_default, {})
|
|
10086
10283
|
] }) })
|
|
10087
10284
|
] })
|
|
10088
10285
|
]
|
|
@@ -10091,7 +10288,7 @@ var TransferWidget = ({
|
|
|
10091
10288
|
};
|
|
10092
10289
|
|
|
10093
10290
|
// src/widgets/common/KimaWidgetWrapper.tsx
|
|
10094
|
-
var
|
|
10291
|
+
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
10095
10292
|
var KimaWidgetWrapper = ({
|
|
10096
10293
|
mode,
|
|
10097
10294
|
txId,
|
|
@@ -10108,7 +10305,7 @@ var KimaWidgetWrapper = ({
|
|
|
10108
10305
|
useDebugCode();
|
|
10109
10306
|
const { kimaBackendUrl } = useKimaContext();
|
|
10110
10307
|
const dispatch = (0, import_react_redux57.useDispatch)();
|
|
10111
|
-
const { setThemeMode, setThemeVariables } = (0,
|
|
10308
|
+
const { setThemeMode, setThemeVariables } = (0, import_react67.useAppKitTheme)();
|
|
10112
10309
|
const submitted = (0, import_react_redux57.useSelector)(selectSubmitted);
|
|
10113
10310
|
const sourceChain = (0, import_react_redux57.useSelector)(selectSourceChain);
|
|
10114
10311
|
const ccTransactionStatus = (0, import_react_redux57.useSelector)(selectCCTransactionStatus);
|
|
@@ -10116,8 +10313,8 @@ var KimaWidgetWrapper = ({
|
|
|
10116
10313
|
const networkOption = envOptions?.env;
|
|
10117
10314
|
const kimaExplorer = envOptions?.kimaExplorer || "https://explorer.sardis.kima.network";
|
|
10118
10315
|
const { currentPlugin } = useGetCurrentPlugin_default();
|
|
10119
|
-
const prevColorMode = (0,
|
|
10120
|
-
(0,
|
|
10316
|
+
const prevColorMode = (0, import_react68.useRef)(void 0);
|
|
10317
|
+
(0, import_react68.useEffect)(() => {
|
|
10121
10318
|
if (prevColorMode.current !== theme?.colorMode) {
|
|
10122
10319
|
dispatch(setTheme(theme));
|
|
10123
10320
|
setThemeMode(
|
|
@@ -10130,7 +10327,7 @@ var KimaWidgetWrapper = ({
|
|
|
10130
10327
|
prevColorMode.current = theme?.colorMode;
|
|
10131
10328
|
}
|
|
10132
10329
|
}, [theme?.colorMode, dispatch, setThemeMode, setThemeVariables, theme]);
|
|
10133
|
-
const prevConfigRef = (0,
|
|
10330
|
+
const prevConfigRef = (0, import_react68.useRef)({
|
|
10134
10331
|
compliantOption: void 0,
|
|
10135
10332
|
backendUrl: void 0,
|
|
10136
10333
|
mode: void 0,
|
|
@@ -10138,7 +10335,7 @@ var KimaWidgetWrapper = ({
|
|
|
10138
10335
|
networkOption: void 0,
|
|
10139
10336
|
kimaExplorer: void 0
|
|
10140
10337
|
});
|
|
10141
|
-
(0,
|
|
10338
|
+
(0, import_react68.useEffect)(() => {
|
|
10142
10339
|
if (prevConfigRef.current.compliantOption !== compliantOption) {
|
|
10143
10340
|
dispatch(setCompliantOption(compliantOption));
|
|
10144
10341
|
prevConfigRef.current.compliantOption = compliantOption;
|
|
@@ -10172,8 +10369,8 @@ var KimaWidgetWrapper = ({
|
|
|
10172
10369
|
kimaExplorer,
|
|
10173
10370
|
dispatch
|
|
10174
10371
|
]);
|
|
10175
|
-
const prevTxOptJson = (0,
|
|
10176
|
-
(0,
|
|
10372
|
+
const prevTxOptJson = (0, import_react68.useRef)(null);
|
|
10373
|
+
(0, import_react68.useEffect)(() => {
|
|
10177
10374
|
const nextJson = transactionOption ? JSON.stringify(transactionOption) : null;
|
|
10178
10375
|
if (nextJson === prevTxOptJson.current) return;
|
|
10179
10376
|
if (transactionOption) {
|
|
@@ -10202,9 +10399,9 @@ var KimaWidgetWrapper = ({
|
|
|
10202
10399
|
}
|
|
10203
10400
|
prevTxOptJson.current = nextJson;
|
|
10204
10401
|
}, [transactionOption, chainData, dispatch]);
|
|
10205
|
-
const prevModeRef = (0,
|
|
10206
|
-
const prevTxIdRef = (0,
|
|
10207
|
-
(0,
|
|
10402
|
+
const prevModeRef = (0, import_react68.useRef)(void 0);
|
|
10403
|
+
const prevTxIdRef = (0, import_react68.useRef)(void 0);
|
|
10404
|
+
(0, import_react68.useEffect)(() => {
|
|
10208
10405
|
const modeChanged = prevModeRef.current !== mode;
|
|
10209
10406
|
const txChanged = prevTxIdRef.current !== txId;
|
|
10210
10407
|
if (mode === "payment" /* payment */ && !transactionOption) {
|
|
@@ -10235,8 +10432,8 @@ var KimaWidgetWrapper = ({
|
|
|
10235
10432
|
prevTxIdRef.current = txId;
|
|
10236
10433
|
}
|
|
10237
10434
|
}, [mode, txId, transactionOption, dispatch]);
|
|
10238
|
-
const didIndex = (0,
|
|
10239
|
-
(0,
|
|
10435
|
+
const didIndex = (0, import_react68.useRef)(false);
|
|
10436
|
+
(0, import_react68.useEffect)(() => {
|
|
10240
10437
|
if (!chainData?.length || didIndex.current) return;
|
|
10241
10438
|
logger_default.debug(
|
|
10242
10439
|
"[KimaWidgetWrapper] indexing plugins for chains:",
|
|
@@ -10245,7 +10442,7 @@ var KimaWidgetWrapper = ({
|
|
|
10245
10442
|
indexPluginsByChain(chainData);
|
|
10246
10443
|
didIndex.current = true;
|
|
10247
10444
|
}, [chainData]);
|
|
10248
|
-
(0,
|
|
10445
|
+
(0, import_react68.useEffect)(() => {
|
|
10249
10446
|
logger_default.debug("[KimaWidgetWrapper] render", {
|
|
10250
10447
|
mode,
|
|
10251
10448
|
dAppOption,
|
|
@@ -10255,16 +10452,16 @@ var KimaWidgetWrapper = ({
|
|
|
10255
10452
|
sourceChain: sourceChain?.shortName
|
|
10256
10453
|
});
|
|
10257
10454
|
});
|
|
10258
|
-
const pluginKey = (0,
|
|
10455
|
+
const pluginKey = (0, import_react68.useMemo)(() => {
|
|
10259
10456
|
if (!currentPlugin?.id) return null;
|
|
10260
10457
|
return `transfer-${currentPlugin.id}-${sourceChain?.shortName ?? "unknown"}`;
|
|
10261
10458
|
}, [currentPlugin?.id, sourceChain?.shortName]);
|
|
10262
|
-
const content = (0,
|
|
10459
|
+
const content = (0, import_react68.useMemo)(() => {
|
|
10263
10460
|
if (mode === "status" /* status */) {
|
|
10264
|
-
return /* @__PURE__ */ (0,
|
|
10461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TransactionWidget, { theme });
|
|
10265
10462
|
}
|
|
10266
10463
|
if (!currentPlugin && !sourceChain?.shortName) {
|
|
10267
|
-
return /* @__PURE__ */ (0,
|
|
10464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
10268
10465
|
TransferWidget,
|
|
10269
10466
|
{
|
|
10270
10467
|
theme,
|
|
@@ -10276,15 +10473,15 @@ var KimaWidgetWrapper = ({
|
|
|
10276
10473
|
);
|
|
10277
10474
|
}
|
|
10278
10475
|
if (!currentPlugin) {
|
|
10279
|
-
return /* @__PURE__ */ (0,
|
|
10476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SkeletonLoader_default, { theme });
|
|
10280
10477
|
}
|
|
10281
10478
|
if (sourceChain.shortName === "CC") {
|
|
10282
10479
|
if (submitted) {
|
|
10283
10480
|
logger_default.debug("[KimaWidgetWrapper] CC mode -> TransactionWidget");
|
|
10284
|
-
return /* @__PURE__ */ (0,
|
|
10481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TransactionWidget, { theme });
|
|
10285
10482
|
}
|
|
10286
10483
|
if (ccTransactionStatus === "error-id") {
|
|
10287
|
-
return /* @__PURE__ */ (0,
|
|
10484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
10288
10485
|
ErrorWidget_default,
|
|
10289
10486
|
{
|
|
10290
10487
|
theme,
|
|
@@ -10299,7 +10496,7 @@ var KimaWidgetWrapper = ({
|
|
|
10299
10496
|
);
|
|
10300
10497
|
}
|
|
10301
10498
|
if (ccTransactionStatus === "error-generic") {
|
|
10302
|
-
return /* @__PURE__ */ (0,
|
|
10499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
10303
10500
|
ErrorWidget_default,
|
|
10304
10501
|
{
|
|
10305
10502
|
theme,
|
|
@@ -10313,7 +10510,7 @@ var KimaWidgetWrapper = ({
|
|
|
10313
10510
|
}
|
|
10314
10511
|
);
|
|
10315
10512
|
}
|
|
10316
|
-
return /* @__PURE__ */ (0,
|
|
10513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
10317
10514
|
TransferWidget,
|
|
10318
10515
|
{
|
|
10319
10516
|
theme,
|
|
@@ -10328,7 +10525,7 @@ var KimaWidgetWrapper = ({
|
|
|
10328
10525
|
"[KimaWidgetWrapper] rendering TransferWidget with plugin",
|
|
10329
10526
|
currentPlugin?.id
|
|
10330
10527
|
);
|
|
10331
|
-
return submitted ? /* @__PURE__ */ (0,
|
|
10528
|
+
return submitted ? /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TransactionWidget, { theme }) : /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
10332
10529
|
TransferWidget,
|
|
10333
10530
|
{
|
|
10334
10531
|
theme,
|
|
@@ -10357,7 +10554,7 @@ var KimaWidgetWrapper = ({
|
|
|
10357
10554
|
var KimaWidgetWrapper_default = KimaWidgetWrapper;
|
|
10358
10555
|
|
|
10359
10556
|
// src/widgets/common/KimaTransactionWidget.tsx
|
|
10360
|
-
var
|
|
10557
|
+
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
10361
10558
|
var KimaTransactionWidget = ({
|
|
10362
10559
|
mode,
|
|
10363
10560
|
txId,
|
|
@@ -10371,7 +10568,7 @@ var KimaTransactionWidget = ({
|
|
|
10371
10568
|
}) => {
|
|
10372
10569
|
const dispatch = (0, import_react_redux58.useDispatch)();
|
|
10373
10570
|
const { kimaBackendUrl } = useKimaContext();
|
|
10374
|
-
const [hydrated, setHydrated] = (0,
|
|
10571
|
+
const [hydrated, setHydrated] = (0, import_react69.useState)(false);
|
|
10375
10572
|
const {
|
|
10376
10573
|
data: envOptions,
|
|
10377
10574
|
error: envOptionsError,
|
|
@@ -10382,20 +10579,20 @@ var KimaTransactionWidget = ({
|
|
|
10382
10579
|
error: chainDataError,
|
|
10383
10580
|
isLoading: isLoadingChainData
|
|
10384
10581
|
} = useChainData(kimaBackendUrl);
|
|
10385
|
-
(0,
|
|
10582
|
+
(0, import_react69.useEffect)(() => {
|
|
10386
10583
|
if (typeof window !== "undefined") setHydrated(true);
|
|
10387
10584
|
}, []);
|
|
10388
|
-
(0,
|
|
10585
|
+
(0, import_react69.useEffect)(() => {
|
|
10389
10586
|
if (theme?.colorMode) {
|
|
10390
10587
|
dispatch(setTheme(theme));
|
|
10391
10588
|
}
|
|
10392
10589
|
}, [theme?.colorMode, dispatch, theme]);
|
|
10393
10590
|
if (!hydrated || !theme?.colorMode)
|
|
10394
|
-
return /* @__PURE__ */ (0,
|
|
10591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ring_default, { width: 20, height: 20, fill: "#86b8ce" });
|
|
10395
10592
|
if (isLoadingEnvs || isLoadingChainData)
|
|
10396
|
-
return /* @__PURE__ */ (0,
|
|
10593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SkeletonLoader_default, { theme });
|
|
10397
10594
|
if (envOptionsError || !envOptions)
|
|
10398
|
-
return /* @__PURE__ */ (0,
|
|
10595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
10399
10596
|
ErrorWidget_default,
|
|
10400
10597
|
{
|
|
10401
10598
|
theme,
|
|
@@ -10404,7 +10601,7 @@ var KimaTransactionWidget = ({
|
|
|
10404
10601
|
}
|
|
10405
10602
|
);
|
|
10406
10603
|
if (chainDataError || !chainData)
|
|
10407
|
-
return /* @__PURE__ */ (0,
|
|
10604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
10408
10605
|
ErrorWidget_default,
|
|
10409
10606
|
{
|
|
10410
10607
|
theme,
|
|
@@ -10412,7 +10609,7 @@ var KimaTransactionWidget = ({
|
|
|
10412
10609
|
message: "There was an error loading the chain data from the backend. Please check that the backend is running properly and the widget points to the corresponding url." /* ChainLoadingError */
|
|
10413
10610
|
}
|
|
10414
10611
|
);
|
|
10415
|
-
return /* @__PURE__ */ (0,
|
|
10612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
10416
10613
|
KimaWidgetWrapper_default,
|
|
10417
10614
|
{
|
|
10418
10615
|
...{
|