@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.cjs
CHANGED
|
@@ -2544,11 +2544,12 @@ function useIsWalletReady() {
|
|
|
2544
2544
|
checkChainId();
|
|
2545
2545
|
}, [externalProvider, sourceChain, switchNetwork, walletChainId, isConnected]);
|
|
2546
2546
|
(0, import_react76.useEffect)(() => {
|
|
2547
|
-
if (isConnected) {
|
|
2547
|
+
if (isConnected && sourceChain.compatibility === "EVM" /* EVM */) {
|
|
2548
2548
|
console.debug(
|
|
2549
2549
|
"useIsWalletReady:EVM: Dispatching source address:",
|
|
2550
2550
|
walletAddress
|
|
2551
2551
|
);
|
|
2552
|
+
console.log("dispatching evm address: ", walletAddress);
|
|
2552
2553
|
dispatch(setSourceAddress(walletAddress ?? ""));
|
|
2553
2554
|
}
|
|
2554
2555
|
}, [walletAddress, isConnected, dispatch]);
|
|
@@ -2798,10 +2799,7 @@ function useEvmAllowance() {
|
|
|
2798
2799
|
});
|
|
2799
2800
|
return await walletClient.signMessage({
|
|
2800
2801
|
account: walletAddress,
|
|
2801
|
-
message: `
|
|
2802
|
-
Target Address: ${data.targetAddress}
|
|
2803
|
-
Target Chain: ${data.targetChain}
|
|
2804
|
-
Target Symbol: ${data.targetSymbol}`
|
|
2802
|
+
message: `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`
|
|
2805
2803
|
});
|
|
2806
2804
|
} catch (error) {
|
|
2807
2805
|
console.error("useEvmAllowance: Error on signing message:", error);
|
|
@@ -3112,13 +3110,10 @@ function useSolanaAllowance() {
|
|
|
3112
3110
|
return;
|
|
3113
3111
|
}
|
|
3114
3112
|
try {
|
|
3115
|
-
const message = `
|
|
3116
|
-
Target Address: ${data.targetAddress}
|
|
3117
|
-
Target Chain: ${data.targetChain}
|
|
3118
|
-
Target Symbol: ${data.targetSymbol}`;
|
|
3113
|
+
const message = `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`;
|
|
3119
3114
|
const encodedMessage = new TextEncoder().encode(message);
|
|
3120
3115
|
const signature = await signMessage(encodedMessage);
|
|
3121
|
-
return signature
|
|
3116
|
+
return `0x${Buffer.from(signature).toString("hex")}`;
|
|
3122
3117
|
} catch (error2) {
|
|
3123
3118
|
console.error("Error signing message:", error2);
|
|
3124
3119
|
throw error2;
|
|
@@ -3697,10 +3692,7 @@ function useTronAllowance() {
|
|
|
3697
3692
|
return;
|
|
3698
3693
|
}
|
|
3699
3694
|
try {
|
|
3700
|
-
const message = `
|
|
3701
|
-
Target Address: ${data.targetAddress}
|
|
3702
|
-
Target Chain: ${data.targetChain}
|
|
3703
|
-
Target Symbol: ${data.targetSymbol}`;
|
|
3695
|
+
const message = `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`;
|
|
3704
3696
|
const signedMessage = await signMessage(message);
|
|
3705
3697
|
return signedMessage;
|
|
3706
3698
|
} catch (error2) {
|
|
@@ -3918,7 +3910,7 @@ var import_react136 = __toESM(require("react"), 1);
|
|
|
3918
3910
|
|
|
3919
3911
|
// src/components/KimaWidgetWrapper.tsx
|
|
3920
3912
|
var import_react134 = __toESM(require("react"), 1);
|
|
3921
|
-
var
|
|
3913
|
+
var import_react_redux53 = require("react-redux");
|
|
3922
3914
|
|
|
3923
3915
|
// src/components/TransactionWidget.tsx
|
|
3924
3916
|
var import_react121 = __toESM(require("react"), 1);
|
|
@@ -5234,7 +5226,7 @@ var TransactionWidget = ({ theme }) => {
|
|
|
5234
5226
|
|
|
5235
5227
|
// src/components/TransferWidget.tsx
|
|
5236
5228
|
var import_react133 = __toESM(require("react"), 1);
|
|
5237
|
-
var
|
|
5229
|
+
var import_react_redux52 = require("react-redux");
|
|
5238
5230
|
|
|
5239
5231
|
// src/components/reusable/SingleForm.tsx
|
|
5240
5232
|
var import_react123 = __toESM(require("react"), 1);
|
|
@@ -5996,6 +5988,7 @@ var useValidateTransaction_default = useValidateTransaction;
|
|
|
5996
5988
|
// src/hooks/useSubmitTransaction.tsx
|
|
5997
5989
|
var import_react131 = require("react");
|
|
5998
5990
|
var import_react_redux50 = require("react-redux");
|
|
5991
|
+
var import_react_redux51 = require("react-redux");
|
|
5999
5992
|
var useSubmitTransaction = ({
|
|
6000
5993
|
amount,
|
|
6001
5994
|
totalFee,
|
|
@@ -6010,7 +6003,8 @@ var useSubmitTransaction = ({
|
|
|
6010
6003
|
}) => {
|
|
6011
6004
|
const dispatch = (0, import_react_redux50.useDispatch)();
|
|
6012
6005
|
const [isSubmitting, setSubmitting] = (0, import_react131.useState)(false);
|
|
6013
|
-
const
|
|
6006
|
+
const signature = (0, import_react_redux51.useSelector)(selectSignature);
|
|
6007
|
+
const submitTransaction = async () => {
|
|
6014
6008
|
try {
|
|
6015
6009
|
setSubmitting(true);
|
|
6016
6010
|
const params = JSON.stringify({
|
|
@@ -6152,37 +6146,38 @@ var TransferWidget = ({
|
|
|
6152
6146
|
titleOption,
|
|
6153
6147
|
paymentTitleOption
|
|
6154
6148
|
}) => {
|
|
6155
|
-
const dispatch = (0,
|
|
6149
|
+
const dispatch = (0, import_react_redux52.useDispatch)();
|
|
6156
6150
|
const mainRef = (0, import_react133.useRef)(null);
|
|
6157
6151
|
const [formStep, setFormStep] = (0, import_react133.useState)(0);
|
|
6158
6152
|
const [warningModalOpen, setWarningModalOpen] = (0, import_react133.useState)(null);
|
|
6159
|
-
const dAppOption = (0,
|
|
6160
|
-
const mode = (0,
|
|
6161
|
-
const transactionOption = (0,
|
|
6162
|
-
const backendUrl = (0,
|
|
6163
|
-
const sourceAddress = (0,
|
|
6164
|
-
const targetAddress = (0,
|
|
6165
|
-
const sourceChain = (0,
|
|
6166
|
-
const targetChain = (0,
|
|
6167
|
-
const sourceCurrency = (0,
|
|
6168
|
-
const targetCurrency = (0,
|
|
6169
|
-
const amount = (0,
|
|
6153
|
+
const dAppOption = (0, import_react_redux52.useSelector)(selectDappOption);
|
|
6154
|
+
const mode = (0, import_react_redux52.useSelector)(selectMode);
|
|
6155
|
+
const transactionOption = (0, import_react_redux52.useSelector)(selectTransactionOption);
|
|
6156
|
+
const backendUrl = (0, import_react_redux52.useSelector)(selectBackendUrl);
|
|
6157
|
+
const sourceAddress = (0, import_react_redux52.useSelector)(selectSourceAddress);
|
|
6158
|
+
const targetAddress = (0, import_react_redux52.useSelector)(selectTargetAddress);
|
|
6159
|
+
const sourceChain = (0, import_react_redux52.useSelector)(selectSourceChain);
|
|
6160
|
+
const targetChain = (0, import_react_redux52.useSelector)(selectTargetChain);
|
|
6161
|
+
const sourceCurrency = (0, import_react_redux52.useSelector)(selectSourceCurrency);
|
|
6162
|
+
const targetCurrency = (0, import_react_redux52.useSelector)(selectTargetCurrency);
|
|
6163
|
+
const amount = (0, import_react_redux52.useSelector)(selectAmount);
|
|
6170
6164
|
const {
|
|
6171
6165
|
totalFeeUsd,
|
|
6172
6166
|
totalFee,
|
|
6173
6167
|
targetNetworkFee,
|
|
6174
6168
|
submitAmount,
|
|
6175
6169
|
decimals: feeDecimals
|
|
6176
|
-
} = (0,
|
|
6177
|
-
const compliantOption = (0,
|
|
6178
|
-
const networkOptions3 = (0,
|
|
6179
|
-
const feeDeduct = (0,
|
|
6170
|
+
} = (0, import_react_redux52.useSelector)(selectServiceFee);
|
|
6171
|
+
const compliantOption = (0, import_react_redux52.useSelector)(selectCompliantOption);
|
|
6172
|
+
const networkOptions3 = (0, import_react_redux52.useSelector)(selectNetworkOption);
|
|
6173
|
+
const feeDeduct = (0, import_react_redux52.useSelector)(selectFeeDeduct);
|
|
6180
6174
|
const { keplrHandler, closeHandler } = useKimaContext();
|
|
6181
6175
|
const [isCancellingApprove, setCancellingApprove] = (0, import_react133.useState)(false);
|
|
6182
6176
|
const [isApproving, setApproving] = (0, import_react133.useState)(false);
|
|
6183
6177
|
const [isSigning, setSigning] = (0, import_react133.useState)(false);
|
|
6184
|
-
const pendingTxs = (0,
|
|
6185
|
-
const networks = (0,
|
|
6178
|
+
const pendingTxs = (0, import_react_redux52.useSelector)(selectPendingTxs);
|
|
6179
|
+
const networks = (0, import_react_redux52.useSelector)(selectNetworks);
|
|
6180
|
+
const signature = (0, import_react_redux52.useSelector)(selectSignature);
|
|
6186
6181
|
const { width: windowWidth } = useWidth_default();
|
|
6187
6182
|
const { disconnectWallet } = useDisconnectWallet4();
|
|
6188
6183
|
const { balance } = useBalance2();
|
|
@@ -6238,20 +6233,29 @@ var TransferWidget = ({
|
|
|
6238
6233
|
return import_react_hot_toast5.toast.error(validationMessage, { icon: /* @__PURE__ */ import_react133.default.createElement(Error_default, null) });
|
|
6239
6234
|
}
|
|
6240
6235
|
if (error === "ApprovalNeeded" /* ApprovalNeeded */) {
|
|
6236
|
+
const signature2 = await signMessage?.({
|
|
6237
|
+
targetAddress,
|
|
6238
|
+
targetChain: targetChain.name,
|
|
6239
|
+
originSymbol: sourceCurrency,
|
|
6240
|
+
originChain: sourceChain.name
|
|
6241
|
+
});
|
|
6242
|
+
setSignature(signature2);
|
|
6241
6243
|
return approve();
|
|
6242
6244
|
}
|
|
6243
6245
|
if (dAppOption === "LPDrain" /* LPDrain */ || dAppOption === "LPAdd" /* LPAdd */) {
|
|
6244
6246
|
keplrHandler && keplrHandler(sourceAddress);
|
|
6245
6247
|
return;
|
|
6246
6248
|
}
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6249
|
+
if (!signature?.length) {
|
|
6250
|
+
const signature2 = await signMessage?.({
|
|
6251
|
+
targetAddress,
|
|
6252
|
+
targetChain: targetChain.name,
|
|
6253
|
+
originSymbol: sourceCurrency,
|
|
6254
|
+
originChain: sourceChain.name
|
|
6255
|
+
});
|
|
6256
|
+
setSignature(signature2);
|
|
6257
|
+
}
|
|
6258
|
+
const { success, message: submitMessage } = await submitTransaction();
|
|
6255
6259
|
if (!success) return import_react_hot_toast5.toast.error(submitMessage, { icon: /* @__PURE__ */ import_react133.default.createElement(Error_default, null) });
|
|
6256
6260
|
};
|
|
6257
6261
|
const onNext = () => {
|
|
@@ -6477,8 +6481,8 @@ var KimaWidgetWrapper = ({
|
|
|
6477
6481
|
excludedTargetNetworks = []
|
|
6478
6482
|
}) => {
|
|
6479
6483
|
const { kimaBackendUrl } = useKimaContext();
|
|
6480
|
-
const submitted = (0,
|
|
6481
|
-
const dispatch = (0,
|
|
6484
|
+
const submitted = (0, import_react_redux53.useSelector)(selectSubmitted);
|
|
6485
|
+
const dispatch = (0, import_react_redux53.useDispatch)();
|
|
6482
6486
|
const { setThemeMode, setThemeVariables } = (0, import_react135.useAppKitTheme)();
|
|
6483
6487
|
const { data: chainData } = useChainData(kimaBackendUrl);
|
|
6484
6488
|
const { data: envOptions } = useGetEnvOptions({ kimaBackendUrl });
|
|
@@ -6544,7 +6548,7 @@ var KimaWidgetWrapper = ({
|
|
|
6544
6548
|
var KimaWidgetWrapper_default = KimaWidgetWrapper;
|
|
6545
6549
|
|
|
6546
6550
|
// src/components/KimaTransactionWidget.tsx
|
|
6547
|
-
var
|
|
6551
|
+
var import_react_redux54 = require("react-redux");
|
|
6548
6552
|
var KimaTransactionWidget = ({
|
|
6549
6553
|
mode,
|
|
6550
6554
|
txId,
|
|
@@ -6553,12 +6557,12 @@ var KimaTransactionWidget = ({
|
|
|
6553
6557
|
titleOption,
|
|
6554
6558
|
paymentTitleOption,
|
|
6555
6559
|
helpURL = "",
|
|
6556
|
-
compliantOption =
|
|
6560
|
+
compliantOption = false,
|
|
6557
6561
|
transactionOption,
|
|
6558
6562
|
excludedSourceNetworks = [],
|
|
6559
6563
|
excludedTargetNetworks = []
|
|
6560
6564
|
}) => {
|
|
6561
|
-
const dispatch = (0,
|
|
6565
|
+
const dispatch = (0, import_react_redux54.useDispatch)();
|
|
6562
6566
|
const { kimaBackendUrl } = useKimaContext();
|
|
6563
6567
|
const { isLoading: isLoadingEnvs } = useGetEnvOptions({
|
|
6564
6568
|
kimaBackendUrl
|