@xswap-link/sdk 0.0.3

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.
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
package/.eslintrc.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "plugins": [
5
+ "@typescript-eslint"
6
+ ],
7
+ "extends": [
8
+ "plugin:@typescript-eslint/recommended"
9
+ ]
10
+ }
@@ -0,0 +1,21 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches:
5
+ - "**"
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - uses: pnpm/action-setup@v2
13
+ with:
14
+ version: 7
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 16.x
18
+ cache: "pnpm"
19
+
20
+ - run: pnpm install --frozen-lockfile
21
+ - run: pnpm run lint && pnpm run build
@@ -0,0 +1,36 @@
1
+ name: Publish
2
+ on:
3
+ workflow_run:
4
+ workflows: [CI]
5
+ branches: [main]
6
+ types: [completed]
7
+
8
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
9
+
10
+ permissions:
11
+ contents: write
12
+ pull-requests: write
13
+
14
+ jobs:
15
+ publish:
16
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - uses: pnpm/action-setup@v2
21
+ with:
22
+ version: 7
23
+ - uses: actions/setup-node@v3
24
+ with:
25
+ node-version: 16.x
26
+ cache: "pnpm"
27
+
28
+ - run: pnpm install --frozen-lockfile
29
+ - name: Create Release Pull Request or Publish
30
+ id: changesets
31
+ uses: changesets/action@v1
32
+ with:
33
+ publish: pnpm run release
34
+ env:
35
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @xswap-link/xswap-sdk
2
+
3
+ ## 0.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ee64995: change lib name from @xswap-link/xswap-sdk to @xswap-link/sdk
8
+
9
+ ## 0.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - ca41676: fix wrong urlPath params
14
+
15
+ ## 0.0.1
16
+
17
+ ### Patch Changes
18
+
19
+ - fed9022: init
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 xswap-link
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ <a name="readme-top"></a>
2
+
3
+ <!-- PROJECT LOGO -->
4
+ <br />
5
+ <div align="center">
6
+
7
+ <h1 align="center">XSwap SDK</h1>
8
+
9
+ <p align="center">
10
+ XSwap SDK exposes a variety of models and tools for other projects to use.
11
+ <br />
12
+ <a href="https://docs.xswap.link/xswap/introduction/what-is-xswap"><strong>Explore the docs »</strong></a>
13
+ <br />
14
+ </p>
15
+ </div>
16
+
17
+ <!-- TABLE OF CONTENTS -->
18
+ <details>
19
+ <summary>Table of Contents</summary>
20
+ <ol>
21
+ <li>
22
+ <a href="#about-the-project">About The Project</a>
23
+ </li>
24
+ <li>
25
+ <a href="#getting-started">Getting Started</a>
26
+ <ul>
27
+ <li><a href="#prerequisites">Prerequisites</a></li>
28
+ <li><a href="#installation">Installation</a></li>
29
+ </ul>
30
+ </li>
31
+ <li><a href="#usage">Usage</a></li>
32
+ </ol>
33
+ </details>
34
+
35
+ <!-- ABOUT THE PROJECT -->
36
+
37
+ ## About The Project
38
+
39
+ XSwap SDK exposes a functions to access the advanced cross-chain routing solution offered by XSwap.
40
+
41
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
42
+
43
+ <!-- GETTING STARTED -->
44
+
45
+ ## Getting Started
46
+
47
+ To get the library follow these simple example steps.
48
+
49
+ ### Prerequisites
50
+
51
+ - npm
52
+ ```sh
53
+ npm i pnpm@latest -g
54
+ ```
55
+
56
+ ### Installation
57
+
58
+ Below you will find a step-by-step installation guide.
59
+
60
+ 1. Install the library in your project
61
+ ```sh
62
+ npm i @xswap-link/xswap-sdk
63
+ ```
64
+
65
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
66
+
67
+ <!-- USAGE EXAMPLES -->
68
+
69
+ ## Usage
70
+
71
+ Simply import the stuff from the library.
72
+
73
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
74
+
75
+ ## Contribution
76
+
77
+ This is open-source library and below you will find a step-by-step contribution guide.
78
+
79
+ ### Prerequisites
80
+
81
+ - pnpm
82
+ ```sh
83
+ npm i pnpm@latest -g
84
+ ```
85
+
86
+ #### 1. Get the project and install dependencies
87
+
88
+ ```sh
89
+ git clone git@github.com:xswap-link/xswap-sdk.git
90
+
91
+ cd xswap-sdk
92
+
93
+ pnpm i
94
+ ```
95
+
96
+ #### 2. Create new branch based on the `develop` one
97
+
98
+ ```sh
99
+ git checkout -b feature/<your_feature_name>
100
+ ```
101
+
102
+ #### 3. Commit changes
103
+
104
+ #### 4. Create PR to `develop` branch
105
+
106
+ ### Publishing changes
107
+
108
+ #### Create changeset file and include into PR to `main`
109
+
110
+ Github workflow will fail to publish if you skip it
111
+
112
+ ```sh
113
+ pnpm changeset
114
+ ```
115
+
116
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -0,0 +1,32 @@
1
+ import { GetRoutePayload, ApiOverrides, Route, Ecosystem, Chain, Token } from '@xswap-link/xswap-common';
2
+ export * from '@xswap-link/xswap-common';
3
+
4
+ /**
5
+ * Get swap route based on provided criteria.
6
+ * @param payload required
7
+ * @param overrides optional - e.g. {apiUrl}
8
+ */
9
+ declare function getRoute(payload: GetRoutePayload, overrides?: ApiOverrides): Promise<Route>;
10
+ /**
11
+ * GET chains based on provided criteria.
12
+ * @param ecosystem optional
13
+ * @param overrides optional - e.g. {apiUrl}
14
+ */
15
+ declare function getChains(ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain[]>;
16
+ /**
17
+ * GET chain data based on provided criteria.
18
+ * @param chainId
19
+ * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
20
+ * @param overrides optional - e.g. {apiUrl}
21
+ */
22
+ declare function getChainData(chainId?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain>;
23
+ /**
24
+ * GET Tokens based on provided criteria
25
+ * @param chainId required
26
+ * @param address optional
27
+ * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
28
+ * @param overrides optional - e.g. {apiUrl}
29
+ */
30
+ declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Token[]>;
31
+
32
+ export { getChainData, getChains, getRoute, getTokens };
@@ -0,0 +1,32 @@
1
+ import { GetRoutePayload, ApiOverrides, Route, Ecosystem, Chain, Token } from '@xswap-link/xswap-common';
2
+ export * from '@xswap-link/xswap-common';
3
+
4
+ /**
5
+ * Get swap route based on provided criteria.
6
+ * @param payload required
7
+ * @param overrides optional - e.g. {apiUrl}
8
+ */
9
+ declare function getRoute(payload: GetRoutePayload, overrides?: ApiOverrides): Promise<Route>;
10
+ /**
11
+ * GET chains based on provided criteria.
12
+ * @param ecosystem optional
13
+ * @param overrides optional - e.g. {apiUrl}
14
+ */
15
+ declare function getChains(ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain[]>;
16
+ /**
17
+ * GET chain data based on provided criteria.
18
+ * @param chainId
19
+ * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
20
+ * @param overrides optional - e.g. {apiUrl}
21
+ */
22
+ declare function getChainData(chainId?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain>;
23
+ /**
24
+ * GET Tokens based on provided criteria
25
+ * @param chainId required
26
+ * @param address optional
27
+ * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
28
+ * @param overrides optional - e.g. {apiUrl}
29
+ */
30
+ declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Token[]>;
31
+
32
+ export { getChainData, getChains, getRoute, getTokens };
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // index.ts
22
+ var xswap_sdk_exports = {};
23
+ __export(xswap_sdk_exports, {
24
+ getChainData: () => getChainData,
25
+ getChains: () => getChains,
26
+ getRoute: () => getRoute,
27
+ getTokens: () => getTokens
28
+ });
29
+ module.exports = __toCommonJS(xswap_sdk_exports);
30
+ __reExport(xswap_sdk_exports, require("@xswap-link/xswap-common"), module.exports);
31
+
32
+ // src/services/api.ts
33
+ var import_xswap_common = require("@xswap-link/xswap-common");
34
+ async function _sendRequest(urlPath, options, overrides) {
35
+ const apiUrl = overrides?.apiUrl || import_xswap_common.DEFAULT_API_URL;
36
+ const response = await fetch(`${apiUrl}${urlPath}`, {
37
+ ...options,
38
+ headers: {
39
+ "Content-Type": "application/json",
40
+ ...options.headers
41
+ }
42
+ });
43
+ if (!response.ok) {
44
+ throw new Error(
45
+ `API request failed with status ${response.status}: ${response.statusText}`
46
+ );
47
+ }
48
+ return response.json();
49
+ }
50
+ async function getRoute(payload, overrides) {
51
+ return _sendRequest(
52
+ "/route",
53
+ {
54
+ method: "POST",
55
+ body: JSON.stringify(payload)
56
+ },
57
+ overrides
58
+ );
59
+ }
60
+ async function getChains(ecosystem, overrides) {
61
+ const data = { ecosystem };
62
+ return _sendRequest(
63
+ `/chains?data=${JSON.stringify(data)}`,
64
+ {
65
+ method: "GET"
66
+ },
67
+ overrides
68
+ );
69
+ }
70
+ async function getChainData(chainId, ecosystem, overrides) {
71
+ const data = { chainId, ecosystem };
72
+ return _sendRequest(
73
+ `/chains?data=${JSON.stringify(data)}`,
74
+ {
75
+ method: "GET"
76
+ },
77
+ overrides
78
+ );
79
+ }
80
+ async function getTokens(chainId, address, ecosystem, overrides) {
81
+ const data = { chainId, address, ecosystem };
82
+ return _sendRequest(
83
+ `/tokens?data=${JSON.stringify(data)}`,
84
+ {
85
+ method: "GET"
86
+ },
87
+ overrides
88
+ );
89
+ }
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ getChainData,
93
+ getChains,
94
+ getRoute,
95
+ getTokens,
96
+ ...require("@xswap-link/xswap-common")
97
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,69 @@
1
+ // index.ts
2
+ export * from "@xswap-link/xswap-common";
3
+
4
+ // src/services/api.ts
5
+ import {
6
+ DEFAULT_API_URL
7
+ } from "@xswap-link/xswap-common";
8
+ async function _sendRequest(urlPath, options, overrides) {
9
+ const apiUrl = overrides?.apiUrl || DEFAULT_API_URL;
10
+ const response = await fetch(`${apiUrl}${urlPath}`, {
11
+ ...options,
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ ...options.headers
15
+ }
16
+ });
17
+ if (!response.ok) {
18
+ throw new Error(
19
+ `API request failed with status ${response.status}: ${response.statusText}`
20
+ );
21
+ }
22
+ return response.json();
23
+ }
24
+ async function getRoute(payload, overrides) {
25
+ return _sendRequest(
26
+ "/route",
27
+ {
28
+ method: "POST",
29
+ body: JSON.stringify(payload)
30
+ },
31
+ overrides
32
+ );
33
+ }
34
+ async function getChains(ecosystem, overrides) {
35
+ const data = { ecosystem };
36
+ return _sendRequest(
37
+ `/chains?data=${JSON.stringify(data)}`,
38
+ {
39
+ method: "GET"
40
+ },
41
+ overrides
42
+ );
43
+ }
44
+ async function getChainData(chainId, ecosystem, overrides) {
45
+ const data = { chainId, ecosystem };
46
+ return _sendRequest(
47
+ `/chains?data=${JSON.stringify(data)}`,
48
+ {
49
+ method: "GET"
50
+ },
51
+ overrides
52
+ );
53
+ }
54
+ async function getTokens(chainId, address, ecosystem, overrides) {
55
+ const data = { chainId, address, ecosystem };
56
+ return _sendRequest(
57
+ `/tokens?data=${JSON.stringify(data)}`,
58
+ {
59
+ method: "GET"
60
+ },
61
+ overrides
62
+ );
63
+ }
64
+ export {
65
+ getChainData,
66
+ getChains,
67
+ getRoute,
68
+ getTokens
69
+ };
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@xswap-link/xswap-common";
2
+ export * from "./src/services";
@@ -0,0 +1,8 @@
1
+ {
2
+ "verbose": true,
3
+ "preset": "ts-jest",
4
+ "testEnvironment": "node",
5
+ "setupFilesAfterEnv": [
6
+ "./test/setupTests.ts"
7
+ ]
8
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@xswap-link/sdk",
3
+ "version": "0.0.3",
4
+ "description": "JavaScript SDK for XSwap platform",
5
+ "homepage": "https://github.com/xswap-link/xswap-sdk",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/xswap-link/xswap-sdk.git"
9
+ },
10
+ "author": "XSwap",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "xswap",
14
+ "bridge",
15
+ "blockchain",
16
+ "cross-chain"
17
+ ],
18
+ "main": "dist/index.js",
19
+ "module": "dist/index.mjs",
20
+ "types": "dist/index.d.ts",
21
+ "scripts": {
22
+ "build": "tsup index.ts --format cjs,esm --dts",
23
+ "release": "pnpm run build && changeset publish",
24
+ "lint": "tsc && eslint . --ext .ts",
25
+ "test": "jest"
26
+ },
27
+ "dependencies": {
28
+ "@xswap-link/xswap-common": "^0.0.2",
29
+ "ethers": "^5.7.2"
30
+ },
31
+ "devDependencies": {
32
+ "@changesets/cli": "^2.27.1",
33
+ "@types/jest": "^29.5.12",
34
+ "@types/node": "^20.11.17",
35
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
36
+ "@typescript-eslint/parser": "^7.1.0",
37
+ "eslint": "^8.57.0",
38
+ "jest": "^29.7.0",
39
+ "jest-fetch": "^1.1.1",
40
+ "jest-fetch-mock": "^3.0.3",
41
+ "ts-jest": "^29.1.2",
42
+ "ts-node": "^10.9.2",
43
+ "tsup": "^8.0.2",
44
+ "typescript": "^5.3.3"
45
+ }
46
+ }
@@ -0,0 +1,119 @@
1
+ import {
2
+ Chain,
3
+ DEFAULT_API_URL,
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ DEFAULT_ECOSYSTEM,
6
+ Ecosystem,
7
+ GetRoutePayload,
8
+ ApiOverrides,
9
+ Route,
10
+ Token,
11
+ } from "@xswap-link/xswap-common";
12
+
13
+ async function _sendRequest<T>(
14
+ urlPath: string,
15
+ options: RequestInit,
16
+ overrides?: ApiOverrides
17
+ ): Promise<T> {
18
+ const apiUrl = overrides?.apiUrl || DEFAULT_API_URL;
19
+ const response = await fetch(`${apiUrl}${urlPath}`, {
20
+ ...options,
21
+ headers: {
22
+ "Content-Type": "application/json",
23
+ ...options.headers,
24
+ },
25
+ });
26
+
27
+ if (!response.ok) {
28
+ throw new Error(
29
+ `API request failed with status ${response.status}: ${response.statusText}`
30
+ );
31
+ }
32
+
33
+ return response.json();
34
+ }
35
+
36
+ /**
37
+ * Get swap route based on provided criteria.
38
+ * @param payload required
39
+ * @param overrides optional - e.g. {apiUrl}
40
+ */
41
+ export async function getRoute(
42
+ payload: GetRoutePayload,
43
+ overrides?: ApiOverrides
44
+ ): Promise<Route> {
45
+ return _sendRequest<Route>(
46
+ "/route",
47
+ {
48
+ method: "POST",
49
+ body: JSON.stringify(payload),
50
+ },
51
+ overrides
52
+ );
53
+ }
54
+
55
+ /**
56
+ * GET chains based on provided criteria.
57
+ * @param ecosystem optional
58
+ * @param overrides optional - e.g. {apiUrl}
59
+ */
60
+ export async function getChains(
61
+ ecosystem?: Ecosystem,
62
+ overrides?: ApiOverrides
63
+ ): Promise<Chain[]> {
64
+ const data = { ecosystem };
65
+
66
+ return _sendRequest<Chain[]>(
67
+ `/chains?data=${JSON.stringify(data)}`,
68
+ {
69
+ method: "GET",
70
+ },
71
+ overrides
72
+ );
73
+ }
74
+
75
+ /**
76
+ * GET chain data based on provided criteria.
77
+ * @param chainId
78
+ * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
79
+ * @param overrides optional - e.g. {apiUrl}
80
+ */
81
+ export async function getChainData(
82
+ chainId?: string,
83
+ ecosystem?: Ecosystem,
84
+ overrides?: ApiOverrides
85
+ ): Promise<Chain> {
86
+ const data = { chainId, ecosystem };
87
+
88
+ return _sendRequest<Chain>(
89
+ `/chains?data=${JSON.stringify(data)}`,
90
+ {
91
+ method: "GET",
92
+ },
93
+ overrides
94
+ );
95
+ }
96
+
97
+ /**
98
+ * GET Tokens based on provided criteria
99
+ * @param chainId required
100
+ * @param address optional
101
+ * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
102
+ * @param overrides optional - e.g. {apiUrl}
103
+ */
104
+ export async function getTokens(
105
+ chainId: string,
106
+ address?: string,
107
+ ecosystem?: Ecosystem,
108
+ overrides?: ApiOverrides
109
+ ): Promise<Token[]> {
110
+ const data = { chainId, address, ecosystem };
111
+
112
+ return _sendRequest<Token[]>(
113
+ `/tokens?data=${JSON.stringify(data)}`,
114
+ {
115
+ method: "GET",
116
+ },
117
+ overrides
118
+ );
119
+ }
@@ -0,0 +1 @@
1
+ export * from "./api";
@@ -0,0 +1,106 @@
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
+ ];
@@ -0,0 +1,19 @@
1
+ import fetch from "jest-fetch-mock";
2
+ import { chains } from "./api.mock";
3
+ import { getChains } from "../src/services";
4
+
5
+ describe("API", () => {
6
+ beforeEach(() => {
7
+ fetch.resetMocks();
8
+ });
9
+
10
+ describe("getChains", () => {
11
+ it("should return all supported chains", async () => {
12
+ fetch.mockResponseOnce(JSON.stringify(chains));
13
+
14
+ const supportedChains = await getChains();
15
+
16
+ expect(supportedChains).toHaveLength(4);
17
+ });
18
+ });
19
+ });
@@ -0,0 +1,3 @@
1
+ import fetchMock from "jest-fetch-mock";
2
+
3
+ fetchMock.enableMocks();
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "skipLibCheck": true,
5
+ "target": "es2021",
6
+ "verbatimModuleSyntax": false,
7
+ "allowJs": true,
8
+ "resolveJsonModule": true,
9
+ "moduleDetection": "force",
10
+ "strict": true,
11
+ "noUncheckedIndexedAccess": true,
12
+ "moduleResolution": "Bundler",
13
+ "module": "ESNext",
14
+ "noEmit": true
15
+ }
16
+ }