@kimafinance/kima-transaction-widget 1.5.10 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -45
- 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
|
@@ -6197,36 +6197,45 @@ var ConfirmDetails = ({
|
|
|
6197
6197
|
),
|
|
6198
6198
|
[originNetwork, sourceCurrency, targetNetwork, targetCurrency]
|
|
6199
6199
|
);
|
|
6200
|
-
const
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6200
|
+
const chargeFeeAtOrigin = !isSwap && feeDeduct;
|
|
6201
|
+
const baseSubmit = (0, import_react47.useMemo)(
|
|
6202
|
+
() => transactionValues.feeFromOrigin.submitAmount,
|
|
6203
|
+
[transactionValues.feeFromOrigin.submitAmount]
|
|
6204
|
+
);
|
|
6205
|
+
const totalFeeInSubmitDec = (0, import_react47.useMemo)(
|
|
6206
|
+
() => bigIntChangeDecimals({
|
|
6207
|
+
...totalFee,
|
|
6208
|
+
newDecimals: baseSubmit.decimals
|
|
6209
|
+
}),
|
|
6210
|
+
[totalFee, baseSubmit.decimals]
|
|
6211
|
+
);
|
|
6212
|
+
const amountToTransferBig = (0, import_react47.useMemo)(() => {
|
|
6213
|
+
if (isSwap)
|
|
6214
|
+
return { value: baseSubmit.value, decimals: baseSubmit.decimals };
|
|
6215
|
+
const val = chargeFeeAtOrigin ? baseSubmit.value : baseSubmit.value + totalFeeInSubmitDec.value;
|
|
6216
|
+
return { value: val, decimals: baseSubmit.decimals };
|
|
6217
|
+
}, [isSwap, chargeFeeAtOrigin, baseSubmit, totalFeeInSubmitDec]);
|
|
6218
|
+
const targetTransferBig = (0, import_react47.useMemo)(() => {
|
|
6219
|
+
if (isSwap) {
|
|
6220
|
+
if (swapInfo?.amountOutBigInt) return swapInfo.amountOutBigInt;
|
|
6221
|
+
return transactionValues.feeFromOrigin.submitAmount;
|
|
6222
|
+
}
|
|
6223
|
+
const minus = baseSubmit.value - totalFeeInSubmitDec.value;
|
|
6224
|
+
const val = chargeFeeAtOrigin ? minus > 0n ? minus : 0n : baseSubmit.value;
|
|
6225
|
+
return { value: val, decimals: baseSubmit.decimals };
|
|
6226
|
+
}, [
|
|
6227
|
+
isSwap,
|
|
6228
|
+
swapInfo?.amountOutBigInt,
|
|
6229
|
+
transactionValues.feeFromOrigin.submitAmount,
|
|
6230
|
+
baseSubmit.value,
|
|
6231
|
+
baseSubmit.decimals,
|
|
6232
|
+
totalFeeInSubmitDec.value,
|
|
6233
|
+
chargeFeeAtOrigin
|
|
6234
|
+
]);
|
|
6208
6235
|
const combinedSwapFees = (0, import_react47.useMemo)(
|
|
6209
6236
|
() => sumBigAmts([sourceFee, targetFee, swapFee ?? { value: 0n, decimals: 0 }]),
|
|
6210
6237
|
[sourceFee, targetFee, swapFee]
|
|
6211
6238
|
);
|
|
6212
|
-
const originChargeAmount = (0, import_react47.useMemo)(() => {
|
|
6213
|
-
if (["CC", "BANK"].includes(originNetwork.shortName)) {
|
|
6214
|
-
const submit = txValues.submitAmount;
|
|
6215
|
-
const feeInSubmitDec = bigIntChangeDecimals({
|
|
6216
|
-
...totalFee,
|
|
6217
|
-
newDecimals: submit.decimals
|
|
6218
|
-
});
|
|
6219
|
-
const val = feeDeduct ? submit.value : submit.value + feeInSubmitDec.value;
|
|
6220
|
-
return { value: val, decimals: submit.decimals };
|
|
6221
|
-
}
|
|
6222
|
-
return txValues.allowanceAmount;
|
|
6223
|
-
}, [
|
|
6224
|
-
originNetwork.shortName,
|
|
6225
|
-
txValues.submitAmount,
|
|
6226
|
-
txValues.allowanceAmount,
|
|
6227
|
-
totalFee,
|
|
6228
|
-
feeDeduct
|
|
6229
|
-
]);
|
|
6230
6239
|
(0, import_react47.useEffect)(() => {
|
|
6231
6240
|
width === 0 && updateWidth(window.innerWidth);
|
|
6232
6241
|
}, [width, updateWidth]);
|
|
@@ -6261,15 +6270,15 @@ var ConfirmDetails = ({
|
|
|
6261
6270
|
] })
|
|
6262
6271
|
] }),
|
|
6263
6272
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "detail-item amount", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "amount-container", children: [
|
|
6264
|
-
|
|
6273
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "amount-details", children: [
|
|
6265
6274
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { children: "Amount to Transfer" }),
|
|
6266
6275
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "coin-details", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("p", { children: [
|
|
6267
|
-
formatBigInt(
|
|
6276
|
+
formatBigInt(amountToTransferBig),
|
|
6268
6277
|
" ",
|
|
6269
6278
|
sourceCurrency
|
|
6270
6279
|
] }) })
|
|
6271
6280
|
] }),
|
|
6272
|
-
|
|
6281
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "amount-details", children: [
|
|
6273
6282
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { children: "Total Fees" }),
|
|
6274
6283
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
6275
6284
|
"div",
|
|
@@ -6347,7 +6356,7 @@ var ConfirmDetails = ({
|
|
|
6347
6356
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "amount-details", children: [
|
|
6348
6357
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { children: "Target Transfer Amount" }),
|
|
6349
6358
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "service-fee", children: [
|
|
6350
|
-
formatBigInt(
|
|
6359
|
+
formatBigInt(targetTransferBig),
|
|
6351
6360
|
" ",
|
|
6352
6361
|
targetCurrency
|
|
6353
6362
|
] })
|
|
@@ -8625,7 +8634,7 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8625
8634
|
const networkOption = (0, import_react_redux48.useSelector)(selectNetworkOption);
|
|
8626
8635
|
const sourceCurrency = (0, import_react_redux48.useSelector)(selectSourceCurrency);
|
|
8627
8636
|
const sourceChain = (0, import_react_redux48.useSelector)(selectSourceChain);
|
|
8628
|
-
const { transactionValues
|
|
8637
|
+
const { transactionValues } = (0, import_react_redux48.useSelector)(selectServiceFee);
|
|
8629
8638
|
const ccTransactionIdSeedRef = (0, import_react57.useRef)((0, import_uuid.v4)());
|
|
8630
8639
|
const ccTransactionSubmittedRef = (0, import_react57.useRef)(false);
|
|
8631
8640
|
const { data: envOptions, isLoading: isEnvLoading } = useGetEnvOptions({
|
|
@@ -8642,18 +8651,9 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8642
8651
|
dispatch(setCCTransactionId(data?.transactionId));
|
|
8643
8652
|
}, [dispatch, data, isTransactionIdLoading]);
|
|
8644
8653
|
const txValues = feeDeduct ? transactionValues.feeFromTarget : transactionValues.feeFromOrigin;
|
|
8645
|
-
const
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
...totalFee,
|
|
8649
|
-
newDecimals: submit.decimals
|
|
8650
|
-
});
|
|
8651
|
-
const val = feeDeduct ? submit.value : submit.value + feeInSubmitDec.value;
|
|
8652
|
-
return { value: val, decimals: submit.decimals };
|
|
8653
|
-
}, [txValues.submitAmount, totalFee, feeDeduct]);
|
|
8654
|
-
const chargeAmount = (0, import_react57.useMemo)(
|
|
8655
|
-
() => formatBigInt(chargeAmountBig),
|
|
8656
|
-
[chargeAmountBig]
|
|
8654
|
+
const allowanceAmount = (0, import_react57.useMemo)(
|
|
8655
|
+
() => formatBigInt(txValues.allowanceAmount),
|
|
8656
|
+
[txValues]
|
|
8657
8657
|
);
|
|
8658
8658
|
const [isLoading, setIsLoading] = (0, import_react57.useState)(true);
|
|
8659
8659
|
const baseUrl = (0, import_react57.useMemo)(
|
|
@@ -8666,7 +8666,9 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8666
8666
|
);
|
|
8667
8667
|
(0, import_react57.useEffect)(() => {
|
|
8668
8668
|
const handleMessage = (event) => {
|
|
8669
|
-
if (event.origin !== baseUrl)
|
|
8669
|
+
if (event.origin !== baseUrl) {
|
|
8670
|
+
return;
|
|
8671
|
+
}
|
|
8670
8672
|
logger_default.info("postMessage: new message: ", event);
|
|
8671
8673
|
if (event.data.type === "isCompleted") {
|
|
8672
8674
|
logger_default.info("cc widget isCompleted", ccTransactionSubmittedRef.current);
|
|
@@ -8701,7 +8703,7 @@ var FiatWidget = ({ submitCallback }) => {
|
|
|
8701
8703
|
{
|
|
8702
8704
|
width: isLoading || isTransactionIdLoading || ccTransactionStatus === "success" || error ? 0 : "100%",
|
|
8703
8705
|
height: isLoading || isTransactionIdLoading || ccTransactionStatus === "success" || error ? 0 : "100%",
|
|
8704
|
-
src: `${baseUrl}/widgets/kyc?partner=${partnerId}&amount=${
|
|
8706
|
+
src: `${baseUrl}/widgets/kyc?partner=${partnerId}&amount=${allowanceAmount}¤cy=${sourceCurrency}&trx_uuid=${data?.transactionId}&scenario=${scenario}&postmessage=true`,
|
|
8705
8707
|
loading: "lazy",
|
|
8706
8708
|
title: "Credit Card Widget",
|
|
8707
8709
|
allow: "camera; clipboard-write",
|