@coinlist-co/react 0.12.1-rc.14ac67e → 0.12.1-rc.a230abc

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.
@@ -248,8 +248,9 @@ var SolanaChain = (value) => {
248
248
  }
249
249
  return value;
250
250
  };
251
+ var isChain = (value) => Object.keys(ETHEREUM_CHAINS).includes(value) || Object.keys(SOLANA_CHAINS).includes(value);
251
252
  var Chain = (value) => {
252
- if (!Object.keys(ETHEREUM_CHAINS).includes(value) && !Object.keys(SOLANA_CHAINS).includes(value)) {
253
+ if (!isChain(value)) {
253
254
  throw new ValidationError(`Unsupported chain: "${value}"`);
254
255
  }
255
256
  return value;
@@ -916,7 +917,7 @@ var Offer = {
916
917
  logoUrl: dto.logo_url,
917
918
  startsAt: new Date(dto.starts_at),
918
919
  endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
919
- tokens: dto.tokens.map(OfferToken.fromDto)
920
+ tokens: OfferToken.listFromDto(dto.tokens)
920
921
  };
921
922
  }
922
923
  };
@@ -925,7 +926,19 @@ var OfferToken = {
925
926
  role: dto.role,
926
927
  chain: Chain(dto.chain),
927
928
  address: EvmContractAddress(dto.address)
928
- })
929
+ }),
930
+ /**
931
+ * Maps an offer's token list, dropping every token on a chain this SDK does
932
+ * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
933
+ * plain `.map` would throw out of `Offer.fromDto` and, through
934
+ * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
935
+ * one Base token blanked production's offers list. Dropping costs that
936
+ * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
937
+ * so nobody could have looked it up anyway.
938
+ *
939
+ * Same shape as `TokenMetadata.fromRegistryDto`.
940
+ */
941
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
929
942
  };
930
943
 
931
944
  // src/shared/core/utils/crypto.ts
@@ -1037,7 +1050,7 @@ var OfferDetail = {
1037
1050
  name: dto.name,
1038
1051
  asset: Asset.fromDto(dto.asset),
1039
1052
  fundingAssets: dto.funding_assets.map(Asset.fromDto),
1040
- tokens: dto.tokens.map(OfferToken.fromDto),
1053
+ tokens: OfferToken.listFromDto(dto.tokens),
1041
1054
  swapContracts: swapContracts.map(OfferSwapContract.fromDto),
1042
1055
  about: notBlankStringOrNull(dto.about),
1043
1056
  tagline: dto.tagline,
@@ -2305,6 +2318,7 @@ export {
2305
2318
  EthereumChain,
2306
2319
  SOLANA_CHAINS,
2307
2320
  SolanaChain,
2321
+ isChain,
2308
2322
  Chain,
2309
2323
  EvmWalletAddress,
2310
2324
  EvmContractAddress,
@@ -2410,4 +2424,4 @@ export {
2410
2424
  OAuthRefreshToken,
2411
2425
  OAuthSession
2412
2426
  };
2413
- //# sourceMappingURL=chunk-3ATIDGVR.js.map
2427
+ //# sourceMappingURL=chunk-GFLU5OMP.js.map