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