@kimafinance/kima-transaction-widget 1.3.7 → 1.3.9
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 +52 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -44
- 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.js
CHANGED
|
@@ -2561,11 +2561,12 @@ function useIsWalletReady() {
|
|
|
2561
2561
|
checkChainId();
|
|
2562
2562
|
}, [externalProvider, sourceChain, switchNetwork, walletChainId, isConnected]);
|
|
2563
2563
|
useEffect(() => {
|
|
2564
|
-
if (isConnected) {
|
|
2564
|
+
if (isConnected && sourceChain.compatibility === "EVM" /* EVM */) {
|
|
2565
2565
|
console.debug(
|
|
2566
2566
|
"useIsWalletReady:EVM: Dispatching source address:",
|
|
2567
2567
|
walletAddress
|
|
2568
2568
|
);
|
|
2569
|
+
console.log("dispatching evm address: ", walletAddress);
|
|
2569
2570
|
dispatch(setSourceAddress(walletAddress ?? ""));
|
|
2570
2571
|
}
|
|
2571
2572
|
}, [walletAddress, isConnected, dispatch]);
|
|
@@ -2822,10 +2823,7 @@ function useEvmAllowance() {
|
|
|
2822
2823
|
});
|
|
2823
2824
|
return await walletClient.signMessage({
|
|
2824
2825
|
account: walletAddress,
|
|
2825
|
-
message: `
|
|
2826
|
-
Target Address: ${data.targetAddress}
|
|
2827
|
-
Target Chain: ${data.targetChain}
|
|
2828
|
-
Target Symbol: ${data.targetSymbol}`
|
|
2826
|
+
message: `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`
|
|
2829
2827
|
});
|
|
2830
2828
|
} catch (error) {
|
|
2831
2829
|
console.error("useEvmAllowance: Error on signing message:", error);
|
|
@@ -3150,13 +3148,10 @@ function useSolanaAllowance() {
|
|
|
3150
3148
|
return;
|
|
3151
3149
|
}
|
|
3152
3150
|
try {
|
|
3153
|
-
const message = `
|
|
3154
|
-
Target Address: ${data.targetAddress}
|
|
3155
|
-
Target Chain: ${data.targetChain}
|
|
3156
|
-
Target Symbol: ${data.targetSymbol}`;
|
|
3151
|
+
const message = `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`;
|
|
3157
3152
|
const encodedMessage = new TextEncoder().encode(message);
|
|
3158
3153
|
const signature = await signMessage(encodedMessage);
|
|
3159
|
-
return signature
|
|
3154
|
+
return `0x${Buffer.from(signature).toString("hex")}`;
|
|
3160
3155
|
} catch (error2) {
|
|
3161
3156
|
console.error("Error signing message:", error2);
|
|
3162
3157
|
throw error2;
|
|
@@ -3741,10 +3736,7 @@ function useTronAllowance() {
|
|
|
3741
3736
|
return;
|
|
3742
3737
|
}
|
|
3743
3738
|
try {
|
|
3744
|
-
const message = `
|
|
3745
|
-
Target Address: ${data.targetAddress}
|
|
3746
|
-
Target Chain: ${data.targetChain}
|
|
3747
|
-
Target Symbol: ${data.targetSymbol}`;
|
|
3739
|
+
const message = `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`;
|
|
3748
3740
|
const signedMessage = await signMessage(message);
|
|
3749
3741
|
return signedMessage;
|
|
3750
3742
|
} catch (error2) {
|
|
@@ -3962,7 +3954,7 @@ import React113, { useEffect as useEffect20 } from "react";
|
|
|
3962
3954
|
|
|
3963
3955
|
// src/components/KimaWidgetWrapper.tsx
|
|
3964
3956
|
import React112, { useEffect as useEffect19 } from "react";
|
|
3965
|
-
import { useDispatch as useDispatch26, useSelector as
|
|
3957
|
+
import { useDispatch as useDispatch26, useSelector as useSelector39 } from "react-redux";
|
|
3966
3958
|
|
|
3967
3959
|
// src/components/TransactionWidget.tsx
|
|
3968
3960
|
import React101, { useEffect as useEffect13, useMemo as useMemo13, useState as useState10 } from "react";
|
|
@@ -5278,7 +5270,7 @@ var TransactionWidget = ({ theme }) => {
|
|
|
5278
5270
|
|
|
5279
5271
|
// src/components/TransferWidget.tsx
|
|
5280
5272
|
import React111, { useEffect as useEffect18, useState as useState14, useRef as useRef7 } from "react";
|
|
5281
|
-
import { useDispatch as useDispatch25, useSelector as
|
|
5273
|
+
import { useDispatch as useDispatch25, useSelector as useSelector38 } from "react-redux";
|
|
5282
5274
|
|
|
5283
5275
|
// src/components/reusable/SingleForm.tsx
|
|
5284
5276
|
import React103, { useEffect as useEffect15, useMemo as useMemo15, useState as useState12 } from "react";
|
|
@@ -6040,6 +6032,7 @@ var useValidateTransaction_default = useValidateTransaction;
|
|
|
6040
6032
|
// src/hooks/useSubmitTransaction.tsx
|
|
6041
6033
|
import { useState as useState13 } from "react";
|
|
6042
6034
|
import { useDispatch as useDispatch24 } from "react-redux";
|
|
6035
|
+
import { useSelector as useSelector37 } from "react-redux";
|
|
6043
6036
|
var useSubmitTransaction = ({
|
|
6044
6037
|
amount,
|
|
6045
6038
|
totalFee,
|
|
@@ -6054,7 +6047,8 @@ var useSubmitTransaction = ({
|
|
|
6054
6047
|
}) => {
|
|
6055
6048
|
const dispatch = useDispatch24();
|
|
6056
6049
|
const [isSubmitting, setSubmitting] = useState13(false);
|
|
6057
|
-
const
|
|
6050
|
+
const signature = useSelector37(selectSignature);
|
|
6051
|
+
const submitTransaction = async () => {
|
|
6058
6052
|
try {
|
|
6059
6053
|
setSubmitting(true);
|
|
6060
6054
|
const params = JSON.stringify({
|
|
@@ -6200,33 +6194,34 @@ var TransferWidget = ({
|
|
|
6200
6194
|
const mainRef = useRef7(null);
|
|
6201
6195
|
const [formStep, setFormStep] = useState14(0);
|
|
6202
6196
|
const [warningModalOpen, setWarningModalOpen] = useState14(null);
|
|
6203
|
-
const dAppOption =
|
|
6204
|
-
const mode =
|
|
6205
|
-
const transactionOption =
|
|
6206
|
-
const backendUrl =
|
|
6207
|
-
const sourceAddress =
|
|
6208
|
-
const targetAddress =
|
|
6209
|
-
const sourceChain =
|
|
6210
|
-
const targetChain =
|
|
6211
|
-
const sourceCurrency =
|
|
6212
|
-
const targetCurrency =
|
|
6213
|
-
const amount =
|
|
6197
|
+
const dAppOption = useSelector38(selectDappOption);
|
|
6198
|
+
const mode = useSelector38(selectMode);
|
|
6199
|
+
const transactionOption = useSelector38(selectTransactionOption);
|
|
6200
|
+
const backendUrl = useSelector38(selectBackendUrl);
|
|
6201
|
+
const sourceAddress = useSelector38(selectSourceAddress);
|
|
6202
|
+
const targetAddress = useSelector38(selectTargetAddress);
|
|
6203
|
+
const sourceChain = useSelector38(selectSourceChain);
|
|
6204
|
+
const targetChain = useSelector38(selectTargetChain);
|
|
6205
|
+
const sourceCurrency = useSelector38(selectSourceCurrency);
|
|
6206
|
+
const targetCurrency = useSelector38(selectTargetCurrency);
|
|
6207
|
+
const amount = useSelector38(selectAmount);
|
|
6214
6208
|
const {
|
|
6215
6209
|
totalFeeUsd,
|
|
6216
6210
|
totalFee,
|
|
6217
6211
|
targetNetworkFee,
|
|
6218
6212
|
submitAmount,
|
|
6219
6213
|
decimals: feeDecimals
|
|
6220
|
-
} =
|
|
6221
|
-
const compliantOption =
|
|
6222
|
-
const networkOptions3 =
|
|
6223
|
-
const feeDeduct =
|
|
6214
|
+
} = useSelector38(selectServiceFee);
|
|
6215
|
+
const compliantOption = useSelector38(selectCompliantOption);
|
|
6216
|
+
const networkOptions3 = useSelector38(selectNetworkOption);
|
|
6217
|
+
const feeDeduct = useSelector38(selectFeeDeduct);
|
|
6224
6218
|
const { keplrHandler, closeHandler } = useKimaContext();
|
|
6225
6219
|
const [isCancellingApprove, setCancellingApprove] = useState14(false);
|
|
6226
6220
|
const [isApproving, setApproving] = useState14(false);
|
|
6227
6221
|
const [isSigning, setSigning] = useState14(false);
|
|
6228
|
-
const pendingTxs =
|
|
6229
|
-
const networks =
|
|
6222
|
+
const pendingTxs = useSelector38(selectPendingTxs);
|
|
6223
|
+
const networks = useSelector38(selectNetworks);
|
|
6224
|
+
const signature = useSelector38(selectSignature);
|
|
6230
6225
|
const { width: windowWidth } = useWidth_default();
|
|
6231
6226
|
const { disconnectWallet } = useDisconnectWallet4();
|
|
6232
6227
|
const { balance } = useBalance2();
|
|
@@ -6282,20 +6277,29 @@ var TransferWidget = ({
|
|
|
6282
6277
|
return toast5.error(validationMessage, { icon: /* @__PURE__ */ React111.createElement(Error_default, null) });
|
|
6283
6278
|
}
|
|
6284
6279
|
if (error === "ApprovalNeeded" /* ApprovalNeeded */) {
|
|
6280
|
+
const signature2 = await signMessage?.({
|
|
6281
|
+
targetAddress,
|
|
6282
|
+
targetChain: targetChain.name,
|
|
6283
|
+
originSymbol: sourceCurrency,
|
|
6284
|
+
originChain: sourceChain.name
|
|
6285
|
+
});
|
|
6286
|
+
setSignature(signature2);
|
|
6285
6287
|
return approve();
|
|
6286
6288
|
}
|
|
6287
6289
|
if (dAppOption === "LPDrain" /* LPDrain */ || dAppOption === "LPAdd" /* LPAdd */) {
|
|
6288
6290
|
keplrHandler && keplrHandler(sourceAddress);
|
|
6289
6291
|
return;
|
|
6290
6292
|
}
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6293
|
+
if (!signature?.length) {
|
|
6294
|
+
const signature2 = await signMessage?.({
|
|
6295
|
+
targetAddress,
|
|
6296
|
+
targetChain: targetChain.name,
|
|
6297
|
+
originSymbol: sourceCurrency,
|
|
6298
|
+
originChain: sourceChain.name
|
|
6299
|
+
});
|
|
6300
|
+
setSignature(signature2);
|
|
6301
|
+
}
|
|
6302
|
+
const { success, message: submitMessage } = await submitTransaction();
|
|
6299
6303
|
if (!success) return toast5.error(submitMessage, { icon: /* @__PURE__ */ React111.createElement(Error_default, null) });
|
|
6300
6304
|
};
|
|
6301
6305
|
const onNext = () => {
|
|
@@ -6521,7 +6525,7 @@ var KimaWidgetWrapper = ({
|
|
|
6521
6525
|
excludedTargetNetworks = []
|
|
6522
6526
|
}) => {
|
|
6523
6527
|
const { kimaBackendUrl } = useKimaContext();
|
|
6524
|
-
const submitted =
|
|
6528
|
+
const submitted = useSelector39(selectSubmitted);
|
|
6525
6529
|
const dispatch = useDispatch26();
|
|
6526
6530
|
const { setThemeMode, setThemeVariables } = useAppKitTheme();
|
|
6527
6531
|
const { data: chainData } = useChainData(kimaBackendUrl);
|
|
@@ -6597,7 +6601,7 @@ var KimaTransactionWidget = ({
|
|
|
6597
6601
|
titleOption,
|
|
6598
6602
|
paymentTitleOption,
|
|
6599
6603
|
helpURL = "",
|
|
6600
|
-
compliantOption =
|
|
6604
|
+
compliantOption = false,
|
|
6601
6605
|
transactionOption,
|
|
6602
6606
|
excludedSourceNetworks = [],
|
|
6603
6607
|
excludedTargetNetworks = []
|