@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.
Files changed (39) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +31 -0
  3. package/dist/chains/index.d.ts +2 -0
  4. package/dist/chains/index.js +2 -0
  5. package/dist/chains/supportedChains.d.ts +6 -0
  6. package/dist/chains/supportedChains.js +1174 -0
  7. package/dist/chains/supportedChains.unit.spec.d.ts +1 -0
  8. package/dist/chains/supportedChains.unit.spec.js +79 -0
  9. package/dist/chains/utils.d.ts +1 -0
  10. package/dist/chains/utils.js +4 -0
  11. package/dist/cjs/chains/index.d.ts +2 -0
  12. package/dist/cjs/chains/index.js +18 -0
  13. package/dist/cjs/chains/supportedChains.d.ts +6 -0
  14. package/dist/cjs/chains/supportedChains.js +1179 -0
  15. package/dist/cjs/chains/supportedChains.unit.spec.d.ts +1 -0
  16. package/dist/cjs/chains/supportedChains.unit.spec.js +81 -0
  17. package/dist/cjs/chains/utils.d.ts +1 -0
  18. package/dist/cjs/chains/utils.js +8 -0
  19. package/dist/cjs/coins/coins.d.ts +26 -0
  20. package/dist/cjs/coins/coins.int.spec.d.ts +1 -0
  21. package/dist/cjs/coins/coins.int.spec.js +31 -0
  22. package/dist/cjs/coins/coins.js +1842 -0
  23. package/dist/cjs/coins/index.d.ts +1 -0
  24. package/dist/cjs/coins/index.js +17 -0
  25. package/dist/cjs/index.d.ts +3 -0
  26. package/dist/cjs/index.js +19 -0
  27. package/dist/cjs/multicall.d.ts +3 -0
  28. package/dist/cjs/multicall.js +79 -0
  29. package/dist/coins/coins.d.ts +26 -0
  30. package/dist/coins/coins.int.spec.d.ts +1 -0
  31. package/dist/coins/coins.int.spec.js +29 -0
  32. package/dist/coins/coins.js +1835 -0
  33. package/dist/coins/index.d.ts +1 -0
  34. package/dist/coins/index.js +1 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.js +3 -0
  37. package/dist/multicall.d.ts +3 -0
  38. package/dist/multicall.js +76 -0
  39. package/package.json +90 -0
@@ -0,0 +1 @@
1
+ export * from './coins';
@@ -0,0 +1,17 @@
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("./coins"), exports);
@@ -0,0 +1,3 @@
1
+ export * from './chains';
2
+ export * from './coins';
3
+ export * from './multicall';
@@ -0,0 +1,19 @@
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("./chains"), exports);
18
+ __exportStar(require("./coins"), exports);
19
+ __exportStar(require("./multicall"), exports);
@@ -0,0 +1,3 @@
1
+ export declare const multicallAddresses: {
2
+ [ChainId: number]: string;
3
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.multicallAddresses = void 0;
4
+ const types_1 = require("@lifi/types");
5
+ // based on:
6
+ // new nice tool to search for addresses: https://www.multicall3.com/deployments
7
+ // - https://github.com/mds1/multicall#deployments
8
+ // - https://github.com/sushiswap/sushiswap-sdk/blob/canary/src/constants/addresses.ts#L323
9
+ // - https://github.com/joshstevens19/ethereum-multicall#multicall-contracts
10
+ // '0xcA11bde05977b3631167028862bE2a173976CA11' is a Multicall3 contract
11
+ // export const multicallAddresses: Record<ChainId, string> = {
12
+ exports.multicallAddresses = {
13
+ // Mainnet
14
+ [types_1.ChainId.ETH]: '0xcA11bde05977b3631167028862bE2a173976CA11',
15
+ [types_1.ChainId.POL]: '0xcA11bde05977b3631167028862bE2a173976CA11',
16
+ [types_1.ChainId.BSC]: '0xcA11bde05977b3631167028862bE2a173976CA11',
17
+ [types_1.ChainId.DAI]: '0xcA11bde05977b3631167028862bE2a173976CA11',
18
+ [types_1.ChainId.OKT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
19
+ [types_1.ChainId.FTM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
20
+ [types_1.ChainId.AVA]: '0xcA11bde05977b3631167028862bE2a173976CA11',
21
+ [types_1.ChainId.ARB]: '0xcA11bde05977b3631167028862bE2a173976CA11',
22
+ [types_1.ChainId.HEC]: '0xcA11bde05977b3631167028862bE2a173976CA11',
23
+ [types_1.ChainId.OPT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
24
+ [types_1.ChainId.ONE]: '0xcA11bde05977b3631167028862bE2a173976CA11',
25
+ [types_1.ChainId.FSN]: '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
26
+ [types_1.ChainId.MOR]: '0xcA11bde05977b3631167028862bE2a173976CA11',
27
+ [types_1.ChainId.CEL]: '0xcA11bde05977b3631167028862bE2a173976CA11',
28
+ [types_1.ChainId.FUS]: '0xcA11bde05977b3631167028862bE2a173976CA11',
29
+ [types_1.ChainId.CRO]: '0xcA11bde05977b3631167028862bE2a173976CA11',
30
+ [types_1.ChainId.BOB]: '0xcA11bde05977b3631167028862bE2a173976CA11',
31
+ [types_1.ChainId.MOO]: '0xcA11bde05977b3631167028862bE2a173976CA11',
32
+ [types_1.ChainId.MAM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
33
+ [types_1.ChainId.AUR]: '0xcA11bde05977b3631167028862bE2a173976CA11',
34
+ [types_1.ChainId.EVM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
35
+ [types_1.ChainId.MET]: '0xcA11bde05977b3631167028862bE2a173976CA11',
36
+ [types_1.ChainId.RSK]: '0xcA11bde05977b3631167028862bE2a173976CA11',
37
+ [types_1.ChainId.VEL]: '0x6ede559F2Bd951777470595761672091CCD21Ac6',
38
+ [types_1.ChainId.PZE]: '0xcA11bde05977b3631167028862bE2a173976CA11',
39
+ [types_1.ChainId.ERA]: '0xF9cda624FBC7e059355ce98a31693d299FACd963',
40
+ [types_1.ChainId.LNA]: '0xcA11bde05977b3631167028862bE2a173976CA11',
41
+ [types_1.ChainId.ARN]: '0xcA11bde05977b3631167028862bE2a173976CA11',
42
+ // TODO
43
+ // [ChainId.EXP]: '', // TODO
44
+ // [ChainId.TCH]: '', // TODO
45
+ // [ChainId.UBQ]: '', // TODO
46
+ // [ChainId.DIO]: '', // TODO
47
+ // [ChainId.TLO]: '', // TODO
48
+ // [ChainId.SHI]: '', // TODO
49
+ // [ChainId.GL1]: '', // TODO
50
+ // [ChainId.TBW]: '', // TODO
51
+ // [ChainId.PALM]: '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
52
+ // [ChainId.TELOS]: '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
53
+ // Testnet
54
+ [types_1.ChainId.GOR]: '0xcA11bde05977b3631167028862bE2a173976CA11',
55
+ [types_1.ChainId.MUM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
56
+ [types_1.ChainId.BSCT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
57
+ [types_1.ChainId.ONET]: '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
58
+ [types_1.ChainId.AVAT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
59
+ [types_1.ChainId.OPTG]: '0xcA11bde05977b3631167028862bE2a173976CA11',
60
+ [types_1.ChainId.EVMT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
61
+ [types_1.ChainId.MORT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
62
+ [types_1.ChainId.FTMT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
63
+ [types_1.ChainId.RSKT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
64
+ [types_1.ChainId.ARBG]: '0xcA11bde05977b3631167028862bE2a173976CA11',
65
+ [types_1.ChainId.LNAT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
66
+ // TODO
67
+ // [ChainId.METT]: '', // TODO
68
+ // [ChainId.DIOT]: '', // TODO
69
+ // [ChainId.HECT]: '', // TODO
70
+ // [ChainId.FUST]: '', // TODO
71
+ // [ChainId.TLOT]: '', // TODO
72
+ // none EVM
73
+ // [ChainId.SOL]: '', // NOT NEEDED
74
+ // [ChainId.TER]: '', // NOT NEEDED
75
+ // [ChainId.OAS]: '', // NOT NEEDED
76
+ // [ChainId.SOLT]: '', // NOT NEEDED
77
+ // [ChainId.TERT]: '', // NOT NEEDED
78
+ // [ChainId.OAST]: '', // NOT NEEDED
79
+ };
@@ -0,0 +1,26 @@
1
+ import { ChainId, Coin, CoinKey, StaticToken } from '@lifi/types';
2
+ type BasicToken = {
3
+ address: string;
4
+ decimals: number;
5
+ name?: string;
6
+ symbol?: string;
7
+ };
8
+ type BasicCoin = {
9
+ key: CoinKey;
10
+ name: string;
11
+ logoURI: string;
12
+ verified: boolean;
13
+ chains: {
14
+ [key: number]: BasicToken;
15
+ };
16
+ };
17
+ export declare const basicCoins: BasicCoin[];
18
+ export declare const defaultCoins: Array<Coin>;
19
+ export declare const wrappedTokens: {
20
+ [ChainId: string]: StaticToken;
21
+ };
22
+ export declare const findDefaultCoin: (coinKey: CoinKey) => Coin;
23
+ export declare const findDefaultToken: (coinKey: CoinKey, chainId: ChainId) => StaticToken;
24
+ export declare const findWrappedGasOnChain: (chainId: ChainId) => StaticToken;
25
+ export declare const findTokenByChainIdAndAddress: (chainId: number, tokenAddress: string) => StaticToken | null;
26
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { defaultCoins, wrappedTokens } from './coins';
11
+ jest.setTimeout(20000);
12
+ describe('Coin logo test', () => {
13
+ const allImages = [];
14
+ // default coins
15
+ allImages.push(...defaultCoins
16
+ .map((coin) => {
17
+ const baseURL = coin.logoURI;
18
+ const tokenSpecificURLs = Object.values(coin.chains).flatMap(({ logoURI }) => (logoURI ? [logoURI] : []));
19
+ return [baseURL, ...tokenSpecificURLs];
20
+ })
21
+ .flat());
22
+ // wrapped tokens
23
+ allImages.push(...Object.values(wrappedTokens).map((token) => token.logoURI));
24
+ test.each([...new Set(allImages)])('check that logoURI %s is valid', (image) => __awaiter(void 0, void 0, void 0, function* () {
25
+ expect(image.startsWith('https://')).toBeTruthy();
26
+ const response = yield fetch(image);
27
+ expect(response.status).toEqual(200);
28
+ }), 2000);
29
+ });