@xswap-link/sdk 0.13.1 → 0.14.1

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 (70) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/index.d.mts +10 -2
  3. package/dist/index.d.ts +10 -2
  4. package/dist/index.global.js +87 -86
  5. package/dist/index.js +2888 -2521
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +2828 -2458
  8. package/dist/index.mjs.map +1 -1
  9. package/localTheme.ts +5 -3
  10. package/package.json +1 -1
  11. package/src/assets/icons/AdjustmentsIcon.tsx +16 -0
  12. package/src/assets/icons/CaretDownIcon.tsx +12 -0
  13. package/src/assets/icons/CaretsUpDownIcon.tsx +13 -0
  14. package/src/assets/icons/ChainlinkMarkIcon.tsx +17 -0
  15. package/src/assets/icons/ClockIcon.tsx +14 -0
  16. package/src/assets/icons/CloseIcon.tsx +6 -2
  17. package/src/assets/icons/WarningIcon.tsx +19 -0
  18. package/src/assets/icons/index.ts +6 -0
  19. package/src/components/Modal/index.tsx +14 -9
  20. package/src/components/PoweredBy/index.tsx +12 -5
  21. package/src/components/Swap/Header/Controls/index.tsx +50 -36
  22. package/src/components/Swap/Header/index.tsx +12 -5
  23. package/src/components/Swap/HistoryView/ActivityCard/index.tsx +212 -0
  24. package/src/components/Swap/HistoryView/index.tsx +24 -6
  25. package/src/components/Swap/PickerView/index.tsx +151 -0
  26. package/src/components/Swap/ReorderButton/ReorderButton.tsx +5 -7
  27. package/src/components/Swap/SettingsView/Delivery/index.tsx +27 -28
  28. package/src/components/Swap/SettingsView/InfiniteApproval/index.tsx +27 -24
  29. package/src/components/Swap/SettingsView/Slippage/index.tsx +44 -43
  30. package/src/components/Swap/SettingsView/index.tsx +1 -1
  31. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +50 -4
  32. package/src/components/Swap/SwapView/FeesPanel/DeliveryInfo/index.tsx +9 -19
  33. package/src/components/Swap/SwapView/FeesPanel/Fee/index.tsx +4 -4
  34. package/src/components/Swap/SwapView/FeesPanel/Fees/index.tsx +5 -9
  35. package/src/components/Swap/SwapView/FeesPanel/index.tsx +21 -22
  36. package/src/components/Swap/SwapView/SwapButton/index.tsx +25 -6
  37. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/Balance/index.tsx +56 -12
  38. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +42 -41
  39. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/ChainPicker/index.tsx +143 -0
  40. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/NetworkFilter/index.tsx +159 -0
  41. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +105 -55
  42. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +226 -276
  43. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +57 -97
  44. package/src/components/Swap/SwapView/SwapPanel/UsdValue/index.tsx +27 -0
  45. package/src/components/Swap/SwapView/SwapPanel/WalletPanel/index.tsx +60 -49
  46. package/src/components/Swap/SwapView/SwapPanel/index.tsx +20 -25
  47. package/src/components/Swap/SwapView/WalletPicker/index.tsx +6 -1
  48. package/src/components/Swap/SwapView/index.tsx +2 -1
  49. package/src/components/Swap/index.tsx +20 -4
  50. package/src/components/ToggleButton/index.tsx +18 -15
  51. package/src/components/TxConfigForm/index.tsx +5 -5
  52. package/src/components/TxWidgetWC/index.tsx +4 -0
  53. package/src/components/TxWidgetWCWrapped/index.tsx +2 -0
  54. package/src/context/HistoryProvider.tsx +2 -1
  55. package/src/context/SwapProvider.tsx +87 -62
  56. package/src/context/TxUIWrapper.tsx +3 -3
  57. package/src/hooks/useEvmContractApi.ts +28 -4
  58. package/src/models/TransactionHistory.ts +1 -0
  59. package/src/models/payloads/GetBalancesPayload.ts +1 -0
  60. package/src/models/payloads/ModalIntegrationPayload.ts +1 -0
  61. package/src/models/payloads/WidgetIntegrationPayload.ts +1 -0
  62. package/src/services/api.ts +37 -0
  63. package/src/utils/index.ts +48 -1
  64. package/src/utils/tokens.ts +20 -1
  65. package/tailwind.config.js +4 -1
  66. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +0 -97
  67. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +0 -103
  68. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +0 -65
  69. package/src/components/Swap/SwapView/SwapPanel/MaxPanel/index.tsx +0 -43
  70. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/QuickPickTokenItem/index.tsx +0 -37
@@ -1,103 +0,0 @@
1
- import { CloseIcon, SearchIcon } from "@src/assets/icons";
2
- import { useSwapContext } from "@src/context";
3
- import { useMemo, useState, useRef, useEffect } from "react";
4
- import { Virtuoso } from "react-virtuoso";
5
- import { SwapPanelType } from "../../../../SwapView";
6
- import { ChainItem } from "./ChainItem";
7
- import { TextInput } from "@src/components";
8
-
9
- type Props = {
10
- type: SwapPanelType;
11
- onClose: () => void;
12
- };
13
-
14
- export const ChainPicker = ({ type, onClose }: Props) => {
15
- const { setSrcChain, setDstChain, srcChainOptions, dstChainOptions } =
16
- useSwapContext();
17
-
18
- const [searchValue, setSearchValue] = useState("");
19
- const chainSearchRef = useRef<HTMLInputElement | null>(null);
20
-
21
- useEffect(() => {
22
- if (chainSearchRef.current) {
23
- setTimeout(() => {
24
- chainSearchRef.current?.focus();
25
- }, 10);
26
- }
27
- }, []);
28
-
29
- // search input filtering
30
- const filteredChains = useMemo(() => {
31
- const chains = type === "source" ? srcChainOptions : dstChainOptions;
32
- if (!searchValue) return chains;
33
-
34
- return chains.filter((chain) => {
35
- const searchLower = searchValue.toLowerCase();
36
- return (
37
- chain.displayName.toLowerCase().includes(searchLower) ||
38
- chain.chainId.toLowerCase().includes(searchLower)
39
- );
40
- });
41
- }, [type, srcChainOptions, dstChainOptions, searchValue]);
42
-
43
- const select = (selectedChainId: string) => {
44
- const chain = filteredChains.find(
45
- ({ chainId }) => chainId === selectedChainId,
46
- );
47
-
48
- if (!chain) {
49
- throw new Error(
50
- `ChainPicker > selected chain id that is absent in chain options list.`,
51
- );
52
- }
53
-
54
- type === "source" ? setSrcChain(chain) : setDstChain(chain);
55
- onClose();
56
- };
57
-
58
- return (
59
- <div className="flex flex-col h-full">
60
- <div className="flex justify-between">
61
- <div className="text-base/4 text-t_text_primary mb-4">{`Pick ${type} chain`}</div>
62
- <div
63
- className="w-4 h-4 fill-t_text_primary cursor-pointer"
64
- onClick={onClose}
65
- >
66
- <CloseIcon />
67
- </div>
68
- </div>
69
-
70
- <TextInput
71
- ref={chainSearchRef}
72
- inputIcon={
73
- <div className="fill-t_text_primary">
74
- <SearchIcon />
75
- </div>
76
- }
77
- placeholder="Search chain name"
78
- value={searchValue}
79
- handleChange={setSearchValue}
80
- />
81
-
82
- <div className="horizontal-separator mt-4" />
83
- <div className="h-full pt-4">
84
- {filteredChains.length ? (
85
- <Virtuoso
86
- style={{ height: "100%" }}
87
- data={filteredChains}
88
- itemContent={(_, chain) => (
89
- <ChainItem
90
- chain={chain}
91
- type={type}
92
- disabled={chain.disabled}
93
- onClick={select}
94
- />
95
- )}
96
- />
97
- ) : (
98
- <div className="flex justify-center mt-4">No chain found.</div>
99
- )}
100
- </div>
101
- </div>
102
- );
103
- };
@@ -1,65 +0,0 @@
1
- import { ArrowDownIcon } from "@src/assets/icons";
2
- import { Modal } from "@src/components/Modal";
3
- import { useSwapContext } from "@src/context";
4
- import { Chain } from "@src/models";
5
- import { useMemo, useState } from "react";
6
- import { SwapPanelType } from "../../../SwapView";
7
- import { ChainPicker } from "./ChainPicker";
8
-
9
- type Props = {
10
- chain: Chain | undefined;
11
- type: SwapPanelType;
12
- className?: string;
13
- };
14
-
15
- export const ChainPanel = ({ chain, type, className }: Props) => {
16
- const { srcChainLocked, dstChainLocked } = useSwapContext();
17
-
18
- const projectLockedDestinationChain = useMemo(
19
- () => type === "destination" && dstChainLocked,
20
- [type, dstChainLocked],
21
- );
22
-
23
- const projectLockedSourceChain = useMemo(
24
- () => type === "source" && srcChainLocked,
25
- [type, srcChainLocked],
26
- );
27
-
28
- const [chainPickerModalOpen, setChainPickerModalOpen] = useState(false);
29
-
30
- return (
31
- <>
32
- {chainPickerModalOpen && (
33
- <Modal onClose={() => setChainPickerModalOpen(false)}>
34
- <ChainPicker
35
- type={type}
36
- onClose={() => setChainPickerModalOpen(false)}
37
- />
38
- </Modal>
39
- )}
40
-
41
- <button
42
- type="button"
43
- disabled={projectLockedDestinationChain || projectLockedSourceChain}
44
- onClick={() => setChainPickerModalOpen(true)}
45
- className={`${className || ""}`}
46
- >
47
- <div className="flex justify-between items-center p-4 gap-8">
48
- <div className="flex flex-col font-medium items-start">
49
- <p className="text-xs opacity-60">
50
- {type === "source" ? "From:" : "To:"}
51
- </p>
52
- <p className={`${chain ? "" : "opacity-60"}`}>
53
- {chain ? chain.displayName : "Select"}
54
- </p>
55
- </div>
56
- {!projectLockedDestinationChain && !projectLockedSourceChain && (
57
- <div className="w-4 h-2 fill-t_text_primary">
58
- <ArrowDownIcon />
59
- </div>
60
- )}
61
- </div>
62
- </button>
63
- </>
64
- );
65
- };
@@ -1,43 +0,0 @@
1
- import { useSwapContext } from "@src/context";
2
- import { weiToHumanReadable } from "@src/utils";
3
- import { SwapPanelType } from "../../index";
4
-
5
- type Props = {
6
- type: SwapPanelType;
7
- };
8
- export const MaxPanel = ({ type }: Props) => {
9
- const { srcToken, srcTokenBalanceWei, srcTokenBalanceInfo, setSrcValue } =
10
- useSwapContext();
11
-
12
- return (
13
- <button
14
- type="button"
15
- className={`flex items-center w-16 justify-center p-4 gap-8 ${
16
- !srcTokenBalanceInfo && "opacity-60"
17
- } ${
18
- type === "source" &&
19
- "border-l border-solid border-t_text_primary border-opacity-10"
20
- }`}
21
- disabled={!srcTokenBalanceInfo}
22
- onClick={() =>
23
- setSrcValue(
24
- weiToHumanReadable({
25
- amount: srcTokenBalanceWei,
26
- decimals: srcToken?.decimals || 18,
27
- precisionFractionalPlaces: srcToken?.decimals || 18,
28
- }),
29
- )
30
- }
31
- >
32
- {type === "source" && (
33
- <p
34
- className={`border-b border-solid border-t_text_primary ${
35
- !srcTokenBalanceInfo && "border-opacity-60"
36
- }`}
37
- >
38
- Max
39
- </p>
40
- )}
41
- </button>
42
- );
43
- };
@@ -1,37 +0,0 @@
1
- import { TokenLogo } from "@src/components";
2
- import { TokenOption } from "@src/models";
3
-
4
- type Props = {
5
- token: TokenOption;
6
- selectedTokenAddress: string | undefined;
7
- onClick: () => void;
8
- };
9
- export const QuickPickTokenItem = ({
10
- token,
11
- selectedTokenAddress,
12
- onClick,
13
- }: Props) => {
14
- return (
15
- <button
16
- type="button"
17
- className={`flex gap-2 py-2 pr-[14px] pl-2 items-center border border-solid border-t_text_primary border-opacity-10 rounded-3xl text-start hover:bg-t_bg_tertiary hover:bg-opacity-10 ${
18
- token.address.toLowerCase() === selectedTokenAddress?.toLowerCase()
19
- ? "bg-t_bg_tertiary bg-opacity-10"
20
- : "bg-t_bg_primary"
21
- }`}
22
- onClick={onClick}
23
- >
24
- <TokenLogo
25
- token={token}
26
- className="w-6 h-6"
27
- generatedLogoClassName="w-6 h-6"
28
- />
29
- <div className="flex flex-col gap-1 text-xs font-medium !leading-3">
30
- <div className="text-t_text_primary">{token.name}</div>
31
- <div className="text-t_text_primary text-opacity-50">
32
- {token.symbol}
33
- </div>
34
- </div>
35
- </button>
36
- );
37
- };