@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
@@ -7,7 +7,7 @@ import {
7
7
  notifySessionExpired,
8
8
  publicClients,
9
9
  systemDelay
10
- } from "../chunk-STAHYDLY.js";
10
+ } from "../chunk-4IZ2F732.js";
11
11
  import {
12
12
  AuthorizationCode,
13
13
  CodeVerifier,
@@ -36,12 +36,13 @@ import {
36
36
  decodeSwappedOutputAmount,
37
37
  formattedPricePerShare,
38
38
  generatePKCEParams,
39
+ isOndoNotTradableError,
39
40
  isSwapAvailable,
40
41
  offerDisplayTokens,
41
42
  ondoQuoteOfferDeadline,
42
43
  superstateSwapContractAddress,
43
44
  swapSpender
44
- } from "../chunk-KRA6EM2L.js";
45
+ } from "../chunk-UJYSXXJF.js";
45
46
  import {
46
47
  API_VERSION,
47
48
  AssetDecimals,
@@ -94,7 +95,7 @@ import {
94
95
  shortenAddress,
95
96
  txExplorerUrl,
96
97
  usdAmount
97
- } from "../chunk-BNMF2HMW.js";
98
+ } from "../chunk-NBO5E2RO.js";
98
99
 
99
100
  // src/client/CoinListProvider.tsx
100
101
  import {
@@ -3021,6 +3022,8 @@ function InfoIcon() {
3021
3022
  import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
3022
3023
  var UNSUPPORTED_CHAIN_TITLE = "Not available on this network";
3023
3024
  var UNSUPPORTED_CHAIN_DESCRIPTION = "Ondo orders cannot be placed on the selected network.";
3025
+ var NOT_TRADABLE_TITLE = "Trading is closed right now";
3026
+ var NOT_TRADABLE_DESCRIPTION = "This asset cannot be traded at the moment. Come back when the market opens.";
3024
3027
  function OndoCheckoutError({
3025
3028
  reason,
3026
3029
  className
@@ -3062,6 +3065,8 @@ function title(reason) {
3062
3065
  switch (reason) {
3063
3066
  case "unsupported-chain":
3064
3067
  return UNSUPPORTED_CHAIN_TITLE;
3068
+ case "not-tradable":
3069
+ return NOT_TRADABLE_TITLE;
3065
3070
  default: {
3066
3071
  const exhaustive = reason;
3067
3072
  return exhaustive;
@@ -3072,6 +3077,8 @@ function description(reason) {
3072
3077
  switch (reason) {
3073
3078
  case "unsupported-chain":
3074
3079
  return UNSUPPORTED_CHAIN_DESCRIPTION;
3080
+ case "not-tradable":
3081
+ return NOT_TRADABLE_DESCRIPTION;
3075
3082
  default: {
3076
3083
  const exhaustive = reason;
3077
3084
  return exhaustive;
@@ -4200,7 +4207,9 @@ import { useCallback as useCallback2, useEffect as useEffect5, useRef as useRef4
4200
4207
 
4201
4208
  // src/client/hooks/checkout/ondo/shared/data/ondo-load-error.ts
4202
4209
  function ondoLoadErrorReason(error) {
4203
- return error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
4210
+ if (error instanceof NotAuthenticatedError) return "not-authenticated";
4211
+ if (isOndoNotTradableError(error)) return "not-tradable";
4212
+ return "generic-error";
4204
4213
  }
4205
4214
 
4206
4215
  // src/client/hooks/checkout/ondo/buy/data/useOndoBuyTransaction.ts
@@ -4505,6 +4514,8 @@ function refreshErrorMessage(reason) {
4505
4514
  switch (reason) {
4506
4515
  case "not-authenticated":
4507
4516
  return "Sign in to refresh this quote.";
4517
+ case "not-tradable":
4518
+ return "Trading is paused for this asset. Try again when the market opens.";
4508
4519
  case "generic-error":
4509
4520
  return "Could not refresh the quote.";
4510
4521
  default: {
@@ -4632,6 +4643,9 @@ function quoteSizeFromKey(key) {
4632
4643
 
4633
4644
  // src/client/hooks/checkout/ondo/shared/data/useOndoTradingStatus.ts
4634
4645
  import { useEffect as useEffect9, useRef as useRef7, useState as useState8 } from "react";
4646
+ function isNotTradable(state) {
4647
+ return state.type === "CONTENT" && state.status.type === "not-tradable";
4648
+ }
4635
4649
  var LOADING2 = { type: "LOADING" };
4636
4650
  function useOndoTradingStatus(options) {
4637
4651
  const {
@@ -4701,6 +4715,30 @@ function useOndoTradingStatus(options) {
4701
4715
  return { state };
4702
4716
  }
4703
4717
 
4718
+ // src/client/hooks/checkout/ondo/shared/ondo-checkout-error.types.ts
4719
+ var OndoCheckoutErrorReason = {
4720
+ /**
4721
+ * Which reason, if any, replaces the whole checkout. `null` means the steps
4722
+ * render.
4723
+ *
4724
+ * `unsupported-chain` wins because it is settled at mount: no market state
4725
+ * can make a chain with no contract tradable. `not-tradable` needs both a
4726
+ * market *known* to be closed and a user still at the start of the flow,
4727
+ * with no order confirmation on screen. Past the first step a pause belongs
4728
+ * to the step it interrupts, and a just-placed order's dialog must not be
4729
+ * hidden by a market that closed after it filled.
4730
+ */
4731
+ of: ({
4732
+ swappableHere,
4733
+ notTradable,
4734
+ atEntry
4735
+ }) => {
4736
+ if (!swappableHere) return "unsupported-chain";
4737
+ if (notTradable && atEntry) return "not-tradable";
4738
+ return null;
4739
+ }
4740
+ };
4741
+
4704
4742
  // src/client/hooks/checkout/ondo/shared/sidebar/useOndoSidebarViewModel.ts
4705
4743
  var MARKET_OPEN = "Market open";
4706
4744
  var MARKET_CLOSED2 = "Market closed";
@@ -5019,18 +5057,19 @@ function useOndoBuyCheckoutViewModel({
5019
5057
  const [orderConfirmed, setOrderConfirmed] = useState11(null);
5020
5058
  const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
5021
5059
  const live = enabled && swappableHere;
5022
- const { state: priceState } = useOndoPrice({
5060
+ const { state: tradingStatusState } = useOndoTradingStatus({
5023
5061
  symbol: ondoSymbol,
5024
5062
  side: "buy",
5025
- size: priceSize(step),
5026
5063
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
5027
5064
  enabled: live
5028
5065
  });
5029
- const { state: tradingStatusState } = useOndoTradingStatus({
5066
+ const notTradable = isNotTradable(tradingStatusState);
5067
+ const { state: priceState } = useOndoPrice({
5030
5068
  symbol: ondoSymbol,
5031
5069
  side: "buy",
5070
+ size: priceSize(step),
5032
5071
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
5033
- enabled: live
5072
+ enabled: live && !notTradable
5034
5073
  });
5035
5074
  const { state: outputTokenMetadataState } = useCheckoutOfferTokenMetadata({
5036
5075
  offer,
@@ -5108,7 +5147,12 @@ function useOndoBuyCheckoutViewModel({
5108
5147
  priceState,
5109
5148
  tradingStatusState
5110
5149
  });
5111
- const state = !swappableHere ? { type: "error", reason: "unsupported-chain" } : {
5150
+ const errorReason = OndoCheckoutErrorReason.of({
5151
+ swappableHere,
5152
+ notTradable,
5153
+ atEntry: step.type === "wallet" && orderConfirmed === null
5154
+ });
5155
+ const state = errorReason !== null ? { type: "error", reason: errorReason } : {
5112
5156
  type: "content",
5113
5157
  wallet: walletState,
5114
5158
  amount: amountState,
@@ -6565,6 +6609,8 @@ function refreshErrorMessage2(reason) {
6565
6609
  switch (reason) {
6566
6610
  case "not-authenticated":
6567
6611
  return "Sign in to refresh this quote.";
6612
+ case "not-tradable":
6613
+ return "Trading is paused for this asset. Try again when the market opens.";
6568
6614
  case "generic-error":
6569
6615
  return "Could not refresh the quote.";
6570
6616
  default: {
@@ -6618,18 +6664,19 @@ function useOndoSellCheckoutViewModel({
6618
6664
  const [orderConfirmed, setOrderConfirmed] = useState16(null);
6619
6665
  const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
6620
6666
  const live = enabled && swappableHere;
6621
- const { state: priceState } = useOndoPrice({
6667
+ const { state: tradingStatusState } = useOndoTradingStatus({
6622
6668
  symbol: ondoSymbol,
6623
6669
  side: "sell",
6624
- size: priceSize2(step),
6625
6670
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
6626
6671
  enabled: live
6627
6672
  });
6628
- const { state: tradingStatusState } = useOndoTradingStatus({
6673
+ const notTradable = isNotTradable(tradingStatusState);
6674
+ const { state: priceState } = useOndoPrice({
6629
6675
  symbol: ondoSymbol,
6630
6676
  side: "sell",
6677
+ size: priceSize2(step),
6631
6678
  pollIntervalMs: ONDO_POLL_INTERVAL_MS,
6632
- enabled: live
6679
+ enabled: live && !notTradable
6633
6680
  });
6634
6681
  const { state: inputTokenMetadataState } = useCheckoutOfferTokenMetadata({
6635
6682
  offer,
@@ -6707,7 +6754,14 @@ function useOndoSellCheckoutViewModel({
6707
6754
  priceState,
6708
6755
  tradingStatusState
6709
6756
  });
6710
- const state = !swappableHere ? { type: "error", reason: "unsupported-chain" } : {
6757
+ const errorReason = OndoCheckoutErrorReason.of({
6758
+ swappableHere,
6759
+ notTradable,
6760
+ // The step the flow opened on, which for a preselected wallet is the
6761
+ // amount rather than a wallet step it never had.
6762
+ atEntry: step.type === initialStep.type && orderConfirmed === null
6763
+ });
6764
+ const state = errorReason !== null ? { type: "error", reason: errorReason } : {
6711
6765
  type: "content",
6712
6766
  wallet: hasWalletStep ? walletState : null,
6713
6767
  amount: amountState,
@@ -9244,7 +9298,8 @@ function CheckoutContainer({
9244
9298
  className
9245
9299
  }
9246
9300
  ),
9247
- tokenSale: (tokenSaleOffer) => config["coinlist::token_sale"].render(tokenSaleOffer)
9301
+ tokenSale: (tokenSaleOffer) => config["coinlist::token_sale"].render(tokenSaleOffer),
9302
+ centrifugeVault: (vaultOffer) => config["centrifuge::vault"].render(vaultOffer)
9248
9303
  });
9249
9304
  }
9250
9305
  function OndoCheckoutContainer({
@@ -9292,6 +9347,8 @@ function renderOffer(offer, branches) {
9292
9347
  return branches.superstate(offer);
9293
9348
  case "coinlist::token_sale":
9294
9349
  return branches.tokenSale(offer);
9350
+ case "centrifuge::vault":
9351
+ return branches.centrifugeVault(offer);
9295
9352
  default: {
9296
9353
  const exhaustive = offer;
9297
9354
  return exhaustive;
@@ -9893,6 +9950,7 @@ function saleWindow(offer) {
9893
9950
  case "superstate::swap":
9894
9951
  return { tagline: offer.tagline, startsAt: offer.startsAt };
9895
9952
  case "ondo::swap":
9953
+ case "centrifuge::vault":
9896
9954
  return { tagline: null, startsAt: null };
9897
9955
  default: {
9898
9956
  const exhaustive = offer;
@@ -12711,6 +12769,7 @@ export {
12711
12769
  OndoBuyOrderConfirmed,
12712
12770
  OndoBuyReviewView,
12713
12771
  OndoCheckoutError,
12772
+ OndoCheckoutErrorReason,
12714
12773
  OndoSellAmountView,
12715
12774
  OndoSellCheckoutContainer,
12716
12775
  OndoSellCheckoutView,
@@ -12750,6 +12809,7 @@ export {
12750
12809
  formatCountdown,
12751
12810
  formatMonthYear,
12752
12811
  formatSaleCardCountdown,
12812
+ isNotTradable,
12753
12813
  offerAssetIconUrl,
12754
12814
  offerIconUrl,
12755
12815
  offerTokenIdentifier,