@uniswap/token-list-bridge-utils 2.9.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
@@ -6154,6 +6154,10 @@ var unichainMappings = {
6154
6154
  "0x72e4f9f808c49a2a61de9c5896298920dc4eeea9": {
6155
6155
  childToken: "0x41f6e69166e81a9583dbc96604b01d2e9b3d706f",
6156
6156
  decimals: 8
6157
+ },
6158
+ "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": {
6159
+ childToken: "0x4200000000000000000000000000000000000006",
6160
+ decimals: 18
6157
6161
  }
6158
6162
  };
6159
6163
 
@@ -7126,6 +7130,23 @@ var SoneiumMappingProvider = /*#__PURE__*/function () {
7126
7130
  return SoneiumMappingProvider;
7127
7131
  }();
7128
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
+
7129
7150
  var web3 = /*#__PURE__*/new Web3__default["default"](); // chains we support fetching mappings for (can be different than the l2ChainIds arg for buildList)
7130
7151
 
7131
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];
@@ -7170,6 +7191,7 @@ function _buildList() {
7170
7191
  _context2.next = 6;
7171
7192
  return Promise.all(l2ChainIds.map( /*#__PURE__*/function () {
7172
7193
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(chainId) {
7194
+ var childTokenAddress;
7173
7195
  return _regeneratorRuntime.wrap(function _callee$(_context) {
7174
7196
  while (1) {
7175
7197
  switch (_context.prev = _context.next) {
@@ -7179,14 +7201,16 @@ function _buildList() {
7179
7201
 
7180
7202
  case 2:
7181
7203
  chainIdToChildTokenDetailsMap[chainId] = _context.sent;
7204
+ childTokenAddress = chainIdToChildTokenDetailsMap[chainId].childTokenAddress; // Only add bridgeInfo if child token is valid and not excluded
7182
7205
 
7183
- 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)) {
7184
7208
  l2MappingExtension.extensions.bridgeInfo[chainId] = {
7185
- tokenAddress: chainIdToChildTokenDetailsMap[chainId].childTokenAddress
7209
+ tokenAddress: childTokenAddress
7186
7210
  };
7187
7211
  }
7188
7212
 
7189
- case 4:
7213
+ case 5:
7190
7214
  case "end":
7191
7215
  return _context.stop();
7192
7216
  }
@@ -7202,15 +7226,23 @@ function _buildList() {
7202
7226
  case 6:
7203
7227
  // build the TokenInfo objects with bridgeInfo extension
7204
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
+
7205
7237
  if (chainId === ChainId.MAINNET || chainIdToChildTokenDetailsMap[chainId].childTokenValid) {
7206
- var _chainIdToChildTokenD, _bridgeInfo;
7238
+ var _chainIdToChildTokenD2, _bridgeInfo;
7207
7239
 
7208
7240
  var tokenInfo = chainId === ChainId.MAINNET ? _extends({}, l1Token, {
7209
7241
  extensions: Object.keys(l2MappingExtension.extensions.bridgeInfo).length > 0 ? {
7210
7242
  bridgeInfo: l2MappingExtension.extensions.bridgeInfo
7211
7243
  } : undefined
7212
7244
  }) : _extends({}, l1Token, {
7213
- decimals: (_chainIdToChildTokenD = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD : l1Token.decimals,
7245
+ decimals: (_chainIdToChildTokenD2 = chainIdToChildTokenDetailsMap[chainId].decimals) != null ? _chainIdToChildTokenD2 : l1Token.decimals,
7214
7246
  chainId: chainId,
7215
7247
  address: chainIdToChildTokenDetailsMap[chainId].childTokenAddress,
7216
7248
  extensions: {
@@ -7652,7 +7684,9 @@ function mergeTokenLists(primary, secondary) {
7652
7684
  }));
7653
7685
  }
7654
7686
 
7687
+ exports.EXCLUDED_TOKENS = EXCLUDED_TOKENS;
7655
7688
  exports.chainify = chainify;
7656
7689
  exports.chainifyTokenList = chainifyTokenList;
7690
+ exports.isTokenExcluded = isTokenExcluded;
7657
7691
  exports.mergeTokenLists = mergeTokenLists;
7658
7692
  //# sourceMappingURL=token-list-bridge-utils.cjs.development.js.map