@xswap-link/sdk 0.8.7 → 0.9.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.
- package/.github/workflows/main.yml +2 -1
- package/CHANGELOG.md +12 -0
- package/babel.config.cjs +8 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.global.js +132 -135
- package/dist/index.js +9 -9
- package/dist/index.mjs +10 -10
- package/jest.config.ts +37 -0
- package/package.json +17 -5
- package/src/components/Modal/index.tsx +1 -1
- package/src/components/Swap/Header/index.tsx +1 -1
- package/src/components/Swap/ReorderButton/ReorderButton.tsx +12 -10
- package/src/components/Swap/SwapView/FeesPanel/index.tsx +1 -1
- package/src/components/Swap/SwapView/SwapButton/index.tsx +23 -21
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +4 -2
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +51 -59
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +47 -13
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +138 -35
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +6 -2
- package/src/components/Swap/SwapView/SwapPanel/index.tsx +1 -1
- package/src/components/Swap/SwapView/index.tsx +2 -2
- package/src/components/Tooltip/index.tsx +1 -1
- package/src/context/HistoryProvider.tsx +2 -2
- package/src/context/SwapProvider.tsx +174 -100
- package/src/context/TransactionProvider.tsx +1 -1
- package/src/models/TokenData.ts +3 -1
- package/src/models/payloads/GetPricesPayload.ts +1 -1
- package/src/utils/validation.ts +50 -16
- package/tailwind.config.js +1 -0
- package/test/context/SwapProvider.test.tsx +851 -0
- package/test/fileMock.ts +1 -0
- package/test/fixtures/bridgeTokens.mock.ts +1318 -0
- package/test/fixtures/bridgeTokensDictionary.mock.ts +1272 -0
- package/test/fixtures/integrationConfig.mock.ts +10 -0
- package/test/fixtures/supportedChains.mock.ts +32950 -0
- package/test/{api.test.ts → services/getChains.test.ts} +6 -5
- package/test/setup.ts +13 -0
- package/test/styleMock.ts +1 -0
- package/jest.config.json +0 -8
- package/test/api.mock.ts +0 -106
- package/test/setupTests.ts +0 -3
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import fetchMock from "jest-fetch-mock";
|
|
2
|
+
import { getChains } from "../../src/services";
|
|
3
|
+
|
|
4
|
+
const chains = ["test", "test2", "test3", "test4"];
|
|
4
5
|
|
|
5
6
|
describe("API", () => {
|
|
6
7
|
beforeEach(() => {
|
|
7
|
-
|
|
8
|
+
fetchMock.resetMocks();
|
|
8
9
|
});
|
|
9
10
|
|
|
10
11
|
describe("getChains", () => {
|
|
11
12
|
it("should return all supported chains", async () => {
|
|
12
|
-
|
|
13
|
+
fetchMock.mockResponse(JSON.stringify(chains));
|
|
13
14
|
|
|
14
15
|
const supportedChains = await getChains();
|
|
15
16
|
|
package/test/setup.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextEncoder, TextDecoder } from "util";
|
|
2
|
+
import "@testing-library/jest-dom";
|
|
3
|
+
import fetchMock from "jest-fetch-mock";
|
|
4
|
+
fetchMock.enableMocks();
|
|
5
|
+
|
|
6
|
+
global.TextEncoder = TextEncoder;
|
|
7
|
+
// @ts-expect-error -- Type mismatch but it works at runtime
|
|
8
|
+
global.TextDecoder = TextDecoder;
|
|
9
|
+
|
|
10
|
+
// Mock crypto.randomUUID
|
|
11
|
+
Object.defineProperty(global.crypto, "randomUUID", {
|
|
12
|
+
value: () => "test-uuid",
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
package/jest.config.json
DELETED
package/test/api.mock.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export const chains = [
|
|
2
|
-
{
|
|
3
|
-
_id: "65e6fb6a332ca66c92561432",
|
|
4
|
-
ecosystem: "evm",
|
|
5
|
-
chainId: "1",
|
|
6
|
-
name: "ethereum",
|
|
7
|
-
displayName: "Ethereum",
|
|
8
|
-
web3Environment: "mainnet",
|
|
9
|
-
transactionExplorer: "https://etherscan.io/tx",
|
|
10
|
-
rpcUrls: ["https://mock-rpc-url.com"],
|
|
11
|
-
ccipChainId: "5009297550715157269",
|
|
12
|
-
tokens: [
|
|
13
|
-
{
|
|
14
|
-
address: "0x0000000000000000000000000000000000000000",
|
|
15
|
-
symbol: "ETH",
|
|
16
|
-
name: "Ether",
|
|
17
|
-
decimals: 18,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
address: "0x2c537e5624e4af88a7ae4060c022609376c8d0eb",
|
|
21
|
-
symbol: "TRYB",
|
|
22
|
-
name: "BiLira",
|
|
23
|
-
decimals: 6,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
_id: "65e6fb6a332ca66c92561433",
|
|
29
|
-
ecosystem: "evm",
|
|
30
|
-
chainId: "10",
|
|
31
|
-
name: "optimism",
|
|
32
|
-
displayName: "Optimism",
|
|
33
|
-
web3Environment: "mainnet",
|
|
34
|
-
transactionExplorer: "https://optimistic.etherscan.io/tx",
|
|
35
|
-
rpcUrls: [],
|
|
36
|
-
ccipChainId: "3734403246176062136",
|
|
37
|
-
tokens: [
|
|
38
|
-
{
|
|
39
|
-
address: "0x0000000000000000000000000000000000000000",
|
|
40
|
-
symbol: "ETH",
|
|
41
|
-
name: "Ether",
|
|
42
|
-
decimals: 18,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
address: "0x4200000000000000000000000000000000000006",
|
|
46
|
-
symbol: "WETH",
|
|
47
|
-
name: "Wrapped Ether",
|
|
48
|
-
decimals: 18,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
address: "0x8700daec35af8ff88c16bdf0418774cb3d7599b4",
|
|
52
|
-
symbol: "SNX",
|
|
53
|
-
name: "Synthetix",
|
|
54
|
-
decimals: 18,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
_id: "65e6fb6a332ca66c9256143b",
|
|
60
|
-
ecosystem: "evm",
|
|
61
|
-
chainId: "80001",
|
|
62
|
-
name: "mumbai",
|
|
63
|
-
displayName: "Polygon Mumbai",
|
|
64
|
-
web3Environment: "testnet",
|
|
65
|
-
transactionExplorer: "https://mumbai.polygonscan.com/tx",
|
|
66
|
-
ccipChainId: "12532609583862916517",
|
|
67
|
-
tokens: [
|
|
68
|
-
{
|
|
69
|
-
address: "0x0000000000000000000000000000000000000000",
|
|
70
|
-
symbol: "MATIC",
|
|
71
|
-
name: "MATIC",
|
|
72
|
-
decimals: 18,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
address: "0xf1e3a5842eeef51f2967b3f05d45dd4f4205ff40",
|
|
76
|
-
symbol: "USDC",
|
|
77
|
-
name: "USD Coin",
|
|
78
|
-
decimals: 18,
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
_id: "65e6fb6a332ca66c9256143b",
|
|
84
|
-
ecosystem: "test-ecosystem",
|
|
85
|
-
chainId: "test-chainId",
|
|
86
|
-
name: "test-chain-name",
|
|
87
|
-
displayName: "Test Chain",
|
|
88
|
-
web3Environment: "testnet",
|
|
89
|
-
transactionExplorer: "https://test-tx-explorer.com",
|
|
90
|
-
ccipChainId: "1234567890",
|
|
91
|
-
tokens: [
|
|
92
|
-
{
|
|
93
|
-
address: "0x0000000000000000000000000000000000000000",
|
|
94
|
-
symbol: "NATIVE",
|
|
95
|
-
name: "Native Token",
|
|
96
|
-
decimals: 18,
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
address: "0x0000000000000000000000000000000000000001",
|
|
100
|
-
symbol: "TEST",
|
|
101
|
-
name: "Test Token",
|
|
102
|
-
decimals: 18,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
];
|
package/test/setupTests.ts
DELETED