@coinlist-co/react 0.12.2-rc.9fb6364 → 0.12.2-rc.a59b344

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 (32) hide show
  1. package/dist/{chunk-STAHYDLY.js → chunk-4IZ2F732.js} +2 -2
  2. package/dist/{chunk-BNMF2HMW.js → chunk-NBO5E2RO.js} +39 -3
  3. package/dist/chunk-NBO5E2RO.js.map +1 -0
  4. package/dist/{chunk-KRA6EM2L.js → chunk-UJYSXXJF.js} +168 -3
  5. package/dist/chunk-UJYSXXJF.js.map +1 -0
  6. package/dist/client/index.cjs +147 -49
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +92 -29
  9. package/dist/client/index.d.ts +92 -29
  10. package/dist/client/index.js +75 -15
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +70 -40
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +20 -5
  15. package/dist/server/index.d.ts +20 -5
  16. package/dist/server/index.js +7 -6
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/{time-BY3apBpc.d.cts → time-CFocgYyl.d.cts} +1 -1
  19. package/dist/{time-B5YOQxuh.d.ts → time-DvgN98Q9.d.ts} +1 -1
  20. package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-BsAfBL_b.d.ts} +9 -7
  21. package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-Cc_eA5zM.d.cts} +9 -7
  22. package/dist/{tokens-namespace-BJfFeowE.d.cts → tokens-namespace-D_XSpiS-.d.cts} +102 -19
  23. package/dist/{tokens-namespace-BJfFeowE.d.ts → tokens-namespace-D_XSpiS-.d.ts} +102 -19
  24. package/dist/universal/index.cjs +233 -37
  25. package/dist/universal/index.cjs.map +1 -1
  26. package/dist/universal/index.d.cts +341 -6
  27. package/dist/universal/index.d.ts +341 -6
  28. package/dist/universal/index.js +18 -2
  29. package/package.json +1 -1
  30. package/dist/chunk-BNMF2HMW.js.map +0 -1
  31. package/dist/chunk-KRA6EM2L.js.map +0 -1
  32. /package/dist/{chunk-STAHYDLY.js.map → chunk-4IZ2F732.js.map} +0 -0
@@ -71,6 +71,7 @@ __export(client_exports, {
71
71
  OndoBuyOrderConfirmed: () => OndoBuyOrderConfirmed,
72
72
  OndoBuyReviewView: () => OndoBuyReviewView,
73
73
  OndoCheckoutError: () => OndoCheckoutError,
74
+ OndoCheckoutErrorReason: () => OndoCheckoutErrorReason,
74
75
  OndoSellAmountView: () => OndoSellAmountView,
75
76
  OndoSellCheckoutContainer: () => OndoSellCheckoutContainer,
76
77
  OndoSellCheckoutView: () => OndoSellCheckoutView,
@@ -110,6 +111,7 @@ __export(client_exports, {
110
111
  formatCountdown: () => formatCountdown,
111
112
  formatMonthYear: () => formatMonthYear,
112
113
  formatSaleCardCountdown: () => formatSaleCardCountdown,
114
+ isNotTradable: () => isNotTradable,
113
115
  offerAssetIconUrl: () => offerAssetIconUrl,
114
116
  offerIconUrl: () => offerIconUrl,
115
117
  offerTokenIdentifier: () => offerTokenIdentifier,
@@ -1604,40 +1606,6 @@ var Asset = {
1604
1606
  })
1605
1607
  };
1606
1608
 
1607
- // src/universal/core/shared/utils/wire.ts
1608
- function unknownTypeError(dto, model) {
1609
- const type = dto.type;
1610
- throw new ValidationError(
1611
- `${model}.type: unknown type ${JSON.stringify(type)}`
1612
- );
1613
- }
1614
- function requiredString(value, field) {
1615
- const text = notBlankStringOrNull(value);
1616
- if (text === null) {
1617
- throw new ValidationError(
1618
- `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
1619
- );
1620
- }
1621
- return text;
1622
- }
1623
- function requiredDate(value, field) {
1624
- const date = typeof value === "string" ? new Date(value) : null;
1625
- if (date === null || Number.isNaN(date.getTime())) {
1626
- throw new ValidationError(
1627
- `${field}: expected a date, got ${JSON.stringify(value)}`
1628
- );
1629
- }
1630
- return date;
1631
- }
1632
- function requiredArray(value, field) {
1633
- if (!Array.isArray(value)) {
1634
- throw new ValidationError(
1635
- `${field}: expected an array, got ${typeof value}`
1636
- );
1637
- }
1638
- return value;
1639
- }
1640
-
1641
1609
  // src/universal/types/blockchain/core.ts
1642
1610
  var ETHEREUM_CHAINS = {
1643
1611
  ethereum_mainnet: true,
@@ -1728,13 +1696,51 @@ var AssetSymbol = (value) => value;
1728
1696
  var StablecoinSymbol = (value) => value;
1729
1697
  var Bps = (value) => value;
1730
1698
 
1699
+ // src/universal/core/shared/utils/wire.ts
1700
+ function unknownTypeError(dto, model) {
1701
+ const type = dto.type;
1702
+ throw new ValidationError(
1703
+ `${model}.type: unknown type ${JSON.stringify(type)}`
1704
+ );
1705
+ }
1706
+ function requiredString(value, field) {
1707
+ const text = notBlankStringOrNull(value);
1708
+ if (text === null) {
1709
+ throw new ValidationError(
1710
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
1711
+ );
1712
+ }
1713
+ return text;
1714
+ }
1715
+ function requiredDate(value, field) {
1716
+ const date = typeof value === "string" ? new Date(value) : null;
1717
+ if (date === null || Number.isNaN(date.getTime())) {
1718
+ throw new ValidationError(
1719
+ `${field}: expected a date, got ${JSON.stringify(value)}`
1720
+ );
1721
+ }
1722
+ return date;
1723
+ }
1724
+ function decimalOrNull(value) {
1725
+ return value === null ? null : DecimalString(value);
1726
+ }
1727
+ function requiredArray(value, field) {
1728
+ if (!Array.isArray(value)) {
1729
+ throw new ValidationError(
1730
+ `${field}: expected an array, got ${typeof value}`
1731
+ );
1732
+ }
1733
+ return value;
1734
+ }
1735
+
1731
1736
  // src/universal/types/offer.ts
1732
1737
  var OfferId = (value) => value;
1733
1738
  var OfferSlug = (value) => value;
1734
1739
  var OFFER_TYPES = {
1735
1740
  "coinlist::token_sale": true,
1736
1741
  "superstate::swap": true,
1737
- "ondo::swap": true
1742
+ "ondo::swap": true,
1743
+ "centrifuge::vault": true
1738
1744
  };
1739
1745
  var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
1740
1746
  var OfferEditorial = {
@@ -1776,6 +1782,7 @@ var Offer = {
1776
1782
  // on the wire: copying them would hand every consumer a `startsAt` that
1777
1783
  // is 1970 for one variant and a date for the others.
1778
1784
  case "ondo::swap":
1785
+ case "centrifuge::vault":
1779
1786
  return {
1780
1787
  ...base2,
1781
1788
  type: dto.type,
@@ -1828,6 +1835,19 @@ var OfferSwapContract = {
1828
1835
  address: EvmContractAddress(dto.address)
1829
1836
  })
1830
1837
  };
1838
+ var OfferVaultContract = {
1839
+ fromDto: (dto) => ({
1840
+ chain: Chain(dto.chain),
1841
+ address: EvmContractAddress(dto.address)
1842
+ }),
1843
+ /**
1844
+ * Drops every proxy on a chain this SDK does not name, as
1845
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1846
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1847
+ * should not throw away the proxies the SDK can use.
1848
+ */
1849
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1850
+ };
1831
1851
  var OfferDetail = {
1832
1852
  fromDto: (dto) => {
1833
1853
  const fundingAssets = requiredArray(
@@ -1890,6 +1910,18 @@ var OfferDetail = {
1890
1910
  "OfferDetail.swap_contracts"
1891
1911
  ).map(OfferSwapContract.fromDto)
1892
1912
  };
1913
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1914
+ // the same reason as `swap_contracts`: this is the spender a user
1915
+ // approves.
1916
+ case "centrifuge::vault":
1917
+ return {
1918
+ ...base2,
1919
+ type: dto.type,
1920
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1921
+ vaultContracts: OfferVaultContract.listFromDto(
1922
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1923
+ )
1924
+ };
1893
1925
  default:
1894
1926
  return unknownTypeError(dto, "OfferDetail");
1895
1927
  }
@@ -2162,6 +2194,12 @@ function assertPriceFits(raw) {
2162
2194
  }
2163
2195
  }
2164
2196
 
2197
+ // src/universal/core/checkout/ondo/not-tradable.ts
2198
+ var ONDO_NOT_TRADABLE_CODE = "not_tradable";
2199
+ function isOndoNotTradableError(error) {
2200
+ return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
2201
+ }
2202
+
2165
2203
  // src/universal/core/shared/blockchain/formatters.ts
2166
2204
  var import_viem3 = require("viem");
2167
2205
 
@@ -2402,7 +2440,6 @@ var OndoTradingStatus = {
2402
2440
  };
2403
2441
  }
2404
2442
  };
2405
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
2406
2443
  var OndoQuote = {
2407
2444
  fromDto: (dto) => {
2408
2445
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -4133,7 +4170,9 @@ var TokenRegistrySnapshot = {
4133
4170
  }
4134
4171
  };
4135
4172
  function offerDisplayTokens(offer) {
4136
- const swaps = offer.tokens.filter((token) => token.role === "swap");
4173
+ const swaps = offer.tokens.filter(
4174
+ (token) => token.role === "swap" || token.role === "vault"
4175
+ );
4137
4176
  const distributions = offer.tokens.filter(
4138
4177
  (token) => token.role === "distribution"
4139
4178
  );
@@ -7115,6 +7154,8 @@ function InfoIcon() {
7115
7154
  var import_jsx_runtime26 = require("react/jsx-runtime");
7116
7155
  var UNSUPPORTED_CHAIN_TITLE = "Not available on this network";
7117
7156
  var UNSUPPORTED_CHAIN_DESCRIPTION = "Ondo orders cannot be placed on the selected network.";
7157
+ var NOT_TRADABLE_TITLE = "Trading is closed right now";
7158
+ var NOT_TRADABLE_DESCRIPTION = "This asset cannot be traded at the moment. Come back when the market opens.";
7118
7159
  function OndoCheckoutError({
7119
7160
  reason,
7120
7161
  className
@@ -7156,6 +7197,8 @@ function title(reason) {
7156
7197
  switch (reason) {
7157
7198
  case "unsupported-chain":
7158
7199
  return UNSUPPORTED_CHAIN_TITLE;
7200
+ case "not-tradable":
7201
+ return NOT_TRADABLE_TITLE;
7159
7202
  default: {
7160
7203
  const exhaustive = reason;
7161
7204
  return exhaustive;
@@ -7166,6 +7209,8 @@ function description(reason) {
7166
7209
  switch (reason) {
7167
7210
  case "unsupported-chain":
7168
7211
  return UNSUPPORTED_CHAIN_DESCRIPTION;
7212
+ case "not-tradable":
7213
+ return NOT_TRADABLE_DESCRIPTION;
7169
7214
  default: {
7170
7215
  const exhaustive = reason;
7171
7216
  return exhaustive;
@@ -8294,7 +8339,9 @@ var import_react15 = require("react");
8294
8339
 
8295
8340
  // src/client/hooks/checkout/ondo/shared/data/ondo-load-error.ts
8296
8341
  function ondoLoadErrorReason(error) {
8297
- return error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
8342
+ if (error instanceof NotAuthenticatedError) return "not-authenticated";
8343
+ if (isOndoNotTradableError(error)) return "not-tradable";
8344
+ return "generic-error";
8298
8345
  }
8299
8346
 
8300
8347
  // src/client/hooks/checkout/ondo/buy/data/useOndoBuyTransaction.ts
@@ -8599,6 +8646,8 @@ function refreshErrorMessage(reason) {
8599
8646
  switch (reason) {
8600
8647
  case "not-authenticated":
8601
8648
  return "Sign in to refresh this quote.";
8649
+ case "not-tradable":
8650
+ return "Trading is paused for this asset. Try again when the market opens.";
8602
8651
  case "generic-error":
8603
8652
  return "Could not refresh the quote.";
8604
8653
  default: {
@@ -8726,6 +8775,9 @@ function quoteSizeFromKey(key) {
8726
8775
 
8727
8776
  // src/client/hooks/checkout/ondo/shared/data/useOndoTradingStatus.ts
8728
8777
  var import_react19 = require("react");
8778
+ function isNotTradable(state) {
8779
+ return state.type === "CONTENT" && state.status.type === "not-tradable";
8780
+ }
8729
8781
  var LOADING2 = { type: "LOADING" };
8730
8782
  function useOndoTradingStatus(options) {
8731
8783
  const {
@@ -8795,6 +8847,30 @@ function useOndoTradingStatus(options) {
8795
8847
  return { state };
8796
8848
  }
8797
8849
 
8850
+ // src/client/hooks/checkout/ondo/shared/ondo-checkout-error.types.ts
8851
+ var OndoCheckoutErrorReason = {
8852
+ /**
8853
+ * Which reason, if any, replaces the whole checkout. `null` means the steps
8854
+ * render.
8855
+ *
8856
+ * `unsupported-chain` wins because it is settled at mount: no market state
8857
+ * can make a chain with no contract tradable. `not-tradable` needs both a
8858
+ * market *known* to be closed and a user still at the start of the flow,
8859
+ * with no order confirmation on screen. Past the first step a pause belongs
8860
+ * to the step it interrupts, and a just-placed order's dialog must not be
8861
+ * hidden by a market that closed after it filled.
8862
+ */
8863
+ of: ({
8864
+ swappableHere,
8865
+ notTradable,
8866
+ atEntry
8867
+ }) => {
8868
+ if (!swappableHere) return "unsupported-chain";
8869
+ if (notTradable && atEntry) return "not-tradable";
8870
+ return null;
8871
+ }
8872
+ };
8873
+
8798
8874
  // src/client/hooks/checkout/ondo/shared/sidebar/useOndoSidebarViewModel.ts
8799
8875
  var MARKET_OPEN = "Market open";
8800
8876
  var MARKET_CLOSED2 = "Market closed";
@@ -9113,18 +9189,19 @@ function useOndoBuyCheckoutViewModel({
9113
9189
  const [orderConfirmed, setOrderConfirmed] = (0, import_react22.useState)(null);
9114
9190
  const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
9115
9191
  const live = enabled && swappableHere;
9116
- const { state: priceState } = useOndoPrice({
9192
+ const { state: tradingStatusState } = useOndoTradingStatus({
9117
9193
  symbol: ondoSymbol,
9118
9194
  side: "buy",
9119
- size: priceSize(step),
9120
9195
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
9121
9196
  enabled: live
9122
9197
  });
9123
- const { state: tradingStatusState } = useOndoTradingStatus({
9198
+ const notTradable = isNotTradable(tradingStatusState);
9199
+ const { state: priceState } = useOndoPrice({
9124
9200
  symbol: ondoSymbol,
9125
9201
  side: "buy",
9202
+ size: priceSize(step),
9126
9203
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
9127
- enabled: live
9204
+ enabled: live && !notTradable
9128
9205
  });
9129
9206
  const { state: outputTokenMetadataState } = useCheckoutOfferTokenMetadata({
9130
9207
  offer,
@@ -9202,7 +9279,12 @@ function useOndoBuyCheckoutViewModel({
9202
9279
  priceState,
9203
9280
  tradingStatusState
9204
9281
  });
9205
- const state = !swappableHere ? { type: "error", reason: "unsupported-chain" } : {
9282
+ const errorReason = OndoCheckoutErrorReason.of({
9283
+ swappableHere,
9284
+ notTradable,
9285
+ atEntry: step.type === "wallet" && orderConfirmed === null
9286
+ });
9287
+ const state = errorReason !== null ? { type: "error", reason: errorReason } : {
9206
9288
  type: "content",
9207
9289
  wallet: walletState,
9208
9290
  amount: amountState,
@@ -10659,6 +10741,8 @@ function refreshErrorMessage2(reason) {
10659
10741
  switch (reason) {
10660
10742
  case "not-authenticated":
10661
10743
  return "Sign in to refresh this quote.";
10744
+ case "not-tradable":
10745
+ return "Trading is paused for this asset. Try again when the market opens.";
10662
10746
  case "generic-error":
10663
10747
  return "Could not refresh the quote.";
10664
10748
  default: {
@@ -10712,18 +10796,19 @@ function useOndoSellCheckoutViewModel({
10712
10796
  const [orderConfirmed, setOrderConfirmed] = (0, import_react27.useState)(null);
10713
10797
  const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
10714
10798
  const live = enabled && swappableHere;
10715
- const { state: priceState } = useOndoPrice({
10799
+ const { state: tradingStatusState } = useOndoTradingStatus({
10716
10800
  symbol: ondoSymbol,
10717
10801
  side: "sell",
10718
- size: priceSize2(step),
10719
10802
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
10720
10803
  enabled: live
10721
10804
  });
10722
- const { state: tradingStatusState } = useOndoTradingStatus({
10805
+ const notTradable = isNotTradable(tradingStatusState);
10806
+ const { state: priceState } = useOndoPrice({
10723
10807
  symbol: ondoSymbol,
10724
10808
  side: "sell",
10809
+ size: priceSize2(step),
10725
10810
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
10726
- enabled: live
10811
+ enabled: live && !notTradable
10727
10812
  });
10728
10813
  const { state: inputTokenMetadataState } = useCheckoutOfferTokenMetadata({
10729
10814
  offer,
@@ -10801,7 +10886,14 @@ function useOndoSellCheckoutViewModel({
10801
10886
  priceState,
10802
10887
  tradingStatusState
10803
10888
  });
10804
- const state = !swappableHere ? { type: "error", reason: "unsupported-chain" } : {
10889
+ const errorReason = OndoCheckoutErrorReason.of({
10890
+ swappableHere,
10891
+ notTradable,
10892
+ // The step the flow opened on, which for a preselected wallet is the
10893
+ // amount rather than a wallet step it never had.
10894
+ atEntry: step.type === initialStep.type && orderConfirmed === null
10895
+ });
10896
+ const state = errorReason !== null ? { type: "error", reason: errorReason } : {
10805
10897
  type: "content",
10806
10898
  wallet: hasWalletStep ? walletState : null,
10807
10899
  amount: amountState,
@@ -13338,7 +13430,8 @@ function CheckoutContainer({
13338
13430
  className
13339
13431
  }
13340
13432
  ),
13341
- tokenSale: (tokenSaleOffer) => config["coinlist::token_sale"].render(tokenSaleOffer)
13433
+ tokenSale: (tokenSaleOffer) => config["coinlist::token_sale"].render(tokenSaleOffer),
13434
+ centrifugeVault: (vaultOffer) => config["centrifuge::vault"].render(vaultOffer)
13342
13435
  });
13343
13436
  }
13344
13437
  function OndoCheckoutContainer({
@@ -13386,6 +13479,8 @@ function renderOffer(offer, branches) {
13386
13479
  return branches.superstate(offer);
13387
13480
  case "coinlist::token_sale":
13388
13481
  return branches.tokenSale(offer);
13482
+ case "centrifuge::vault":
13483
+ return branches.centrifugeVault(offer);
13389
13484
  default: {
13390
13485
  const exhaustive = offer;
13391
13486
  return exhaustive;
@@ -13987,6 +14082,7 @@ function saleWindow(offer) {
13987
14082
  case "superstate::swap":
13988
14083
  return { tagline: offer.tagline, startsAt: offer.startsAt };
13989
14084
  case "ondo::swap":
14085
+ case "centrifuge::vault":
13990
14086
  return { tagline: null, startsAt: null };
13991
14087
  default: {
13992
14088
  const exhaustive = offer;
@@ -16934,6 +17030,7 @@ function formatMonthYear(date, locale) {
16934
17030
  OndoBuyOrderConfirmed,
16935
17031
  OndoBuyReviewView,
16936
17032
  OndoCheckoutError,
17033
+ OndoCheckoutErrorReason,
16937
17034
  OndoSellAmountView,
16938
17035
  OndoSellCheckoutContainer,
16939
17036
  OndoSellCheckoutView,
@@ -16973,6 +17070,7 @@ function formatMonthYear(date, locale) {
16973
17070
  formatCountdown,
16974
17071
  formatMonthYear,
16975
17072
  formatSaleCardCountdown,
17073
+ isNotTradable,
16976
17074
  offerAssetIconUrl,
16977
17075
  offerIconUrl,
16978
17076
  offerTokenIdentifier,