@coinlist-co/react 0.11.0 → 0.11.1-rc.22d81d4

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.
Files changed (34) hide show
  1. package/dist/chunk-AQIHCFW4.js +279 -0
  2. package/dist/chunk-AQIHCFW4.js.map +1 -0
  3. package/dist/{chunk-B2HCVPCQ.js → chunk-PRG3EDQJ.js} +25 -10
  4. package/dist/chunk-PRG3EDQJ.js.map +1 -0
  5. package/dist/{chunk-UIIXXLA7.js → chunk-ZVB6KWZ2.js} +484 -141
  6. package/dist/chunk-ZVB6KWZ2.js.map +1 -0
  7. package/dist/client/index.cjs +1307 -461
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +216 -211
  10. package/dist/client/index.d.ts +216 -211
  11. package/dist/client/index.js +464 -108
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/collections-DrJFEDHl.d.cts +116 -0
  14. package/dist/collections-pLtrj6fw.d.ts +116 -0
  15. package/dist/{config-B5mwS_2l.d.cts → config-C6vlghJY.d.cts} +713 -22
  16. package/dist/{config-B5mwS_2l.d.ts → config-C6vlghJY.d.ts} +713 -22
  17. package/dist/server/index.cjs +766 -209
  18. package/dist/server/index.cjs.map +1 -1
  19. package/dist/server/index.d.cts +80 -3
  20. package/dist/server/index.d.ts +80 -3
  21. package/dist/server/index.js +120 -51
  22. package/dist/server/index.js.map +1 -1
  23. package/dist/shared/index.cjs +486 -123
  24. package/dist/shared/index.cjs.map +1 -1
  25. package/dist/shared/index.d.cts +18 -5
  26. package/dist/shared/index.d.ts +18 -5
  27. package/dist/shared/index.js +8 -2
  28. package/package.json +3 -2
  29. package/dist/chunk-B2HCVPCQ.js.map +0 -1
  30. package/dist/chunk-KDGNDAHA.js +0 -146
  31. package/dist/chunk-KDGNDAHA.js.map +0 -1
  32. package/dist/chunk-UIIXXLA7.js.map +0 -1
  33. package/dist/collections-BhDkYmzV.d.cts +0 -65
  34. package/dist/collections-CZhHoQHr.d.ts +0 -65
@@ -1,7 +1,7 @@
1
- import { a5 as PaginationParams, a6 as PaginatedResponse, m as Bps, a7 as Uint256, a as EthereumChain, M as AssetDecimals, i as AssetSymbol, B as BlockchainAmount, E as EvmWalletAddress, a8 as KnownAssetSymbol, u as Erc20Asset, c as EvmContractAddress, w as StablecoinSymbol, a9 as DecimalString, j as OndoSwapTransaction, aa as SwapStatus, ab as Newtype } from '../config-B5mwS_2l.cjs';
2
- export { ac as AllowWalletParams, ad as AllowWalletResponse, ae as Asset, af as AssetCode, f as AssetId, A as AuthorizationCode, ag as Blockchain, V as BuildOndoSwapTransactionParams, ah as Chain, a2 as ClientCredentialsOAuth, ai as ClientId, a3 as ClientSecret, aj as CodeChallenge, C as CodeVerifier, d as CoinListTokenSaleNamespace, g as CoinListTokenSaleNamespaceImpl, q as Config, ak as ConnectExternalWalletParams, al as CreateKycTokenParams, am as CreateParticipationParams, an as CreateWalletOwnershipChallengeParams, ao as Cursor, ap as DocumentFormType, J as DocumentSubmission, aq as DocumentSubmissionStatus, ar as DocumentType, as as ETHEREUM_CHAINS, b as Erc20Namespace, at as Erc20NamespaceImpl, au as FaqItem, av as GetOndoQuoteParams, aw as GetOndoTradingStatusParams, ax as GetSwapAuthorizationParams, ay as GetSwapPreviewParams, az as GetTokenAllowanceParams, aA as GetTokenBalanceParams, aB as HexEncodedTransactionData, _ as HttpError, $ as HttpResponse, aC as Iso2CountryCode, K as KycLevelName, a0 as KycToken, aD as Link, aE as ListOptionAddressesParams, aF as MAX_ASSET_DECIMALS, aG as MAX_UINT_256, aH as Milestone, r as OAuthAccessToken, aI as OAuthRefreshToken, a1 as OAuthSession, y as Offer, v as OfferDetail, O as OfferId, aJ as OfferOption, G as OfferOptionAddress, X as OfferOptionAddressId, e as OfferOptionId, aK as OfferOptionSlug, aL as OfferSlug, aM as OfferToken, x as OfferType, s as OffersNamespace, aN as OffersNamespaceImpl, h as OndoNamespace, k as OndoNamespaceImpl, N as OndoQuote, aO as OndoQuoteDuration, U as OndoQuoteSize, L as OndoTradingStatus, Q as OrderBookSide, aP as PKCEState, aQ as PaginatedResponseDto, P as Participation, aR as ParticipationId, aS as ParticipationStatus, aT as ParticipationsPaginationParams, aU as Pii, aV as PiiAddress, aW as PiiJurisdiction, aX as PiiKind, aY as QueryParamValue, aZ as QueryParamValues, a_ as RedirectUri, a$ as RemoveOptionAddressParams, o as Requirement, b0 as RequirementActionNeededReason, H as RequirementId, z as RequirementStatusInfo, F as RequirementStatusValue, D as RequirementType, R as RequirementsNamespace, p as RequirementsNamespaceImpl, b1 as SOLANA_CHAINS, b2 as STABLE_DECIMALS, b3 as SolanaChain, b4 as SubmitDocumentParams, l as SuperstateSwapNamespace, n as SuperstateSwapNamespaceImpl, b5 as SwapAuthorization, b6 as SwapContractRef, b7 as SwapPreview, b8 as TermItem, b9 as Ticker, ba as TokenAllowance, bb as TokenBalance, Z as TokenIdentifier, bc as TokenLogo, bd as TokenLogoImage, be as TokenLogoUrl, Y as TokenMetadata, bf as TokenRole, t as TokensNamespace, bg as TokensNamespaceImpl, T as Tx, bh as WalletAddress, I as WalletChallengeType, bi as WalletOwnershipChallenge, bj as WalletProtocol, W as WalletsNamespace, bk as WalletsNamespaceImpl, bl as apiErrorCode, bm as assertUint256 } from '../config-B5mwS_2l.cjs';
3
- import { T as TxExplorerUrl, F as FormattedAmountAssetUi, c as FormattedAmountUi, b as FormattedPercentUi, a as ShortenedWalletAddress, N as NonEmptyArray, S as SwapQuote } from '../collections-BhDkYmzV.cjs';
4
- export { A as AssetIconUrl, P as PKCEConfig, d as PKCEParams, g as generatePKCEParams } from '../collections-BhDkYmzV.cjs';
1
+ import { al as PaginationParams, am as PaginatedResponse, m as Bps, an as Uint256, a as EthereumChain, Q as AssetDecimals, h as AssetSymbol, B as BlockchainAmount, n as EvmWalletAddress, ao as KnownAssetSymbol, u as Erc20Asset, b as EvmContractAddress, w as StablecoinSymbol, ap as DecimalString, i as OndoSwapTransaction, aq as SwapStatus, ar as Newtype } from '../config-C6vlghJY.cjs';
2
+ export { as as AllowWalletParams, at as AllowWalletResponse, au as Asset, av as AssetCode, e as AssetId, A as AuthorizationCode, aw as Blockchain, Y as BuildOndoSwapTransactionParams, ax as Chain, ai as ClientCredentialsOAuth, ay as ClientId, aj as ClientSecret, az as CodeChallenge, C as CodeVerifier, c as CoinListTokenSaleNamespace, f as CoinListTokenSaleNamespaceImpl, r as Config, aA as ConnectExternalWalletParams, aB as CreateKycTokenParams, aC as CreateParticipationParams, aD as CreateWalletOwnershipChallengeParams, aE as Cursor, a0 as DebugEvent, aF as DocumentFormType, I as DocumentSubmission, aG as DocumentSubmissionStatus, aH as DocumentType, aI as ETHEREUM_CHAINS, E as Erc20Namespace, aJ as Erc20NamespaceImpl, aK as FaqItem, a1 as FrontlineEventId, aL as GetOndoQuoteParams, aM as GetOndoTradingStatusParams, aN as GetSwapAuthorizationParams, aO as GetSwapPreviewParams, aP as GetTokenAllowanceParams, aQ as GetTokenBalanceParams, aR as HexEncodedTransactionData, a2 as HttpError, a3 as HttpResponse, aS as Iso2CountryCode, K as KycLevelName, a4 as KycToken, aT as Link, aU as ListOptionAddressesParams, a5 as LogBinding, a6 as LogBindings, a7 as LogCause, a8 as LogLevel, a9 as LogScope, aa as LogValue, L as Logger, aV as MAX_ASSET_DECIMALS, aW as MAX_UINT_256, aX as Milestone, s as OAuthAccessToken, aY as OAuthRefreshToken, ah as OAuthSession, y as Offer, v as OfferDetail, O as OfferId, aZ as OfferOption, G as OfferOptionAddress, Z as OfferOptionAddressId, d as OfferOptionId, a_ as OfferOptionSlug, a$ as OfferSlug, b0 as OfferToken, x as OfferType, t as OffersNamespace, b1 as OffersNamespaceImpl, g as OndoNamespace, j as OndoNamespaceImpl, U as OndoQuote, b2 as OndoQuoteDuration, X as OndoQuoteSize, N as OndoTradingStatus, V as OrderBookSide, b3 as PKCEState, b4 as PaginatedResponseDto, P as Participation, b5 as ParticipationId, b6 as ParticipationStatus, b7 as ParticipationsPaginationParams, b8 as Pii, b9 as PiiAddress, ba as PiiJurisdiction, bb as PiiKind, M as PinoLoggerOptions, ab as ProductionLogLevel, bc as QueryParamValue, bd as QueryParamValues, ac as RedactedWalletError, be as RedirectUri, bf as RemoveOptionAddressParams, ad as RequestId, p as Requirement, bg as RequirementActionNeededReason, H as RequirementId, z as RequirementStatusInfo, F as RequirementStatusValue, D as RequirementType, R as RequirementsNamespace, q as RequirementsNamespaceImpl, bh as SOLANA_CHAINS, bi as STABLE_DECIMALS, ae as SafeEvent, af as SafeFields, bj as SolanaChain, bk as SubmitDocumentParams, k as SuperstateSwapNamespace, o as SuperstateSwapNamespaceImpl, bl as SwapAuthorization, bm as SwapContractRef, bn as SwapPreview, bo as TermItem, bp as Ticker, bq as TokenAllowance, br as TokenBalance, $ as TokenIdentifier, bs as TokenLogo, bt as TokenLogoImage, bu as TokenLogoUrl, _ as TokenMetadata, bv as TokenRole, T as TokensNamespace, bw as TokensNamespaceImpl, bx as Tx, ag as UnredactedFields, by as WalletAddress, J as WalletChallengeType, W as WalletError, bz as WalletOwnershipChallenge, bA as WalletProtocol, l as WalletsNamespace, bB as WalletsNamespaceImpl, bC as apiErrorCode, bD as assertUint256, bE as parseUint256 } from '../config-C6vlghJY.cjs';
3
+ import { T as TxExplorerUrl, F as FormattedAmountAssetUi, d as FormattedAmountUi, b as FormattedPercentUi, a as ShortenedWalletAddress, N as NonEmptyArray, S as SwapQuote } from '../collections-DrJFEDHl.cjs';
4
+ export { A as AssetIconUrl, B as BroadcastTxParams, C as ConnectWallet, c as EvmSigner, E as EvmWallet, P as PKCEConfig, e as PKCEParams, W as WriteContractParams, g as generatePKCEParams } from '../collections-DrJFEDHl.cjs';
5
5
  import { Hash, TransactionReceipt } from 'viem';
6
6
 
7
7
  /**
@@ -766,6 +766,19 @@ declare class NotAuthenticatedError extends Error {
766
766
  declare class ValidationError extends Error {
767
767
  constructor(message: string);
768
768
  }
769
+ /**
770
+ * Error thrown when the SDK computes something impossible: a value outside
771
+ * uint256 after its own arithmetic, a symbol missing from a registry the SDK
772
+ * itself ships. Distinct from {@link ValidationError}, which means the backend
773
+ * sent a shape the SDK does not understand.
774
+ *
775
+ * The two have different remedies, which is the whole reason they are separate
776
+ * types: a {@link ValidationError} is worth reporting to CoinList, an
777
+ * `InvariantError` is an SDK bug worth reporting against the SDK.
778
+ */
779
+ declare class InvariantError extends Error {
780
+ constructor(message: string);
781
+ }
769
782
 
770
783
  type UserDto = {
771
784
  id: string;
@@ -784,4 +797,4 @@ declare const User: {
784
797
  fromDto: (dto: UserDto) => User;
785
798
  };
786
799
 
787
- export { type AmountParseErrorReason, type AmountParseResult, AssetDecimals, AssetSymbol, BPS_DENOM, BlockchainAmount, Bps, DEFAULT_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_SLIPPAGE_BPS, DecimalString, ERC20_ABI, Erc20Asset, EthereumChain, EvmContractAddress, EvmWalletAddress, type FormatAmountOptions, FormattedAmountAssetUi, FormattedAmountUi, FormattedPercentUi, KnownAssetSymbol, NA_AMOUNT_ASSET_UI, NonEmptyArray, NotAuthenticatedError, NotImplementedError, ONDO_POLL_INTERVAL_MS, ONDO_QUOTE_EXPIRY_THRESHOLD_MS, ONDO_SUPPORTED_INPUT_ASSETS, OndoSwapTransaction, PaginatedResponse, PaginationParams, SLIPPAGE_OPTIONS_BPS, SUPERSTATE_ISSUER_NAME, SUPERSTATE_SUPPORTED_INPUT_ASSETS, SUPERSTATE_SWAP_ABI, SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA, SWAP_POLL_INTERVAL_MS, ShortenedWalletAddress, StablecoinSymbol, SwapQuote, SwapStatus, TOKEN_REGISTRY, TxExplorerUrl, USDC, USDC_SYMBOL, USDT, USDT_SYMBOL, Uint256, User, UserEmail, UserId, ValidationError, applyBps, assetAmount, blockchainAmountFromRawOrThrow, chainFromId, computeOndoPrice, computePrice, computeSlip, decodeSwappedOutputAmount, fetchAllPages, formatAmount, formatBpsAsPercent, formatCompactAmount, formatRawAmount, formattedPricePerShare, formattedUsdPrice, getChainId, getNetworkName, isStopped, ondoSwapContractAddress, parseBlockchainAmount, shortenAddress, superstateSwapContractAddress, txExplorerUrl, usdAmount };
800
+ export { type AmountParseErrorReason, type AmountParseResult, AssetDecimals, AssetSymbol, BPS_DENOM, BlockchainAmount, Bps, DEFAULT_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_SLIPPAGE_BPS, DecimalString, ERC20_ABI, Erc20Asset, EthereumChain, EvmContractAddress, EvmWalletAddress, type FormatAmountOptions, FormattedAmountAssetUi, FormattedAmountUi, FormattedPercentUi, InvariantError, KnownAssetSymbol, NA_AMOUNT_ASSET_UI, NonEmptyArray, NotAuthenticatedError, NotImplementedError, ONDO_POLL_INTERVAL_MS, ONDO_QUOTE_EXPIRY_THRESHOLD_MS, ONDO_SUPPORTED_INPUT_ASSETS, OndoSwapTransaction, PaginatedResponse, PaginationParams, SLIPPAGE_OPTIONS_BPS, SUPERSTATE_ISSUER_NAME, SUPERSTATE_SUPPORTED_INPUT_ASSETS, SUPERSTATE_SWAP_ABI, SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA, SWAP_POLL_INTERVAL_MS, ShortenedWalletAddress, StablecoinSymbol, SwapQuote, SwapStatus, TOKEN_REGISTRY, TxExplorerUrl, USDC, USDC_SYMBOL, USDT, USDT_SYMBOL, Uint256, User, UserEmail, UserId, ValidationError, applyBps, assetAmount, blockchainAmountFromRawOrThrow, chainFromId, computeOndoPrice, computePrice, computeSlip, decodeSwappedOutputAmount, fetchAllPages, formatAmount, formatBpsAsPercent, formatCompactAmount, formatRawAmount, formattedPricePerShare, formattedUsdPrice, getChainId, getNetworkName, isStopped, ondoSwapContractAddress, parseBlockchainAmount, shortenAddress, superstateSwapContractAddress, txExplorerUrl, usdAmount };
@@ -1,7 +1,7 @@
1
- import { a5 as PaginationParams, a6 as PaginatedResponse, m as Bps, a7 as Uint256, a as EthereumChain, M as AssetDecimals, i as AssetSymbol, B as BlockchainAmount, E as EvmWalletAddress, a8 as KnownAssetSymbol, u as Erc20Asset, c as EvmContractAddress, w as StablecoinSymbol, a9 as DecimalString, j as OndoSwapTransaction, aa as SwapStatus, ab as Newtype } from '../config-B5mwS_2l.js';
2
- export { ac as AllowWalletParams, ad as AllowWalletResponse, ae as Asset, af as AssetCode, f as AssetId, A as AuthorizationCode, ag as Blockchain, V as BuildOndoSwapTransactionParams, ah as Chain, a2 as ClientCredentialsOAuth, ai as ClientId, a3 as ClientSecret, aj as CodeChallenge, C as CodeVerifier, d as CoinListTokenSaleNamespace, g as CoinListTokenSaleNamespaceImpl, q as Config, ak as ConnectExternalWalletParams, al as CreateKycTokenParams, am as CreateParticipationParams, an as CreateWalletOwnershipChallengeParams, ao as Cursor, ap as DocumentFormType, J as DocumentSubmission, aq as DocumentSubmissionStatus, ar as DocumentType, as as ETHEREUM_CHAINS, b as Erc20Namespace, at as Erc20NamespaceImpl, au as FaqItem, av as GetOndoQuoteParams, aw as GetOndoTradingStatusParams, ax as GetSwapAuthorizationParams, ay as GetSwapPreviewParams, az as GetTokenAllowanceParams, aA as GetTokenBalanceParams, aB as HexEncodedTransactionData, _ as HttpError, $ as HttpResponse, aC as Iso2CountryCode, K as KycLevelName, a0 as KycToken, aD as Link, aE as ListOptionAddressesParams, aF as MAX_ASSET_DECIMALS, aG as MAX_UINT_256, aH as Milestone, r as OAuthAccessToken, aI as OAuthRefreshToken, a1 as OAuthSession, y as Offer, v as OfferDetail, O as OfferId, aJ as OfferOption, G as OfferOptionAddress, X as OfferOptionAddressId, e as OfferOptionId, aK as OfferOptionSlug, aL as OfferSlug, aM as OfferToken, x as OfferType, s as OffersNamespace, aN as OffersNamespaceImpl, h as OndoNamespace, k as OndoNamespaceImpl, N as OndoQuote, aO as OndoQuoteDuration, U as OndoQuoteSize, L as OndoTradingStatus, Q as OrderBookSide, aP as PKCEState, aQ as PaginatedResponseDto, P as Participation, aR as ParticipationId, aS as ParticipationStatus, aT as ParticipationsPaginationParams, aU as Pii, aV as PiiAddress, aW as PiiJurisdiction, aX as PiiKind, aY as QueryParamValue, aZ as QueryParamValues, a_ as RedirectUri, a$ as RemoveOptionAddressParams, o as Requirement, b0 as RequirementActionNeededReason, H as RequirementId, z as RequirementStatusInfo, F as RequirementStatusValue, D as RequirementType, R as RequirementsNamespace, p as RequirementsNamespaceImpl, b1 as SOLANA_CHAINS, b2 as STABLE_DECIMALS, b3 as SolanaChain, b4 as SubmitDocumentParams, l as SuperstateSwapNamespace, n as SuperstateSwapNamespaceImpl, b5 as SwapAuthorization, b6 as SwapContractRef, b7 as SwapPreview, b8 as TermItem, b9 as Ticker, ba as TokenAllowance, bb as TokenBalance, Z as TokenIdentifier, bc as TokenLogo, bd as TokenLogoImage, be as TokenLogoUrl, Y as TokenMetadata, bf as TokenRole, t as TokensNamespace, bg as TokensNamespaceImpl, T as Tx, bh as WalletAddress, I as WalletChallengeType, bi as WalletOwnershipChallenge, bj as WalletProtocol, W as WalletsNamespace, bk as WalletsNamespaceImpl, bl as apiErrorCode, bm as assertUint256 } from '../config-B5mwS_2l.js';
3
- import { T as TxExplorerUrl, F as FormattedAmountAssetUi, c as FormattedAmountUi, b as FormattedPercentUi, a as ShortenedWalletAddress, N as NonEmptyArray, S as SwapQuote } from '../collections-CZhHoQHr.js';
4
- export { A as AssetIconUrl, P as PKCEConfig, d as PKCEParams, g as generatePKCEParams } from '../collections-CZhHoQHr.js';
1
+ import { al as PaginationParams, am as PaginatedResponse, m as Bps, an as Uint256, a as EthereumChain, Q as AssetDecimals, h as AssetSymbol, B as BlockchainAmount, n as EvmWalletAddress, ao as KnownAssetSymbol, u as Erc20Asset, b as EvmContractAddress, w as StablecoinSymbol, ap as DecimalString, i as OndoSwapTransaction, aq as SwapStatus, ar as Newtype } from '../config-C6vlghJY.js';
2
+ export { as as AllowWalletParams, at as AllowWalletResponse, au as Asset, av as AssetCode, e as AssetId, A as AuthorizationCode, aw as Blockchain, Y as BuildOndoSwapTransactionParams, ax as Chain, ai as ClientCredentialsOAuth, ay as ClientId, aj as ClientSecret, az as CodeChallenge, C as CodeVerifier, c as CoinListTokenSaleNamespace, f as CoinListTokenSaleNamespaceImpl, r as Config, aA as ConnectExternalWalletParams, aB as CreateKycTokenParams, aC as CreateParticipationParams, aD as CreateWalletOwnershipChallengeParams, aE as Cursor, a0 as DebugEvent, aF as DocumentFormType, I as DocumentSubmission, aG as DocumentSubmissionStatus, aH as DocumentType, aI as ETHEREUM_CHAINS, E as Erc20Namespace, aJ as Erc20NamespaceImpl, aK as FaqItem, a1 as FrontlineEventId, aL as GetOndoQuoteParams, aM as GetOndoTradingStatusParams, aN as GetSwapAuthorizationParams, aO as GetSwapPreviewParams, aP as GetTokenAllowanceParams, aQ as GetTokenBalanceParams, aR as HexEncodedTransactionData, a2 as HttpError, a3 as HttpResponse, aS as Iso2CountryCode, K as KycLevelName, a4 as KycToken, aT as Link, aU as ListOptionAddressesParams, a5 as LogBinding, a6 as LogBindings, a7 as LogCause, a8 as LogLevel, a9 as LogScope, aa as LogValue, L as Logger, aV as MAX_ASSET_DECIMALS, aW as MAX_UINT_256, aX as Milestone, s as OAuthAccessToken, aY as OAuthRefreshToken, ah as OAuthSession, y as Offer, v as OfferDetail, O as OfferId, aZ as OfferOption, G as OfferOptionAddress, Z as OfferOptionAddressId, d as OfferOptionId, a_ as OfferOptionSlug, a$ as OfferSlug, b0 as OfferToken, x as OfferType, t as OffersNamespace, b1 as OffersNamespaceImpl, g as OndoNamespace, j as OndoNamespaceImpl, U as OndoQuote, b2 as OndoQuoteDuration, X as OndoQuoteSize, N as OndoTradingStatus, V as OrderBookSide, b3 as PKCEState, b4 as PaginatedResponseDto, P as Participation, b5 as ParticipationId, b6 as ParticipationStatus, b7 as ParticipationsPaginationParams, b8 as Pii, b9 as PiiAddress, ba as PiiJurisdiction, bb as PiiKind, M as PinoLoggerOptions, ab as ProductionLogLevel, bc as QueryParamValue, bd as QueryParamValues, ac as RedactedWalletError, be as RedirectUri, bf as RemoveOptionAddressParams, ad as RequestId, p as Requirement, bg as RequirementActionNeededReason, H as RequirementId, z as RequirementStatusInfo, F as RequirementStatusValue, D as RequirementType, R as RequirementsNamespace, q as RequirementsNamespaceImpl, bh as SOLANA_CHAINS, bi as STABLE_DECIMALS, ae as SafeEvent, af as SafeFields, bj as SolanaChain, bk as SubmitDocumentParams, k as SuperstateSwapNamespace, o as SuperstateSwapNamespaceImpl, bl as SwapAuthorization, bm as SwapContractRef, bn as SwapPreview, bo as TermItem, bp as Ticker, bq as TokenAllowance, br as TokenBalance, $ as TokenIdentifier, bs as TokenLogo, bt as TokenLogoImage, bu as TokenLogoUrl, _ as TokenMetadata, bv as TokenRole, T as TokensNamespace, bw as TokensNamespaceImpl, bx as Tx, ag as UnredactedFields, by as WalletAddress, J as WalletChallengeType, W as WalletError, bz as WalletOwnershipChallenge, bA as WalletProtocol, l as WalletsNamespace, bB as WalletsNamespaceImpl, bC as apiErrorCode, bD as assertUint256, bE as parseUint256 } from '../config-C6vlghJY.js';
3
+ import { T as TxExplorerUrl, F as FormattedAmountAssetUi, d as FormattedAmountUi, b as FormattedPercentUi, a as ShortenedWalletAddress, N as NonEmptyArray, S as SwapQuote } from '../collections-pLtrj6fw.js';
4
+ export { A as AssetIconUrl, B as BroadcastTxParams, C as ConnectWallet, c as EvmSigner, E as EvmWallet, P as PKCEConfig, e as PKCEParams, W as WriteContractParams, g as generatePKCEParams } from '../collections-pLtrj6fw.js';
5
5
  import { Hash, TransactionReceipt } from 'viem';
6
6
 
7
7
  /**
@@ -766,6 +766,19 @@ declare class NotAuthenticatedError extends Error {
766
766
  declare class ValidationError extends Error {
767
767
  constructor(message: string);
768
768
  }
769
+ /**
770
+ * Error thrown when the SDK computes something impossible: a value outside
771
+ * uint256 after its own arithmetic, a symbol missing from a registry the SDK
772
+ * itself ships. Distinct from {@link ValidationError}, which means the backend
773
+ * sent a shape the SDK does not understand.
774
+ *
775
+ * The two have different remedies, which is the whole reason they are separate
776
+ * types: a {@link ValidationError} is worth reporting to CoinList, an
777
+ * `InvariantError` is an SDK bug worth reporting against the SDK.
778
+ */
779
+ declare class InvariantError extends Error {
780
+ constructor(message: string);
781
+ }
769
782
 
770
783
  type UserDto = {
771
784
  id: string;
@@ -784,4 +797,4 @@ declare const User: {
784
797
  fromDto: (dto: UserDto) => User;
785
798
  };
786
799
 
787
- export { type AmountParseErrorReason, type AmountParseResult, AssetDecimals, AssetSymbol, BPS_DENOM, BlockchainAmount, Bps, DEFAULT_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_SLIPPAGE_BPS, DecimalString, ERC20_ABI, Erc20Asset, EthereumChain, EvmContractAddress, EvmWalletAddress, type FormatAmountOptions, FormattedAmountAssetUi, FormattedAmountUi, FormattedPercentUi, KnownAssetSymbol, NA_AMOUNT_ASSET_UI, NonEmptyArray, NotAuthenticatedError, NotImplementedError, ONDO_POLL_INTERVAL_MS, ONDO_QUOTE_EXPIRY_THRESHOLD_MS, ONDO_SUPPORTED_INPUT_ASSETS, OndoSwapTransaction, PaginatedResponse, PaginationParams, SLIPPAGE_OPTIONS_BPS, SUPERSTATE_ISSUER_NAME, SUPERSTATE_SUPPORTED_INPUT_ASSETS, SUPERSTATE_SWAP_ABI, SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA, SWAP_POLL_INTERVAL_MS, ShortenedWalletAddress, StablecoinSymbol, SwapQuote, SwapStatus, TOKEN_REGISTRY, TxExplorerUrl, USDC, USDC_SYMBOL, USDT, USDT_SYMBOL, Uint256, User, UserEmail, UserId, ValidationError, applyBps, assetAmount, blockchainAmountFromRawOrThrow, chainFromId, computeOndoPrice, computePrice, computeSlip, decodeSwappedOutputAmount, fetchAllPages, formatAmount, formatBpsAsPercent, formatCompactAmount, formatRawAmount, formattedPricePerShare, formattedUsdPrice, getChainId, getNetworkName, isStopped, ondoSwapContractAddress, parseBlockchainAmount, shortenAddress, superstateSwapContractAddress, txExplorerUrl, usdAmount };
800
+ export { type AmountParseErrorReason, type AmountParseResult, AssetDecimals, AssetSymbol, BPS_DENOM, BlockchainAmount, Bps, DEFAULT_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE, DEFAULT_SLIPPAGE_BPS, DecimalString, ERC20_ABI, Erc20Asset, EthereumChain, EvmContractAddress, EvmWalletAddress, type FormatAmountOptions, FormattedAmountAssetUi, FormattedAmountUi, FormattedPercentUi, InvariantError, KnownAssetSymbol, NA_AMOUNT_ASSET_UI, NonEmptyArray, NotAuthenticatedError, NotImplementedError, ONDO_POLL_INTERVAL_MS, ONDO_QUOTE_EXPIRY_THRESHOLD_MS, ONDO_SUPPORTED_INPUT_ASSETS, OndoSwapTransaction, PaginatedResponse, PaginationParams, SLIPPAGE_OPTIONS_BPS, SUPERSTATE_ISSUER_NAME, SUPERSTATE_SUPPORTED_INPUT_ASSETS, SUPERSTATE_SWAP_ABI, SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA, SWAP_POLL_INTERVAL_MS, ShortenedWalletAddress, StablecoinSymbol, SwapQuote, SwapStatus, TOKEN_REGISTRY, TxExplorerUrl, USDC, USDC_SYMBOL, USDT, USDT_SYMBOL, Uint256, User, UserEmail, UserId, ValidationError, applyBps, assetAmount, blockchainAmountFromRawOrThrow, chainFromId, computeOndoPrice, computePrice, computeSlip, decodeSwappedOutputAmount, fetchAllPages, formatAmount, formatBpsAsPercent, formatCompactAmount, formatRawAmount, formattedPricePerShare, formattedUsdPrice, getChainId, getNetworkName, isStopped, ondoSwapContractAddress, parseBlockchainAmount, shortenAddress, superstateSwapContractAddress, txExplorerUrl, usdAmount };
@@ -14,6 +14,7 @@ import {
14
14
  ONDO_SUPPORTED_INPUT_ASSETS,
15
15
  OffersNamespaceImpl,
16
16
  PKCEState,
17
+ RedactedWalletError,
17
18
  RedirectUri,
18
19
  SLIPPAGE_OPTIONS_BPS,
19
20
  SUPERSTATE_ISSUER_NAME,
@@ -40,7 +41,7 @@ import {
40
41
  isStopped,
41
42
  ondoSwapContractAddress,
42
43
  superstateSwapContractAddress
43
- } from "../chunk-B2HCVPCQ.js";
44
+ } from "../chunk-PRG3EDQJ.js";
44
45
  import {
45
46
  AllowWalletResponse,
46
47
  Asset,
@@ -72,6 +73,7 @@ import {
72
73
  FormattedPercentUi,
73
74
  HexEncodedTransactionData,
74
75
  HttpError,
76
+ InvariantError,
75
77
  Iso2CountryCode,
76
78
  KnownAssetSymbol,
77
79
  KycToken,
@@ -146,10 +148,11 @@ import {
146
148
  getChainId,
147
149
  getNetworkName,
148
150
  parseBlockchainAmount,
151
+ parseUint256,
149
152
  shortenAddress,
150
153
  txExplorerUrl,
151
154
  usdAmount
152
- } from "../chunk-UIIXXLA7.js";
155
+ } from "../chunk-ZVB6KWZ2.js";
153
156
  export {
154
157
  AllowWalletResponse,
155
158
  Asset,
@@ -191,6 +194,7 @@ export {
191
194
  FormattedPercentUi,
192
195
  HexEncodedTransactionData,
193
196
  HttpError,
197
+ InvariantError,
194
198
  Iso2CountryCode,
195
199
  KnownAssetSymbol,
196
200
  KycToken,
@@ -230,6 +234,7 @@ export {
230
234
  Pii,
231
235
  PiiAddress,
232
236
  PiiJurisdiction,
237
+ RedactedWalletError,
233
238
  RedirectUri,
234
239
  Requirement,
235
240
  RequirementId,
@@ -295,6 +300,7 @@ export {
295
300
  isStopped,
296
301
  ondoSwapContractAddress,
297
302
  parseBlockchainAmount,
303
+ parseUint256,
298
304
  shortenAddress,
299
305
  superstateSwapContractAddress,
300
306
  txExplorerUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinlist-co/react",
3
- "version": "0.11.0",
3
+ "version": "0.11.1-rc.22d81d4",
4
4
  "description": "CoinList Partner SDK",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -108,6 +108,7 @@
108
108
  "@sumsub/websdk-react": "^2.6.3",
109
109
  "class-variance-authority": "^0.7.1",
110
110
  "clsx": "^2.1.1",
111
- "lucide-react": "^0.577.0"
111
+ "lucide-react": "^0.577.0",
112
+ "pino": "^10.3.1"
112
113
  }
113
114
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/shared/types/oauth.ts","../src/shared/core/auth/pkce.ts","../src/shared/core/blockchain/bps.ts","../src/shared/core/blockchain/erc20/abi.ts","../src/shared/core/blockchain/token-registry.ts","../src/shared/core/checkout/ondo/constants.ts","../src/shared/core/checkout/ondo/math.ts","../src/shared/core/checkout/superstate/blockchain/abi.ts","../src/shared/core/checkout/superstate/blockchain/math.ts","../src/shared/core/checkout/superstate/blockchain/quote.ts","../src/shared/core/checkout/superstate/blockchain/status.ts","../src/shared/core/checkout/superstate/blockchain/swapped-event.ts","../src/shared/core/checkout/superstate/constants.ts","../src/shared/core/checkout/superstate/formatters.ts","../src/shared/core/offers/offers-namespace.ts","../src/shared/types/user.ts"],"sourcesContent":["import type { Newtype } from '@/shared/types/newtype';\n\nexport type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;\nexport const AuthorizationCode = (value: string): AuthorizationCode =>\n value as AuthorizationCode;\n\nexport type CodeVerifier = Newtype<string, 'CodeVerifier'>;\nexport const CodeVerifier = (value: string): CodeVerifier =>\n value as CodeVerifier;\n\nexport type CodeChallenge = Newtype<string, 'CodeChallenge'>;\nexport const CodeChallenge = (value: string): CodeChallenge =>\n value as CodeChallenge;\n\nexport type PKCEState = Newtype<string, 'PKCEState'>;\nexport const PKCEState = (value: string) => value as PKCEState;\n\nexport type RedirectUri = Newtype<string, 'RedirectUri'>;\nexport const RedirectUri = (value: string): RedirectUri => value as RedirectUri;\n\nexport type ClientId = Newtype<string, 'ClientId'>;\nexport const ClientId = (value: string): ClientId => value as ClientId;\n\nexport type ClientSecret = Newtype<string, 'ClientSecret'>;\nexport const ClientSecret = (value: string): ClientSecret =>\n value as ClientSecret;\n","import {\n arrayBufferToBase64Url,\n generateSecureRandomBase64Url,\n sha256,\n} from '@/shared/core/utils/crypto';\nimport type {\n CodeChallenge as CodeChallengeType,\n CodeVerifier as CodeVerifierType,\n PKCEState as PKCEStateType,\n} from '@/shared/types/oauth';\nimport {\n type ClientId,\n CodeChallenge,\n CodeVerifier,\n PKCEState,\n type RedirectUri,\n} from '@/shared/types/oauth';\n\nexport type PKCEParams = {\n clientId: ClientId;\n responseType: 'code';\n redirectUri: RedirectUri;\n codeChallenge: CodeChallengeType;\n codeChallengeMethod: 'S256';\n state: PKCEStateType;\n codeVerifier: CodeVerifierType;\n};\n\nexport type PKCEConfig = {\n clientId: ClientId;\n redirectUri: RedirectUri;\n};\n\n/**\n * Generates PKCE parameters for an OAuth2 authorization code flow.\n * Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use\n * in server-side code and Next.js middleware.\n */\nexport async function generatePKCEParams(\n config: PKCEConfig\n): Promise<PKCEParams> {\n const state = generateSecureRandomBase64Url(32);\n const codeVerifier = generateSecureRandomBase64Url(32);\n const codeChallengeRaw = await sha256(codeVerifier);\n const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);\n\n return {\n clientId: config.clientId,\n responseType: 'code',\n redirectUri: config.redirectUri,\n codeChallenge: CodeChallenge(codeChallenge),\n codeChallengeMethod: 'S256',\n state: PKCEState(state),\n codeVerifier: CodeVerifier(codeVerifier),\n };\n}\n","import {\n assertUint256,\n Bps,\n type Uint256,\n} from '@/shared/types/blockchain/core';\n\n/** Basis-point denominator: 10_000 bps = 100%. */\nexport const BPS_DENOM: Bps = Bps(10_000n);\n\n/**\n * Applies a basis-point fraction to an amount, flooring the result.\n * `floor((amount × bps) / BPS_DENOM)`. The result is bounds-checked, so an\n * overflow (bps far above BPS_DENOM) or a negative product is rejected.\n */\nexport function applyBps(amount: Uint256, bps: Bps): Uint256 {\n return assertUint256((amount * bps) / BPS_DENOM);\n}\n","/**\n * Minimal ERC-20 ABI the SDK writes against (mirrors viem's `erc20Abi`). The\n * swap flow uses `approve`; `allowance`/`balanceOf`/`decimals`/`symbol`/`name`\n * are included so reads share a single SDK-owned ABI.\n */\nexport const ERC20_ABI = [\n {\n type: 'function',\n name: 'allowance',\n inputs: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n ],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'approve',\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'balanceOf',\n inputs: [{ name: 'account', type: 'address' }],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'decimals',\n inputs: [],\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'name',\n inputs: [],\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'symbol',\n inputs: [],\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totalSupply',\n inputs: [],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'transferFrom',\n inputs: [\n { name: 'sender', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'event',\n name: 'Approval',\n inputs: [\n { name: 'owner', type: 'address', indexed: true },\n { name: 'spender', type: 'address', indexed: true },\n { name: 'value', type: 'uint256', indexed: false },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transfer',\n inputs: [\n { name: 'from', type: 'address', indexed: true },\n { name: 'to', type: 'address', indexed: true },\n { name: 'value', type: 'uint256', indexed: false },\n ],\n anonymous: false,\n },\n] as const;\n","import {\n AssetDecimals,\n type Erc20Asset,\n type EthereumChain,\n EvmContractAddress,\n type KnownAssetSymbol,\n StablecoinSymbol,\n} from '@/shared/types/blockchain/core';\n\nexport const USDC_SYMBOL: StablecoinSymbol = StablecoinSymbol('USDC');\nexport const USDC: Erc20Asset = {\n name: 'USD Coin',\n symbol: USDC_SYMBOL,\n decimals: AssetDecimals(6),\n};\n\nexport const USDT_SYMBOL: StablecoinSymbol = StablecoinSymbol('USDT');\nexport const USDT: Erc20Asset = {\n name: 'Tether USD',\n symbol: USDT_SYMBOL,\n decimals: AssetDecimals(6),\n};\n\n/** ERC-20 contract addresses for a supported stablecoin, keyed by chain. */\ntype TokenAddresses = Record<EthereumChain, EvmContractAddress>;\n\nconst USDC_ADDRESSES: TokenAddresses = {\n ethereum_mainnet: EvmContractAddress(\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'\n ),\n ethereum_sepolia: EvmContractAddress(\n '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'\n ),\n};\n\nconst USDT_ADDRESSES: TokenAddresses = {\n ethereum_mainnet: EvmContractAddress(\n '0xdac17f958d2ee523a2206206994597c13d831ec7'\n ),\n ethereum_sepolia: EvmContractAddress(\n '0x7169D38820dfd117C3FA1f22a697dBA58d90BA06'\n ),\n};\n\n/** Lookups for the stablecoins the SDK's swap flows support out of the box. */\nexport const TOKEN_REGISTRY = {\n erc20: (symbol: KnownAssetSymbol): Erc20Asset => {\n switch (symbol) {\n case 'USDC':\n return USDC;\n case 'USDT':\n return USDT;\n default:\n throw new Error(`Unknown asset symbol: ${symbol}`);\n }\n },\n contractAddress: (\n symbol: KnownAssetSymbol,\n chain: EthereumChain\n ): EvmContractAddress => {\n switch (symbol) {\n case 'USDC':\n return USDC_ADDRESSES[chain];\n case 'USDT':\n return USDT_ADDRESSES[chain];\n default:\n throw new Error(`Unknown asset symbol: ${symbol}`);\n }\n },\n};\n","import { USDC_SYMBOL } from '@/shared/core/blockchain/token-registry';\nimport {\n DecimalString,\n type EthereumChain,\n EvmContractAddress,\n type StablecoinSymbol,\n} from '@/shared/types/blockchain/core';\nimport type { NonEmptyArray } from '@/shared/types/collections';\n\n/**\n * The CoinList integration contract an Ondo swap is sent to, and therefore the\n * ERC-20 spender the user approves.\n *\n * It is a constant rather than a value read off the built transaction because\n * the approval has to happen *before* the transaction is built: the calldata\n * is only good for a minute, and an approval takes most of one to mine. The\n * built transaction's `tx.to` is checked against this before broadcasting, so a\n * stale constant fails loudly instead of sending a transaction that reverts on\n * `transferFrom`.\n *\n * Mainnet is absent, not zeroed: Ondo's production integration contract is not\n * deployed yet, and a zero address would be approved happily and revert only\n * later. Flows return `unsupported-chain` for a chain with no entry.\n */\nconst ONDO_SWAP_CONTRACT_ADDRESSES: Partial<\n Record<EthereumChain, EvmContractAddress>\n> = {\n ethereum_sepolia: EvmContractAddress(\n '0xFF9c5Ade32d9B4102469Bd5F3817CB0061b25feC'\n ),\n};\n\n/** The Ondo integration contract on `chain`, or `null` where none is deployed. */\nexport function ondoSwapContractAddress(\n chain: EthereumChain\n): EvmContractAddress | null {\n return ONDO_SWAP_CONTRACT_ADDRESSES[chain] ?? null;\n}\n\n/**\n * How often the Ondo checkout refreshes what it is allowed to poll: the market\n * status and the indicative price. Both are free - neither spends an\n * attestation - so this is paced for a price the user can trust rather than\n * for cost.\n *\n * A built transaction is deliberately not on this timer. Building spends an\n * attestation, so it happens once per order and once per refresh the user\n * asks for.\n */\nexport const ONDO_POLL_INTERVAL_MS = 15_000;\n\n/**\n * How close to its deadline a built transaction stops being offerable.\n *\n * Placing an order is not instant - the wallet has to prompt, the user has to\n * confirm, and the transaction has to reach a node - so calldata with a second\n * left is one the contract will reject. Treating the last few seconds as\n * already expired turns a paid-for revert into a refresh button.\n */\nexport const ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5_000;\n\n/**\n * The order size the sidebar prices against before the user names one.\n *\n * Ondo prices by size, so some amount has to be sent. $1,000 is a plausible\n * order rather than a token one: a size so small that Ondo's minimum rejects\n * it would leave the panel permanently blank.\n *\n * Named distinctly from `DEFAULT_AMOUNT_TO_COMPUTE_PRICE` in the swap\n * constants, which is a raw `bigint` of USDC base units for a different\n * endpoint. Both barrels are flat, so two constants of the same name could not\n * coexist - and they mean different things anyway.\n */\nexport const DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString('1000');\n\n/**\n * The coins an Ondo buy can be funded with, in display order, with the first\n * preselected.\n *\n * USDC alone today: it is what the Sepolia integration contract accepts. The\n * amount step renders a single entry as a plain card and two or more as a\n * picker, so adding one here is all it takes.\n */\nexport const ONDO_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol> = [\n USDC_SYMBOL,\n];\n","import {\n assertUint256,\n BlockchainAmount,\n type Uint256,\n} from '@/shared/types/blockchain/core';\nimport { ValidationError } from '@/shared/types/errors';\nimport type { OndoSwapTransaction } from '@/shared/types/providers/ondo/ondo';\n\n/**\n * The price of one whole asset token in an Ondo swap transaction, in the\n * funding token's units.\n *\n * `POST /v1/ondo/swap/transaction` publishes no price. Frontline drops\n * Ninshubur's deliberately, because `GET /v1/ondo/swap/quote` already serves\n * one under that name at a different scale, and echoing both would leave a\n * caller to guess which was which.\n *\n * Dividing the two amounts the response *does* carry is better than reading\n * the indicative one anyway: it is the price this transaction fills at, rather\n * than a poll that has since moved and was struck against a different size.\n *\n * **Fee-exclusive.** `notionalValue` is the deposit after CoinList's fee comes\n * off, so this is the price Ondo filled at, not the buyer's all-in cost per\n * token - that would be `payInputAmount / receiveOutputAmount`, and it is\n * higher. Fee-exclusive is what the review screen wants, because it renders\n * the fee on its own line: price x quantity, plus fee, comes to the total.\n * Making this all-in would double-count the fee against that breakdown.\n *\n * The two are equal until ENG-1718 turns a fee on, which frontline rejects\n * today. They diverge the moment it does, so the choice is load-bearing rather\n * than academic.\n *\n * Denominated in the *funding* token's decimals, so it pairs with\n * `formattedUsdPrice` and with the fee and total rendered beside it.\n */\nexport function computeOndoPrice(\n transaction: Pick<\n OndoSwapTransaction,\n 'notionalValue' | 'receiveOutputAmount'\n >\n): BlockchainAmount {\n const { notionalValue, receiveOutputAmount } = transaction;\n\n // Unreachable through `OndoSwapTransaction.fromDto`, which rejects a\n // non-positive output at the boundary - frontline refuses to emit one. The\n // guard is here because this runs during render, where a RangeError from a\n // bare BigInt division would take the checkout down instead of a step.\n if (receiveOutputAmount.raw <= 0n) {\n throw new ValidationError(\n 'Ondo price: receiveOutputAmount must be greater than zero'\n );\n }\n\n // Scale the numerator by the asset's exponent so the quotient lands back in\n // the funding token's, which is the scale every other amount on the review\n // screen is in. Floor division: a price is truncated towards zero rather\n // than rounded, so the total it implies never overstates what was paid.\n const scaled =\n notionalValue.raw * 10n ** BigInt(receiveOutputAmount.decimals);\n const raw = scaled / receiveOutputAmount.raw;\n\n return BlockchainAmount({\n raw: assertPriceFits(raw),\n decimals: notionalValue.decimals,\n });\n}\n\n/**\n * A price past uint256 needs an output amount of a few base units against a\n * notional no real balance holds. It cannot come off the wire, so it is a\n * corrupt response rather than an expensive order.\n */\nfunction assertPriceFits(raw: bigint): Uint256 {\n try {\n return assertUint256(raw);\n } catch {\n throw new ValidationError(`Ondo price: out of uint256 bounds (${raw})`);\n }\n}\n","export const SUPERSTATE_SWAP_ABI = [\n {\n type: 'function',\n name: 'authorized',\n inputs: [{ name: 'user', type: 'address', internalType: 'address' }],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'stopped',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'SWAP_LEVEL',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'preview',\n inputs: [\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct Preview',\n components: [\n { name: 'input', type: 'uint256', internalType: 'uint256' },\n { name: 'fee', type: 'uint256', internalType: 'uint256' },\n { name: 'output', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'swap',\n inputs: [\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n { name: 'slip', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'tokenBalance',\n inputs: [{ name: 'token', type: 'address', internalType: 'address' }],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'outputToken',\n inputs: [],\n outputs: [{ name: '', type: 'address', internalType: 'address' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'outputTokenBalance',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totals',\n inputs: [{ name: 'token', type: 'address', internalType: 'address' }],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct SwapTotal',\n components: [\n { name: 'inputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'feeSum', type: 'uint256', internalType: 'uint256' },\n { name: 'outputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'count', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totals',\n inputs: [\n { name: 'user', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n ],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct SwapTotal',\n components: [\n { name: 'inputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'feeSum', type: 'uint256', internalType: 'uint256' },\n { name: 'outputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'count', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'to', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'to', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'setBps',\n inputs: [{ name: 'points', type: 'uint256', internalType: 'uint256' }],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'event',\n name: 'Swapped',\n inputs: [\n { name: 'user', type: 'address', indexed: true, internalType: 'address' },\n {\n name: 'inputToken',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'outputToken',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'inputAmount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n {\n name: 'outputAmount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transferred',\n inputs: [\n { name: 'to', type: 'address', indexed: true, internalType: 'address' },\n {\n name: 'token',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'amount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'error',\n name: 'InvalidAddress',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InsufficientAmount',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidAmount',\n inputs: [],\n },\n {\n type: 'error',\n name: 'SwapFailed',\n inputs: [\n { name: 'user', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n ],\n },\n] as const;\n","import { applyBps, BPS_DENOM } from '@/shared/core/blockchain/bps';\nimport type { SwapQuote } from '@/shared/core/checkout/superstate/blockchain/quote';\nimport {\n assertUint256,\n BlockchainAmount,\n Bps,\n} from '@/shared/types/blockchain/core';\n\n/**\n * Price of 1 output token in USD, assuming the input token is a $1 stablecoin.\n *\n * `raw_price = inputTokenAmount.raw × 10^outputDecimals ÷ outputTokenAmount.raw`\n *\n * The multiplication happens before the division so we never lose precision to\n * integer truncation early. This mirrors standard fixed-point practice on-chain.\n * Returned decimals match the input token decimals (always the stablecoin's 6).\n */\nexport function computePrice({\n inputTokenAmount,\n outputTokenAmount,\n}: SwapQuote): BlockchainAmount | null {\n if (outputTokenAmount.raw === 0n) return null;\n\n const scale = 10n ** BigInt(outputTokenAmount.decimals);\n const raw = assertUint256(\n (inputTokenAmount.raw * scale) / outputTokenAmount.raw\n );\n\n return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });\n}\n\n/**\n * Applies slippage to an amount, returning the minimum acceptable amount:\n * `amount × (BPS_DENOM − slippage) / BPS_DENOM`. Throws when `slippage` exceeds\n * `BPS_DENOM` (the retained fraction would be negative).\n */\nexport function computeSlip(\n amount: BlockchainAmount,\n slippage: Bps\n): BlockchainAmount {\n const retained = Bps(assertUint256(BPS_DENOM - slippage));\n const slipRaw = applyBps(amount.raw, retained);\n return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });\n}\n","import {\n type AssetDecimals,\n BlockchainAmount,\n} from '@/shared/types/blockchain/core';\nimport type { SwapPreview } from '@/shared/types/providers/superstate/swap';\n\n/**\n * A read-only quote for a swap as domain amounts: how much goes in, the\n * protocol fee, and how much would come out. Derived from the raw\n * {@link SwapPreview} the swap contract returns.\n */\nexport type SwapQuote = {\n inputTokenAmount: BlockchainAmount;\n fee: BlockchainAmount;\n outputTokenAmount: BlockchainAmount;\n};\n\nexport const SwapQuote = {\n /**\n * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The\n * input and fee are denominated in the input token; the output in the output\n * token.\n */\n fromPreview: (\n preview: SwapPreview,\n inputDecimals: AssetDecimals,\n outputDecimals: AssetDecimals\n ): SwapQuote => ({\n inputTokenAmount: BlockchainAmount({\n raw: preview.inputAmount,\n decimals: inputDecimals,\n }),\n fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),\n outputTokenAmount: BlockchainAmount({\n raw: preview.outputAmount,\n decimals: outputDecimals,\n }),\n }),\n};\n","import type { SwapStatus } from '@/shared/types/providers/superstate/swap';\n\n/**\n * Interprets the on-chain swap availability read from `stopped()` and\n * `SWAP_LEVEL()`.\n *\n * The contract tracks paused operations as a bitmask in `stopped`. The swap is\n * stopped when the SWAP_LEVEL flag is set:\n *\n * (stopped & SWAP_LEVEL) != 0 -> stopped (not active)\n */\nexport function isStopped(status: SwapStatus): boolean {\n return (status.stopped & status.swapLevel) !== 0n;\n}\n","import { parseEventLogs, type TransactionReceipt } from 'viem';\nimport { SUPERSTATE_SWAP_ABI } from '@/shared/core/checkout/superstate/blockchain/abi';\nimport {\n type AssetDecimals,\n BlockchainAmount,\n MAX_UINT_256,\n} from '@/shared/types/blockchain/core';\n\n/**\n * Decodes the confirmed output amount from the `Swapped` event in a swap\n * transaction receipt.\n *\n * Returns `null` when the event is absent or the amount is not a valid uint256\n * so callers can fall back to the quote's expected output — the swap already\n * confirmed on-chain, so a missing/undecodable event should not fail the flow.\n */\nexport function decodeSwappedOutputAmount(\n receipt: TransactionReceipt,\n outputDecimals: AssetDecimals\n): BlockchainAmount | null {\n try {\n const [swapped] = parseEventLogs({\n abi: SUPERSTATE_SWAP_ABI,\n eventName: 'Swapped',\n logs: receipt.logs,\n });\n if (!swapped) return null;\n\n const raw = swapped.args.outputAmount;\n if (raw < 0n || raw > MAX_UINT_256) return null;\n return BlockchainAmount({ raw, decimals: outputDecimals });\n } catch {\n // Undecodable log (ABI mismatch / malformed) — fall back to the\n // quote. The swap already confirmed on-chain, so never fail here.\n return null;\n }\n}\n","import { USDC_SYMBOL } from '@/shared/core/blockchain/token-registry';\nimport {\n Bps,\n type EthereumChain,\n EvmContractAddress,\n type StablecoinSymbol,\n} from '@/shared/types/blockchain/core';\nimport type { NonEmptyArray } from '@/shared/types/collections';\n\n/**\n * Who issues the asset a Superstate swap pays out.\n *\n * A constant rather than a field off the offer: no frontline endpoint carries\n * an issuer, and every offer this checkout serves is Superstate's by\n * definition — `CheckoutContainer` routes here on `superstate::swap` alone.\n */\nexport const SUPERSTATE_ISSUER_NAME = 'Superstate';\n\n/**\n * The coins a Superstate swap can be funded with, in display order, with the\n * first preselected.\n *\n * USDC alone today: it is what the deployed swap contract accepts. The amount\n * step renders a single entry as a plain card and two or more as a picker, so\n * adding one here is all it takes.\n */\nexport const SUPERSTATE_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol> =\n [USDC_SYMBOL];\n\n/** Poll interval for refreshing on-chain swap quotes and balances. */\nexport const SWAP_POLL_INTERVAL_MS = 15_000;\n\n/**\n * Notional input used to derive a display price-per-share when the user has\n * not yet entered an amount (1 USDC at 6 decimals).\n */\nexport const DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1_000_000n;\n\n/** Slippage tolerances offered in the review step, in basis points. */\nexport const SLIPPAGE_OPTIONS_BPS: Bps[] = [25n, 50n, 100n, 200n, 500n].map(\n (n) => Bps(n)\n);\n\n/** Default slippage tolerance (0.5%). */\nexport const DEFAULT_SLIPPAGE_BPS: Bps = Bps(50n);\n\n/**\n * The Superstate swap contract on Ethereum Sepolia, and therefore the ERC-20\n * spender the user approves there.\n *\n * Exported in its own right for a partner driving `coinlist.superstate.execute`\n * at Level 1, where the contract is an explicit parameter.\n */\nexport const SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: EvmContractAddress =\n EvmContractAddress('0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557');\n\n/**\n * The Superstate swap contract per chain.\n *\n * Mainnet is absent, not zeroed: the production address is not finalized\n * upstream, and a zero address would be approved happily and revert only later.\n * A chain with no entry has no checkout — `useSuperstateSwapCheckoutViewModel`\n * reports it as the flow-level error rather than quoting against nothing.\n */\nconst SUPERSTATE_SWAP_CONTRACT_ADDRESSES: Partial<\n Record<EthereumChain, EvmContractAddress>\n> = {\n ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,\n};\n\n/** The Superstate swap contract on `chain`, or `null` where none is deployed. */\nexport function superstateSwapContractAddress(\n chain: EthereumChain\n): EvmContractAddress | null {\n return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;\n}\n","import {\n formattedUsdPrice,\n NA_AMOUNT_ASSET_UI,\n} from '@/shared/core/blockchain/formatters';\nimport { computePrice } from '@/shared/core/checkout/superstate/blockchain/math';\nimport type { SwapQuote } from '@/shared/core/checkout/superstate/blockchain/quote';\nimport type { FormattedAmountAssetUi } from '@/shared/types/blockchain/ui';\n\n/**\n * Formats a quote's implied price per output token as a USD amount.\n *\n * Lives with the provider rather than in `@/shared/core/blockchain/formatters`\n * because {@link SwapQuote} and {@link computePrice} are Superstate's: the\n * shared formatters stay provider-agnostic.\n */\nexport function formattedPricePerShare(\n quote: SwapQuote | null,\n locale: string\n): FormattedAmountAssetUi {\n if (!quote) return NA_AMOUNT_ASSET_UI;\n return formattedUsdPrice(computePrice(quote), locale);\n}\n","import * as offersApi from '@/shared/api/frontline/offers';\nimport type { SharedNamespaceContext } from '@/shared/core/namespace-context';\nimport type { Offer, OfferId } from '@/shared/types/offer';\nimport type { OfferDetail } from '@/shared/types/offer-detail';\nimport type {\n PaginatedResponse,\n PaginationParams,\n} from '@/shared/types/pagination';\n\n/**\n * Reads over CoinList's offers: the catalogue a user can browse, and the full\n * detail of a single offer.\n *\n * Every method requires an authenticated user and throws\n * {@link NotAuthenticatedError} otherwise. On the server, the same reads are\n * additionally available with an app-level token — see\n * `ServerOffersNamespace`.\n */\nexport interface OffersNamespace {\n /**\n * Fetches every offer, iterating through all pages. Prefer {@link listPage}\n * when you render a paginated list yourself.\n */\n list(): Promise<Offer[]>;\n\n /**\n * Fetches a single page of offers. Pass the previous response's\n * `startingAfter` as `after` to advance.\n */\n listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;\n\n /**\n * Fetches the full detail of one offer, including its options. Note this\n * returns {@link OfferDetail} — a richer model than the {@link Offer}\n * summaries {@link list} returns.\n */\n get(id: OfferId): Promise<OfferDetail>;\n}\n\nexport class OffersNamespaceImpl implements OffersNamespace {\n constructor(private readonly ctx: SharedNamespaceContext) {}\n\n async list(): Promise<Offer[]> {\n await this.ctx.ensureUserAuthenticated();\n return offersApi.fetchOffers(this.ctx.api, undefined);\n }\n\n async listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>> {\n await this.ctx.ensureUserAuthenticated();\n return offersApi.fetchOffersPage(this.ctx.api, params, undefined);\n }\n\n async get(id: OfferId): Promise<OfferDetail> {\n await this.ctx.ensureUserAuthenticated();\n return offersApi.fetchOfferDetails(this.ctx.api, id, undefined);\n }\n}\n","import type { UserDto } from '@/shared/types/dto/user';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type UserId = Newtype<string, 'UserId'>;\nexport const UserId = (value: string) => value as UserId;\nexport type UserEmail = Newtype<string, 'UserEmail'>;\nexport const UserEmail = (value: string) => value as UserEmail;\n\nexport type User = {\n id: UserId;\n email: UserEmail;\n};\n\nexport const User = {\n fromDto: (dto: UserDto): User => ({\n id: UserId(dto.id),\n email: UserEmail(dto.email),\n }),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,oBAAoB,CAAC,UAChC;AAGK,IAAM,eAAe,CAAC,UAC3B;AAGK,IAAM,gBAAgB,CAAC,UAC5B;AAGK,IAAM,YAAY,CAAC,UAAkB;AAGrC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IAAI,KAAK;AAAA,EAC5B;AACF;","names":[]}
@@ -1,146 +0,0 @@
1
- import {
2
- Attributes,
3
- HEADER_IDEMPOTENCY_KEY,
4
- HttpClient,
5
- HttpError,
6
- Request,
7
- getUUIDv4
8
- } from "./chunk-UIIXXLA7.js";
9
-
10
- // src/shared/api/nabu/config.ts
11
- var NABU_BASE_URL = "https://asset.coinlist.co";
12
-
13
- // src/shared/api/middleware/attach-session-middleware.ts
14
- function attachSessionMiddleware(fetchAccessToken) {
15
- return async (request) => {
16
- if (!Attributes.isProtected(request.attributes)) {
17
- return request;
18
- }
19
- let accessToken = await fetchAccessToken(false);
20
- if (!accessToken) {
21
- const clientCreds = Attributes.getClientCredentials(request.attributes);
22
- if (clientCreds) {
23
- accessToken = clientCreds;
24
- }
25
- }
26
- if (accessToken === null) {
27
- return request;
28
- }
29
- return {
30
- ...request,
31
- headers: {
32
- ...request.headers ?? {},
33
- Authorization: `Bearer ${accessToken.value}`
34
- }
35
- };
36
- };
37
- }
38
-
39
- // src/shared/api/middleware/idempotency-key.ts
40
- var idempotencyKeyMiddleware = async (request) => {
41
- if (!Attributes.isIdempotent(request.attributes)) {
42
- return request;
43
- }
44
- const existingHeaders = request.headers ?? {};
45
- if (existingHeaders[HEADER_IDEMPOTENCY_KEY]) {
46
- return request;
47
- }
48
- return {
49
- ...request,
50
- headers: {
51
- ...existingHeaders,
52
- [HEADER_IDEMPOTENCY_KEY]: getUUIDv4()
53
- }
54
- };
55
- };
56
-
57
- // src/shared/api/middleware/request-retry.ts
58
- var MAX_ATTEMPTS = 3;
59
- var INITIAL_DELAY_MS = 300;
60
- var MAX_DELAY_MS = 2e3;
61
- var RETRYABLE_4XX = /* @__PURE__ */ new Set([408, 409, 429]);
62
- function isRetryableStatus(status) {
63
- return status >= 500 && status < 600 || RETRYABLE_4XX.has(status);
64
- }
65
- function getRetryDelayMs(attempt) {
66
- return Math.min(INITIAL_DELAY_MS * 2 ** (attempt - 1), MAX_DELAY_MS);
67
- }
68
- function createRequestRetryMiddleware(options = {}) {
69
- const delayFn = options.delayFn ?? defaultDelay;
70
- return async ({ request, response, retry }) => {
71
- if (!isRetryableStatus(response.status)) {
72
- return response;
73
- }
74
- const currentAttempt = Attributes.getRetryAttempt(request.attributes);
75
- if (currentAttempt >= MAX_ATTEMPTS - 1) {
76
- return response;
77
- }
78
- const nextAttempt = currentAttempt + 1;
79
- await delayFn(getRetryDelayMs(nextAttempt));
80
- const nextRequest = Request.concatAttributes(
81
- request,
82
- Attributes.retryAttempt(nextAttempt)
83
- );
84
- return retry(nextRequest);
85
- };
86
- }
87
- function defaultDelay(ms) {
88
- return new Promise((resolve) => setTimeout(resolve, ms));
89
- }
90
- var requestRetryMiddleware = createRequestRetryMiddleware();
91
-
92
- // src/shared/api/middleware/session-renewal.ts
93
- function renewSessionMiddleware(fetchAccessToken) {
94
- return async ({ request, response, retry }) => {
95
- if (response.status !== 401) {
96
- return response;
97
- }
98
- if (!Attributes.isProtected(request.attributes)) {
99
- return response;
100
- }
101
- if (Attributes.wasRenewAttempted(request.attributes)) {
102
- return response;
103
- }
104
- const newToken = await fetchAccessToken(true);
105
- if (newToken) {
106
- const nextRequest = Request.concatAttributes(
107
- request,
108
- Attributes.renewAttempted(true)
109
- );
110
- return retry(nextRequest);
111
- } else {
112
- return response;
113
- }
114
- };
115
- }
116
-
117
- // src/shared/api/authenticated-api-client.ts
118
- var AuthenticatedApiClient = class {
119
- constructor(config, fetchAccessToken, additionalBeforeRequest = []) {
120
- this.httpClient = new HttpClient(config, {
121
- beforeRequest: [
122
- attachSessionMiddleware(fetchAccessToken),
123
- ...additionalBeforeRequest,
124
- idempotencyKeyMiddleware
125
- ],
126
- afterRequest: [
127
- renewSessionMiddleware(fetchAccessToken),
128
- requestRetryMiddleware
129
- ]
130
- });
131
- }
132
- async send(request) {
133
- const response = await this.httpClient.send(request);
134
- if (response.status >= 200 && response.status < 300) {
135
- return response.body;
136
- } else {
137
- throw new HttpError(response);
138
- }
139
- }
140
- };
141
-
142
- export {
143
- AuthenticatedApiClient,
144
- NABU_BASE_URL
145
- };
146
- //# sourceMappingURL=chunk-KDGNDAHA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/shared/api/nabu/config.ts","../src/shared/api/middleware/attach-session-middleware.ts","../src/shared/api/middleware/idempotency-key.ts","../src/shared/api/middleware/request-retry.ts","../src/shared/api/middleware/session-renewal.ts","../src/shared/api/authenticated-api-client.ts"],"sourcesContent":["/**\n * Base URL of CoinList's public token registry (Nabu), a static CDN serving\n * token display metadata keyed by chain + contract address. Override per\n * environment via `Config.tokensBaseUrl`.\n */\nexport const NABU_BASE_URL = 'https://asset.coinlist.co';\n","import type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport function attachSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): BeforeRequestMiddleware {\n return async (request: HttpRequest): Promise<HttpRequest> => {\n if (!Attributes.isProtected(request.attributes)) {\n return request;\n }\n\n let accessToken = await fetchAccessToken(false);\n if (!accessToken) {\n const clientCreds = Attributes.getClientCredentials(request.attributes);\n if (clientCreds) {\n accessToken = clientCreds;\n }\n }\n\n if (accessToken === null) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...(request.headers ?? {}),\n Authorization: `Bearer ${accessToken.value}`,\n },\n };\n };\n}\n","import { HEADER_IDEMPOTENCY_KEY } from '@/shared/api/frontline/config';\nimport type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport { getUUIDv4 } from '@/shared/core/utils/crypto';\n\nexport const idempotencyKeyMiddleware: BeforeRequestMiddleware = async (\n request: HttpRequest\n): Promise<HttpRequest> => {\n if (!Attributes.isIdempotent(request.attributes)) {\n return request;\n }\n\n const existingHeaders = request.headers ?? {};\n if (existingHeaders[HEADER_IDEMPOTENCY_KEY]) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...existingHeaders,\n [HEADER_IDEMPOTENCY_KEY]: getUUIDv4(),\n },\n };\n};\n","import { Request } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/shared/api/http-client';\n\nconst MAX_ATTEMPTS = 3;\nconst INITIAL_DELAY_MS = 300;\nconst MAX_DELAY_MS = 2000;\n\nconst RETRYABLE_4XX = new Set([408, 409, 429]);\n\nexport function isRetryableStatus(status: number): boolean {\n return (status >= 500 && status < 600) || RETRYABLE_4XX.has(status);\n}\n\nfunction getRetryDelayMs(attempt: number): number {\n return Math.min(INITIAL_DELAY_MS * 2 ** (attempt - 1), MAX_DELAY_MS);\n}\n\nexport type RequestRetryMiddlewareOptions = {\n /**\n * Optional delay function. Defaults to real setTimeout-based delay.\n * Use a no-op (e.g. () => Promise.resolve()) in tests to avoid slow tests.\n */\n delayFn?: (ms: number) => Promise<void>;\n};\n\n/**\n * Creates the request retry after-request middleware. Inject a no-op delayFn\n * in tests to avoid real delays (unit testing best practice).\n */\nexport function createRequestRetryMiddleware(\n options: RequestRetryMiddlewareOptions = {}\n): AfterRequestMiddleware {\n const delayFn = options.delayFn ?? defaultDelay;\n\n return async ({ request, response, retry }) => {\n if (!isRetryableStatus(response.status)) {\n return response;\n }\n\n const currentAttempt = Attributes.getRetryAttempt(request.attributes);\n if (currentAttempt >= MAX_ATTEMPTS - 1) {\n return response;\n }\n\n const nextAttempt = currentAttempt + 1;\n await delayFn(getRetryDelayMs(nextAttempt));\n\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.retryAttempt(nextAttempt)\n );\n return retry(nextRequest);\n };\n}\n\nfunction defaultDelay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Retries the request up to 3 times with exponential backoff when the response\n * has a retryable status (5xx server errors). Uses request.attributes.retryAttempt\n * to decide delay and whether to retry, so the middleware does not loop when\n * retry() runs the full HTTP middleware chain again.\n */\nexport const requestRetryMiddleware: AfterRequestMiddleware =\n createRequestRetryMiddleware();\n","import { Request } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/shared/api/http-client';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport function renewSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): AfterRequestMiddleware {\n return async ({ request, response, retry }) => {\n if (response.status !== 401) {\n return response;\n }\n if (!Attributes.isProtected(request.attributes)) {\n return response;\n }\n if (Attributes.wasRenewAttempted(request.attributes)) {\n return response;\n }\n\n const newToken = await fetchAccessToken(true);\n if (newToken) {\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.renewAttempted(true)\n );\n return retry(nextRequest);\n } else {\n return response;\n }\n };\n}\n","import type { HttpClientConfig, HttpRequest } from '@/shared/api/http';\nimport { HttpError } from '@/shared/api/http';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport { HttpClient } from '@/shared/api/http-client';\nimport { attachSessionMiddleware } from '@/shared/api/middleware/attach-session-middleware';\nimport { idempotencyKeyMiddleware } from '@/shared/api/middleware/idempotency-key';\nimport { requestRetryMiddleware } from '@/shared/api/middleware/request-retry';\nimport { renewSessionMiddleware } from '@/shared/api/middleware/session-renewal';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\n/**\n * Isomorphic HTTP client with session attachment, session renewal on 401,\n * idempotency key injection, and request retry. Works in both browser and\n * Node/server environments. Pass `additionalBeforeRequest` to inject\n * environment-specific middleware (e.g. `userAgentMiddleware` on the client).\n */\nexport class AuthenticatedApiClient {\n private readonly httpClient: HttpClient;\n\n constructor(\n config: HttpClientConfig,\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>,\n additionalBeforeRequest: BeforeRequestMiddleware[] = []\n ) {\n this.httpClient = new HttpClient(config, {\n beforeRequest: [\n attachSessionMiddleware(fetchAccessToken),\n ...additionalBeforeRequest,\n idempotencyKeyMiddleware,\n ],\n afterRequest: [\n renewSessionMiddleware(fetchAccessToken),\n requestRetryMiddleware,\n ],\n });\n }\n\n async send<TResponse>(request: HttpRequest): Promise<TResponse> {\n const response = await this.httpClient.send<TResponse>(request);\n if (response.status >= 200 && response.status < 300) {\n return response.body as TResponse;\n } else {\n throw new HttpError(response);\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAKO,IAAM,gBAAgB;;;ACAtB,SAAS,wBACd,kBACyB;AACzB,SAAO,OAAO,YAA+C;AAC3D,QAAI,CAAC,WAAW,YAAY,QAAQ,UAAU,GAAG;AAC/C,aAAO;AAAA,IACT;AAEA,QAAI,cAAc,MAAM,iBAAiB,KAAK;AAC9C,QAAI,CAAC,aAAa;AAChB,YAAM,cAAc,WAAW,qBAAqB,QAAQ,UAAU;AACtE,UAAI,aAAa;AACf,sBAAc;AAAA,MAChB;AAAA,IACF;AAEA,QAAI,gBAAgB,MAAM;AACxB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAI,QAAQ,WAAW,CAAC;AAAA,QACxB,eAAe,UAAU,YAAY,KAAK;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;;;AC3BO,IAAM,2BAAoD,OAC/D,YACyB;AACzB,MAAI,CAAC,WAAW,aAAa,QAAQ,UAAU,GAAG;AAChD,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,QAAQ,WAAW,CAAC;AAC5C,MAAI,gBAAgB,sBAAsB,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG;AAAA,MACH,CAAC,sBAAsB,GAAG,UAAU;AAAA,IACtC;AAAA,EACF;AACF;;;ACrBA,IAAM,eAAe;AACrB,IAAM,mBAAmB;AACzB,IAAM,eAAe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