@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,9 +1,9 @@
1
- import { StarsIcon } from "@src/assets/icons";
1
+ import { StarsIcon, WarningIcon } from "@src/assets/icons";
2
2
  import { Skeleton, TokenLogoWithChain } from "@src/components";
3
3
  import { SwapPanelType } from "@src/components/Swap/SwapView";
4
4
  import { useSwapContext } from "@src/context";
5
5
  import { TokenOption } from "@src/models";
6
- import { weiToHumanReadable } from "@src/utils";
6
+ import { shortAddress, weiToHumanReadable } from "@src/utils";
7
7
  import { ethers } from "ethers";
8
8
  import { useMemo } from "react";
9
9
  import { useAccount } from "wagmi";
@@ -14,6 +14,11 @@ type Props = {
14
14
  selectedChainId: string | undefined;
15
15
  onClick: () => void;
16
16
  panelType: SwapPanelType;
17
+ /**
18
+ * When picking this token would disconnect the other side of the swap,
19
+ * names the side that will be reset ("source" | "destination").
20
+ */
21
+ resetWarning?: SwapPanelType | null;
17
22
  };
18
23
  export const TokenItem = ({
19
24
  token,
@@ -21,6 +26,7 @@ export const TokenItem = ({
21
26
  onClick,
22
27
  selectedChainId,
23
28
  panelType,
29
+ resetWarning,
24
30
  }: Props) => {
25
31
  const {
26
32
  supportedChains,
@@ -55,66 +61,110 @@ export const TokenItem = ({
55
61
  return tokenBalance * +tokenPrice;
56
62
  }, [tokenBalance, tokenPrice, hasBalance]);
57
63
 
64
+ const isSelected =
65
+ token.address.toLowerCase() === selectedTokenAddress?.toLowerCase() &&
66
+ selectedChainId &&
67
+ token.chainId === selectedChainId;
68
+
58
69
  return (
59
- <div
60
- className={`token-picker-container ${
61
- token.address.toLowerCase() === selectedTokenAddress?.toLowerCase() &&
62
- selectedChainId &&
63
- token.chainId === selectedChainId
64
- ? "bg-t_bg_tertiary bg-opacity-10"
65
- : ""
66
- }`}
67
- onClick={onClick}
68
- >
69
- <TokenLogoWithChain
70
- token={token}
71
- chain={chain}
72
- tokenLogoClassName="min-w-9 w-9 h-9"
73
- generatedLogoClassName="min-w-9 w-9 h-9 text-[16px]"
74
- chainLogoClassName="w-5"
75
- />
76
- <div className="flex justify-between items-center gap-1 w-full">
77
- <div className="text-left">
78
- <div className="text-sm font-medium text-ellipsis text-t_text_primary flex items-center gap-1">
79
- {token.name}
80
- {integrationConfig?.highlightedDstTokens?.includes(token.symbol) &&
81
- panelType === "destination" && (
70
+ <div className="pb-2">
71
+ <div
72
+ className={`flex gap-3 items-center p-3 sm:p-4 rounded-xl cursor-pointer bg-gradient-to-r from-t_bg_tertiary/[0.02] to-t_bg_tertiary/[0.02] bg-[rgba(40,40,40,0.15)] hover:bg-t_bg_tertiary hover:bg-opacity-10 transition-colors ${
73
+ isSelected ? "!bg-t_bg_tertiary !bg-opacity-10" : ""
74
+ }`}
75
+ onClick={onClick}
76
+ >
77
+ <div className={`shrink-0 ${resetWarning ? "opacity-40" : ""}`}>
78
+ <TokenLogoWithChain
79
+ token={token}
80
+ chain={chain}
81
+ tokenLogoClassName="min-w-10 w-10 h-10"
82
+ generatedLogoClassName="min-w-10 w-10 h-10 text-[16px]"
83
+ chainLogoClassName="w-[18px]"
84
+ />
85
+ </div>
86
+ <div className="flex justify-between items-center gap-2 w-full min-w-0">
87
+ <div
88
+ className={`text-left min-w-0 ${resetWarning ? "opacity-40" : ""}`}
89
+ >
90
+ <div className="text-sm font-medium leading-5 tracking-[0.01em] text-t_text_primary flex items-center gap-1">
91
+ {token.symbol}
92
+ {integrationConfig?.highlightedDstTokens?.includes(
93
+ token.symbol,
94
+ ) &&
95
+ panelType === "destination" && (
96
+ <div
97
+ className="flex items-center justify-center text-t_text_primary rounded-full w-3.5 h-3.5 text-xs"
98
+ title="AI-powered token"
99
+ >
100
+ <StarsIcon />
101
+ </div>
102
+ )}
103
+ </div>
104
+ <div className="flex gap-2 items-center text-xs leading-[18px] tracking-[0.01em] text-t_text_primary text-opacity-50">
105
+ <span className="whitespace-nowrap">
106
+ {chain?.displayName || token.name}
107
+ </span>
108
+ {!resetWarning && (
109
+ <>
110
+ <span className="w-0.5 h-0.5 bg-t_text_primary opacity-25 shrink-0" />
111
+ <span className="whitespace-nowrap hidden sm:block">
112
+ {shortAddress(token.address)}
113
+ </span>
114
+ </>
115
+ )}
116
+ </div>
117
+ </div>
118
+
119
+ <div className="text-right shrink-0">
120
+ {address && isFetchingBalances ? (
121
+ <Skeleton className="w-[48px] h-[12px]" />
122
+ ) : (
123
+ token.balance &&
124
+ token.decimals &&
125
+ address && (
82
126
  <div
83
- className={`flex items-center justify-center text-white rounded-full border-t_bg_secondary ${"w-3.5 h-3.5 text-xs"}`}
84
- title="AI-powered token"
127
+ className={`text-sm font-medium leading-5 tracking-[0.01em] text-t_text_primary ${
128
+ resetWarning ? "opacity-40" : ""
129
+ }`}
85
130
  >
86
- <StarsIcon />
131
+ {token.balance.eq(0) || tokenBalance! > 0.0001
132
+ ? weiToHumanReadable({
133
+ amount: token.balance.toString(),
134
+ decimals: token.decimals,
135
+ precisionFractionalPlaces: 4,
136
+ })
137
+ : "<0.0001"}
87
138
  </div>
88
- )}
89
- </div>
90
- <div className="text-xs text-t_text_primary text-opacity-50 font-medium">
91
- {token.symbol}
92
- </div>
93
- </div>
94
- {token.balance && token.decimals && address && !isFetchingBalances && (
95
- <div className="text-right">
96
- <div className="text-xs text-t_text_primary">
97
- {token.balance.eq(0) || tokenBalance! > 0.0001
98
- ? weiToHumanReadable({
99
- amount: token.balance.toString(),
100
- decimals: token.decimals,
101
- precisionFractionalPlaces: 4,
102
- })
103
- : "<0.0001"}
104
- </div>
105
- {hasBalance && (
106
- <div className="text-xs text-t_text_primary text-opacity-50">
107
- {tokenValueUsd ? `$${tokenValueUsd.toFixed(2)}` : "$ -"}
139
+ )
140
+ )}
141
+ {resetWarning ? (
142
+ <div className="flex items-center justify-end gap-1.5 text-[#D77F02]">
143
+ <WarningIcon className="w-3.5 h-3.5 shrink-0" />
144
+ <span className="text-xs leading-[18px] tracking-[0.01em] whitespace-nowrap">
145
+ <span className="sm:hidden">
146
+ {resetWarning === "source"
147
+ ? "Source will reset."
148
+ : "Destination will reset."}
149
+ </span>
150
+ <span className="hidden sm:inline">
151
+ {resetWarning === "source"
152
+ ? "Source will reset after selection."
153
+ : "Destination will reset after selection."}
154
+ </span>
155
+ </span>
108
156
  </div>
157
+ ) : (
158
+ !isFetchingBalances &&
159
+ hasBalance &&
160
+ address && (
161
+ <div className="text-xs leading-[18px] tracking-[0.01em] text-t_text_primary text-opacity-50">
162
+ {tokenValueUsd ? `${tokenValueUsd.toFixed(2)} USD` : "-"}
163
+ </div>
164
+ )
109
165
  )}
110
166
  </div>
111
- )}
112
-
113
- {address && isFetchingBalances && (
114
- <div>
115
- <Skeleton className="w-[48px] h-[12px]" />
116
- </div>
117
- )}
167
+ </div>
118
168
  </div>
119
169
  </div>
120
170
  );