@uniswap/token-list-bridge-utils 0.1.1-beta.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/LICENSE +674 -0
- package/README.md +17 -0
- package/dist/arb-token-lists/server/app.d.ts +1 -0
- package/dist/arb-token-lists/src/lib/getClargs.d.ts +8 -0
- package/dist/arb-token-lists/src/lib/graph.d.ts +2 -0
- package/dist/arb-token-lists/src/lib/instantiate_bridge.d.ts +15 -0
- package/dist/arb-token-lists/src/lib/token_list_gen.d.ts +23 -0
- package/dist/arb-token-lists/src/lib/types.d.ts +36 -0
- package/dist/arb-token-lists/src/lib/utils.d.ts +18 -0
- package/dist/arb-token-lists/src/main.d.ts +1 -0
- package/dist/constants/chainId.d.ts +10 -0
- package/dist/constants/tokens.d.ts +5 -0
- package/dist/fixtures/index.d.ts +24 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +8 -0
- package/dist/providers/ArbitrumMappingProvider.d.ts +11 -0
- package/dist/providers/MappingProvider.d.ts +4 -0
- package/dist/providers/OptimismMappingProvider.d.ts +10 -0
- package/dist/providers/PolygonMappingProvider.d.ts +9 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/token-list-bridge-utils.cjs.development.js +2217 -0
- package/dist/token-list-bridge-utils.cjs.development.js.map +1 -0
- package/dist/token-list-bridge-utils.cjs.production.min.js +2 -0
- package/dist/token-list-bridge-utils.cjs.production.min.js.map +1 -0
- package/dist/token-list-bridge-utils.esm.js +2201 -0
- package/dist/token-list-bridge-utils.esm.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/verify.d.ts +9 -0
- package/package.json +68 -0
- package/src/arb-token-lists/.env.sample +4 -0
- package/src/arb-token-lists/.eslintrc.js +43 -0
- package/src/arb-token-lists/.gitignore +4 -0
- package/src/arb-token-lists/package.json +40 -0
- package/src/arb-token-lists/readme.md +14 -0
- package/src/arb-token-lists/server/app.ts +21 -0
- package/src/arb-token-lists/src/Assets/coingecko_uris.json +5108 -0
- package/src/arb-token-lists/src/Assets/logo_uris.json +44 -0
- package/src/arb-token-lists/src/WarningList/warningTokens.json +290 -0
- package/src/arb-token-lists/src/lib/getClargs.ts +32 -0
- package/src/arb-token-lists/src/lib/graph.ts +116 -0
- package/src/arb-token-lists/src/lib/instantiate_bridge.ts +35 -0
- package/src/arb-token-lists/src/lib/token_list_gen.ts +334 -0
- package/src/arb-token-lists/src/lib/types.ts +44 -0
- package/src/arb-token-lists/src/lib/utils.ts +285 -0
- package/src/arb-token-lists/src/main.ts +54 -0
- package/src/arb-token-lists/tsconfig.json +20 -0
- package/src/arb-token-lists/update_all +6 -0
- package/src/arb-token-lists/yarn.lock +4273 -0
- package/src/constants/chainId.ts +13 -0
- package/src/constants/tokens.ts +31 -0
- package/src/fixtures/index.ts +104 -0
- package/src/index.test.ts +211 -0
- package/src/index.ts +92 -0
- package/src/providers/ArbitrumMappingProvider.ts +28 -0
- package/src/providers/MappingProvider.ts +5 -0
- package/src/providers/OptimismMappingProvider.ts +13 -0
- package/src/providers/PolygonMappingProvider.ts +127 -0
- package/src/providers/index.ts +17 -0
- package/src/utils.ts +21 -0
- package/src/verify.test.ts +19 -0
- package/src/verify.ts +60 -0
package/src/verify.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { TokenList } from '@uniswap/token-lists'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Verifies that for each token with extensions.bridgeInfo defined, for every
|
|
5
|
+
* chainId there exists a token with that chainId at the root-level of the
|
|
6
|
+
* token list.
|
|
7
|
+
*
|
|
8
|
+
* @returns input TokenList if valid, throws otherwise
|
|
9
|
+
*/
|
|
10
|
+
export function verifyExtensions(tokenList: TokenList) {
|
|
11
|
+
for (const token of tokenList.tokens) {
|
|
12
|
+
if (!token.extensions?.bridgeInfo) continue
|
|
13
|
+
|
|
14
|
+
// if has extension, make sure that:
|
|
15
|
+
// 1/ other token has root-level entry
|
|
16
|
+
// 2/ other root entry has extension pointing to it
|
|
17
|
+
for (const destChainId of Object.keys(token.extensions.bridgeInfo)) {
|
|
18
|
+
const destTokens = tokenList.tokens.filter(
|
|
19
|
+
(t) =>
|
|
20
|
+
t.chainId === Number(destChainId) &&
|
|
21
|
+
t.address ===
|
|
22
|
+
// @ts-expect-error TokenList schema does not allow bridgeInfo objetcs yet
|
|
23
|
+
token.extensions.bridgeInfo[destChainId].tokenAddress
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if (destTokens.length > 1) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`TokenList has duplicate root-level tokens for ${token.symbol} ${token.chainId}`
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const destToken = destTokens[0]
|
|
33
|
+
|
|
34
|
+
if (!destToken) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`TokenList is missing root-level TokenInfo for ${token.symbol} ${token.chainId}`
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ensure destToken has an extension pointing back to this
|
|
41
|
+
const srcToken: { tokenAddress: string } | undefined =
|
|
42
|
+
// @ts-expect-error TokenList schema does not allow bridgeInfo objects yet
|
|
43
|
+
destToken.extensions?.bridgeInfo[token.chainId]
|
|
44
|
+
|
|
45
|
+
if (!srcToken) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`TokenList is missing root-level TokenInfo.extensions.bridgeInfo for ${token.symbol} ${token.chainId}`
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (srcToken.tokenAddress !== token.address) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`TokenList has invalid root-level TokenInfo.extensions.bridgeInfo for ${token.symbol} ${token.chainId}. Expected ${token.address} but got ${srcToken.tokenAddress}`
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return tokenList
|
|
60
|
+
}
|