@lifi/data-types 1.0.0-alpha.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.
- package/LICENSE.md +201 -0
- package/README.md +31 -0
- package/dist/chains/index.d.ts +2 -0
- package/dist/chains/index.js +2 -0
- package/dist/chains/supportedChains.d.ts +6 -0
- package/dist/chains/supportedChains.js +1174 -0
- package/dist/chains/supportedChains.unit.spec.d.ts +1 -0
- package/dist/chains/supportedChains.unit.spec.js +79 -0
- package/dist/chains/utils.d.ts +1 -0
- package/dist/chains/utils.js +4 -0
- package/dist/cjs/chains/index.d.ts +2 -0
- package/dist/cjs/chains/index.js +18 -0
- package/dist/cjs/chains/supportedChains.d.ts +6 -0
- package/dist/cjs/chains/supportedChains.js +1179 -0
- package/dist/cjs/chains/supportedChains.unit.spec.d.ts +1 -0
- package/dist/cjs/chains/supportedChains.unit.spec.js +81 -0
- package/dist/cjs/chains/utils.d.ts +1 -0
- package/dist/cjs/chains/utils.js +8 -0
- package/dist/cjs/coins/coins.d.ts +26 -0
- package/dist/cjs/coins/coins.int.spec.d.ts +1 -0
- package/dist/cjs/coins/coins.int.spec.js +31 -0
- package/dist/cjs/coins/coins.js +1842 -0
- package/dist/cjs/coins/index.d.ts +1 -0
- package/dist/cjs/coins/index.js +17 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/multicall.d.ts +3 -0
- package/dist/cjs/multicall.js +79 -0
- package/dist/coins/coins.d.ts +26 -0
- package/dist/coins/coins.int.spec.d.ts +1 -0
- package/dist/coins/coins.int.spec.js +29 -0
- package/dist/coins/coins.js +1835 -0
- package/dist/coins/index.d.ts +1 -0
- package/dist/coins/index.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/multicall.d.ts +3 -0
- package/dist/multicall.js +76 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ChainId, ChainKey, CoinKey } from '@lifi/types';
|
|
2
|
+
import { findDefaultToken, findTokenByChainIdAndAddress, findWrappedGasOnChain, } from '../coins';
|
|
3
|
+
import { getChainById, getChainByKey, supportedEVMChains, } from './supportedChains';
|
|
4
|
+
import { prefixChainId } from './utils';
|
|
5
|
+
test('getChainById', () => {
|
|
6
|
+
expect(getChainById(ChainId.ETH)).toBeDefined();
|
|
7
|
+
});
|
|
8
|
+
test('getChainByKey', () => {
|
|
9
|
+
expect(getChainByKey(ChainKey.ETH)).toBeDefined();
|
|
10
|
+
});
|
|
11
|
+
test('native token defined for all chains', () => {
|
|
12
|
+
// currently unused chains
|
|
13
|
+
const ignoredChains = [
|
|
14
|
+
ChainId.FSN,
|
|
15
|
+
ChainId.EXP,
|
|
16
|
+
ChainId.TCH,
|
|
17
|
+
ChainId.UBQ,
|
|
18
|
+
ChainId.MET,
|
|
19
|
+
ChainId.DIO,
|
|
20
|
+
ChainId.TLO,
|
|
21
|
+
ChainId.SHI,
|
|
22
|
+
ChainId.GL1,
|
|
23
|
+
ChainId.RSK,
|
|
24
|
+
ChainId.TBW,
|
|
25
|
+
ChainId.METT,
|
|
26
|
+
ChainId.DIOT,
|
|
27
|
+
ChainId.HECT,
|
|
28
|
+
ChainId.FUST,
|
|
29
|
+
ChainId.TLOT,
|
|
30
|
+
ChainId.RSKT,
|
|
31
|
+
];
|
|
32
|
+
for (const chain of supportedEVMChains) {
|
|
33
|
+
if (ignoredChains.includes(chain.id))
|
|
34
|
+
continue;
|
|
35
|
+
try {
|
|
36
|
+
const gasToken = findDefaultToken(chain.coin, chain.id);
|
|
37
|
+
expect(gasToken).toBeDefined();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new Error(`Failed to load gas token for ${chain.name}(${chain.id})`);
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const wrappedGasToken = findWrappedGasOnChain(chain.id);
|
|
44
|
+
expect(wrappedGasToken).toBeDefined();
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
throw new Error(`Failed to load wrapped gas token for ${chain.name}(${chain.id})`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
describe('findTokenByChainIdAndAddress', () => {
|
|
52
|
+
describe('token has no name override', () => {
|
|
53
|
+
it('returns a token with the coin name', () => {
|
|
54
|
+
expect(findTokenByChainIdAndAddress(ChainId.LNAT, '0xb706319d37b945727e71ae0d4353699d19112576').name).toEqual(CoinKey.CXTT);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('token has a name override', () => {
|
|
58
|
+
it('returns a token with the overrode name', () => {
|
|
59
|
+
expect(findTokenByChainIdAndAddress(ChainId.GOR, '0x7ea6eA49B0b0Ae9c5db7907d139D9Cd3439862a1').name).toEqual('Goerli CXTT');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
describe('validate chains', () => {
|
|
64
|
+
supportedEVMChains.forEach((chain) => {
|
|
65
|
+
it(`validate chain ${chain.name}`, () => {
|
|
66
|
+
// blockExplorerUrls
|
|
67
|
+
expect(chain.metamask.blockExplorerUrls.length).toBeGreaterThan(0);
|
|
68
|
+
chain.metamask.blockExplorerUrls.forEach((blockExplorerUrl) => {
|
|
69
|
+
expect(blockExplorerUrl.startsWith('https://')).toBeTruthy();
|
|
70
|
+
expect(blockExplorerUrl.endsWith('/')).toBeTruthy();
|
|
71
|
+
});
|
|
72
|
+
const chainId = prefixChainId(chain.id);
|
|
73
|
+
// chain ids match
|
|
74
|
+
expect(chainId).toEqual(chain.metamask.chainId);
|
|
75
|
+
// rpcs defined
|
|
76
|
+
expect(chain.metamask.rpcUrls.length).toBeGreaterThan(0);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prefixChainId: (chainId: number) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./supportedChains"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Chain, ChainKey, EVMChain, SolanaChain } from '@lifi/types';
|
|
2
|
+
export declare const supportedEVMChains: EVMChain[];
|
|
3
|
+
export declare const supportedSolanaChains: SolanaChain[];
|
|
4
|
+
export declare const supportedChains: EVMChain[];
|
|
5
|
+
export declare const getChainByKey: (chainKey: ChainKey) => Chain;
|
|
6
|
+
export declare const getChainById: (chainId: number) => Chain;
|