@coinlist-co/react 0.12.2-rc.0fda52c → 0.12.2-rc.5f2ca48
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.
- package/dist/{chunk-STAHYDLY.js → chunk-6NCNF5GF.js} +2 -2
- package/dist/{chunk-KRA6EM2L.js → chunk-VUIDJYHY.js} +18 -3
- package/dist/chunk-VUIDJYHY.js.map +1 -0
- package/dist/{chunk-BNMF2HMW.js → chunk-XCRU3YE2.js} +628 -402
- package/dist/chunk-XCRU3YE2.js.map +1 -0
- package/dist/client/index.cjs +605 -160
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +271 -29
- package/dist/client/index.d.ts +271 -29
- package/dist/client/index.js +294 -21
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +216 -62
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +10 -2
- package/dist/server/index.d.ts +10 -2
- package/dist/server/index.js +4 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{time-B5YOQxuh.d.ts → time-CTuVDTx6.d.ts} +1 -1
- package/dist/{time-BY3apBpc.d.cts → time-Dv1dejVB.d.cts} +1 -1
- package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +9 -7
- package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +9 -7
- package/dist/{tokens-namespace-BJfFeowE.d.cts → tokens-namespace-CcvHrw-k.d.cts} +462 -20
- package/dist/{tokens-namespace-BJfFeowE.d.ts → tokens-namespace-CcvHrw-k.d.ts} +462 -20
- package/dist/universal/index.cjs +568 -316
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +38 -6
- package/dist/universal/index.d.ts +38 -6
- package/dist/universal/index.js +22 -2
- package/package.json +1 -1
- package/dist/chunk-BNMF2HMW.js.map +0 -1
- package/dist/chunk-KRA6EM2L.js.map +0 -1
- /package/dist/{chunk-STAHYDLY.js.map → chunk-6NCNF5GF.js.map} +0 -0
package/dist/client/index.js
CHANGED
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
notifySessionExpired,
|
|
8
8
|
publicClients,
|
|
9
9
|
systemDelay
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-6NCNF5GF.js";
|
|
11
11
|
import {
|
|
12
12
|
AuthorizationCode,
|
|
13
|
+
CENTRIFUGE_POLL_INTERVAL_MS,
|
|
13
14
|
CodeVerifier,
|
|
14
15
|
DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
|
|
15
16
|
DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
|
|
@@ -36,12 +37,13 @@ import {
|
|
|
36
37
|
decodeSwappedOutputAmount,
|
|
37
38
|
formattedPricePerShare,
|
|
38
39
|
generatePKCEParams,
|
|
40
|
+
isOndoNotTradableError,
|
|
39
41
|
isSwapAvailable,
|
|
40
42
|
offerDisplayTokens,
|
|
41
43
|
ondoQuoteOfferDeadline,
|
|
42
44
|
superstateSwapContractAddress,
|
|
43
45
|
swapSpender
|
|
44
|
-
} from "../chunk-
|
|
46
|
+
} from "../chunk-VUIDJYHY.js";
|
|
45
47
|
import {
|
|
46
48
|
API_VERSION,
|
|
47
49
|
AssetDecimals,
|
|
@@ -51,6 +53,7 @@ import {
|
|
|
51
53
|
Blockchain,
|
|
52
54
|
BlockchainAmount,
|
|
53
55
|
COINLIST_BASE_URL,
|
|
56
|
+
CentrifugeNamespaceImpl,
|
|
54
57
|
CoinListTokenSaleNamespaceImpl,
|
|
55
58
|
DecimalString,
|
|
56
59
|
ERC20_ABI,
|
|
@@ -94,7 +97,7 @@ import {
|
|
|
94
97
|
shortenAddress,
|
|
95
98
|
txExplorerUrl,
|
|
96
99
|
usdAmount
|
|
97
|
-
} from "../chunk-
|
|
100
|
+
} from "../chunk-XCRU3YE2.js";
|
|
98
101
|
|
|
99
102
|
// src/client/CoinListProvider.tsx
|
|
100
103
|
import {
|
|
@@ -1163,6 +1166,7 @@ var CoinListClientImpl = class {
|
|
|
1163
1166
|
this.wallets
|
|
1164
1167
|
);
|
|
1165
1168
|
this.ondo = new ClientOndoNamespaceImpl(ctx, this.erc20);
|
|
1169
|
+
this.centrifuge = new CentrifugeNamespaceImpl(ctx);
|
|
1166
1170
|
this.tokens = new TokensNamespaceImpl(
|
|
1167
1171
|
config.tokensBaseUrl ?? NABU_BASE_URL,
|
|
1168
1172
|
logger
|
|
@@ -3021,6 +3025,8 @@ function InfoIcon() {
|
|
|
3021
3025
|
import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3022
3026
|
var UNSUPPORTED_CHAIN_TITLE = "Not available on this network";
|
|
3023
3027
|
var UNSUPPORTED_CHAIN_DESCRIPTION = "Ondo orders cannot be placed on the selected network.";
|
|
3028
|
+
var NOT_TRADABLE_TITLE = "Trading is closed right now";
|
|
3029
|
+
var NOT_TRADABLE_DESCRIPTION = "This asset cannot be traded at the moment. Come back when the market opens.";
|
|
3024
3030
|
function OndoCheckoutError({
|
|
3025
3031
|
reason,
|
|
3026
3032
|
className
|
|
@@ -3062,6 +3068,8 @@ function title(reason) {
|
|
|
3062
3068
|
switch (reason) {
|
|
3063
3069
|
case "unsupported-chain":
|
|
3064
3070
|
return UNSUPPORTED_CHAIN_TITLE;
|
|
3071
|
+
case "not-tradable":
|
|
3072
|
+
return NOT_TRADABLE_TITLE;
|
|
3065
3073
|
default: {
|
|
3066
3074
|
const exhaustive = reason;
|
|
3067
3075
|
return exhaustive;
|
|
@@ -3072,6 +3080,8 @@ function description(reason) {
|
|
|
3072
3080
|
switch (reason) {
|
|
3073
3081
|
case "unsupported-chain":
|
|
3074
3082
|
return UNSUPPORTED_CHAIN_DESCRIPTION;
|
|
3083
|
+
case "not-tradable":
|
|
3084
|
+
return NOT_TRADABLE_DESCRIPTION;
|
|
3075
3085
|
default: {
|
|
3076
3086
|
const exhaustive = reason;
|
|
3077
3087
|
return exhaustive;
|
|
@@ -4200,7 +4210,9 @@ import { useCallback as useCallback2, useEffect as useEffect5, useRef as useRef4
|
|
|
4200
4210
|
|
|
4201
4211
|
// src/client/hooks/checkout/ondo/shared/data/ondo-load-error.ts
|
|
4202
4212
|
function ondoLoadErrorReason(error) {
|
|
4203
|
-
|
|
4213
|
+
if (error instanceof NotAuthenticatedError) return "not-authenticated";
|
|
4214
|
+
if (isOndoNotTradableError(error)) return "not-tradable";
|
|
4215
|
+
return "generic-error";
|
|
4204
4216
|
}
|
|
4205
4217
|
|
|
4206
4218
|
// src/client/hooks/checkout/ondo/buy/data/useOndoBuyTransaction.ts
|
|
@@ -4505,6 +4517,8 @@ function refreshErrorMessage(reason) {
|
|
|
4505
4517
|
switch (reason) {
|
|
4506
4518
|
case "not-authenticated":
|
|
4507
4519
|
return "Sign in to refresh this quote.";
|
|
4520
|
+
case "not-tradable":
|
|
4521
|
+
return "Trading is paused for this asset. Try again when the market opens.";
|
|
4508
4522
|
case "generic-error":
|
|
4509
4523
|
return "Could not refresh the quote.";
|
|
4510
4524
|
default: {
|
|
@@ -4632,6 +4646,9 @@ function quoteSizeFromKey(key) {
|
|
|
4632
4646
|
|
|
4633
4647
|
// src/client/hooks/checkout/ondo/shared/data/useOndoTradingStatus.ts
|
|
4634
4648
|
import { useEffect as useEffect9, useRef as useRef7, useState as useState8 } from "react";
|
|
4649
|
+
function isNotTradable(state) {
|
|
4650
|
+
return state.type === "CONTENT" && state.status.type === "not-tradable";
|
|
4651
|
+
}
|
|
4635
4652
|
var LOADING2 = { type: "LOADING" };
|
|
4636
4653
|
function useOndoTradingStatus(options) {
|
|
4637
4654
|
const {
|
|
@@ -4701,6 +4718,30 @@ function useOndoTradingStatus(options) {
|
|
|
4701
4718
|
return { state };
|
|
4702
4719
|
}
|
|
4703
4720
|
|
|
4721
|
+
// src/client/hooks/checkout/ondo/shared/ondo-checkout-error.types.ts
|
|
4722
|
+
var OndoCheckoutErrorReason = {
|
|
4723
|
+
/**
|
|
4724
|
+
* Which reason, if any, replaces the whole checkout. `null` means the steps
|
|
4725
|
+
* render.
|
|
4726
|
+
*
|
|
4727
|
+
* `unsupported-chain` wins because it is settled at mount: no market state
|
|
4728
|
+
* can make a chain with no contract tradable. `not-tradable` needs both a
|
|
4729
|
+
* market *known* to be closed and a user still at the start of the flow,
|
|
4730
|
+
* with no order confirmation on screen. Past the first step a pause belongs
|
|
4731
|
+
* to the step it interrupts, and a just-placed order's dialog must not be
|
|
4732
|
+
* hidden by a market that closed after it filled.
|
|
4733
|
+
*/
|
|
4734
|
+
of: ({
|
|
4735
|
+
swappableHere,
|
|
4736
|
+
notTradable,
|
|
4737
|
+
atEntry
|
|
4738
|
+
}) => {
|
|
4739
|
+
if (!swappableHere) return "unsupported-chain";
|
|
4740
|
+
if (notTradable && atEntry) return "not-tradable";
|
|
4741
|
+
return null;
|
|
4742
|
+
}
|
|
4743
|
+
};
|
|
4744
|
+
|
|
4704
4745
|
// src/client/hooks/checkout/ondo/shared/sidebar/useOndoSidebarViewModel.ts
|
|
4705
4746
|
var MARKET_OPEN = "Market open";
|
|
4706
4747
|
var MARKET_CLOSED2 = "Market closed";
|
|
@@ -5019,18 +5060,19 @@ function useOndoBuyCheckoutViewModel({
|
|
|
5019
5060
|
const [orderConfirmed, setOrderConfirmed] = useState11(null);
|
|
5020
5061
|
const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
|
|
5021
5062
|
const live = enabled && swappableHere;
|
|
5022
|
-
const { state:
|
|
5063
|
+
const { state: tradingStatusState } = useOndoTradingStatus({
|
|
5023
5064
|
symbol: ondoSymbol,
|
|
5024
5065
|
side: "buy",
|
|
5025
|
-
size: priceSize(step),
|
|
5026
5066
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
5027
5067
|
enabled: live
|
|
5028
5068
|
});
|
|
5029
|
-
const
|
|
5069
|
+
const notTradable = isNotTradable(tradingStatusState);
|
|
5070
|
+
const { state: priceState } = useOndoPrice({
|
|
5030
5071
|
symbol: ondoSymbol,
|
|
5031
5072
|
side: "buy",
|
|
5073
|
+
size: priceSize(step),
|
|
5032
5074
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
5033
|
-
enabled: live
|
|
5075
|
+
enabled: live && !notTradable
|
|
5034
5076
|
});
|
|
5035
5077
|
const { state: outputTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
5036
5078
|
offer,
|
|
@@ -5108,7 +5150,12 @@ function useOndoBuyCheckoutViewModel({
|
|
|
5108
5150
|
priceState,
|
|
5109
5151
|
tradingStatusState
|
|
5110
5152
|
});
|
|
5111
|
-
const
|
|
5153
|
+
const errorReason = OndoCheckoutErrorReason.of({
|
|
5154
|
+
swappableHere,
|
|
5155
|
+
notTradable,
|
|
5156
|
+
atEntry: step.type === "wallet" && orderConfirmed === null
|
|
5157
|
+
});
|
|
5158
|
+
const state = errorReason !== null ? { type: "error", reason: errorReason } : {
|
|
5112
5159
|
type: "content",
|
|
5113
5160
|
wallet: walletState,
|
|
5114
5161
|
amount: amountState,
|
|
@@ -6565,6 +6612,8 @@ function refreshErrorMessage2(reason) {
|
|
|
6565
6612
|
switch (reason) {
|
|
6566
6613
|
case "not-authenticated":
|
|
6567
6614
|
return "Sign in to refresh this quote.";
|
|
6615
|
+
case "not-tradable":
|
|
6616
|
+
return "Trading is paused for this asset. Try again when the market opens.";
|
|
6568
6617
|
case "generic-error":
|
|
6569
6618
|
return "Could not refresh the quote.";
|
|
6570
6619
|
default: {
|
|
@@ -6618,18 +6667,19 @@ function useOndoSellCheckoutViewModel({
|
|
|
6618
6667
|
const [orderConfirmed, setOrderConfirmed] = useState16(null);
|
|
6619
6668
|
const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
|
|
6620
6669
|
const live = enabled && swappableHere;
|
|
6621
|
-
const { state:
|
|
6670
|
+
const { state: tradingStatusState } = useOndoTradingStatus({
|
|
6622
6671
|
symbol: ondoSymbol,
|
|
6623
6672
|
side: "sell",
|
|
6624
|
-
size: priceSize2(step),
|
|
6625
6673
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
6626
6674
|
enabled: live
|
|
6627
6675
|
});
|
|
6628
|
-
const
|
|
6676
|
+
const notTradable = isNotTradable(tradingStatusState);
|
|
6677
|
+
const { state: priceState } = useOndoPrice({
|
|
6629
6678
|
symbol: ondoSymbol,
|
|
6630
6679
|
side: "sell",
|
|
6680
|
+
size: priceSize2(step),
|
|
6631
6681
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
6632
|
-
enabled: live
|
|
6682
|
+
enabled: live && !notTradable
|
|
6633
6683
|
});
|
|
6634
6684
|
const { state: inputTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
6635
6685
|
offer,
|
|
@@ -6707,7 +6757,14 @@ function useOndoSellCheckoutViewModel({
|
|
|
6707
6757
|
priceState,
|
|
6708
6758
|
tradingStatusState
|
|
6709
6759
|
});
|
|
6710
|
-
const
|
|
6760
|
+
const errorReason = OndoCheckoutErrorReason.of({
|
|
6761
|
+
swappableHere,
|
|
6762
|
+
notTradable,
|
|
6763
|
+
// The step the flow opened on, which for a preselected wallet is the
|
|
6764
|
+
// amount rather than a wallet step it never had.
|
|
6765
|
+
atEntry: step.type === initialStep.type && orderConfirmed === null
|
|
6766
|
+
});
|
|
6767
|
+
const state = errorReason !== null ? { type: "error", reason: errorReason } : {
|
|
6711
6768
|
type: "content",
|
|
6712
6769
|
wallet: hasWalletStep ? walletState : null,
|
|
6713
6770
|
amount: amountState,
|
|
@@ -9244,7 +9301,8 @@ function CheckoutContainer({
|
|
|
9244
9301
|
className
|
|
9245
9302
|
}
|
|
9246
9303
|
),
|
|
9247
|
-
tokenSale: (tokenSaleOffer) => config["coinlist::token_sale"].render(tokenSaleOffer)
|
|
9304
|
+
tokenSale: (tokenSaleOffer) => config["coinlist::token_sale"].render(tokenSaleOffer),
|
|
9305
|
+
centrifugeVault: (vaultOffer) => config["centrifuge::vault"].render(vaultOffer)
|
|
9248
9306
|
});
|
|
9249
9307
|
}
|
|
9250
9308
|
function OndoCheckoutContainer({
|
|
@@ -9292,6 +9350,8 @@ function renderOffer(offer, branches) {
|
|
|
9292
9350
|
return branches.superstate(offer);
|
|
9293
9351
|
case "coinlist::token_sale":
|
|
9294
9352
|
return branches.tokenSale(offer);
|
|
9353
|
+
case "centrifuge::vault":
|
|
9354
|
+
return branches.centrifugeVault(offer);
|
|
9295
9355
|
default: {
|
|
9296
9356
|
const exhaustive = offer;
|
|
9297
9357
|
return exhaustive;
|
|
@@ -9893,6 +9953,7 @@ function saleWindow(offer) {
|
|
|
9893
9953
|
case "superstate::swap":
|
|
9894
9954
|
return { tagline: offer.tagline, startsAt: offer.startsAt };
|
|
9895
9955
|
case "ondo::swap":
|
|
9956
|
+
case "centrifuge::vault":
|
|
9896
9957
|
return { tagline: null, startsAt: null };
|
|
9897
9958
|
default: {
|
|
9898
9959
|
const exhaustive = offer;
|
|
@@ -12527,17 +12588,220 @@ function useCompleteOAuth(options) {
|
|
|
12527
12588
|
}, [coinlist, log]);
|
|
12528
12589
|
}
|
|
12529
12590
|
|
|
12591
|
+
// src/client/hooks/checkout/centrifuge/shared/centrifuge-order-reason.ts
|
|
12592
|
+
var CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES = {
|
|
12593
|
+
vault_unlinked: "This vault is no longer available on this network.",
|
|
12594
|
+
vault_halted: "Investing in this vault is paused.",
|
|
12595
|
+
proxy_not_permissioned: "This vault cannot accept investments right now.",
|
|
12596
|
+
price_unavailable: "A price is not available for this vault right now.",
|
|
12597
|
+
below_minimum: "Enter at least the minimum amount to invest."
|
|
12598
|
+
};
|
|
12599
|
+
var ORDER_REASON_SEVERITY = {
|
|
12600
|
+
vault_unlinked: 0,
|
|
12601
|
+
vault_halted: 1,
|
|
12602
|
+
proxy_not_permissioned: 2,
|
|
12603
|
+
price_unavailable: 3,
|
|
12604
|
+
below_minimum: 4
|
|
12605
|
+
};
|
|
12606
|
+
function centrifugeVaultOrderReasonMessage(reason) {
|
|
12607
|
+
return CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES[reason];
|
|
12608
|
+
}
|
|
12609
|
+
function primaryCentrifugeVaultOrderReason(reasons) {
|
|
12610
|
+
if (reasons.length === 0) return null;
|
|
12611
|
+
return reasons.reduce(
|
|
12612
|
+
(best, reason) => ORDER_REASON_SEVERITY[reason] < ORDER_REASON_SEVERITY[best] ? reason : best
|
|
12613
|
+
);
|
|
12614
|
+
}
|
|
12615
|
+
function centrifugeVaultOrderingMessage(orderability) {
|
|
12616
|
+
if (orderability.type === "orderable") return null;
|
|
12617
|
+
const reason = primaryCentrifugeVaultOrderReason(orderability.reasons);
|
|
12618
|
+
return reason === null ? null : centrifugeVaultOrderReasonMessage(reason);
|
|
12619
|
+
}
|
|
12620
|
+
|
|
12621
|
+
// src/client/hooks/checkout/centrifuge/shared/data/centrifuge-load-error.ts
|
|
12622
|
+
function centrifugeLoadErrorReason(error) {
|
|
12623
|
+
return error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
|
|
12624
|
+
}
|
|
12625
|
+
|
|
12626
|
+
// src/client/hooks/checkout/centrifuge/shared/data/useCentrifugeQuote.ts
|
|
12627
|
+
import { useEffect as useEffect32, useRef as useRef19, useState as useState33 } from "react";
|
|
12628
|
+
var LOADING3 = { type: "LOADING" };
|
|
12629
|
+
function useCentrifugeQuote(options) {
|
|
12630
|
+
const {
|
|
12631
|
+
symbol,
|
|
12632
|
+
chain,
|
|
12633
|
+
amount,
|
|
12634
|
+
pollIntervalMs = CENTRIFUGE_POLL_INTERVAL_MS,
|
|
12635
|
+
data,
|
|
12636
|
+
enabled
|
|
12637
|
+
} = options;
|
|
12638
|
+
const { coinlist, isReady } = useCoinList();
|
|
12639
|
+
const log = useLogger("useCentrifugeQuote");
|
|
12640
|
+
const [state, setState] = useState33(
|
|
12641
|
+
() => data === void 0 ? LOADING3 : { type: "CONTENT", quote: data, isRefreshing: false }
|
|
12642
|
+
);
|
|
12643
|
+
const fetchIdRef = useRef19(0);
|
|
12644
|
+
const isFetchingRef = useRef19(false);
|
|
12645
|
+
const hasQuoteRef = useRef19(data !== void 0);
|
|
12646
|
+
useEffect32(() => {
|
|
12647
|
+
if (!isReady || !enabled) return;
|
|
12648
|
+
const currentFetchId = ++fetchIdRef.current;
|
|
12649
|
+
isFetchingRef.current = false;
|
|
12650
|
+
const load = async () => {
|
|
12651
|
+
if (isFetchingRef.current) return;
|
|
12652
|
+
isFetchingRef.current = true;
|
|
12653
|
+
setState(
|
|
12654
|
+
(previous) => previous.type === "CONTENT" ? { ...previous, isRefreshing: true } : previous
|
|
12655
|
+
);
|
|
12656
|
+
try {
|
|
12657
|
+
const quote = await coinlist.centrifuge.getQuote({
|
|
12658
|
+
symbol,
|
|
12659
|
+
chain,
|
|
12660
|
+
// Rebuilt from primitives the effect depends on, so an inline
|
|
12661
|
+
// `amount` from the checkout viewmodel does not restart the poll.
|
|
12662
|
+
amount: BlockchainAmount({
|
|
12663
|
+
raw: amount.raw,
|
|
12664
|
+
decimals: amount.decimals
|
|
12665
|
+
})
|
|
12666
|
+
});
|
|
12667
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
12668
|
+
log.debug(() => ({
|
|
12669
|
+
msg: "settled",
|
|
12670
|
+
fields: { state: "CONTENT" }
|
|
12671
|
+
}));
|
|
12672
|
+
hasQuoteRef.current = true;
|
|
12673
|
+
setState({ type: "CONTENT", quote, isRefreshing: false });
|
|
12674
|
+
} catch (error) {
|
|
12675
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
12676
|
+
const reason = centrifugeLoadErrorReason(error);
|
|
12677
|
+
if (hasQuoteRef.current) {
|
|
12678
|
+
log.warning(
|
|
12679
|
+
() => ({
|
|
12680
|
+
msg: "poll failed; keeping the last quote",
|
|
12681
|
+
fields: { reason }
|
|
12682
|
+
}),
|
|
12683
|
+
error
|
|
12684
|
+
);
|
|
12685
|
+
} else {
|
|
12686
|
+
log.failure(
|
|
12687
|
+
() => ({ msg: "settled", fields: { state: "ERROR", reason } }),
|
|
12688
|
+
error
|
|
12689
|
+
);
|
|
12690
|
+
}
|
|
12691
|
+
setState(
|
|
12692
|
+
(previous) => previous.type === "CONTENT" ? { ...previous, isRefreshing: false } : { type: "ERROR", reason }
|
|
12693
|
+
);
|
|
12694
|
+
} finally {
|
|
12695
|
+
if (currentFetchId === fetchIdRef.current) {
|
|
12696
|
+
isFetchingRef.current = false;
|
|
12697
|
+
}
|
|
12698
|
+
}
|
|
12699
|
+
};
|
|
12700
|
+
load();
|
|
12701
|
+
const interval = setInterval(load, pollIntervalMs);
|
|
12702
|
+
return () => {
|
|
12703
|
+
clearInterval(interval);
|
|
12704
|
+
++fetchIdRef.current;
|
|
12705
|
+
};
|
|
12706
|
+
}, [
|
|
12707
|
+
coinlist,
|
|
12708
|
+
isReady,
|
|
12709
|
+
enabled,
|
|
12710
|
+
symbol,
|
|
12711
|
+
chain,
|
|
12712
|
+
amount.raw,
|
|
12713
|
+
amount.decimals,
|
|
12714
|
+
pollIntervalMs,
|
|
12715
|
+
log
|
|
12716
|
+
]);
|
|
12717
|
+
return { state };
|
|
12718
|
+
}
|
|
12719
|
+
|
|
12720
|
+
// src/client/hooks/checkout/centrifuge/shared/data/useCentrifugeVaultStatus.ts
|
|
12721
|
+
import { useEffect as useEffect33, useRef as useRef20, useState as useState34 } from "react";
|
|
12722
|
+
var LOADING4 = { type: "LOADING" };
|
|
12723
|
+
function useCentrifugeVaultStatus(options) {
|
|
12724
|
+
const {
|
|
12725
|
+
symbol,
|
|
12726
|
+
chain,
|
|
12727
|
+
pollIntervalMs = CENTRIFUGE_POLL_INTERVAL_MS,
|
|
12728
|
+
data,
|
|
12729
|
+
enabled
|
|
12730
|
+
} = options;
|
|
12731
|
+
const { coinlist, isReady } = useCoinList();
|
|
12732
|
+
const log = useLogger("useCentrifugeVaultStatus");
|
|
12733
|
+
const [state, setState] = useState34(
|
|
12734
|
+
() => data === void 0 ? LOADING4 : { type: "CONTENT", status: data }
|
|
12735
|
+
);
|
|
12736
|
+
const fetchIdRef = useRef20(0);
|
|
12737
|
+
const isFetchingRef = useRef20(false);
|
|
12738
|
+
const hasStatusRef = useRef20(data !== void 0);
|
|
12739
|
+
useEffect33(() => {
|
|
12740
|
+
if (!isReady || !enabled) return;
|
|
12741
|
+
const currentFetchId = ++fetchIdRef.current;
|
|
12742
|
+
isFetchingRef.current = false;
|
|
12743
|
+
const load = async () => {
|
|
12744
|
+
if (isFetchingRef.current) return;
|
|
12745
|
+
isFetchingRef.current = true;
|
|
12746
|
+
try {
|
|
12747
|
+
const status = await coinlist.centrifuge.getVaultStatus({
|
|
12748
|
+
symbol,
|
|
12749
|
+
chain
|
|
12750
|
+
});
|
|
12751
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
12752
|
+
log.debug(() => ({
|
|
12753
|
+
msg: "settled",
|
|
12754
|
+
fields: { state: "CONTENT", orderability: status.orderability.type }
|
|
12755
|
+
}));
|
|
12756
|
+
hasStatusRef.current = true;
|
|
12757
|
+
setState({ type: "CONTENT", status });
|
|
12758
|
+
} catch (error) {
|
|
12759
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
12760
|
+
const reason = centrifugeLoadErrorReason(error);
|
|
12761
|
+
if (hasStatusRef.current) {
|
|
12762
|
+
log.warning(
|
|
12763
|
+
() => ({
|
|
12764
|
+
msg: "poll failed; keeping the last status",
|
|
12765
|
+
fields: { reason }
|
|
12766
|
+
}),
|
|
12767
|
+
error
|
|
12768
|
+
);
|
|
12769
|
+
} else {
|
|
12770
|
+
log.failure(
|
|
12771
|
+
() => ({ msg: "settled", fields: { state: "ERROR", reason } }),
|
|
12772
|
+
error
|
|
12773
|
+
);
|
|
12774
|
+
}
|
|
12775
|
+
setState(
|
|
12776
|
+
(previous) => previous.type === "CONTENT" ? previous : { type: "ERROR", reason }
|
|
12777
|
+
);
|
|
12778
|
+
} finally {
|
|
12779
|
+
if (currentFetchId === fetchIdRef.current) {
|
|
12780
|
+
isFetchingRef.current = false;
|
|
12781
|
+
}
|
|
12782
|
+
}
|
|
12783
|
+
};
|
|
12784
|
+
load();
|
|
12785
|
+
const interval = setInterval(load, pollIntervalMs);
|
|
12786
|
+
return () => {
|
|
12787
|
+
clearInterval(interval);
|
|
12788
|
+
++fetchIdRef.current;
|
|
12789
|
+
};
|
|
12790
|
+
}, [coinlist, isReady, enabled, symbol, chain, pollIntervalMs, log]);
|
|
12791
|
+
return { state };
|
|
12792
|
+
}
|
|
12793
|
+
|
|
12530
12794
|
// src/client/hooks/checkout/coin-list/token-sale/data/useParticipations.ts
|
|
12531
|
-
import { useEffect as
|
|
12795
|
+
import { useEffect as useEffect34, useState as useState35 } from "react";
|
|
12532
12796
|
var LOADING_STATE9 = { type: "LOADING" };
|
|
12533
12797
|
function useParticipations(offerId, options = {}) {
|
|
12534
12798
|
const { coinlist, isReady } = useCoinList();
|
|
12535
12799
|
const log = useLogger("useParticipations");
|
|
12536
12800
|
const { data, enabled = true } = options;
|
|
12537
|
-
const [participationsState, setParticipationsState] =
|
|
12801
|
+
const [participationsState, setParticipationsState] = useState35(
|
|
12538
12802
|
data !== void 0 ? { type: "CONTENT", participations: data } : LOADING_STATE9
|
|
12539
12803
|
);
|
|
12540
|
-
|
|
12804
|
+
useEffect34(() => {
|
|
12541
12805
|
let isCancelled = false;
|
|
12542
12806
|
if (!enabled) {
|
|
12543
12807
|
return () => {
|
|
@@ -12584,16 +12848,16 @@ function useParticipations(offerId, options = {}) {
|
|
|
12584
12848
|
}
|
|
12585
12849
|
|
|
12586
12850
|
// src/client/hooks/offers/data/useOfferDetails.ts
|
|
12587
|
-
import { useEffect as
|
|
12851
|
+
import { useEffect as useEffect35, useState as useState36 } from "react";
|
|
12588
12852
|
var LOADING_STATE10 = { type: "LOADING" };
|
|
12589
12853
|
function useOfferDetails(offerId, options = {}) {
|
|
12590
12854
|
const { coinlist, isReady } = useCoinList();
|
|
12591
12855
|
const log = useLogger("useOfferDetails");
|
|
12592
12856
|
const { data, enabled = true } = options;
|
|
12593
|
-
const [offerDetailsState, setOfferDetailsState] =
|
|
12857
|
+
const [offerDetailsState, setOfferDetailsState] = useState36(
|
|
12594
12858
|
data !== void 0 ? { type: "CONTENT", offerDetail: data } : LOADING_STATE10
|
|
12595
12859
|
);
|
|
12596
|
-
|
|
12860
|
+
useEffect35(() => {
|
|
12597
12861
|
let isCancelled = false;
|
|
12598
12862
|
if (!enabled) {
|
|
12599
12863
|
return () => {
|
|
@@ -12670,6 +12934,7 @@ function formatMonthYear(date, locale) {
|
|
|
12670
12934
|
}).format(date);
|
|
12671
12935
|
}
|
|
12672
12936
|
export {
|
|
12937
|
+
CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES,
|
|
12673
12938
|
ChecklistStatus,
|
|
12674
12939
|
CheckoutAssetUi,
|
|
12675
12940
|
CheckoutContainer,
|
|
@@ -12711,6 +12976,7 @@ export {
|
|
|
12711
12976
|
OndoBuyOrderConfirmed,
|
|
12712
12977
|
OndoBuyReviewView,
|
|
12713
12978
|
OndoCheckoutError,
|
|
12979
|
+
OndoCheckoutErrorReason,
|
|
12714
12980
|
OndoSellAmountView,
|
|
12715
12981
|
OndoSellCheckoutContainer,
|
|
12716
12982
|
OndoSellCheckoutView,
|
|
@@ -12739,6 +13005,9 @@ export {
|
|
|
12739
13005
|
USDT_ICON_URL,
|
|
12740
13006
|
VerificationOverlay,
|
|
12741
13007
|
authorizeWallet,
|
|
13008
|
+
centrifugeLoadErrorReason,
|
|
13009
|
+
centrifugeVaultOrderReasonMessage,
|
|
13010
|
+
centrifugeVaultOrderingMessage,
|
|
12742
13011
|
classifyWalletError,
|
|
12743
13012
|
connectExternalWalletFlow,
|
|
12744
13013
|
createCoinListClient,
|
|
@@ -12750,6 +13019,7 @@ export {
|
|
|
12750
13019
|
formatCountdown,
|
|
12751
13020
|
formatMonthYear,
|
|
12752
13021
|
formatSaleCardCountdown,
|
|
13022
|
+
isNotTradable,
|
|
12753
13023
|
offerAssetIconUrl,
|
|
12754
13024
|
offerIconUrl,
|
|
12755
13025
|
offerTokenIdentifier,
|
|
@@ -12757,6 +13027,7 @@ export {
|
|
|
12757
13027
|
pinoClientLogger,
|
|
12758
13028
|
prepareOndoBuy,
|
|
12759
13029
|
prepareOndoSell,
|
|
13030
|
+
primaryCentrifugeVaultOrderReason,
|
|
12760
13031
|
quoteIsStale,
|
|
12761
13032
|
quoteOverAsks,
|
|
12762
13033
|
stablecoinIconUrl,
|
|
@@ -12764,6 +13035,8 @@ export {
|
|
|
12764
13035
|
tokenLogoSrcSet,
|
|
12765
13036
|
tokenLogoUrl,
|
|
12766
13037
|
tokenMetadataOf,
|
|
13038
|
+
useCentrifugeQuote,
|
|
13039
|
+
useCentrifugeVaultStatus,
|
|
12767
13040
|
useCheckoutOfferTokenMetadata,
|
|
12768
13041
|
useCoinList,
|
|
12769
13042
|
useCoinListSignInCardViewModel,
|