@kimafinance/kima-transaction-widget 1.3.10 → 1.3.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 CHANGED
@@ -2750,12 +2750,14 @@ function useEvmAllowance() {
2750
2750
  const appkitAccountInfo = (0, import_react79.useAppKitAccount)();
2751
2751
  const sourceChain = (0, import_react_redux5.useSelector)(selectSourceChain);
2752
2752
  const networkOption = (0, import_react_redux5.useSelector)(selectNetworkOption);
2753
- const { totalFeeUsd, allowanceAmount, decimals } = (0, import_react_redux5.useSelector)(selectServiceFee);
2753
+ const { totalFeeUsd, allowanceAmount, submitAmount, decimals } = (0, import_react_redux5.useSelector)(selectServiceFee);
2754
2754
  const selectedCoin = (0, import_react_redux5.useSelector)(selectSourceCurrency);
2755
2755
  const tokenOptions = (0, import_react_redux5.useSelector)(selectTokenOptions);
2756
2756
  const backendUrl = (0, import_react_redux5.useSelector)(selectBackendUrl);
2757
2757
  const feeDeduct = (0, import_react_redux5.useSelector)(selectFeeDeduct);
2758
- const allowanceNumber = Number((0, import_ethers6.formatUnits)(allowanceAmount ?? "0", decimals));
2758
+ const allowanceNumber = Number(
2759
+ (0, import_ethers6.formatUnits)(feeDeduct ? submitAmount : allowanceAmount ?? "0", decimals)
2760
+ );
2759
2761
  const amount = (0, import_react_redux5.useSelector)(selectAmount);
2760
2762
  const { pools } = useGetPools_default(backendUrl, networkOption);
2761
2763
  const walletAddress = externalProvider?.signer?.address || appkitAccountInfo?.address;
@@ -2799,7 +2801,7 @@ function useEvmAllowance() {
2799
2801
  });
2800
2802
  return await walletClient.signMessage({
2801
2803
  account: walletAddress,
2802
- message: `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`
2804
+ message: `I approve the transfer of ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}.`
2803
2805
  });
2804
2806
  } catch (error) {
2805
2807
  console.error("useEvmAllowance: Error on signing message:", error);
@@ -3057,10 +3059,13 @@ var import_web38 = require("@solana/web3.js");
3057
3059
  var import_ethers7 = require("ethers");
3058
3060
  function useSolanaAllowance() {
3059
3061
  const sourceChain = (0, import_react_redux7.useSelector)(selectSourceChain);
3060
- const { allowanceAmount, decimals } = (0, import_react_redux7.useSelector)(selectServiceFee);
3062
+ const { allowanceAmount, submitAmount, decimals } = (0, import_react_redux7.useSelector)(selectServiceFee);
3063
+ const feeDeduct = (0, import_react_redux7.useSelector)(selectFeeDeduct);
3061
3064
  const backendUrl = (0, import_react_redux7.useSelector)(selectBackendUrl);
3062
3065
  const networkOption = (0, import_react_redux7.useSelector)(selectNetworkOption);
3063
- const allowanceNumber = Number((0, import_ethers7.formatUnits)(allowanceAmount ?? "0", decimals));
3066
+ const allowanceNumber = Number(
3067
+ (0, import_ethers7.formatUnits)(feeDeduct ? submitAmount : allowanceAmount ?? "0", decimals)
3068
+ );
3064
3069
  const { externalProvider } = useKimaContext();
3065
3070
  const { connection: internalConnection } = (0, import_wallet_adapter_react3.useConnection)();
3066
3071
  const {
@@ -3110,7 +3115,7 @@ function useSolanaAllowance() {
3110
3115
  return;
3111
3116
  }
3112
3117
  try {
3113
- const message = `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`;
3118
+ const message = `I approve the transfer of ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}.`;
3114
3119
  const encodedMessage = new TextEncoder().encode(message);
3115
3120
  const signature = await signMessage(encodedMessage);
3116
3121
  return `0x${Buffer.from(signature).toString("hex")}`;
@@ -3644,11 +3649,14 @@ function useTronAllowance() {
3644
3649
  const sourceChain = (0, import_react_redux11.useSelector)(selectSourceChain);
3645
3650
  const networkOption = (0, import_react_redux11.useSelector)(selectNetworkOption);
3646
3651
  const backendUrl = (0, import_react_redux11.useSelector)(selectBackendUrl);
3647
- const { allowanceAmount, decimals } = (0, import_react_redux11.useSelector)(selectServiceFee);
3652
+ const { allowanceAmount, submitAmount, decimals } = (0, import_react_redux11.useSelector)(selectServiceFee);
3648
3653
  (0, import_tronwallet_adapter_react_hooks3.useWallet)();
3649
3654
  const selectedCoin = (0, import_react_redux11.useSelector)(selectSourceCurrency);
3650
3655
  const tokenOptions = (0, import_react_redux11.useSelector)(selectTokenOptions);
3651
- const allowanceNumber = Number((0, import_ethers9.formatUnits)(allowanceAmount ?? "0", decimals));
3656
+ const feeDeduct = (0, import_react_redux11.useSelector)(selectFeeDeduct);
3657
+ const allowanceNumber = Number(
3658
+ (0, import_ethers9.formatUnits)(feeDeduct ? submitAmount : allowanceAmount ?? "0", decimals)
3659
+ );
3652
3660
  const { pools } = useGetPools_default(backendUrl, networkOption);
3653
3661
  const {
3654
3662
  address: internalUserAddress,
@@ -3692,7 +3700,7 @@ function useTronAllowance() {
3692
3700
  return;
3693
3701
  }
3694
3702
  try {
3695
- const message = `I approve moving ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}`;
3703
+ const message = `I approve the transfer of ${allowanceNumber} ${data.originSymbol} from ${data.originChain} to ${data.targetAddress} on ${data.targetChain}.`;
3696
3704
  const signedMessage = await signMessage(message);
3697
3705
  return signedMessage;
3698
3706
  } catch (error2) {
@@ -6233,9 +6241,9 @@ var TransferWidget = ({
6233
6241
  if (error === "ApprovalNeeded" /* ApprovalNeeded */) {
6234
6242
  const sig2 = await signMessage?.({
6235
6243
  targetAddress,
6236
- targetChain: targetChain.name,
6244
+ targetChain: targetChain.shortName,
6237
6245
  originSymbol: sourceCurrency,
6238
- originChain: sourceChain.name
6246
+ originChain: sourceChain.shortName
6239
6247
  });
6240
6248
  setSignature2(sig2);
6241
6249
  return approve();
@@ -6248,9 +6256,9 @@ var TransferWidget = ({
6248
6256
  if (!sig) {
6249
6257
  sig = await signMessage?.({
6250
6258
  targetAddress,
6251
- targetChain: targetChain.name,
6259
+ targetChain: targetChain.shortName,
6252
6260
  originSymbol: sourceCurrency,
6253
- originChain: sourceChain.name
6261
+ originChain: sourceChain.shortName
6254
6262
  });
6255
6263
  }
6256
6264
  const { success, message: submitMessage } = await submitTransaction(sig);