@uniswap/token-list-bridge-utils 2.0.0 → 2.1.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/dist/constants/chainId.d.ts +2 -1
- package/dist/constants/tokens.d.ts +3 -0
- package/dist/fixtures/index.d.ts +31 -0
- package/dist/providers/BaseGoerliMappingProvider.d.ts +9 -0
- package/dist/token-list-bridge-utils.cjs.development.js +85 -6
- 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 +85 -6
- package/dist/token-list-bridge-utils.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/constants/chainId.ts +2 -0
- package/src/constants/tokens.ts +24 -0
- package/src/fixtures/index.ts +51 -0
- package/src/index.test.ts +153 -0
- package/src/index.ts +10 -1
- package/src/providers/BaseGoerliMappingProvider.ts +43 -0
- package/src/providers/index.ts +4 -0
- package/src/utils.ts +3 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Token } from '@uniswap/sdk-core';
|
|
2
|
+
export declare const COINBASE_WRAPPED_STAKED_ETH: Token;
|
|
3
|
+
export declare const COINBASE_WRAPPED_STAKED_ETH_BASE_GOERLI: Token;
|
|
4
|
+
export declare const COINBASE_WRAPPED_STAKED_ETH_ARBITRUM_ONE: Token;
|
|
2
5
|
export declare const DAI: Token;
|
|
3
6
|
export declare const DAI_ARBITRUM_ONE: Token;
|
|
4
7
|
export declare const DAI_OPTIMISM: Token;
|
package/dist/fixtures/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ChainId } from '../constants/chainId';
|
|
|
3
3
|
export declare const Tokens: Partial<Record<ChainId, Record<string, TokenInfo>>>;
|
|
4
4
|
export declare const sampleL1TokenList: TokenList;
|
|
5
5
|
export declare const sampleL1TokenList_2: TokenList;
|
|
6
|
+
export declare const sampleL1TokenList_3: TokenList;
|
|
6
7
|
export declare const arbBridgeL2Address = "0x467194771dae2967aef3ecbedd3bf9a310c76c65";
|
|
7
8
|
export declare const arbBridgeL1Address = "0xd3b5b60020504bc3489d6949d545893982ba3011";
|
|
8
9
|
export declare const arbedSampleTokenList: {
|
|
@@ -10,6 +11,9 @@ export declare const arbedSampleTokenList: {
|
|
|
10
11
|
tokens: TokenInfo[];
|
|
11
12
|
timestamp: string;
|
|
12
13
|
version: import("@uniswap/token-lists").Version;
|
|
14
|
+
tokenMap?: {
|
|
15
|
+
readonly [key: string]: TokenInfo;
|
|
16
|
+
} | undefined;
|
|
13
17
|
keywords?: string[] | undefined;
|
|
14
18
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
15
19
|
logoURI?: string | undefined;
|
|
@@ -19,6 +23,9 @@ export declare const polygonedSampleTokenList: {
|
|
|
19
23
|
tokens: TokenInfo[];
|
|
20
24
|
timestamp: string;
|
|
21
25
|
version: import("@uniswap/token-lists").Version;
|
|
26
|
+
tokenMap?: {
|
|
27
|
+
readonly [key: string]: TokenInfo;
|
|
28
|
+
} | undefined;
|
|
22
29
|
keywords?: string[] | undefined;
|
|
23
30
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
24
31
|
logoURI?: string | undefined;
|
|
@@ -28,6 +35,9 @@ export declare const avalanchedSampleTokenList: {
|
|
|
28
35
|
tokens: TokenInfo[];
|
|
29
36
|
timestamp: string;
|
|
30
37
|
version: import("@uniswap/token-lists").Version;
|
|
38
|
+
tokenMap?: {
|
|
39
|
+
readonly [key: string]: TokenInfo;
|
|
40
|
+
} | undefined;
|
|
31
41
|
keywords?: string[] | undefined;
|
|
32
42
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
33
43
|
logoURI?: string | undefined;
|
|
@@ -37,6 +47,9 @@ export declare const bnbedSampleTokenList: {
|
|
|
37
47
|
tokens: TokenInfo[];
|
|
38
48
|
timestamp: string;
|
|
39
49
|
version: import("@uniswap/token-lists").Version;
|
|
50
|
+
tokenMap?: {
|
|
51
|
+
readonly [key: string]: TokenInfo;
|
|
52
|
+
} | undefined;
|
|
40
53
|
keywords?: string[] | undefined;
|
|
41
54
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
42
55
|
logoURI?: string | undefined;
|
|
@@ -46,6 +59,21 @@ export declare const bnbedSampleTokenList_2: {
|
|
|
46
59
|
tokens: TokenInfo[];
|
|
47
60
|
timestamp: string;
|
|
48
61
|
version: import("@uniswap/token-lists").Version;
|
|
62
|
+
tokenMap?: {
|
|
63
|
+
readonly [key: string]: TokenInfo;
|
|
64
|
+
} | undefined;
|
|
65
|
+
keywords?: string[] | undefined;
|
|
66
|
+
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
67
|
+
logoURI?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
export declare const baseGoerliSampleTokenList_3: {
|
|
70
|
+
name: string;
|
|
71
|
+
tokens: TokenInfo[];
|
|
72
|
+
timestamp: string;
|
|
73
|
+
version: import("@uniswap/token-lists").Version;
|
|
74
|
+
tokenMap?: {
|
|
75
|
+
readonly [key: string]: TokenInfo;
|
|
76
|
+
} | undefined;
|
|
49
77
|
keywords?: string[] | undefined;
|
|
50
78
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
51
79
|
logoURI?: string | undefined;
|
|
@@ -55,6 +83,9 @@ export declare const optimizedSampleTokenList: {
|
|
|
55
83
|
tokens: TokenInfo[];
|
|
56
84
|
timestamp: string;
|
|
57
85
|
version: import("@uniswap/token-lists").Version;
|
|
86
|
+
tokenMap?: {
|
|
87
|
+
readonly [key: string]: TokenInfo;
|
|
88
|
+
} | undefined;
|
|
58
89
|
keywords?: string[] | undefined;
|
|
59
90
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
60
91
|
logoURI?: string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MappingProvider } from './MappingProvider';
|
|
2
|
+
import { GenericMappedTokenData } from '../constants/types';
|
|
3
|
+
/**
|
|
4
|
+
* The Base Goerli mapping (linked above) is manually maintained by the Coinbase team
|
|
5
|
+
* in this repository: https://github.com/ethereum-optimism/ethereum-optimism.github.io.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BaseGoerliMappingProvider implements MappingProvider {
|
|
8
|
+
provide(): Promise<GenericMappedTokenData>;
|
|
9
|
+
}
|
|
@@ -899,6 +899,7 @@ var ChainId;
|
|
|
899
899
|
ChainId[ChainId["CELO"] = 42220] = "CELO";
|
|
900
900
|
ChainId[ChainId["BNB"] = 56] = "BNB";
|
|
901
901
|
ChainId[ChainId["AVALANCHE"] = 43114] = "AVALANCHE";
|
|
902
|
+
ChainId[ChainId["BASE_GOERLI"] = 84531] = "BASE_GOERLI";
|
|
902
903
|
})(ChainId || (ChainId = {}));
|
|
903
904
|
|
|
904
905
|
function compareTokenInfos(t1, t2) {
|
|
@@ -1124,6 +1125,9 @@ function getRpcUrl(chainId) {
|
|
|
1124
1125
|
|
|
1125
1126
|
case ChainId.AVALANCHE:
|
|
1126
1127
|
return 'https://api.avax.network/ext/bc/C/rpc';
|
|
1128
|
+
|
|
1129
|
+
case ChainId.BASE_GOERLI:
|
|
1130
|
+
return 'https://goerli.base.org';
|
|
1127
1131
|
}
|
|
1128
1132
|
|
|
1129
1133
|
throw new Error('Unsupported ChainId');
|
|
@@ -5690,9 +5694,70 @@ var AvalancheMappingProvider = /*#__PURE__*/function () {
|
|
|
5690
5694
|
return AvalancheMappingProvider;
|
|
5691
5695
|
}();
|
|
5692
5696
|
|
|
5697
|
+
var baseGoerliTokenListURL = 'https://raw.githubusercontent.com/' + 'ethereum-optimism/ethereum-optimism.github.io/master/optimism.tokenlist.json';
|
|
5698
|
+
/**
|
|
5699
|
+
* The Base Goerli mapping (linked above) is manually maintained by the Coinbase team
|
|
5700
|
+
* in this repository: https://github.com/ethereum-optimism/ethereum-optimism.github.io.
|
|
5701
|
+
*/
|
|
5702
|
+
|
|
5703
|
+
var BaseGoerliMappingProvider = /*#__PURE__*/function () {
|
|
5704
|
+
function BaseGoerliMappingProvider() {}
|
|
5705
|
+
|
|
5706
|
+
var _proto = BaseGoerliMappingProvider.prototype;
|
|
5707
|
+
|
|
5708
|
+
_proto.provide = /*#__PURE__*/function () {
|
|
5709
|
+
var _provide = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
5710
|
+
var tokens, allTokens, opTokenId_baseGoerliAddressMap;
|
|
5711
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5712
|
+
while (1) {
|
|
5713
|
+
switch (_context.prev = _context.next) {
|
|
5714
|
+
case 0:
|
|
5715
|
+
tokens = {};
|
|
5716
|
+
_context.next = 3;
|
|
5717
|
+
return getTokenList(baseGoerliTokenListURL);
|
|
5718
|
+
|
|
5719
|
+
case 3:
|
|
5720
|
+
allTokens = _context.sent;
|
|
5721
|
+
opTokenId_baseGoerliAddressMap = {};
|
|
5722
|
+
allTokens.tokens.forEach(function (token) {
|
|
5723
|
+
if (token.chainId === ChainId.BASE_GOERLI) {
|
|
5724
|
+
var _token$extensions;
|
|
5725
|
+
|
|
5726
|
+
if (typeof ((_token$extensions = token.extensions) == null ? void 0 : _token$extensions.opTokenId) === 'string') {
|
|
5727
|
+
opTokenId_baseGoerliAddressMap[token.extensions.opTokenId] = token.address;
|
|
5728
|
+
}
|
|
5729
|
+
}
|
|
5730
|
+
});
|
|
5731
|
+
allTokens.tokens.forEach(function (token) {
|
|
5732
|
+
var _token$extensions2;
|
|
5733
|
+
|
|
5734
|
+
if (token.chainId === ChainId.MAINNET && typeof ((_token$extensions2 = token.extensions) == null ? void 0 : _token$extensions2.opTokenId) === 'string' && token.extensions.opTokenId in opTokenId_baseGoerliAddressMap) {
|
|
5735
|
+
tokens[token.address.toLowerCase()] = opTokenId_baseGoerliAddressMap[token.extensions.opTokenId];
|
|
5736
|
+
}
|
|
5737
|
+
});
|
|
5738
|
+
return _context.abrupt("return", tokens);
|
|
5739
|
+
|
|
5740
|
+
case 8:
|
|
5741
|
+
case "end":
|
|
5742
|
+
return _context.stop();
|
|
5743
|
+
}
|
|
5744
|
+
}
|
|
5745
|
+
}, _callee);
|
|
5746
|
+
}));
|
|
5747
|
+
|
|
5748
|
+
function provide() {
|
|
5749
|
+
return _provide.apply(this, arguments);
|
|
5750
|
+
}
|
|
5751
|
+
|
|
5752
|
+
return provide;
|
|
5753
|
+
}();
|
|
5754
|
+
|
|
5755
|
+
return BaseGoerliMappingProvider;
|
|
5756
|
+
}();
|
|
5757
|
+
|
|
5693
5758
|
var web3 = /*#__PURE__*/new Web3__default["default"](); // chains we support fetching mappings for (can be different than the l2ChainIds arg for buildList)
|
|
5694
5759
|
|
|
5695
|
-
var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE];
|
|
5760
|
+
var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE_GOERLI];
|
|
5696
5761
|
function buildList(_x, _x2) {
|
|
5697
5762
|
return _buildList.apply(this, arguments);
|
|
5698
5763
|
} // using a symbol lookup contract call to check whether the token exists on the L2
|
|
@@ -5884,6 +5949,9 @@ function getMappingProvider(chainId, l1TokenList) {
|
|
|
5884
5949
|
case ChainId.AVALANCHE:
|
|
5885
5950
|
return new AvalancheMappingProvider();
|
|
5886
5951
|
|
|
5952
|
+
case ChainId.BASE_GOERLI:
|
|
5953
|
+
return new BaseGoerliMappingProvider();
|
|
5954
|
+
|
|
5887
5955
|
default:
|
|
5888
5956
|
throw new Error("Chain " + chainId + " not supported for fetching mappings.");
|
|
5889
5957
|
}
|
|
@@ -6084,7 +6152,7 @@ function chainify(_x) {
|
|
|
6084
6152
|
|
|
6085
6153
|
function _chainify() {
|
|
6086
6154
|
_chainify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(l1TokenListOrPathOrUrl) {
|
|
6087
|
-
var l1TokenList, l2Chains, chainified;
|
|
6155
|
+
var l1TokenList, l2Chains, chainified, merged, tokenMap;
|
|
6088
6156
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6089
6157
|
while (1) {
|
|
6090
6158
|
switch (_context.prev = _context.next) {
|
|
@@ -6094,16 +6162,27 @@ function _chainify() {
|
|
|
6094
6162
|
|
|
6095
6163
|
case 2:
|
|
6096
6164
|
l1TokenList = _context.sent;
|
|
6097
|
-
l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE];
|
|
6165
|
+
l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE_GOERLI];
|
|
6098
6166
|
_context.next = 6;
|
|
6099
6167
|
return chainifyTokenList(l2Chains, l1TokenListOrPathOrUrl);
|
|
6100
6168
|
|
|
6101
6169
|
case 6:
|
|
6102
6170
|
chainified = _context.sent;
|
|
6103
|
-
|
|
6104
|
-
chainified)
|
|
6171
|
+
merged = mergeTokenLists(l1TokenList, // providing l1 first to make sure duplicated tokens resolve to this list
|
|
6172
|
+
chainified);
|
|
6173
|
+
tokenMap = {};
|
|
6105
6174
|
|
|
6106
|
-
|
|
6175
|
+
if (merged.tokens && merged.tokens.length > 0) {
|
|
6176
|
+
merged.tokens.forEach(function (token) {
|
|
6177
|
+
tokenMap[token.chainId + "_" + token.address] = token;
|
|
6178
|
+
});
|
|
6179
|
+
}
|
|
6180
|
+
|
|
6181
|
+
return _context.abrupt("return", _extends({}, merged, {
|
|
6182
|
+
tokenMap: tokenMap
|
|
6183
|
+
}));
|
|
6184
|
+
|
|
6185
|
+
case 11:
|
|
6107
6186
|
case "end":
|
|
6108
6187
|
return _context.stop();
|
|
6109
6188
|
}
|