@uniswap/token-list-bridge-utils 0.1.1-beta.1 → 1.0.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/README.md +102 -5
- package/dist/arbitrum/gateway.d.ts +2 -0
- package/dist/{arb-token-lists/src/lib → arbitrum}/instantiate_bridge.d.ts +3 -4
- package/dist/constants/types.d.ts +30 -0
- package/dist/fixtures/index.d.ts +9 -0
- package/dist/providers/ArbitrumMappingProvider.d.ts +7 -6
- package/dist/providers/MappingProvider.d.ts +4 -2
- package/dist/providers/OptimismMappingProvider.d.ts +5 -4
- package/dist/providers/PolygonMappingProvider.d.ts +4 -2
- package/dist/providers/index.d.ts +2 -4
- package/dist/token-list-bridge-utils.cjs.development.js +327 -906
- package/dist/token-list-bridge-utils.cjs.development.js.map +1 -1
- package/dist/token-list-bridge-utils.cjs.production.min.js +1 -1
- package/dist/token-list-bridge-utils.cjs.production.min.js.map +1 -1
- package/dist/token-list-bridge-utils.esm.js +329 -902
- package/dist/token-list-bridge-utils.esm.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/package.json +7 -4
- package/src/.DS_Store +0 -0
- package/src/arbitrum/gateway.ts +25 -0
- package/src/{arb-token-lists/src/lib → arbitrum}/instantiate_bridge.ts +11 -15
- package/src/constants/types.ts +28 -0
- package/src/fixtures/index.ts +40 -5
- package/src/index.test.ts +60 -18
- package/src/index.ts +5 -7
- package/src/providers/ArbitrumMappingProvider.ts +31 -21
- package/src/providers/MappingProvider.ts +4 -2
- package/src/providers/OptimismMappingProvider.ts +21 -5
- package/src/providers/PolygonMappingProvider.ts +22 -114
- package/src/providers/index.ts +82 -2
- package/src/utils.ts +71 -1
- package/dist/arb-token-lists/server/app.d.ts +0 -1
- package/dist/arb-token-lists/src/lib/getClargs.d.ts +0 -8
- package/dist/arb-token-lists/src/lib/graph.d.ts +0 -2
- package/dist/arb-token-lists/src/lib/token_list_gen.d.ts +0 -23
- package/dist/arb-token-lists/src/lib/types.d.ts +0 -36
- package/dist/arb-token-lists/src/lib/utils.d.ts +0 -18
- package/dist/arb-token-lists/src/main.d.ts +0 -1
- package/src/arb-token-lists/.env.sample +0 -4
- package/src/arb-token-lists/.eslintrc.js +0 -43
- package/src/arb-token-lists/.gitignore +0 -4
- package/src/arb-token-lists/package.json +0 -40
- package/src/arb-token-lists/readme.md +0 -14
- package/src/arb-token-lists/server/app.ts +0 -21
- package/src/arb-token-lists/src/Assets/coingecko_uris.json +0 -5108
- package/src/arb-token-lists/src/Assets/logo_uris.json +0 -44
- package/src/arb-token-lists/src/WarningList/warningTokens.json +0 -290
- package/src/arb-token-lists/src/lib/getClargs.ts +0 -32
- package/src/arb-token-lists/src/lib/graph.ts +0 -116
- package/src/arb-token-lists/src/lib/token_list_gen.ts +0 -334
- package/src/arb-token-lists/src/lib/types.ts +0 -44
- package/src/arb-token-lists/src/lib/utils.ts +0 -285
- package/src/arb-token-lists/src/main.ts +0 -54
- package/src/arb-token-lists/tsconfig.json +0 -20
- package/src/arb-token-lists/update_all +0 -6
- package/src/arb-token-lists/yarn.lock +0 -4273
package/README.md
CHANGED
|
@@ -1,6 +1,105 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Token List Bridge Utils
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Description
|
|
4
|
+
This package contains utility functions used for converting an L1 token list into a cross-chain tokenlist by adding cross-chain mapping information for Arbitrum, Optimism, and Polygon to a given L1 list.
|
|
5
|
+
|
|
6
|
+
Mappings get added in the form of an extensions field, following this [schema](https://github.com/Uniswap/token-lists/issues/51#issuecomment-952268629).
|
|
7
|
+
(Currently does not fill information for origin and destination bridge addresses)
|
|
8
|
+
|
|
9
|
+
ex:
|
|
10
|
+
|
|
11
|
+
"name": "Uniswap",
|
|
12
|
+
"address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
|
|
13
|
+
"symbol": "UNI",
|
|
14
|
+
"decimals": 18,
|
|
15
|
+
"chainId": 1,
|
|
16
|
+
"logoURI": "ipfs://QmXttGpZrECX5qCyXbBQiqgQNytVGeZW5Anewvh2jc4psg",
|
|
17
|
+
"extensions": {
|
|
18
|
+
"bridgeInfo": {
|
|
19
|
+
"10": {
|
|
20
|
+
"tokenAddress": "0x6fd9d7AD17242c41f7131d257212c54A0e816691"
|
|
21
|
+
},
|
|
22
|
+
"137": {
|
|
23
|
+
"tokenAddress": "0xb33EaAd8d922B1083446DC23f610c2567fB5180f"
|
|
24
|
+
},
|
|
25
|
+
"42161": {
|
|
26
|
+
"tokenAddress": "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}}
|
|
30
|
+
Also adds a "root-level" token entry for each of the L2's that a token maps to.
|
|
31
|
+
|
|
32
|
+
ex. for Optimism:
|
|
33
|
+
`
|
|
34
|
+
|
|
35
|
+
{
|
|
36
|
+
"name": "Uniswap",
|
|
37
|
+
"address": "0x6fd9d7AD17242c41f7131d257212c54A0e816691",
|
|
38
|
+
"symbol": "UNI",
|
|
39
|
+
"decimals": 18,
|
|
40
|
+
"chainId": 10,
|
|
41
|
+
"logoURI": "ipfs://QmXttGpZrECX5qCyXbBQiqgQNytVGeZW5Anewvh2jc4psg",
|
|
42
|
+
"extensions": {
|
|
43
|
+
"bridgeInfo": {
|
|
44
|
+
"1": {
|
|
45
|
+
"tokenAddress": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
## Functions Overview
|
|
53
|
+
|
|
54
|
+
chainify
|
|
55
|
+
|
|
56
|
+
* Adds bridgeInfo to the given token list for Optimism, Polygon and Arbitrum.
|
|
57
|
+
* @param l1TokenListOrPathOrUrl
|
|
58
|
+
* @returns TokenList with l2 bridgeInfo filled
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
chainifyTokenList
|
|
62
|
+
|
|
63
|
+
* Given a chain ID (Optimism, Polygon, or Arbitrum) and a TokenList, returns the TokenList with `extensions` filled.
|
|
64
|
+
* @param chainId chainId to operate on
|
|
65
|
+
* @param l1TokenListOrPathOrUrl either an L1 TokenList object or a path/url to a TokenList
|
|
66
|
+
* @returns L1 TokenList with `extensions` filled for the given network
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
mergeTokenLists
|
|
70
|
+
* Merges two token lists, resolving conflicts to primary list.
|
|
71
|
+
* @param primary primary token list to resolve conflicts to
|
|
72
|
+
* @param secondary secondary token list
|
|
73
|
+
* @returns merged token list
|
|
74
|
+
|
|
75
|
+
## Usage (from external package):
|
|
76
|
+
### Install Package
|
|
77
|
+
`yarn add @uniswap/token-list-bridge-utils`
|
|
78
|
+
|
|
79
|
+
or
|
|
80
|
+
|
|
81
|
+
`npm i @uniswap/token-list-bridge-utils`
|
|
82
|
+
|
|
83
|
+
### Call Function
|
|
84
|
+
#### CommonJS
|
|
85
|
+
`const bridge_utils = require('@uniswap/token-list-bridge-utils');`
|
|
86
|
+
|
|
87
|
+
`let chainifiedList = await bridge_utils.chainify(tokenList);`
|
|
88
|
+
#### ESM
|
|
89
|
+
`import { chainify } from '@uniswap/token-list-bridge-utils';`
|
|
90
|
+
|
|
91
|
+
`let chainifiedList = await chainify(tokenList);`
|
|
92
|
+
|
|
93
|
+
## Run Tests
|
|
94
|
+
|
|
95
|
+
`yarn install`
|
|
96
|
+
|
|
97
|
+
`yarn build`
|
|
98
|
+
|
|
99
|
+
`yarn test`
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## DTS User Guide
|
|
4
103
|
|
|
5
104
|
DTS scaffolds your new library inside `/src`.
|
|
6
105
|
|
|
@@ -12,6 +111,4 @@ npm start # or yarn start
|
|
|
12
111
|
|
|
13
112
|
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
|
|
14
113
|
|
|
15
|
-
To do a one-off build, use `npm run build` or `yarn build`.
|
|
16
|
-
|
|
17
|
-
To run tests, use `npm test` or `yarn test`.
|
|
114
|
+
To do a one-off build, use `npm run build` or `yarn build`.
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { providers } from 'ethers';
|
|
2
|
-
import { MultiCaller
|
|
2
|
+
import { MultiCaller } from '@arbitrum/sdk';
|
|
3
3
|
export declare const getNetworkConfig: () => Promise<{
|
|
4
4
|
l1: {
|
|
5
|
-
network: import("
|
|
5
|
+
network: import("@arbitrum/sdk").L1Network;
|
|
6
6
|
provider: providers.JsonRpcProvider;
|
|
7
7
|
multiCaller: MultiCaller;
|
|
8
8
|
};
|
|
9
9
|
l2: {
|
|
10
|
-
network: import("
|
|
10
|
+
network: import("@arbitrum/sdk").L2Network;
|
|
11
11
|
provider: providers.JsonRpcProvider;
|
|
12
12
|
multiCaller: MultiCaller;
|
|
13
13
|
};
|
|
14
|
-
tokenBridger: TokenBridger;
|
|
15
14
|
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface PolygonMappedToken {
|
|
2
|
+
chainId: number;
|
|
3
|
+
child_address_passed_by_user: boolean;
|
|
4
|
+
child_token: string;
|
|
5
|
+
count: number;
|
|
6
|
+
created_at: string;
|
|
7
|
+
decimals: number;
|
|
8
|
+
deleted: boolean;
|
|
9
|
+
id: number;
|
|
10
|
+
map_type: 'POS';
|
|
11
|
+
mintable: boolean;
|
|
12
|
+
name: string;
|
|
13
|
+
new_child_token: string;
|
|
14
|
+
new_mintable: boolean;
|
|
15
|
+
owner: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
reason_for_remapping: string;
|
|
18
|
+
remapping_allowed: boolean;
|
|
19
|
+
remapping_request_submitted: boolean;
|
|
20
|
+
remapping_verified: boolean;
|
|
21
|
+
root_token: string;
|
|
22
|
+
status: number;
|
|
23
|
+
symbol: string;
|
|
24
|
+
token_type: string;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
uri: string;
|
|
27
|
+
}
|
|
28
|
+
export declare type PolygonMappedTokenData = {
|
|
29
|
+
[key: string]: PolygonMappedToken;
|
|
30
|
+
};
|
package/dist/fixtures/index.d.ts
CHANGED
|
@@ -22,3 +22,12 @@ export declare const polygonedSampleTokenList: {
|
|
|
22
22
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
23
23
|
logoURI?: string | undefined;
|
|
24
24
|
};
|
|
25
|
+
export declare const optimizedSampleTokenList: {
|
|
26
|
+
name: string;
|
|
27
|
+
tokens: TokenInfo[];
|
|
28
|
+
timestamp: string;
|
|
29
|
+
version: import("@uniswap/token-lists").Version;
|
|
30
|
+
keywords?: string[] | undefined;
|
|
31
|
+
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
32
|
+
logoURI?: string | undefined;
|
|
33
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { TokenList } from '@uniswap/token-lists';
|
|
2
1
|
import { MappingProvider } from './MappingProvider';
|
|
2
|
+
import { TokenList } from '@uniswap/token-lists';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* token list.
|
|
6
|
-
*
|
|
7
|
-
* The provider simply invokes this package which we host as a submodule.
|
|
4
|
+
* This provider provides the l1->l2(Arbitrum) address mappings using the arbitrum SDK.
|
|
8
5
|
*/
|
|
9
6
|
export declare class ArbitrumMappingProvider implements MappingProvider {
|
|
10
|
-
|
|
7
|
+
l1TokenList: TokenList;
|
|
8
|
+
constructor(l1TokenList: TokenList);
|
|
9
|
+
provide(): Promise<{
|
|
10
|
+
[key: string]: string | undefined;
|
|
11
|
+
}>;
|
|
11
12
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PolygonMappedTokenData } from '../constants/types';
|
|
2
2
|
export interface MappingProvider {
|
|
3
|
-
provide(
|
|
3
|
+
provide(): Promise<PolygonMappedTokenData | {
|
|
4
|
+
[key: string]: string | undefined;
|
|
5
|
+
}>;
|
|
4
6
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { TokenList } from '@uniswap/token-lists';
|
|
2
1
|
import { MappingProvider } from './MappingProvider';
|
|
3
2
|
/**
|
|
4
|
-
* The Optimism L2 mapping is manually maintained by the Optimism team.
|
|
3
|
+
* The Optimism L2 mapping (linked above) is manually maintained by the Optimism team.
|
|
5
4
|
*
|
|
6
|
-
* This provider
|
|
5
|
+
* This provider provides the l1->l2(Optimism) token mappings.
|
|
7
6
|
*/
|
|
8
7
|
export declare class OptimismMappingProvider implements MappingProvider {
|
|
9
|
-
provide(
|
|
8
|
+
provide(): Promise<{
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
}>;
|
|
10
11
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { TokenList } from '@uniswap/token-lists';
|
|
2
1
|
import { MappingProvider } from './MappingProvider';
|
|
2
|
+
import { PolygonMappedTokenData } from '../constants/types';
|
|
3
3
|
/**
|
|
4
4
|
* The Polygon team manually maintains the mapping via user submissions at
|
|
5
5
|
* https://mapper.polygon.technology.
|
|
6
|
+
*
|
|
7
|
+
* This provider provides the l1->l2(Polygon) token mappings.
|
|
6
8
|
*/
|
|
7
9
|
export declare class PolygonMappingProvider implements MappingProvider {
|
|
8
|
-
provide(
|
|
10
|
+
provide(): Promise<PolygonMappedTokenData>;
|
|
9
11
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { ChainId } from '../constants/chainId';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { PolygonMappingProvider } from './PolygonMappingProvider';
|
|
5
|
-
export declare function getMappingProvider(chainId: ChainId): ArbitrumMappingProvider | OptimismMappingProvider | PolygonMappingProvider;
|
|
2
|
+
import { TokenList } from '@uniswap/token-lists';
|
|
3
|
+
export declare function buildList(chainId: ChainId, l1TokenList: TokenList): Promise<TokenList>;
|