@uniswap/token-list-bridge-utils 2.0.0 → 2.2.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 +3 -1
- package/dist/constants/tokens.d.ts +7 -0
- package/dist/fixtures/index.d.ts +43 -0
- package/dist/providers/BaseGoerliMappingProvider.d.ts +9 -0
- package/dist/providers/BaseMappingProvider.d.ts +9 -0
- package/dist/token-list-bridge-utils.cjs.development.js +191 -32
- 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 +191 -32
- package/dist/token-list-bridge-utils.esm.js.map +1 -1
- package/package.json +14 -23
- package/src/arbitrum/instantiate_bridge.ts +10 -2
- package/src/constants/chainId.ts +3 -0
- package/src/constants/tokens.ts +56 -0
- package/src/fixtures/index.ts +93 -0
- package/src/index.test.ts +141 -0
- package/src/index.ts +9 -2
- package/src/providers/BaseGoerliMappingProvider.ts +43 -0
- package/src/providers/BaseMappingProvider.ts +42 -0
- package/src/providers/OptimismMappingProvider.ts +19 -6
- package/src/providers/index.ts +18 -5
- package/src/utils.ts +5 -1
|
@@ -1,9 +1,16 @@
|
|
|
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_BASE: Token;
|
|
5
|
+
export declare const COINBASE_WRAPPED_STAKED_ETH_ARBITRUM_ONE: Token;
|
|
6
|
+
export declare const COINBASE_WRAPPED_STAKED_ETH_OPTIMISM: Token;
|
|
2
7
|
export declare const DAI: Token;
|
|
3
8
|
export declare const DAI_ARBITRUM_ONE: Token;
|
|
4
9
|
export declare const DAI_OPTIMISM: Token;
|
|
5
10
|
export declare const DAI_POLYGON: Token;
|
|
6
11
|
export declare const DAI_BNB: Token;
|
|
7
12
|
export declare const DAI_AVALANCHE: Token;
|
|
13
|
+
export declare const DAI_BASE: Token;
|
|
14
|
+
export declare const DAI_BASE_GOERLI: Token;
|
|
8
15
|
export declare const USDT: Token;
|
|
9
16
|
export declare const USDT_BNB: 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,33 @@ 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;
|
|
77
|
+
keywords?: string[] | undefined;
|
|
78
|
+
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
79
|
+
logoURI?: string | undefined;
|
|
80
|
+
};
|
|
81
|
+
export declare const baseSampleTokenList_3: {
|
|
82
|
+
name: string;
|
|
83
|
+
tokens: TokenInfo[];
|
|
84
|
+
timestamp: string;
|
|
85
|
+
version: import("@uniswap/token-lists").Version;
|
|
86
|
+
tokenMap?: {
|
|
87
|
+
readonly [key: string]: TokenInfo;
|
|
88
|
+
} | undefined;
|
|
49
89
|
keywords?: string[] | undefined;
|
|
50
90
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
51
91
|
logoURI?: string | undefined;
|
|
@@ -55,6 +95,9 @@ export declare const optimizedSampleTokenList: {
|
|
|
55
95
|
tokens: TokenInfo[];
|
|
56
96
|
timestamp: string;
|
|
57
97
|
version: import("@uniswap/token-lists").Version;
|
|
98
|
+
tokenMap?: {
|
|
99
|
+
readonly [key: string]: TokenInfo;
|
|
100
|
+
} | undefined;
|
|
58
101
|
keywords?: string[] | undefined;
|
|
59
102
|
tags?: import("@uniswap/token-lists").Tags | undefined;
|
|
60
103
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MappingProvider } from './MappingProvider';
|
|
2
|
+
import { GenericMappedTokenData } from '../constants/types';
|
|
3
|
+
/**
|
|
4
|
+
* The Base 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 BaseMappingProvider implements MappingProvider {
|
|
8
|
+
provide(): Promise<GenericMappedTokenData>;
|
|
9
|
+
}
|
|
@@ -899,6 +899,8 @@ 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"] = 8453] = "BASE";
|
|
903
|
+
ChainId[ChainId["BASE_GOERLI"] = 84531] = "BASE_GOERLI";
|
|
902
904
|
})(ChainId || (ChainId = {}));
|
|
903
905
|
|
|
904
906
|
function compareTokenInfos(t1, t2) {
|
|
@@ -1124,6 +1126,12 @@ function getRpcUrl(chainId) {
|
|
|
1124
1126
|
|
|
1125
1127
|
case ChainId.AVALANCHE:
|
|
1126
1128
|
return 'https://api.avax.network/ext/bc/C/rpc';
|
|
1129
|
+
|
|
1130
|
+
case ChainId.BASE:
|
|
1131
|
+
return 'https://mainnet.base.org';
|
|
1132
|
+
|
|
1133
|
+
case ChainId.BASE_GOERLI:
|
|
1134
|
+
return 'https://goerli.base.org';
|
|
1127
1135
|
}
|
|
1128
1136
|
|
|
1129
1137
|
throw new Error('Unsupported ChainId');
|
|
@@ -1161,7 +1169,13 @@ var _process$env, _process$env$MAINNET_;
|
|
|
1161
1169
|
dotenv.config();
|
|
1162
1170
|
(_process$env$MAINNET_ = (_process$env = process.env).MAINNET_RPC) != null ? _process$env$MAINNET_ : _process$env.MAINNET_RPC = /*#__PURE__*/getRpcUrl(ChainId.MAINNET);
|
|
1163
1171
|
|
|
1164
|
-
var networkID = 42161;
|
|
1172
|
+
var networkID = 42161;
|
|
1173
|
+
|
|
1174
|
+
var l2Rpc = function l2Rpc(chainId) {
|
|
1175
|
+
if (chainId === 42161) return 'https://arb1.arbitrum.io/rpc';else if (chainId === 421611) return 'https://rinkeby.arbitrum.io/rpc';else if (chainId === 42170) return 'https://nova.arbitrum.io/rpc';else if (chainId === 421613) return 'https://goerli-rollup.arbitrum.io/rpc';
|
|
1176
|
+
throw new Error('No L2 RPC detected');
|
|
1177
|
+
}; // ref: https://github.com/OffchainLabs/arb-token-lists/blob/master/src/lib/instantiate_bridge.ts
|
|
1178
|
+
|
|
1165
1179
|
|
|
1166
1180
|
var getNetworkConfig = /*#__PURE__*/function () {
|
|
1167
1181
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -1189,8 +1203,8 @@ var getNetworkConfig = /*#__PURE__*/function () {
|
|
|
1189
1203
|
|
|
1190
1204
|
case 11:
|
|
1191
1205
|
l1Network = _context.sent;
|
|
1192
|
-
arbProvider = new ethers.providers.JsonRpcProvider(l2Network.
|
|
1193
|
-
ethProvider = new ethers.providers.JsonRpcProvider(
|
|
1206
|
+
arbProvider = new ethers.providers.JsonRpcProvider(l2Rpc(l2Network.chainID));
|
|
1207
|
+
ethProvider = new ethers.providers.JsonRpcProvider(process.env.MAINNET_RPC);
|
|
1194
1208
|
_context.next = 16;
|
|
1195
1209
|
return MultiCaller.fromProvider(ethProvider);
|
|
1196
1210
|
|
|
@@ -1325,7 +1339,7 @@ var ArbitrumMappingProvider = /*#__PURE__*/function () {
|
|
|
1325
1339
|
return ArbitrumMappingProvider;
|
|
1326
1340
|
}();
|
|
1327
1341
|
|
|
1328
|
-
var optimismTokenListURL = 'https://raw.githubusercontent.com/' + 'ethereum-optimism/ethereum-optimism.github.io/
|
|
1342
|
+
var optimismTokenListURL = 'https://raw.githubusercontent.com/' + 'ethereum-optimism/ethereum-optimism.github.io/master/optimism.tokenlist.json';
|
|
1329
1343
|
/**
|
|
1330
1344
|
* The Optimism L2 mapping (linked above) is manually maintained by the Optimism team.
|
|
1331
1345
|
*
|
|
@@ -1339,8 +1353,7 @@ var OptimismMappingProvider = /*#__PURE__*/function () {
|
|
|
1339
1353
|
|
|
1340
1354
|
_proto.provide = /*#__PURE__*/function () {
|
|
1341
1355
|
var _provide = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
1342
|
-
var tokens,
|
|
1343
|
-
|
|
1356
|
+
var tokens, allTokens, opTokenId_baseAddressMap;
|
|
1344
1357
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1345
1358
|
while (1) {
|
|
1346
1359
|
switch (_context.prev = _context.next) {
|
|
@@ -1350,19 +1363,27 @@ var OptimismMappingProvider = /*#__PURE__*/function () {
|
|
|
1350
1363
|
return getTokenList(optimismTokenListURL);
|
|
1351
1364
|
|
|
1352
1365
|
case 3:
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
token
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1366
|
+
allTokens = _context.sent;
|
|
1367
|
+
opTokenId_baseAddressMap = {};
|
|
1368
|
+
allTokens.tokens.forEach(function (token) {
|
|
1369
|
+
if (token.chainId === ChainId.OPTIMISM) {
|
|
1370
|
+
var _token$extensions;
|
|
1371
|
+
|
|
1372
|
+
if (typeof ((_token$extensions = token.extensions) == null ? void 0 : _token$extensions.opTokenId) === 'string') {
|
|
1373
|
+
opTokenId_baseAddressMap[token.extensions.opTokenId] = token.address;
|
|
1374
|
+
}
|
|
1360
1375
|
}
|
|
1361
|
-
}
|
|
1376
|
+
});
|
|
1377
|
+
allTokens.tokens.forEach(function (token) {
|
|
1378
|
+
var _token$extensions2;
|
|
1362
1379
|
|
|
1380
|
+
if (token.chainId === ChainId.MAINNET && typeof ((_token$extensions2 = token.extensions) == null ? void 0 : _token$extensions2.opTokenId) === 'string' && token.extensions.opTokenId in opTokenId_baseAddressMap) {
|
|
1381
|
+
tokens[token.address.toLowerCase()] = opTokenId_baseAddressMap[token.extensions.opTokenId];
|
|
1382
|
+
}
|
|
1383
|
+
});
|
|
1363
1384
|
return _context.abrupt("return", tokens);
|
|
1364
1385
|
|
|
1365
|
-
case
|
|
1386
|
+
case 8:
|
|
1366
1387
|
case "end":
|
|
1367
1388
|
return _context.stop();
|
|
1368
1389
|
}
|
|
@@ -5690,9 +5711,131 @@ var AvalancheMappingProvider = /*#__PURE__*/function () {
|
|
|
5690
5711
|
return AvalancheMappingProvider;
|
|
5691
5712
|
}();
|
|
5692
5713
|
|
|
5714
|
+
var baseGoerliTokenListURL$1 = 'https://raw.githubusercontent.com/' + 'ethereum-optimism/ethereum-optimism.github.io/master/optimism.tokenlist.json';
|
|
5715
|
+
/**
|
|
5716
|
+
* The Base Goerli mapping (linked above) is manually maintained by the Coinbase team
|
|
5717
|
+
* in this repository: https://github.com/ethereum-optimism/ethereum-optimism.github.io.
|
|
5718
|
+
*/
|
|
5719
|
+
|
|
5720
|
+
var BaseGoerliMappingProvider = /*#__PURE__*/function () {
|
|
5721
|
+
function BaseGoerliMappingProvider() {}
|
|
5722
|
+
|
|
5723
|
+
var _proto = BaseGoerliMappingProvider.prototype;
|
|
5724
|
+
|
|
5725
|
+
_proto.provide = /*#__PURE__*/function () {
|
|
5726
|
+
var _provide = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
5727
|
+
var tokens, allTokens, opTokenId_baseGoerliAddressMap;
|
|
5728
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5729
|
+
while (1) {
|
|
5730
|
+
switch (_context.prev = _context.next) {
|
|
5731
|
+
case 0:
|
|
5732
|
+
tokens = {};
|
|
5733
|
+
_context.next = 3;
|
|
5734
|
+
return getTokenList(baseGoerliTokenListURL$1);
|
|
5735
|
+
|
|
5736
|
+
case 3:
|
|
5737
|
+
allTokens = _context.sent;
|
|
5738
|
+
opTokenId_baseGoerliAddressMap = {};
|
|
5739
|
+
allTokens.tokens.forEach(function (token) {
|
|
5740
|
+
if (token.chainId === ChainId.BASE_GOERLI) {
|
|
5741
|
+
var _token$extensions;
|
|
5742
|
+
|
|
5743
|
+
if (typeof ((_token$extensions = token.extensions) == null ? void 0 : _token$extensions.opTokenId) === 'string') {
|
|
5744
|
+
opTokenId_baseGoerliAddressMap[token.extensions.opTokenId] = token.address;
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
});
|
|
5748
|
+
allTokens.tokens.forEach(function (token) {
|
|
5749
|
+
var _token$extensions2;
|
|
5750
|
+
|
|
5751
|
+
if (token.chainId === ChainId.MAINNET && typeof ((_token$extensions2 = token.extensions) == null ? void 0 : _token$extensions2.opTokenId) === 'string' && token.extensions.opTokenId in opTokenId_baseGoerliAddressMap) {
|
|
5752
|
+
tokens[token.address.toLowerCase()] = opTokenId_baseGoerliAddressMap[token.extensions.opTokenId];
|
|
5753
|
+
}
|
|
5754
|
+
});
|
|
5755
|
+
return _context.abrupt("return", tokens);
|
|
5756
|
+
|
|
5757
|
+
case 8:
|
|
5758
|
+
case "end":
|
|
5759
|
+
return _context.stop();
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
}, _callee);
|
|
5763
|
+
}));
|
|
5764
|
+
|
|
5765
|
+
function provide() {
|
|
5766
|
+
return _provide.apply(this, arguments);
|
|
5767
|
+
}
|
|
5768
|
+
|
|
5769
|
+
return provide;
|
|
5770
|
+
}();
|
|
5771
|
+
|
|
5772
|
+
return BaseGoerliMappingProvider;
|
|
5773
|
+
}();
|
|
5774
|
+
|
|
5775
|
+
var baseGoerliTokenListURL = 'https://raw.githubusercontent.com/' + 'ethereum-optimism/ethereum-optimism.github.io/master/optimism.tokenlist.json';
|
|
5776
|
+
/**
|
|
5777
|
+
* The Base mapping (linked above) is manually maintained by the Coinbase team
|
|
5778
|
+
* in this repository: https://github.com/ethereum-optimism/ethereum-optimism.github.io.
|
|
5779
|
+
*/
|
|
5780
|
+
|
|
5781
|
+
var BaseMappingProvider = /*#__PURE__*/function () {
|
|
5782
|
+
function BaseMappingProvider() {}
|
|
5783
|
+
|
|
5784
|
+
var _proto = BaseMappingProvider.prototype;
|
|
5785
|
+
|
|
5786
|
+
_proto.provide = /*#__PURE__*/function () {
|
|
5787
|
+
var _provide = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
5788
|
+
var tokens, allTokens, opTokenId_baseAddressMap;
|
|
5789
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5790
|
+
while (1) {
|
|
5791
|
+
switch (_context.prev = _context.next) {
|
|
5792
|
+
case 0:
|
|
5793
|
+
tokens = {};
|
|
5794
|
+
_context.next = 3;
|
|
5795
|
+
return getTokenList(baseGoerliTokenListURL);
|
|
5796
|
+
|
|
5797
|
+
case 3:
|
|
5798
|
+
allTokens = _context.sent;
|
|
5799
|
+
opTokenId_baseAddressMap = {};
|
|
5800
|
+
allTokens.tokens.forEach(function (token) {
|
|
5801
|
+
if (token.chainId === ChainId.BASE) {
|
|
5802
|
+
var _token$extensions;
|
|
5803
|
+
|
|
5804
|
+
if (typeof ((_token$extensions = token.extensions) == null ? void 0 : _token$extensions.opTokenId) === 'string') {
|
|
5805
|
+
opTokenId_baseAddressMap[token.extensions.opTokenId] = token.address;
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
});
|
|
5809
|
+
allTokens.tokens.forEach(function (token) {
|
|
5810
|
+
var _token$extensions2;
|
|
5811
|
+
|
|
5812
|
+
if (token.chainId === ChainId.MAINNET && typeof ((_token$extensions2 = token.extensions) == null ? void 0 : _token$extensions2.opTokenId) === 'string' && token.extensions.opTokenId in opTokenId_baseAddressMap) {
|
|
5813
|
+
tokens[token.address.toLowerCase()] = opTokenId_baseAddressMap[token.extensions.opTokenId];
|
|
5814
|
+
}
|
|
5815
|
+
});
|
|
5816
|
+
return _context.abrupt("return", tokens);
|
|
5817
|
+
|
|
5818
|
+
case 8:
|
|
5819
|
+
case "end":
|
|
5820
|
+
return _context.stop();
|
|
5821
|
+
}
|
|
5822
|
+
}
|
|
5823
|
+
}, _callee);
|
|
5824
|
+
}));
|
|
5825
|
+
|
|
5826
|
+
function provide() {
|
|
5827
|
+
return _provide.apply(this, arguments);
|
|
5828
|
+
}
|
|
5829
|
+
|
|
5830
|
+
return provide;
|
|
5831
|
+
}();
|
|
5832
|
+
|
|
5833
|
+
return BaseMappingProvider;
|
|
5834
|
+
}();
|
|
5835
|
+
|
|
5693
5836
|
var web3 = /*#__PURE__*/new Web3__default["default"](); // chains we support fetching mappings for (can be different than the l2ChainIds arg for buildList)
|
|
5694
5837
|
|
|
5695
|
-
var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE];
|
|
5838
|
+
var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.BASE_GOERLI];
|
|
5696
5839
|
function buildList(_x, _x2) {
|
|
5697
5840
|
return _buildList.apply(this, arguments);
|
|
5698
5841
|
} // using a symbol lookup contract call to check whether the token exists on the L2
|
|
@@ -5884,6 +6027,12 @@ function getMappingProvider(chainId, l1TokenList) {
|
|
|
5884
6027
|
case ChainId.AVALANCHE:
|
|
5885
6028
|
return new AvalancheMappingProvider();
|
|
5886
6029
|
|
|
6030
|
+
case ChainId.BASE:
|
|
6031
|
+
return new BaseMappingProvider();
|
|
6032
|
+
|
|
6033
|
+
case ChainId.BASE_GOERLI:
|
|
6034
|
+
return new BaseGoerliMappingProvider();
|
|
6035
|
+
|
|
5887
6036
|
default:
|
|
5888
6037
|
throw new Error("Chain " + chainId + " not supported for fetching mappings.");
|
|
5889
6038
|
}
|
|
@@ -5947,18 +6096,27 @@ function getChildTokenDetails(_x7, _x8, _x9) {
|
|
|
5947
6096
|
|
|
5948
6097
|
function _getChildTokenDetails() {
|
|
5949
6098
|
_getChildTokenDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(l1Token, chainId, chainIdToMappingsMap) {
|
|
5950
|
-
var _l1Token$extensions
|
|
6099
|
+
var _l1Token$extensions;
|
|
5951
6100
|
|
|
5952
|
-
var existingMapping, childToken, childTokenAddress, childTokenValid, decimals;
|
|
6101
|
+
var bridgeInfo, existingMapping, bridgeInfoForChain, childToken, childTokenAddress, childTokenValid, decimals;
|
|
5953
6102
|
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
5954
6103
|
while (1) {
|
|
5955
6104
|
switch (_context6.prev = _context6.next) {
|
|
5956
6105
|
case 0:
|
|
5957
|
-
|
|
6106
|
+
bridgeInfo = l1Token == null ? void 0 : (_l1Token$extensions = l1Token.extensions) == null ? void 0 : _l1Token$extensions.bridgeInfo;
|
|
6107
|
+
|
|
6108
|
+
if (bridgeInfo && typeof bridgeInfo === 'object') {
|
|
6109
|
+
bridgeInfoForChain = bridgeInfo[chainId];
|
|
6110
|
+
|
|
6111
|
+
if (bridgeInfoForChain && typeof bridgeInfoForChain === 'object') {
|
|
6112
|
+
existingMapping = bridgeInfoForChain.tokenAddress;
|
|
6113
|
+
}
|
|
6114
|
+
} // use the externally fetched mappings if manual entry doesn't exist for the token/chain mapping
|
|
5958
6115
|
// and the given chain is supported for fetching mappings
|
|
5959
6116
|
|
|
6117
|
+
|
|
5960
6118
|
if (!(CHAINS_WITH_MAPPING_PROVIDERS.includes(chainId) && existingMapping === undefined)) {
|
|
5961
|
-
_context6.next =
|
|
6119
|
+
_context6.next = 15;
|
|
5962
6120
|
break;
|
|
5963
6121
|
}
|
|
5964
6122
|
|
|
@@ -5968,17 +6126,17 @@ function _getChildTokenDetails() {
|
|
|
5968
6126
|
_context6.t1 = childTokenAddress;
|
|
5969
6127
|
|
|
5970
6128
|
if (!_context6.t1) {
|
|
5971
|
-
_context6.next =
|
|
6129
|
+
_context6.next = 11;
|
|
5972
6130
|
break;
|
|
5973
6131
|
}
|
|
5974
6132
|
|
|
5975
|
-
_context6.next =
|
|
6133
|
+
_context6.next = 10;
|
|
5976
6134
|
return hasExistingTokenContract(childTokenAddress, chainId);
|
|
5977
6135
|
|
|
5978
|
-
case
|
|
6136
|
+
case 10:
|
|
5979
6137
|
_context6.t1 = _context6.sent;
|
|
5980
6138
|
|
|
5981
|
-
case
|
|
6139
|
+
case 11:
|
|
5982
6140
|
_context6.t2 = _context6.t1;
|
|
5983
6141
|
childTokenValid = (0, _context6.t0)(_context6.t2);
|
|
5984
6142
|
decimals = childToken && (chainId === ChainId.BNB || chainId === ChainId.AVALANCHE) ? childToken.decimals : undefined;
|
|
@@ -5988,13 +6146,13 @@ function _getChildTokenDetails() {
|
|
|
5988
6146
|
decimals: decimals
|
|
5989
6147
|
});
|
|
5990
6148
|
|
|
5991
|
-
case
|
|
6149
|
+
case 15:
|
|
5992
6150
|
return _context6.abrupt("return", {
|
|
5993
6151
|
childTokenValid: !!existingMapping,
|
|
5994
6152
|
childTokenAddress: existingMapping
|
|
5995
6153
|
});
|
|
5996
6154
|
|
|
5997
|
-
case
|
|
6155
|
+
case 16:
|
|
5998
6156
|
case "end":
|
|
5999
6157
|
return _context6.stop();
|
|
6000
6158
|
}
|
|
@@ -6084,7 +6242,7 @@ function chainify(_x) {
|
|
|
6084
6242
|
|
|
6085
6243
|
function _chainify() {
|
|
6086
6244
|
_chainify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(l1TokenListOrPathOrUrl) {
|
|
6087
|
-
var l1TokenList, l2Chains, chainified;
|
|
6245
|
+
var l1TokenList, l2Chains, chainified, merged;
|
|
6088
6246
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6089
6247
|
while (1) {
|
|
6090
6248
|
switch (_context.prev = _context.next) {
|
|
@@ -6094,16 +6252,17 @@ function _chainify() {
|
|
|
6094
6252
|
|
|
6095
6253
|
case 2:
|
|
6096
6254
|
l1TokenList = _context.sent;
|
|
6097
|
-
l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE];
|
|
6255
|
+
l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.BASE_GOERLI];
|
|
6098
6256
|
_context.next = 6;
|
|
6099
6257
|
return chainifyTokenList(l2Chains, l1TokenListOrPathOrUrl);
|
|
6100
6258
|
|
|
6101
6259
|
case 6:
|
|
6102
6260
|
chainified = _context.sent;
|
|
6103
|
-
|
|
6104
|
-
chainified)
|
|
6261
|
+
merged = mergeTokenLists(l1TokenList, // providing l1 first to make sure duplicated tokens resolve to this list
|
|
6262
|
+
chainified);
|
|
6263
|
+
return _context.abrupt("return", merged);
|
|
6105
6264
|
|
|
6106
|
-
case
|
|
6265
|
+
case 9:
|
|
6107
6266
|
case "end":
|
|
6108
6267
|
return _context.stop();
|
|
6109
6268
|
}
|
|
@@ -6168,7 +6327,7 @@ function mergeTokenLists(primary, secondary) {
|
|
|
6168
6327
|
|
|
6169
6328
|
var merged = lodash.merge(group[0], group[1]);
|
|
6170
6329
|
|
|
6171
|
-
if ((_merged$extensions = merged.extensions) != null && _merged$extensions.bridgeInfo) {
|
|
6330
|
+
if ((_merged$extensions = merged.extensions) != null && _merged$extensions.bridgeInfo && typeof merged.extensions.bridgeInfo === 'object') {
|
|
6172
6331
|
// remove reference to self-chain from merge
|
|
6173
6332
|
delete merged.extensions.bridgeInfo[merged.chainId];
|
|
6174
6333
|
}
|