@layerswap/widget 1.0.3 → 1.0.4

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.
Files changed (29) hide show
  1. package/dist/esm/components/Input/Amount/ReceiveAmount.js +1 -1
  2. package/dist/esm/components/Pages/Swap/Form/FeeDetails/index.js +5 -5
  3. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/index.js +1 -1
  4. package/dist/esm/components/Pages/Swap/Withdraw/messages/TransactionMessages.js +3 -3
  5. package/dist/esm/context/LayerswapProvider.js +1 -0
  6. package/dist/esm/helpers/{getSettings.js → getSettings/getSettings.js} +1 -16
  7. package/dist/esm/helpers/getSettings/index.js +2 -0
  8. package/dist/esm/helpers/getSettings/useSettings.js +17 -0
  9. package/dist/esm/lib/AppSettings.js +1 -0
  10. package/dist/esm/lib/apiClients/index.js +2 -1
  11. package/dist/index.css +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts +2 -2
  14. package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts.map +1 -1
  15. package/dist/types/context/LayerswapProvider.d.ts +1 -0
  16. package/dist/types/context/LayerswapProvider.d.ts.map +1 -1
  17. package/dist/types/helpers/getSettings/getSettings.d.ts +7 -0
  18. package/dist/types/helpers/getSettings/getSettings.d.ts.map +1 -0
  19. package/dist/types/helpers/getSettings/index.d.ts +3 -0
  20. package/dist/types/helpers/getSettings/index.d.ts.map +1 -0
  21. package/dist/types/helpers/getSettings/useSettings.d.ts +6 -0
  22. package/dist/types/helpers/getSettings/useSettings.d.ts.map +1 -0
  23. package/dist/types/lib/AppSettings.d.ts +1 -0
  24. package/dist/types/lib/AppSettings.d.ts.map +1 -1
  25. package/dist/types/lib/apiClients/index.d.ts +2 -1
  26. package/dist/types/lib/apiClients/index.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/types/helpers/getSettings.d.ts +0 -12
  29. package/dist/types/helpers/getSettings.d.ts.map +0 -1
@@ -6,5 +6,5 @@ export const ReceiveAmount = ({ source_token, destination_token, fee, isFeeLoadi
6
6
  const receive_amount = fee?.quote.receive_amount;
7
7
  const receiveAmountInUsd = receive_amount && destination_token && fee.quote?.destination_token?.price_in_usd ? (receive_amount * fee.quote.destination_token.price_in_usd).toFixed(2) : undefined;
8
8
  const quote = fee?.quote;
9
- return (_jsx(_Fragment, { children: _jsxs("div", { className: "flex flex-col min-w-0 font-normal border-0 text-[28px] leading-7 text-primary-text w-full relative truncate", children: [_jsx("div", { className: "flex items-center justify-start w-full relative", children: _jsx("div", { className: clsx("w-full flex items-center py-[3px] pr-3", { "animate-pulse-stronger": isFeeLoading }, { "text-secondary-text": !receive_amount }), children: _jsx(NumberFlow, { value: receive_amount || 0, trend: 0, format: { maximumFractionDigits: fee?.quote.destination_token?.decimals || 2 } }) }) }), _jsxs("div", { className: "flex items-baseline space-x-2", children: [_jsx("span", { className: "text-base leading-5 font-medium text-secondary-text h-5", children: _jsx(NumberFlow, { className: "p-0", value: Number(receiveAmountInUsd) || 0, format: { style: 'currency', currency: 'USD', maximumFractionDigits: receiveAmountInUsd ? 2 : 0 }, trend: 0 }) }), _jsx(PriceImpact, { className: "h-5 text-base leading-5", bridgeFee: quote?.blockchain_fee, destinationTokenPriceUsd: quote?.destination_token?.price_in_usd, receiveAmount: quote?.receive_amount, requestedAmount: quote?.requested_amount, serviceFee: quote?.service_fee, sourceTokenPriceUsd: quote?.source_token?.price_in_usd })] })] }) }));
9
+ return (_jsx(_Fragment, { children: _jsxs("div", { className: "flex flex-col min-w-0 font-normal border-0 text-[28px] leading-7 text-primary-text w-full relative truncate", children: [_jsx("div", { className: "flex items-center justify-start w-full relative", children: _jsx("div", { className: clsx("w-full flex items-center pt-2 pr-3", { "animate-pulse-stronger": isFeeLoading }, { "text-secondary-text": !receive_amount }), children: _jsx(NumberFlow, { value: receive_amount || 0, trend: 0, format: { maximumFractionDigits: fee?.quote.destination_token?.decimals || 2 } }) }) }), _jsxs("div", { className: "flex items-baseline space-x-2 h-5", children: [_jsx("span", { className: "text-base leading-5 font-medium text-secondary-text h-5", children: _jsx(NumberFlow, { className: "p-0", value: Number(receiveAmountInUsd) || 0, format: { style: 'currency', currency: 'USD', maximumFractionDigits: receiveAmountInUsd ? 2 : 0 }, trend: 0 }) }), _jsx(PriceImpact, { className: "h-5 text-base leading-5", bridgeFee: quote?.blockchain_fee, destinationTokenPriceUsd: quote?.destination_token?.price_in_usd, receiveAmount: quote?.receive_amount, requestedAmount: quote?.requested_amount, serviceFee: quote?.service_fee, sourceTokenPriceUsd: quote?.source_token?.price_in_usd })] })] }) }));
10
10
  };
@@ -43,10 +43,10 @@ export const DetailsButton = ({ quote: quoteData, isQuoteLoading, swapValues: va
43
43
  const averageCompletionTime = quote?.avg_completion_time;
44
44
  const shouldCheckNFT = reward?.campaign_type === "for_nft_holders" && !!reward?.nft_contract_address;
45
45
  const { balance: nftBalance, isLoading, error } = useSWRNftBalance(destinationAddress || '', destination, reward?.nft_contract_address || '');
46
- return (_jsxs("div", { className: 'flex items-center gap-1 space-x-3', children: [gasFeeInUsd &&
46
+ return (_jsxs("div", { className: 'flex items-center gap-1 space-x-3', children: [gasFeeInUsd ?
47
47
  _jsxs(_Fragment, { children: [_jsxs("div", { className: clsx("inline-flex items-center gap-1", { "animate-pulse-strong": isQuoteLoading }), children: [_jsx("div", { className: 'p-0.5', children: !values.fromExchange ?
48
- _jsx(GasIcon, { className: 'h-4 w-4 text-secondary-text' }) : _jsx(ExchangeGasIcon, { className: 'h-5 w-5 text-secondary-text' }) }), _jsx(NumberFlow, { className: "text-primary-text text-sm leading-6", value: gasFeeInUsd < 0.01 ? '0.01' : gasFeeInUsd, format: { style: 'currency', currency: 'USD' }, prefix: gasFeeInUsd < 0.01 ? '<' : undefined })] }), _jsx("div", { className: "w-px h-3 bg-primary-text-tertiary rounded-2xl" })] }), averageCompletionTime &&
49
- _jsx(_Fragment, { children: _jsxs("div", { className: clsx("text-right inline-flex items-center gap-1 text-sm", { "animate-pulse-strong": isQuoteLoading }), children: [_jsx("div", { className: 'p-0.5', children: _jsx(Clock, { className: 'h-4 w-4 text-secondary-text' }) }), _jsx(AverageCompletionTime, { className: "text-primary-text", avgCompletionTime: quote.avg_completion_time })] }) }), reward &&
50
- (!shouldCheckNFT || (!isLoading && !error && nftBalance !== undefined && nftBalance > 0)) &&
51
- _jsxs(_Fragment, { children: [_jsx("div", { className: "w-px h-3 bg-primary-text-tertiary rounded-2xl" }), _jsxs("div", { className: 'text-right text-primary-text inline-flex items-center gap-1', children: [_jsx(CupIcon, { alt: "Reward", width: 16, height: 16 }), _jsx(NumberFlow, { value: reward?.amount_in_usd < 0.01 ? '0.01' : reward?.amount_in_usd, format: { style: 'currency', currency: 'USD' }, prefix: reward?.amount_in_usd < 0.01 ? '<' : undefined })] })] })] }));
48
+ _jsx(GasIcon, { className: 'h-4 w-4 text-secondary-text' }) : _jsx(ExchangeGasIcon, { className: 'h-5 w-5 text-secondary-text' }) }), _jsx(NumberFlow, { className: "text-primary-text text-sm leading-6", value: gasFeeInUsd < 0.01 ? '0.01' : gasFeeInUsd, format: { style: 'currency', currency: 'USD' }, prefix: gasFeeInUsd < 0.01 ? '<' : undefined })] }), _jsx("div", { className: "w-px h-3 bg-primary-text-tertiary rounded-2xl" })] }) : null, averageCompletionTime ?
49
+ _jsx(_Fragment, { children: _jsxs("div", { className: clsx("text-right inline-flex items-center gap-1 text-sm", { "animate-pulse-strong": isQuoteLoading }), children: [_jsx("div", { className: 'p-0.5', children: _jsx(Clock, { className: 'h-4 w-4 text-secondary-text' }) }), _jsx(AverageCompletionTime, { className: "text-primary-text", avgCompletionTime: quote.avg_completion_time })] }) }) : null, (reward &&
50
+ (!shouldCheckNFT || (!isLoading && !error && nftBalance !== undefined && nftBalance > 0))) ?
51
+ _jsxs(_Fragment, { children: [_jsx("div", { className: "w-px h-3 bg-primary-text-tertiary rounded-2xl" }), _jsxs("div", { className: 'text-right text-primary-text inline-flex items-center gap-1', children: [_jsx(CupIcon, { alt: "Reward", width: 16, height: 16 }), _jsx(NumberFlow, { value: reward?.amount_in_usd < 0.01 ? '0.01' : reward?.amount_in_usd, format: { style: 'currency', currency: 'USD' }, prefix: reward?.amount_in_usd < 0.01 ? '<' : undefined })] })] }) : null] }));
52
52
  };
@@ -147,7 +147,7 @@ const TransactionMessage = ({ error, isLoading }) => {
147
147
  // where: 'swapWithdrawalError',
148
148
  // severity: 'error',
149
149
  // });
150
- return _jsx(TransactionMessages.UexpectedErrorMessage, { message: error.message });
150
+ return _jsx(TransactionMessages.UnexpectedErrorMessage, { message: error.message });
151
151
  }
152
152
  else
153
153
  return _jsx(_Fragment, {});
@@ -25,7 +25,7 @@ const WaletMismatchMessage = ({ address }) => {
25
25
  const SwapErrorMessage = ({ message }) => {
26
26
  return _jsx(WalletMessage, { status: "error", header: 'API error', details: message });
27
27
  };
28
- const UexpectedErrorMessage = ({ message }) => {
28
+ const UnexpectedErrorMessage = ({ message }) => {
29
29
  return _jsx(WalletMessage, { status: "error", header: 'Unexpected error', details: message, showInModal: true });
30
30
  };
31
31
  const ActionMessages = {
@@ -36,7 +36,7 @@ const ActionMessages = {
36
36
  WaletMismatchMessage,
37
37
  TransactionFailedMessage,
38
38
  SwapErrorMessage,
39
- UexpectedErrorMessage,
39
+ UnexpectedErrorMessage,
40
40
  DifferentAccountsNotAllowedError
41
41
  };
42
42
  export var TransactionMessageType;
@@ -47,7 +47,7 @@ export var TransactionMessageType;
47
47
  TransactionMessageType["TransactionRejected"] = "TransactionRejected";
48
48
  TransactionMessageType["WaletMismatch"] = "WaletMismatch";
49
49
  TransactionMessageType["TransactionFailed"] = "TransactionFailed";
50
- TransactionMessageType["UexpectedErrorMessage"] = "UexpectedErrorMessage";
50
+ TransactionMessageType["UnexpectedErrorMessage"] = "UnexpectedErrorMessage";
51
51
  TransactionMessageType["DifferentAccountsNotAllowedError"] = "DifferentAccountsNotAllowedError";
52
52
  })(TransactionMessageType || (TransactionMessageType = {}));
53
53
  export default ActionMessages;
@@ -25,6 +25,7 @@ const LayerswapProviderComponent = ({ children, callbacks, config, walletProvide
25
25
  themeData = { ...THEME_COLORS['default'], ...config?.theme };
26
26
  AppSettings.ApiVersion = version || AppSettings.ApiVersion;
27
27
  AppSettings.ImtblPassportConfig = imtblPassport;
28
+ AppSettings.TonClientConfig = config?.tonConfigs || AppSettings.TonClientConfig;
28
29
  AppSettings.WalletConnectConfig = config?.walletConnect || AppSettings.WalletConnectConfig;
29
30
  AppSettings.ThemeData = themeData;
30
31
  if (apiKey)
@@ -1,5 +1,4 @@
1
- import { useEffect, useState } from "react";
2
- import LayerSwapApiClient from "../lib/apiClients/layerSwapApiClient";
1
+ import LayerSwapApiClient from "../../lib/apiClients/layerSwapApiClient";
3
2
  export async function getSettings(apiKey) {
4
3
  const apiClient = new LayerSwapApiClient();
5
4
  LayerSwapApiClient.apiKey = apiKey;
@@ -17,17 +16,3 @@ export async function getSettings(apiKey) {
17
16
  };
18
17
  return settings;
19
18
  }
20
- export function useSettings(apiKey) {
21
- const [loading, setLoading] = useState(true);
22
- const [settings, setSettings] = useState(null);
23
- useEffect(() => {
24
- (async () => {
25
- const settings = await getSettings(apiKey);
26
- if (!settings)
27
- throw new Error('Failed to fetch settings');
28
- setSettings(settings);
29
- setLoading(false);
30
- })();
31
- }, []);
32
- return { settings, loading };
33
- }
@@ -0,0 +1,2 @@
1
+ export * from './getSettings';
2
+ export * from './useSettings';
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+ import { useEffect, useState } from "react";
3
+ import { getSettings } from "./getSettings";
4
+ export function useSettings(apiKey) {
5
+ const [loading, setLoading] = useState(true);
6
+ const [settings, setSettings] = useState(null);
7
+ useEffect(() => {
8
+ (async () => {
9
+ const settings = await getSettings(apiKey);
10
+ if (!settings)
11
+ throw new Error('Failed to fetch settings');
12
+ setSettings(settings);
13
+ setLoading(false);
14
+ })();
15
+ }, []);
16
+ return { settings, loading };
17
+ }
@@ -19,6 +19,7 @@ AppSettings.WalletConnectConfig = {
19
19
  };
20
20
  AppSettings.TonClientConfig = {
21
21
  tonApiKey: 'ac793ea74c19105d617dfbeedb827f1b267b4e91f1b15b2420d003ec49722c82',
22
+ manifestUrl: `https://layerswap.io/app/tonconnect-manifest.json`
22
23
  };
23
24
  AppSettings.ImtblPassportConfig = {
24
25
  publishableKey: "",
@@ -1,2 +1,3 @@
1
1
  export * from './jsonRpcClient';
2
- export * from './layerSwapApiClient';
2
+ import LayerswapApiClient from './layerSwapApiClient';
3
+ export { LayerswapApiClient };