@xswap-link/sdk 0.14.0 → 0.15.0

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 (78) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/index.d.mts +4 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.global.js +92 -92
  5. package/dist/index.js +3208 -2862
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +3083 -2740
  8. package/dist/index.mjs.map +1 -1
  9. package/localTheme.ts +6 -4
  10. package/package.json +1 -1
  11. package/src/assets/icons/AdjustmentsIcon.tsx +5 -7
  12. package/src/assets/icons/ChainlinkMarkIcon.tsx +4 -5
  13. package/src/assets/icons/CheckCircleThinIcon.tsx +22 -0
  14. package/src/assets/icons/ChevronDownThinIcon.tsx +39 -0
  15. package/src/assets/icons/ChevronDownWideThinIcon.tsx +18 -0
  16. package/src/assets/icons/ChevronsUpDownThinIcon.tsx +21 -0
  17. package/src/assets/icons/ClockIcon.tsx +3 -7
  18. package/src/assets/icons/CloseIcon.tsx +9 -4
  19. package/src/assets/icons/ErrorCircleThinIcon.tsx +22 -0
  20. package/src/assets/icons/LinkExternalThinIcon.tsx +19 -0
  21. package/src/assets/icons/LoadingRingIcon.tsx +22 -0
  22. package/src/assets/icons/ProgressRingThinIcon.tsx +29 -0
  23. package/src/assets/icons/SearchThinIcon.tsx +15 -0
  24. package/src/assets/icons/SignThinIcon.tsx +15 -0
  25. package/src/assets/icons/WalletCheckThinIcon.tsx +24 -0
  26. package/src/assets/icons/WarningIcon.tsx +8 -5
  27. package/src/assets/icons/index.ts +11 -0
  28. package/src/components/Modal/index.tsx +14 -9
  29. package/src/components/PoweredBy/index.tsx +6 -8
  30. package/src/components/Swap/Header/index.tsx +2 -4
  31. package/src/components/Swap/HistoryView/ActivityCard/index.tsx +110 -115
  32. package/src/components/Swap/HistoryView/index.tsx +10 -7
  33. package/src/components/Swap/PickerView/index.tsx +151 -0
  34. package/src/components/Swap/ReorderButton/ReorderButton.tsx +4 -4
  35. package/src/components/Swap/SettingsView/Delivery/index.tsx +19 -17
  36. package/src/components/Swap/SettingsView/InfiniteApproval/index.tsx +19 -17
  37. package/src/components/Swap/SettingsView/Slippage/index.tsx +55 -49
  38. package/src/components/Swap/SwapView/ConfirmationView/TokenTiles/index.tsx +69 -0
  39. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Header/index.tsx +13 -25
  40. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Steps/index.tsx +65 -113
  41. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +68 -26
  42. package/src/components/Swap/SwapView/ConfirmationView/TxResult/index.tsx +51 -74
  43. package/src/components/Swap/SwapView/FeesPanel/DeliveryInfo/index.tsx +1 -1
  44. package/src/components/Swap/SwapView/FeesPanel/index.tsx +5 -5
  45. package/src/components/Swap/SwapView/SwapButton/index.tsx +2 -31
  46. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/Balance/index.tsx +2 -2
  47. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +2 -2
  48. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/ChainPicker/index.tsx +143 -0
  49. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/NetworkFilter/index.tsx +19 -16
  50. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +11 -4
  51. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +185 -105
  52. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +54 -120
  53. package/src/components/Swap/SwapView/SwapPanel/UsdValue/index.tsx +2 -2
  54. package/src/components/Swap/SwapView/SwapPanel/WalletPanel/index.tsx +10 -16
  55. package/src/components/Swap/SwapView/SwapPanel/index.tsx +4 -4
  56. package/src/components/Swap/SwapView/WalletPicker/index.tsx +131 -139
  57. package/src/components/Swap/SwapView/index.tsx +11 -7
  58. package/src/components/Swap/WalletPickerView/index.tsx +65 -0
  59. package/src/components/Swap/index.tsx +39 -8
  60. package/src/components/ToggleButton/index.tsx +5 -7
  61. package/src/components/TokenLogo/index.tsx +1 -1
  62. package/src/components/TxConfigForm/index.tsx +2 -2
  63. package/src/components/TxModal/index.tsx +14 -4
  64. package/src/components/global.css +18 -1
  65. package/src/constants/index.ts +4 -0
  66. package/src/context/HistoryProvider.tsx +1 -1
  67. package/src/context/SwapProvider.tsx +193 -81
  68. package/src/context/TxUIWrapper.tsx +3 -3
  69. package/src/hooks/useEvmContractApi.ts +28 -4
  70. package/src/models/payloads/GetBalancesPayload.ts +1 -0
  71. package/src/services/api.ts +37 -0
  72. package/src/utils/index.ts +27 -1
  73. package/src/utils/tokens.ts +20 -1
  74. package/src/utils/validation.ts +9 -4
  75. package/tailwind.config.js +4 -1
  76. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/ArrowIcon.tsx +0 -13
  77. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/SwapPanel/index.tsx +0 -72
  78. package/src/components/Swap/SwapView/ConfirmationView/TxResult/TokenItem/index.tsx +0 -25
@@ -379,11 +379,16 @@ const mapToValidPathBridge = ({
379
379
  chain: newSourceChain,
380
380
  bridgeTokensDictionary,
381
381
  });
382
- if (defaultToken && newSourceChain && newTargetChain) {
383
- const isDefaultTokenBridgeable =
384
- !!bridgeTokensDictionary[newSourceChain.chainId]?.[
382
+ if (defaultToken && newSourceChain) {
383
+ const bridgeTargets =
384
+ bridgeTokensDictionary[newSourceChain.chainId]?.[
385
385
  defaultToken.address.toLowerCase()
386
- ]?.[newTargetChain.chainId];
386
+ ] || {};
387
+ // With no target chain picked yet the default still applies, as long as
388
+ // the token is bridgeable somewhere.
389
+ const isDefaultTokenBridgeable = newTargetChain
390
+ ? !!bridgeTargets[newTargetChain.chainId]
391
+ : Object.keys(bridgeTargets).length > 0;
387
392
 
388
393
  if (isDefaultTokenBridgeable) {
389
394
  newSourceToken = defaultToken;
@@ -96,7 +96,10 @@ export default {
96
96
  x_modal: "var(--modal-width, 340px)",
97
97
  },
98
98
  width: {
99
- x_modal: "var(--modal-width, 620px)",
99
+ // No fallback on purpose: unless the integrator sets --modal-width,
100
+ // the width resolves to `auto` so the widget can shrink on mobile.
101
+ // The default 620px cap comes from max-width below.
102
+ x_modal: "var(--modal-width)",
100
103
  },
101
104
  maxWidth: {
102
105
  x_modal: "var(--modal-width, 620px)",
@@ -1,13 +0,0 @@
1
- import { ArrowDownLongIcon } from "@src/assets/icons";
2
-
3
- export const ArrowIcon = () => {
4
- return (
5
- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 p-1 border border-solid border-t_text_primary border-opacity-10 rounded-xl bg-t_bg_secondary">
6
- <div className="relative bg-gradient-to-r from-t_main_accent_light to-t_main_accent_dark w-8 h-8 rounded-xl">
7
- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 fill-white">
8
- <ArrowDownLongIcon />
9
- </div>
10
- </div>
11
- </div>
12
- );
13
- };
@@ -1,72 +0,0 @@
1
- import { TokenLogo } from "@src/components";
2
- import { useSwapContext } from "@src/context";
3
- import { SwapPanelType } from "../../../index";
4
- import { useMemo } from "react";
5
- import { Ecosystem } from "@src/models";
6
-
7
- type Props = {
8
- type: SwapPanelType;
9
- };
10
- export const SwapPanel = ({ type }: Props) => {
11
- const {
12
- srcToken,
13
- srcChain,
14
- dstToken,
15
- dstChain,
16
- srcValue,
17
- srcValueUsd,
18
- dstValue,
19
- dstValueUsd,
20
- bridgeUI,
21
- } = useSwapContext();
22
-
23
- const token = useMemo(
24
- () => (type === "source" ? srcToken : dstToken),
25
- [dstToken, srcToken, type],
26
- );
27
-
28
- const chain = useMemo(
29
- () => (type === "source" ? srcChain : dstChain),
30
- [dstChain, srcChain, type],
31
- );
32
-
33
- const value = useMemo(() => {
34
- if (
35
- type === "destination" &&
36
- bridgeUI &&
37
- srcChain?.ecosystem === Ecosystem.SOLANA
38
- ) {
39
- return srcValue;
40
- }
41
- return type === "source" ? srcValue : dstValue;
42
- }, [type, bridgeUI, srcChain?.ecosystem, srcValue, dstValue]);
43
-
44
- const valueUsd = useMemo(() => {
45
- return type === "source" ? srcValueUsd : dstValueUsd;
46
- }, [dstValueUsd, srcValueUsd, type]);
47
-
48
- return (
49
- <div className="flex justify-between bg-gradient-to-r from-t_main_accent_light/20 to-t_main_accent_dark/20 p-5 rounded-xl">
50
- <div className="flex flex-col">
51
- <div className="opacity-60 text-sm mb-2">{`You ${
52
- type === "source" ? "pay" : "receive"
53
- }`}</div>
54
- <div className={`${type === "destination" && "text-t_text_secondary"}`}>
55
- {value}
56
- </div>
57
- {valueUsd && <div className="opacity-60">${valueUsd}</div>}
58
- </div>
59
- <div className="flex items-center gap-3">
60
- <div className="flex flex-col text-right">
61
- <div>{token?.symbol}</div>
62
- <div className="opacity-60">{chain?.displayName}</div>
63
- </div>
64
- <TokenLogo
65
- token={token}
66
- className="w-9 h-9"
67
- generatedLogoClassName="w-9 h-9"
68
- />
69
- </div>
70
- </div>
71
- );
72
- };
@@ -1,25 +0,0 @@
1
- import { TokenLogoWithChain } from "@src/components";
2
- import { Chain, Token } from "@src/models";
3
-
4
- type Props = {
5
- chain: Chain | undefined;
6
- token: Token | undefined;
7
- value: string;
8
- };
9
- export const TokenItem = ({ chain, token, value }: Props) => {
10
- return (
11
- <div className="flex items-center gap-2">
12
- <TokenLogoWithChain
13
- chain={chain}
14
- token={token}
15
- chainLogoClassName="w-5"
16
- tokenLogoClassName="w-9 h-9"
17
- generatedLogoClassName="w-9 h-9 text-[16px]"
18
- />
19
- <div className="flex flex-col w-min sm:w-auto">
20
- <div>{`${value} ${token?.symbol}`}</div>
21
- <div className="opacity-60">{chain?.displayName}</div>
22
- </div>
23
- </div>
24
- );
25
- };