@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.
@@ -13,5 +13,6 @@ export declare enum ChainId {
13
13
  AVALANCHE = 43114,
14
14
  BASE = 8453,
15
15
  UNICHAIN = 130,
16
- SONEIUM = 1868
16
+ SONEIUM = 1868,
17
+ MONAD = 143
17
18
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tokens to exclude from being added to the token list.
3
+ * Key: chainId, Value: Set of lowercase token addresses to exclude on that chain
4
+ */
5
+ export declare const EXCLUDED_TOKENS: {
6
+ [chainId: number]: Set<string>;
7
+ };
8
+ /**
9
+ * Check if a token address should be excluded on a given chain
10
+ */
11
+ export declare function isTokenExcluded(chainId: number, tokenAddress: string): boolean;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { TokenList } from '@uniswap/token-lists';
2
2
  import { ChainId } from './constants/chainId';
3
3
  import { TokenListOrFetchableTokenList } from './utils';
4
+ export { EXCLUDED_TOKENS, isTokenExcluded } from './constants/excludedTokens';
4
5
  /**
5
6
  * Adds bridgeInfo to the given token list for Optimism, Polygon and Arbitrum.
6
7
  * @param l1TokenListOrPathOrUrl
@@ -0,0 +1,5 @@
1
+ import { MappingProvider } from './MappingProvider';
2
+ import { MappedTokenData } from '../constants/types';
3
+ export declare class MonadMappingProvider implements MappingProvider {
4
+ provide(): Promise<MappedTokenData>;
5
+ }
@@ -903,6 +903,7 @@ var ChainId;
903
903
  ChainId[ChainId["BASE"] = 8453] = "BASE";
904
904
  ChainId[ChainId["UNICHAIN"] = 130] = "UNICHAIN";
905
905
  ChainId[ChainId["SONEIUM"] = 1868] = "SONEIUM";
906
+ ChainId[ChainId["MONAD"] = 143] = "MONAD";
906
907
  })(ChainId || (ChainId = {}));
907
908
 
908
909
  function compareTokenInfos(t1, t2) {
@@ -1105,8 +1106,7 @@ function getRpcUrl(chainId) {
1105
1106
  return 'https://ethereum-rpc.publicnode.com';
1106
1107
 
1107
1108
  case ChainId.OPTIMISM:
1108
- return 'https://rpc.ankr.com/optimism';
1109
- // seems to have higher rate limit than https://mainnet.optimism.io/
1109
+ return 'https://mainnet.optimism.io';
1110
1110
 
1111
1111
  case ChainId.OPTIMISTIC_KOVAN:
1112
1112
  return 'https://kovan.optimism.io';
@@ -6194,6 +6194,62 @@ var UnichainMappingProvider = /*#__PURE__*/function () {
6194
6194
  return UnichainMappingProvider;
6195
6195
  }();
6196
6196
 
6197
+ var monadMappings = {
6198
+ "0xdac17f958d2ee523a2206206994597c13d831ec7": {
6199
+ childToken: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
6200
+ decimals: 6
6201
+ },
6202
+ "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": {
6203
+ childToken: "0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
6204
+ decimals: 8
6205
+ },
6206
+ "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": {
6207
+ childToken: "0xEE8c0E9f1BFFb4Eb878d8f15f368A02a35481242",
6208
+ decimals: 18
6209
+ },
6210
+ "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": {
6211
+ childToken: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
6212
+ decimals: 6
6213
+ },
6214
+ "0xd31a59c85ae9d8edefec411d448f90841571b89c": {
6215
+ childToken: "0xea17E5a9efEBf1477dB45082d67010E2245217f1",
6216
+ decimals: 9
6217
+ }
6218
+ };
6219
+
6220
+ var MonadMappingProvider = /*#__PURE__*/function () {
6221
+ function MonadMappingProvider() {}
6222
+
6223
+ var _proto = MonadMappingProvider.prototype;
6224
+
6225
+ _proto.provide = /*#__PURE__*/function () {
6226
+ var _provide = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
6227
+ var tokens;
6228
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
6229
+ while (1) {
6230
+ switch (_context.prev = _context.next) {
6231
+ case 0:
6232
+ tokens = monadMappings;
6233
+ return _context.abrupt("return", tokens);
6234
+
6235
+ case 2:
6236
+ case "end":
6237
+ return _context.stop();
6238
+ }
6239
+ }
6240
+ }, _callee);
6241
+ }));
6242
+
6243
+ function provide() {
6244
+ return _provide.apply(this, arguments);
6245
+ }
6246
+
6247
+ return provide;
6248
+ }();
6249
+
6250
+ return MonadMappingProvider;
6251
+ }();
6252
+
6197
6253
  var abi = [{
6198
6254
  constant: true,
6199
6255
  inputs: [],
@@ -7130,9 +7186,26 @@ var SoneiumMappingProvider = /*#__PURE__*/function () {
7130
7186
  return SoneiumMappingProvider;
7131
7187
  }();
7132
7188
 
7189
+ var _EXCLUDED_TOKENS;
7190
+ /**
7191
+ * Tokens to exclude from being added to the token list.
7192
+ * Key: chainId, Value: Set of lowercase token addresses to exclude on that chain
7193
+ */
7194
+
7195
+ 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);
7196
+ /**
7197
+ * Check if a token address should be excluded on a given chain
7198
+ */
7199
+
7200
+ function isTokenExcluded(chainId, tokenAddress) {
7201
+ var excludedSet = EXCLUDED_TOKENS[chainId];
7202
+ if (!excludedSet) return false;
7203
+ return excludedSet.has(tokenAddress.toLowerCase());
7204
+ }
7205
+
7133
7206
  var web3 = /*#__PURE__*/new Web3__default["default"](); // chains we support fetching mappings for (can be different than the l2ChainIds arg for buildList)
7134
7207
 
7135
- var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE, ChainId.CELO, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM];
7208
+ 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];
7136
7209
  function buildList(_x, _x2) {
7137
7210
  return _buildList.apply(this, arguments);
7138
7211
  } // using a symbol lookup contract call to check whether the token exists on the L2
@@ -7174,6 +7247,7 @@ function _buildList() {
7174
7247
  _context2.next = 6;
7175
7248
  return Promise.all(l2ChainIds.map( /*#__PURE__*/function () {
7176
7249
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(chainId) {
7250
+ var childTokenAddress;
7177
7251
  return _regeneratorRuntime.wrap(function _callee$(_context) {
7178
7252
  while (1) {
7179
7253
  switch (_context.prev = _context.next) {
@@ -7183,14 +7257,16 @@ function _buildList() {
7183
7257
 
7184
7258
  case 2:
7185
7259
  chainIdToChildTokenDetailsMap[chainId] = _context.sent;
7260
+ childTokenAddress = chainIdToChildTokenDetailsMap[chainId].childTokenAddress; // Only add bridgeInfo if child token is valid and not excluded
7186
7261
 
7187
- if (chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7262
+ // Only add bridgeInfo if child token is valid and not excluded
7263
+ if (chainIdToChildTokenDetailsMap[chainId].childTokenValid && childTokenAddress && !isTokenExcluded(chainId, childTokenAddress)) {
7188
7264
  l2MappingExtension.extensions.bridgeInfo[chainId] = {
7189
- tokenAddress: chainIdToChildTokenDetailsMap[chainId].childTokenAddress
7265
+ tokenAddress: childTokenAddress
7190
7266
  };
7191
7267
  }
7192
7268
 
7193
- case 4:
7269
+ case 5:
7194
7270
  case "end":
7195
7271
  return _context.stop();
7196
7272
  }
@@ -7206,15 +7282,23 @@ function _buildList() {
7206
7282
  case 6:
7207
7283
  // build the TokenInfo objects with bridgeInfo extension
7208
7284
  l2ChainIds.concat([ChainId.MAINNET]).forEach(function (chainId) {
7285
+ var _chainIdToChildTokenD;
7286
+
7287
+ var tokenAddress = chainId === ChainId.MAINNET ? l1Token.address : (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId]) == null ? void 0 : _chainIdToChildTokenD.childTokenAddress; // Skip if token is excluded on this chain
7288
+
7289
+ if (tokenAddress && isTokenExcluded(chainId, tokenAddress)) {
7290
+ return;
7291
+ }
7292
+
7209
7293
  if (chainId === ChainId.MAINNET || chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7210
- var _chainIdToChildTokenD, _bridgeInfo;
7294
+ var _chainIdToChildTokenD2, _bridgeInfo;
7211
7295
 
7212
7296
  var tokenInfo = chainId === ChainId.MAINNET ? _extends({}, l1Token, {
7213
7297
  extensions: Object.keys(l2MappingExtension.extensions.bridgeInfo).length > 0 ? {
7214
7298
  bridgeInfo: l2MappingExtension.extensions.bridgeInfo
7215
7299
  } : undefined
7216
7300
  }) : _extends({}, l1Token, {
7217
- decimals: (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD : l1Token.decimals,
7301
+ decimals: (_chainIdToChildTokenD2 = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD2 : l1Token.decimals,
7218
7302
  chainId: chainId,
7219
7303
  address: chainIdToChildTokenDetailsMap[chainId].childTokenAddress,
7220
7304
  extensions: {
@@ -7336,6 +7420,9 @@ function getMappingProvider(chainId, l1TokenList) {
7336
7420
  case ChainId.SONEIUM:
7337
7421
  return new SoneiumMappingProvider();
7338
7422
 
7423
+ case ChainId.MONAD:
7424
+ return new MonadMappingProvider();
7425
+
7339
7426
  default:
7340
7427
  throw new Error("Chain " + chainId + " not supported for fetching mappings.");
7341
7428
  }
@@ -7433,7 +7520,7 @@ function _getChildTokenDetails() {
7433
7520
  break;
7434
7521
  }
7435
7522
 
7436
- 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.
7523
+ 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.
7437
7524
  )) {
7438
7525
  _context6.next = 12;
7439
7526
  break;
@@ -7569,7 +7656,7 @@ function _chainify() {
7569
7656
 
7570
7657
  case 2:
7571
7658
  l1TokenList = _context.sent;
7572
- l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM];
7659
+ l2Chains = [ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM, ChainId.MONAD];
7573
7660
  _context.next = 6;
7574
7661
  return chainifyTokenList(l2Chains, l1TokenListOrPathOrUrl);
7575
7662
 
@@ -7656,7 +7743,9 @@ function mergeTokenLists(primary, secondary) {
7656
7743
  }));
7657
7744
  }
7658
7745
 
7746
+ exports.EXCLUDED_TOKENS = EXCLUDED_TOKENS;
7659
7747
  exports.chainify = chainify;
7660
7748
  exports.chainifyTokenList = chainifyTokenList;
7749
+ exports.isTokenExcluded = isTokenExcluded;
7661
7750
  exports.mergeTokenLists = mergeTokenLists;
7662
7751
  //# sourceMappingURL=token-list-bridge-utils.cjs.development.js.map