@xswap-link/sdk 0.8.6 → 0.9.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 (41) hide show
  1. package/.github/workflows/main.yml +2 -1
  2. package/.github/workflows/pr_agent.yml +22 -0
  3. package/CHANGELOG.md +12 -0
  4. package/babel.config.cjs +8 -0
  5. package/dist/index.global.js +130 -133
  6. package/dist/index.js +10 -10
  7. package/dist/index.mjs +10 -10
  8. package/jest.config.ts +37 -0
  9. package/package.json +17 -5
  10. package/src/components/Modal/index.tsx +1 -1
  11. package/src/components/Swap/Header/index.tsx +1 -1
  12. package/src/components/Swap/ReorderButton/ReorderButton.tsx +12 -10
  13. package/src/components/Swap/SwapView/FeesPanel/index.tsx +1 -1
  14. package/src/components/Swap/SwapView/SwapButton/index.tsx +23 -21
  15. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +4 -2
  16. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +5 -7
  17. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +18 -2
  18. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +1 -24
  19. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/QuickPickTokenItem/index.tsx +2 -11
  20. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +12 -3
  21. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +124 -34
  22. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +1 -1
  23. package/src/components/Swap/SwapView/index.tsx +1 -1
  24. package/src/constants/index.ts +1 -1
  25. package/src/context/HistoryProvider.tsx +2 -2
  26. package/src/context/SwapProvider.tsx +163 -53
  27. package/src/context/TransactionProvider.tsx +1 -1
  28. package/src/utils/validation.ts +239 -186
  29. package/tailwind.config.js +1 -0
  30. package/test/context/SwapProvider.test.tsx +851 -0
  31. package/test/fileMock.ts +1 -0
  32. package/test/fixtures/bridgeTokens.mock.ts +1318 -0
  33. package/test/fixtures/bridgeTokensDictionary.mock.ts +1272 -0
  34. package/test/fixtures/integrationConfig.mock.ts +10 -0
  35. package/test/fixtures/supportedChains.mock.ts +32950 -0
  36. package/test/{api.test.ts → services/getChains.test.ts} +6 -5
  37. package/test/setup.ts +13 -0
  38. package/test/styleMock.ts +1 -0
  39. package/jest.config.json +0 -8
  40. package/test/api.mock.ts +0 -106
  41. package/test/setupTests.ts +0 -3
package/jest.config.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { JestConfigWithTsJest } from "ts-jest";
2
+
3
+ const esmModules = [
4
+ "uuid",
5
+ "wagmi",
6
+ "@wagmi",
7
+ "viem",
8
+ "@viem",
9
+ "@tanstack/react-query",
10
+ ];
11
+
12
+ const config: JestConfigWithTsJest = {
13
+ extensionsToTreatAsEsm: [".ts", ".tsx"],
14
+ verbose: true,
15
+ preset: "ts-jest",
16
+ testEnvironment: "jsdom",
17
+ setupFilesAfterEnv: ["<rootDir>/test/setup.ts"],
18
+ transform: {
19
+ "^.+\\.tsx?$": ["ts-jest", { useESM: true }],
20
+ "\\.jsx?$": "babel-jest",
21
+ },
22
+ transformIgnorePatterns: [
23
+ `node_modules/(?!(?:.pnpm/)?(${esmModules.join("|")}))`,
24
+ ],
25
+ testPathIgnorePatterns: ["./dist"],
26
+ moduleNameMapper: {
27
+ "^@src/(.*)$": "<rootDir>/src/$1",
28
+ "^@/(.*)$": "<rootDir>/src/$1",
29
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
30
+ "<rootDir>/test/fileMock.ts",
31
+ "\\.(css)$": "<rootDir>/test/styleMock.ts",
32
+ },
33
+ automock: false,
34
+ resetMocks: false,
35
+ };
36
+
37
+ export default config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xswap-link/sdk",
3
- "version": "0.8.6",
3
+ "version": "0.9.0",
4
4
  "description": "JavaScript SDK for XSwap platform",
5
5
  "homepage": "https://github.com/xswap-link/xswap-sdk",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "@fortawesome/free-solid-svg-icons": "^6.4.2",
36
36
  "@fortawesome/react-fontawesome": "^0.2.0",
37
37
  "@r2wc/core": "^1.1.0",
38
- "@tanstack/react-query": "^5.35.5",
38
+ "@tanstack/react-query": "^5.64.2",
39
39
  "async-retry": "^1.3.3",
40
40
  "bignumber.js": "4.0.4",
41
41
  "date-fns": "^3.6.0",
@@ -43,11 +43,18 @@
43
43
  "notistack": "^3.0.1",
44
44
  "react-error-boundary": "^4.1.0",
45
45
  "react-virtuoso": "^4.7.12",
46
- "viem": "2.x",
47
- "wagmi": "^2.8.5"
46
+ "viem": "~2.22.12",
47
+ "wagmi": "^2.14.9"
48
48
  },
49
49
  "devDependencies": {
50
+ "@babel/core": "^7.26.0",
51
+ "@babel/preset-env": "^7.26.0",
52
+ "@babel/preset-react": "^7.26.3",
53
+ "@babel/preset-typescript": "^7.26.0",
50
54
  "@changesets/cli": "^2.27.1",
55
+ "@testing-library/jest-dom": "^6.4.2",
56
+ "@testing-library/react": "^14.2.1",
57
+ "@testing-library/user-event": "^14.5.2",
51
58
  "@types/async-retry": "^1.4.8",
52
59
  "@types/jest": "^29.5.12",
53
60
  "@types/node": "^20.11.17",
@@ -55,9 +62,13 @@
55
62
  "@types/react-dom": "^18.2.0",
56
63
  "@typescript-eslint/eslint-plugin": "^7.1.0",
57
64
  "@typescript-eslint/parser": "^7.1.0",
65
+ "babel-jest": "^29.7.0",
66
+ "cross-fetch": "^4.1.0",
58
67
  "eslint": "^8.57.0",
59
68
  "eslint-plugin-react-hooks": "^4.6.2",
69
+ "identity-obj-proxy": "^3.0.0",
60
70
  "jest": "^29.7.0",
71
+ "jest-environment-jsdom": "^29.7.0",
61
72
  "jest-fetch": "^1.1.1",
62
73
  "jest-fetch-mock": "^3.0.3",
63
74
  "nodemon": "^3.1.0",
@@ -67,6 +78,7 @@
67
78
  "react-dom": "^18.2.0",
68
79
  "tailwindcss": "^3.4.3",
69
80
  "ts-jest": "^29.1.2",
81
+ "ts-node": "^10.9.2",
70
82
  "tsup": "^8.1.0",
71
83
  "typescript": "^5.3.3"
72
84
  },
@@ -84,6 +96,6 @@
84
96
  "watch": "tsup && nodemon",
85
97
  "release": "tsup && changeset publish",
86
98
  "lint": "tsc && eslint . --ext .ts",
87
- "test": "jest"
99
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
88
100
  }
89
101
  }
@@ -45,7 +45,7 @@ export const Modal: FC<{
45
45
  }}
46
46
  >
47
47
  <div
48
- className="flex flex-col bg-t_bg_primary x-border rounded-3xl p-4 w-full min-w-[340px]"
48
+ className="flex flex-col bg-t_bg_primary rounded-3xl p-4 w-full min-w-[340px]"
49
49
  style={{
50
50
  height: overlay ? "600px" : "100%",
51
51
  maxWidth: "480px",
@@ -9,7 +9,7 @@ export const Header = ({ onClose }: Props) => {
9
9
 
10
10
  return (
11
11
  <div className="flex justify-between">
12
- <div className="text-xl">
12
+ <div className="text-xl font-sans-bold font-bold">
13
13
  {tab === "Swap" && bridgeUI ? "Bridge" : tab}
14
14
  </div>
15
15
  <Controls onClose={onClose} />
@@ -22,16 +22,18 @@ export const ReorderButton: FC = () => {
22
22
  };
23
23
 
24
24
  return (
25
- <button
26
- onClick={onReorderClick}
27
- aria-label="Switch target token with the source token"
28
- className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-14 p-1 border border-solid border-t_text_primary border-opacity-10 rounded-xl bg-t_bg_secondary"
29
- >
30
- <div className="relative bg-gradient-to-r from-t_main_accent_light to-t_main_accent_dark w-8 h-8 rounded-lg">
31
- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 fill-white">
32
- <ArrowsExchange />
25
+ <div className="h-[1px] w-full">
26
+ <button
27
+ onClick={onReorderClick}
28
+ aria-label="Switch target token with the source token"
29
+ className="absolute -translate-y-5 left-1/2 -translate-x-5 p-1 border border-solid border-t_text_primary border-opacity-10 rounded-xl bg-t_bg_secondary"
30
+ >
31
+ <div className="relative bg-gradient-to-r from-t_main_accent_light to-t_main_accent_dark w-8 h-8 rounded-lg">
32
+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 fill-white">
33
+ <ArrowsExchange />
34
+ </div>
33
35
  </div>
34
- </div>
35
- </button>
36
+ </button>
37
+ </div>
36
38
  );
37
39
  };
@@ -42,7 +42,7 @@ export const FeesPanel = () => {
42
42
  {isFetchingRoute ? (
43
43
  <Skeleton className="w-[100px] h-full" />
44
44
  ) : (
45
- <p>{`${totalFee} ${feeToken?.symbol}`}</p>
45
+ <p>{`${totalFee} ${feeToken?.symbol || ""}`}</p>
46
46
  )}
47
47
  </div>
48
48
  <div className="flex gap-2 items-center fill-t_text_primary">
@@ -33,6 +33,7 @@ export const SwapButton = () => {
33
33
  srcValueWei,
34
34
  srcTokenBalanceWei,
35
35
  isFetchingRoute,
36
+ isAsyncDataLoaded,
36
37
  } = useSwapContext();
37
38
 
38
39
  const { setTxStatus, setTxMsg, setTxModalOpen, enqueueTransaction } =
@@ -92,7 +93,7 @@ export const SwapButton = () => {
92
93
  }, [setTxModalOpen, setTxMsg, setTxStatus]);
93
94
 
94
95
  const button: Button = useMemo(() => {
95
- if (!srcChainId || !dstChainId || !srcTokenAddress || !dstTokenAddress) {
96
+ if (!isAsyncDataLoaded) {
96
97
  return {
97
98
  text: "Loading XPay...",
98
99
  fn: () => {},
@@ -111,8 +112,8 @@ export const SwapButton = () => {
111
112
  if (!address) {
112
113
  return {
113
114
  text: integrationConfig.defaultWalletPicker
114
- ? "Connect wallet"
115
- : "Connect wallet first",
115
+ ? "Connect Wallet"
116
+ : "Connect Wallet First",
116
117
  fn: () => {
117
118
  setConnectWalletModalOpen(true);
118
119
  },
@@ -120,12 +121,20 @@ export const SwapButton = () => {
120
121
  };
121
122
  }
122
123
 
124
+ if (!srcChainId || !dstChainId || !srcTokenAddress || !dstTokenAddress) {
125
+ return {
126
+ text: "Select Tokens",
127
+ fn: () => {},
128
+ disabled: true,
129
+ };
130
+ }
131
+
123
132
  if (
124
133
  srcChainId === dstChainId &&
125
134
  srcTokenAddress.toLowerCase() === dstTokenAddress.toLowerCase()
126
135
  ) {
127
136
  return {
128
- text: "Change token",
137
+ text: "Change Token",
129
138
  fn: () => {},
130
139
  disabled: true,
131
140
  };
@@ -133,7 +142,7 @@ export const SwapButton = () => {
133
142
 
134
143
  if (chainId?.toString() !== srcChainId) {
135
144
  return {
136
- text: "Change chain",
145
+ text: "Change Chain",
137
146
  fn: async () => await switchChainAsync({ chainId: Number(srcChainId) }),
138
147
  disabled: false,
139
148
  };
@@ -145,15 +154,7 @@ export const SwapButton = () => {
145
154
  safeBigNumberFrom(srcValueWei).gt(safeBigNumberFrom(srcTokenBalanceWei))
146
155
  ) {
147
156
  return {
148
- text: "Insufficient balance",
149
- fn: () => {},
150
- disabled: true,
151
- };
152
- }
153
-
154
- if (!srcTokenAddress || !dstTokenAddress) {
155
- return {
156
- text: `Select token`,
157
+ text: "Insufficient Balance",
157
158
  fn: () => {},
158
159
  disabled: true,
159
160
  };
@@ -161,7 +162,7 @@ export const SwapButton = () => {
161
162
 
162
163
  if (safeBigNumberFrom(srcValueWei || "0").lte(safeBigNumberFrom("0"))) {
163
164
  return {
164
- text: `Enter token amount`,
165
+ text: `Enter Token Amount`,
165
166
  fn: () => {},
166
167
  disabled: true,
167
168
  };
@@ -169,7 +170,7 @@ export const SwapButton = () => {
169
170
 
170
171
  if (isFetchingRoute) {
171
172
  return {
172
- text: `Fetching route`,
173
+ text: `Fetching Route`,
173
174
  fn: () => {},
174
175
  disabled: true,
175
176
  };
@@ -181,7 +182,7 @@ export const SwapButton = () => {
181
182
  BigNumber.from(currentTokenAllowance).lt(BigNumber.from(srcValueWei))
182
183
  ) {
183
184
  return {
184
- text: "Reset approval",
185
+ text: "Reset Approval",
185
186
  fn: async () => {
186
187
  enqueueTransaction({
187
188
  executeTransaction: () => approve("0", routerAddress),
@@ -207,18 +208,19 @@ export const SwapButton = () => {
207
208
  disabled: false,
208
209
  };
209
210
  }, [
210
- bridgeUI,
211
+ isAsyncDataLoaded,
212
+ error,
213
+ address,
211
214
  srcChainId,
212
215
  dstChainId,
213
216
  srcTokenAddress,
214
217
  dstTokenAddress,
215
- error,
216
- address,
217
218
  chainId,
218
219
  srcValueWei,
219
220
  srcTokenBalanceWei,
220
221
  isFetchingRoute,
221
222
  currentTokenAllowance,
223
+ bridgeUI,
222
224
  integrationConfig.defaultWalletPicker,
223
225
  switchChainAsync,
224
226
  enqueueTransaction,
@@ -241,7 +243,7 @@ export const SwapButton = () => {
241
243
  type="button"
242
244
  disabled={button.disabled}
243
245
  onClick={button.fn}
244
- className={`text-xl w-full py-5 cursor-pointer disabled:cursor-not-allowed rounded-2xl border-none ${
246
+ className={`text-xl font-sans-bold font-bold w-full py-5 cursor-pointer disabled:cursor-not-allowed rounded-2xl border-none ${
245
247
  button.disabled
246
248
  ? "bg-t_button_pr_off_bg text-t_button_pr_off_text"
247
249
  : "bg-gradient-to-r from-t_main_accent_light to-t_main_accent_dark text-t_button_pr_text"
@@ -31,7 +31,7 @@ export const AmountPanel = ({ type }: Props) => {
31
31
  <>
32
32
  <SafeInput
33
33
  id="swap-amount-input"
34
- className={`bg-transparent border-none p-0 text-xl outline-0`}
34
+ className={`bg-transparent border-none p-0 text-xl outline-0 font-sans-bold font-bold`}
35
35
  regex={NUMBER_INPUT_REGEX}
36
36
  value={srcValue}
37
37
  onChange={(value) => setSrcValue(value)}
@@ -47,7 +47,9 @@ export const AmountPanel = ({ type }: Props) => {
47
47
  </div>
48
48
  ) : (
49
49
  <>
50
- <div className={`text-xl text-t_text_secondary`}>
50
+ <div
51
+ className={`text-xl text-t_text_secondary font-sans-bold font-bold`}
52
+ >
51
53
  {dstValue || 0}
52
54
  </div>
53
55
  {valueUsd && (
@@ -9,11 +9,11 @@ import { useMemo, useRef } from "react";
9
9
  type Props = {
10
10
  chain: Chain;
11
11
  type: SwapPanelType;
12
- disabledChains: string[];
12
+ disabled: boolean;
13
13
  onClick: (chainId: string) => void;
14
14
  };
15
15
 
16
- export const ChainItem = ({ chain, type, onClick, disabledChains }: Props) => {
16
+ export const ChainItem = ({ chain, type, onClick, disabled }: Props) => {
17
17
  const {
18
18
  networks: { evm },
19
19
  } = useNetworks();
@@ -40,12 +40,10 @@ export const ChainItem = ({ chain, type, onClick, disabledChains }: Props) => {
40
40
  return type === "destination" ? srcChain?.chainId : dstChain?.chainId;
41
41
  }, [bridgeUI, dstChain?.chainId, srcChain?.chainId, type]);
42
42
 
43
- const isInDisabledChains = disabledChains.includes(chain.chainId);
44
-
45
43
  return (
46
44
  <div
47
45
  onClick={() => {
48
- if (chain.chainId === sameChainId || isInDisabledChains) {
46
+ if (chain.chainId === sameChainId || disabled) {
49
47
  return;
50
48
  }
51
49
  onClick(chain.chainId);
@@ -53,7 +51,7 @@ export const ChainItem = ({ chain, type, onClick, disabledChains }: Props) => {
53
51
  className={`flex justify-between items-center gap-3 mt-2 mb-2 cursor-pointer p-4 border border-solid border-white border-opacity-0 hover:selected-chain-item ${
54
52
  currentChainId === chain.chainId ? "selected-chain-item" : ""
55
53
  } ${
56
- chain.chainId === sameChainId || isInDisabledChains
54
+ chain.chainId === sameChainId || disabled
57
55
  ? "disabled-chain-item cursor-default"
58
56
  : ""
59
57
  }`}
@@ -70,7 +68,7 @@ export const ChainItem = ({ chain, type, onClick, disabledChains }: Props) => {
70
68
  </div>
71
69
  )}
72
70
 
73
- {isInDisabledChains && chain.chainId !== sameChainId && (
71
+ {disabled && chain.chainId !== sameChainId && (
74
72
  <div className="flex items-center gap-1">
75
73
  <Tooltip
76
74
  text={
@@ -101,6 +101,22 @@ export const ChainPicker = ({
101
101
  supportedChains,
102
102
  ]);
103
103
 
104
+ const sortedChains = useMemo(() => {
105
+ return filteredChains
106
+ .map((chain) => ({
107
+ ...chain,
108
+ disabled: disabledChains.includes(chain.chainId),
109
+ }))
110
+ .sort((a, b) => {
111
+ if (a.disabled === b.disabled) {
112
+ return 0;
113
+ }
114
+
115
+ // Place false before true.
116
+ return a.disabled ? 1 : -1;
117
+ });
118
+ }, [filteredChains, disabledChains]);
119
+
104
120
  return (
105
121
  <div className="flex flex-col h-full">
106
122
  <div className="flex justify-between">
@@ -117,12 +133,12 @@ export const ChainPicker = ({
117
133
  {filteredChains.length ? (
118
134
  <Virtuoso
119
135
  style={{ height: "100%" }}
120
- data={filteredChains}
136
+ data={sortedChains}
121
137
  itemContent={(_, chain) => (
122
138
  <ChainItem
123
139
  chain={chain}
124
140
  type={type}
125
- disabledChains={disabledChains}
141
+ disabled={chain.disabled}
126
142
  onClick={select}
127
143
  />
128
144
  )}
@@ -2,8 +2,7 @@ import { ArrowDownIcon } from "@src/assets/icons";
2
2
  import { Modal } from "@src/components/Modal";
3
3
  import { useSwapContext } from "@src/context";
4
4
  import { Chain, Token } from "@src/models";
5
- import { useCallback, useEffect, useMemo, useState } from "react";
6
- import { useAccount } from "wagmi";
5
+ import { useCallback, useMemo, useState } from "react";
7
6
  import { SwapPanelType } from "../../../SwapView";
8
7
  import { ChainPicker } from "./ChainPicker";
9
8
 
@@ -15,8 +14,6 @@ type Props = {
15
14
 
16
15
  export const ChainPanel = ({ chain, type, className }: Props) => {
17
16
  const {
18
- supportedChains,
19
- srcChain,
20
17
  setSrcChain,
21
18
  setDstChain,
22
19
  srcToken,
@@ -25,13 +22,10 @@ export const ChainPanel = ({ chain, type, className }: Props) => {
25
22
  setDstToken,
26
23
  srcChainLocked,
27
24
  dstChainLocked,
28
- integrationConfig,
29
25
  bridgeUI,
30
26
  bridgeTokensDictionary,
31
27
  } = useSwapContext();
32
28
 
33
- const { chainId } = useAccount();
34
-
35
29
  const projectLockedDestinationChain = useMemo(
36
30
  () => type === "destination" && dstChainLocked,
37
31
  [type, dstChainLocked],
@@ -42,23 +36,6 @@ export const ChainPanel = ({ chain, type, className }: Props) => {
42
36
  [type, srcChainLocked],
43
37
  );
44
38
 
45
- // select chain from user wallet
46
- useEffect(() => {
47
- if (!chainId || integrationConfig.srcChainId) return;
48
-
49
- const userChainFromWallet = supportedChains.find(
50
- (chain) => chain.chainId === String(chainId),
51
- );
52
- if (
53
- !userChainFromWallet ||
54
- srcChain?.chainId === userChainFromWallet.chainId
55
- )
56
- return;
57
-
58
- setSrcChain(userChainFromWallet);
59
- // eslint-disable-next-line react-hooks/exhaustive-deps
60
- }, [chainId]);
61
-
62
39
  const [chainPickerModalOpen, setChainPickerModalOpen] = useState(false);
63
40
 
64
41
  const handleSrcChainChange = useCallback(
@@ -1,7 +1,5 @@
1
1
  import { TokenLogo } from "@src/components";
2
- import { useSwapContext } from "@src/context";
3
2
  import { TokenOption } from "@src/models";
4
- import { useMemo } from "react";
5
3
 
6
4
  type Props = {
7
5
  token: TokenOption;
@@ -13,13 +11,6 @@ export const QuickPickTokenItem = ({
13
11
  selectedTokenAddress,
14
12
  onClick,
15
13
  }: Props) => {
16
- const { supportedChains } = useSwapContext();
17
-
18
- const chain = useMemo(
19
- () => supportedChains.find(({ chainId }) => chainId === token.chainId),
20
- [supportedChains, token],
21
- );
22
-
23
14
  return (
24
15
  <button
25
16
  type="button"
@@ -36,9 +27,9 @@ export const QuickPickTokenItem = ({
36
27
  generatedLogoClassName="w-6 h-6"
37
28
  />
38
29
  <div className="flex flex-col gap-1 text-xs font-medium !leading-3">
39
- <div className="text-t_text_primary">{token.symbol}</div>
30
+ <div className="text-t_text_primary">{token.name}</div>
40
31
  <div className="text-t_text_primary text-opacity-50">
41
- {chain?.displayName}
32
+ {token.symbol}
42
33
  </div>
43
34
  </div>
44
35
  </button>
@@ -9,9 +9,15 @@ import { useAccount } from "wagmi";
9
9
  type Props = {
10
10
  token: TokenOption;
11
11
  selectedTokenAddress: string | undefined;
12
+ selectedChainId: string | undefined;
12
13
  onClick: () => void;
13
14
  };
14
- export const TokenItem = ({ token, selectedTokenAddress, onClick }: Props) => {
15
+ export const TokenItem = ({
16
+ token,
17
+ selectedTokenAddress,
18
+ onClick,
19
+ selectedChainId,
20
+ }: Props) => {
15
21
  const { supportedChains } = useSwapContext();
16
22
  const { address } = useAccount();
17
23
 
@@ -24,7 +30,10 @@ export const TokenItem = ({ token, selectedTokenAddress, onClick }: Props) => {
24
30
  <div
25
31
  className={`token-picker-container ${
26
32
  token.address.toLowerCase() === selectedTokenAddress?.toLowerCase() &&
27
- "bg-t_bg_tertiary bg-opacity-10"
33
+ selectedChainId &&
34
+ token.chainId === selectedChainId
35
+ ? "bg-t_bg_tertiary bg-opacity-10"
36
+ : ""
28
37
  }`}
29
38
  onClick={onClick}
30
39
  >
@@ -41,7 +50,7 @@ export const TokenItem = ({ token, selectedTokenAddress, onClick }: Props) => {
41
50
  {token.name}
42
51
  </div>
43
52
  <div className="text-xs text-t_text_primary text-opacity-50 font-medium">
44
- {chain?.displayName}
53
+ {token.symbol}
45
54
  </div>
46
55
  </div>
47
56