@uniswap/token-list-bridge-utils 2.10.0 → 2.12.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.
@@ -876,6 +876,7 @@ var ChainId;
876
876
  ChainId[ChainId["BASE"] = 8453] = "BASE";
877
877
  ChainId[ChainId["UNICHAIN"] = 130] = "UNICHAIN";
878
878
  ChainId[ChainId["SONEIUM"] = 1868] = "SONEIUM";
879
+ ChainId[ChainId["MONAD"] = 143] = "MONAD";
879
880
  })(ChainId || (ChainId = {}));
880
881
 
881
882
  function compareTokenInfos(t1, t2) {
@@ -1078,8 +1079,7 @@ function getRpcUrl(chainId) {
1078
1079
  return 'https://ethereum-rpc.publicnode.com';
1079
1080
 
1080
1081
  case ChainId.OPTIMISM:
1081
- return 'https://rpc.ankr.com/optimism';
1082
- // seems to have higher rate limit than https://mainnet.optimism.io/
1082
+ return 'https://mainnet.optimism.io';
1083
1083
 
1084
1084
  case ChainId.OPTIMISTIC_KOVAN:
1085
1085
  return 'https://kovan.optimism.io';
@@ -6167,6 +6167,62 @@ var UnichainMappingProvider = /*#__PURE__*/function () {
6167
6167
  return UnichainMappingProvider;
6168
6168
  }();
6169
6169
 
6170
+ var monadMappings = {
6171
+ "0xdac17f958d2ee523a2206206994597c13d831ec7": {
6172
+ childToken: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
6173
+ decimals: 6
6174
+ },
6175
+ "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": {
6176
+ childToken: "0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
6177
+ decimals: 8
6178
+ },
6179
+ "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": {
6180
+ childToken: "0xEE8c0E9f1BFFb4Eb878d8f15f368A02a35481242",
6181
+ decimals: 18
6182
+ },
6183
+ "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": {
6184
+ childToken: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
6185
+ decimals: 6
6186
+ },
6187
+ "0xd31a59c85ae9d8edefec411d448f90841571b89c": {
6188
+ childToken: "0xea17E5a9efEBf1477dB45082d67010E2245217f1",
6189
+ decimals: 9
6190
+ }
6191
+ };
6192
+
6193
+ var MonadMappingProvider = /*#__PURE__*/function () {
6194
+ function MonadMappingProvider() {}
6195
+
6196
+ var _proto = MonadMappingProvider.prototype;
6197
+
6198
+ _proto.provide = /*#__PURE__*/function () {
6199
+ var _provide = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
6200
+ var tokens;
6201
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
6202
+ while (1) {
6203
+ switch (_context.prev = _context.next) {
6204
+ case 0:
6205
+ tokens = monadMappings;
6206
+ return _context.abrupt("return", tokens);
6207
+
6208
+ case 2:
6209
+ case "end":
6210
+ return _context.stop();
6211
+ }
6212
+ }
6213
+ }, _callee);
6214
+ }));
6215
+
6216
+ function provide() {
6217
+ return _provide.apply(this, arguments);
6218
+ }
6219
+
6220
+ return provide;
6221
+ }();
6222
+
6223
+ return MonadMappingProvider;
6224
+ }();
6225
+
6170
6226
  var abi = [{
6171
6227
  constant: true,
6172
6228
  inputs: [],
@@ -7103,9 +7159,26 @@ var SoneiumMappingProvider = /*#__PURE__*/function () {
7103
7159
  return SoneiumMappingProvider;
7104
7160
  }();
7105
7161
 
7162
+ var _EXCLUDED_TOKENS;
7163
+ /**
7164
+ * Tokens to exclude from being added to the token list.
7165
+ * Key: chainId, Value: Set of lowercase token addresses to exclude on that chain
7166
+ */
7167
+
7168
+ var EXCLUDED_TOKENS = (_EXCLUDED_TOKENS = {}, _EXCLUDED_TOKENS[ChainId.ARBITRUM_ONE] = /*#__PURE__*/new Set(['0xfeb4dfc8c4cf7ed305bb08065d08ec6ee6728429']), _EXCLUDED_TOKENS[ChainId.POLYGON] = /*#__PURE__*/new Set(['0x553d3d295e0f695b9228246232edf400ed3560b5']), _EXCLUDED_TOKENS[ChainId.UNICHAIN] = /*#__PURE__*/new Set(['0x89f7c0870794103744c8042630cc1c846a858e57']), _EXCLUDED_TOKENS);
7169
+ /**
7170
+ * Check if a token address should be excluded on a given chain
7171
+ */
7172
+
7173
+ function isTokenExcluded(chainId, tokenAddress) {
7174
+ var excludedSet = EXCLUDED_TOKENS[chainId];
7175
+ if (!excludedSet) return false;
7176
+ return excludedSet.has(tokenAddress.toLowerCase());
7177
+ }
7178
+
7106
7179
  var web3 = /*#__PURE__*/new Web3(); // chains we support fetching mappings for (can be different than the l2ChainIds arg for buildList)
7107
7180
 
7108
- var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE, ChainId.CELO, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM];
7181
+ var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE, ChainId.CELO, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM, ChainId.MONAD];
7109
7182
  function buildList(_x, _x2) {
7110
7183
  return _buildList.apply(this, arguments);
7111
7184
  } // using a symbol lookup contract call to check whether the token exists on the L2
@@ -7147,6 +7220,7 @@ function _buildList() {
7147
7220
  _context2.next = 6;
7148
7221
  return Promise.all(l2ChainIds.map( /*#__PURE__*/function () {
7149
7222
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(chainId) {
7223
+ var childTokenAddress;
7150
7224
  return _regeneratorRuntime.wrap(function _callee$(_context) {
7151
7225
  while (1) {
7152
7226
  switch (_context.prev = _context.next) {
@@ -7156,14 +7230,16 @@ function _buildList() {
7156
7230
 
7157
7231
  case 2:
7158
7232
  chainIdToChildTokenDetailsMap[chainId] = _context.sent;
7233
+ childTokenAddress = chainIdToChildTokenDetailsMap[chainId].childTokenAddress; // Only add bridgeInfo if child token is valid and not excluded
7159
7234
 
7160
- if (chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7235
+ // Only add bridgeInfo if child token is valid and not excluded
7236
+ if (chainIdToChildTokenDetailsMap[chainId].childTokenValid && childTokenAddress && !isTokenExcluded(chainId, childTokenAddress)) {
7161
7237
  l2MappingExtension.extensions.bridgeInfo[chainId] = {
7162
- tokenAddress: chainIdToChildTokenDetailsMap[chainId].childTokenAddress
7238
+ tokenAddress: childTokenAddress
7163
7239
  };
7164
7240
  }
7165
7241
 
7166
- case 4:
7242
+ case 5:
7167
7243
  case "end":
7168
7244
  return _context.stop();
7169
7245
  }
@@ -7179,15 +7255,23 @@ function _buildList() {
7179
7255
  case 6:
7180
7256
  // build the TokenInfo objects with bridgeInfo extension
7181
7257
  l2ChainIds.concat([ChainId.MAINNET]).forEach(function (chainId) {
7258
+ var _chainIdToChildTokenD;
7259
+
7260
+ var tokenAddress = chainId === ChainId.MAINNET ? l1Token.address : (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId]) == null ? void 0 : _chainIdToChildTokenD.childTokenAddress; // Skip if token is excluded on this chain
7261
+
7262
+ if (tokenAddress && isTokenExcluded(chainId, tokenAddress)) {
7263
+ return;
7264
+ }
7265
+
7182
7266
  if (chainId === ChainId.MAINNET || chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7183
- var _chainIdToChildTokenD, _bridgeInfo;
7267
+ var _chainIdToChildTokenD2, _bridgeInfo;
7184
7268
 
7185
7269
  var tokenInfo = chainId === ChainId.MAINNET ? _extends({}, l1Token, {
7186
7270
  extensions: Object.keys(l2MappingExtension.extensions.bridgeInfo).length > 0 ? {
7187
7271
  bridgeInfo: l2MappingExtension.extensions.bridgeInfo
7188
7272
  } : undefined
7189
7273
  }) : _extends({}, l1Token, {
7190
- decimals: (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD : l1Token.decimals,
7274
+ decimals: (_chainIdToChildTokenD2 = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD2 : l1Token.decimals,
7191
7275
  chainId: chainId,
7192
7276
  address: chainIdToChildTokenDetailsMap[chainId].childTokenAddress,
7193
7277
  extensions: {
@@ -7309,6 +7393,9 @@ function getMappingProvider(chainId, l1TokenList) {
7309
7393
  case ChainId.SONEIUM:
7310
7394
  return new SoneiumMappingProvider();
7311
7395
 
7396
+ case ChainId.MONAD:
7397
+ return new MonadMappingProvider();
7398
+
7312
7399
  default:
7313
7400
  throw new Error("Chain " + chainId + " not supported for fetching mappings.");
7314
7401
  }
@@ -7406,7 +7493,7 @@ function _getChildTokenDetails() {
7406
7493
  break;
7407
7494
  }
7408
7495
 
7409
- if (!(chainId === ChainId.UNICHAIN // barring a unichain rpc url, we skip the contract call. Since we're using a manually curated list of tokens, we can assume they exist.
7496
+ if (!(chainId === ChainId.UNICHAIN || chainId === ChainId.MONAD // barring a unichain/monad rpc url, we skip the contract call. Since we're using a manually curated list of tokens, we can assume they exist.
7410
7497
  )) {
7411
7498
  _context6.next = 12;
7412
7499
  break;
@@ -7542,7 +7629,7 @@ function _chainify() {
7542
7629
 
7543
7630
  case 2:
7544
7631
  l1TokenList = _context.sent;
7545
- l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM];
7632
+ l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM, ChainId.MONAD];
7546
7633
  _context.next = 6;
7547
7634
  return chainifyTokenList(l2Chains, l1TokenListOrPathOrUrl);
7548
7635
 
@@ -7629,5 +7716,5 @@ function mergeTokenLists(primary, secondary) {
7629
7716
  }));
7630
7717
  }
7631
7718
 
7632
- export { chainify, chainifyTokenList, mergeTokenLists };
7719
+ export { EXCLUDED_TOKENS, chainify, chainifyTokenList, isTokenExcluded, mergeTokenLists };
7633
7720
  //# sourceMappingURL=token-list-bridge-utils.esm.js.map