@uniswap/token-list-bridge-utils 2.10.0 → 2.11.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.
@@ -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
@@ -7130,6 +7130,23 @@ var SoneiumMappingProvider = /*#__PURE__*/function () {
7130
7130
  return SoneiumMappingProvider;
7131
7131
  }();
7132
7132
 
7133
+ var _EXCLUDED_TOKENS;
7134
+ /**
7135
+ * Tokens to exclude from being added to the token list.
7136
+ * Key: chainId, Value: Set of lowercase token addresses to exclude on that chain
7137
+ */
7138
+
7139
+ 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);
7140
+ /**
7141
+ * Check if a token address should be excluded on a given chain
7142
+ */
7143
+
7144
+ function isTokenExcluded(chainId, tokenAddress) {
7145
+ var excludedSet = EXCLUDED_TOKENS[chainId];
7146
+ if (!excludedSet) return false;
7147
+ return excludedSet.has(tokenAddress.toLowerCase());
7148
+ }
7149
+
7133
7150
  var web3 = /*#__PURE__*/new Web3__default["default"](); // chains we support fetching mappings for (can be different than the l2ChainIds arg for buildList)
7134
7151
 
7135
7152
  var CHAINS_WITH_MAPPING_PROVIDERS = [ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE, ChainId.CELO, ChainId.BASE, ChainId.UNICHAIN, ChainId.SONEIUM];
@@ -7174,6 +7191,7 @@ function _buildList() {
7174
7191
  _context2.next = 6;
7175
7192
  return Promise.all(l2ChainIds.map( /*#__PURE__*/function () {
7176
7193
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(chainId) {
7194
+ var childTokenAddress;
7177
7195
  return _regeneratorRuntime.wrap(function _callee$(_context) {
7178
7196
  while (1) {
7179
7197
  switch (_context.prev = _context.next) {
@@ -7183,14 +7201,16 @@ function _buildList() {
7183
7201
 
7184
7202
  case 2:
7185
7203
  chainIdToChildTokenDetailsMap[chainId] = _context.sent;
7204
+ childTokenAddress = chainIdToChildTokenDetailsMap[chainId].childTokenAddress; // Only add bridgeInfo if child token is valid and not excluded
7186
7205
 
7187
- if (chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7206
+ // Only add bridgeInfo if child token is valid and not excluded
7207
+ if (chainIdToChildTokenDetailsMap[chainId].childTokenValid && childTokenAddress && !isTokenExcluded(chainId, childTokenAddress)) {
7188
7208
  l2MappingExtension.extensions.bridgeInfo[chainId] = {
7189
- tokenAddress: chainIdToChildTokenDetailsMap[chainId].childTokenAddress
7209
+ tokenAddress: childTokenAddress
7190
7210
  };
7191
7211
  }
7192
7212
 
7193
- case 4:
7213
+ case 5:
7194
7214
  case "end":
7195
7215
  return _context.stop();
7196
7216
  }
@@ -7206,15 +7226,23 @@ function _buildList() {
7206
7226
  case 6:
7207
7227
  // build the TokenInfo objects with bridgeInfo extension
7208
7228
  l2ChainIds.concat([ChainId.MAINNET]).forEach(function (chainId) {
7229
+ var _chainIdToChildTokenD;
7230
+
7231
+ var tokenAddress = chainId === ChainId.MAINNET ? l1Token.address : (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId]) == null ? void 0 : _chainIdToChildTokenD.childTokenAddress; // Skip if token is excluded on this chain
7232
+
7233
+ if (tokenAddress && isTokenExcluded(chainId, tokenAddress)) {
7234
+ return;
7235
+ }
7236
+
7209
7237
  if (chainId === ChainId.MAINNET || chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7210
- var _chainIdToChildTokenD, _bridgeInfo;
7238
+ var _chainIdToChildTokenD2, _bridgeInfo;
7211
7239
 
7212
7240
  var tokenInfo = chainId === ChainId.MAINNET ? _extends({}, l1Token, {
7213
7241
  extensions: Object.keys(l2MappingExtension.extensions.bridgeInfo).length > 0 ? {
7214
7242
  bridgeInfo: l2MappingExtension.extensions.bridgeInfo
7215
7243
  } : undefined
7216
7244
  }) : _extends({}, l1Token, {
7217
- decimals: (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD : l1Token.decimals,
7245
+ decimals: (_chainIdToChildTokenD2 = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD2 : l1Token.decimals,
7218
7246
  chainId: chainId,
7219
7247
  address: chainIdToChildTokenDetailsMap[chainId].childTokenAddress,
7220
7248
  extensions: {
@@ -7656,7 +7684,9 @@ function mergeTokenLists(primary, secondary) {
7656
7684
  }));
7657
7685
  }
7658
7686
 
7687
+ exports.EXCLUDED_TOKENS = EXCLUDED_TOKENS;
7659
7688
  exports.chainify = chainify;
7660
7689
  exports.chainifyTokenList = chainifyTokenList;
7690
+ exports.isTokenExcluded = isTokenExcluded;
7661
7691
  exports.mergeTokenLists = mergeTokenLists;
7662
7692
  //# sourceMappingURL=token-list-bridge-utils.cjs.development.js.map