@coinlist-co/react 0.12.1-rc.14ac67e → 0.12.1-rc.73e7e17
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-SOMNMOBU.js → chunk-3ZZCK4IT.js} +9 -9
- package/dist/chunk-3ZZCK4IT.js.map +1 -0
- package/dist/{chunk-3ATIDGVR.js → chunk-D42IQHQZ.js} +661 -638
- package/dist/chunk-D42IQHQZ.js.map +1 -0
- package/dist/{chunk-2XBPKC4C.js → chunk-ZUVVNZJJ.js} +126 -126
- package/dist/chunk-ZUVVNZJJ.js.map +1 -0
- package/dist/client/index.cjs +1560 -1405
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +375 -237
- package/dist/client/index.d.ts +375 -237
- package/dist/client/index.js +850 -723
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-DVCh4jUp.d.ts → collections-CMoojQ9M.d.ts} +1 -1
- package/dist/{collections-DNbBE6Pk.d.cts → collections-koI4cjYa.d.cts} +1 -1
- package/dist/{config-DFYAM0GD.d.cts → config-BmK0t-XO.d.cts} +100 -17
- package/dist/{config-DFYAM0GD.d.ts → config-BmK0t-XO.d.ts} +100 -17
- package/dist/server/index.cjs +259 -238
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +4 -4
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +3 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{shared → universal}/index.cjs +870 -843
- package/dist/universal/index.cjs.map +1 -0
- package/dist/{shared → universal}/index.d.cts +557 -557
- package/dist/{shared → universal}/index.d.ts +557 -557
- package/dist/{shared → universal}/index.js +6 -2
- package/package.json +6 -5
- package/dist/chunk-2XBPKC4C.js.map +0 -1
- package/dist/chunk-3ATIDGVR.js.map +0 -1
- package/dist/chunk-SOMNMOBU.js.map +0 -1
- package/dist/shared/index.cjs.map +0 -1
- /package/dist/{shared → universal}/index.js.map +0 -0
package/dist/client/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
PINO_LEVEL,
|
|
5
5
|
SDK_LOGGER_NAME,
|
|
6
6
|
loggerOverPino
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-3ZZCK4IT.js";
|
|
8
8
|
import {
|
|
9
9
|
AuthorizationCode,
|
|
10
10
|
CodeVerifier,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
isStopped,
|
|
39
39
|
superstateSwapContractAddress,
|
|
40
40
|
swapSpender
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-ZUVVNZJJ.js";
|
|
42
42
|
import {
|
|
43
43
|
API_VERSION,
|
|
44
44
|
AssetDecimals,
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
shortenAddress,
|
|
86
86
|
txExplorerUrl,
|
|
87
87
|
usdAmount
|
|
88
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-D42IQHQZ.js";
|
|
89
89
|
|
|
90
90
|
// src/client/CoinListProvider.tsx
|
|
91
91
|
import {
|
|
@@ -233,7 +233,7 @@ var ClientAuthNamespaceImpl = class {
|
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
// src/client/core/blockchain/wallet-error.ts
|
|
236
|
+
// src/client/core/shared/blockchain/wallet-error.ts
|
|
237
237
|
import {
|
|
238
238
|
BaseError,
|
|
239
239
|
ContractFunctionRevertedError,
|
|
@@ -268,7 +268,7 @@ function revertReason(error) {
|
|
|
268
268
|
return error.reason ?? error.data?.errorName ?? error.signature ?? null;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
// src/client/core/blockchain/erc20/approval.ts
|
|
271
|
+
// src/client/core/shared/blockchain/erc20/approval.ts
|
|
272
272
|
async function ensureErc20Allowance({
|
|
273
273
|
erc20,
|
|
274
274
|
chain,
|
|
@@ -445,7 +445,7 @@ async function executeTokenSale(params) {
|
|
|
445
445
|
return { type: "success", participation, approvalTxHash };
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
// src/client/core/observability/flow-logging.ts
|
|
448
|
+
// src/client/core/shared/observability/flow-logging.ts
|
|
449
449
|
async function withFlowLogging(log, flow, fields, onProgress, run) {
|
|
450
450
|
const flowLog = log.child({ flow });
|
|
451
451
|
flowLog.info(() => ({ msg: "flow started", fields }));
|
|
@@ -895,7 +895,7 @@ var ClientSuperstateSwapNamespaceImpl = class extends SuperstateSwapNamespaceImp
|
|
|
895
895
|
}
|
|
896
896
|
};
|
|
897
897
|
|
|
898
|
-
// src/client/core/utils/open-in-new-tab.ts
|
|
898
|
+
// src/client/core/shared/utils/open-in-new-tab.ts
|
|
899
899
|
function openInNewTab(url) {
|
|
900
900
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
901
901
|
}
|
|
@@ -1621,7 +1621,7 @@ function CoinListSignInCardContainer({
|
|
|
1621
1621
|
}
|
|
1622
1622
|
|
|
1623
1623
|
// src/client/components/checkout/CheckoutContainer.tsx
|
|
1624
|
-
import { useState as
|
|
1624
|
+
import { useState as useState23 } from "react";
|
|
1625
1625
|
|
|
1626
1626
|
// src/client/components/checkout/shared/amount/CheckoutAmountInput.tsx
|
|
1627
1627
|
import { useId } from "react";
|
|
@@ -3085,6 +3085,7 @@ var ISSUER_LABEL = "Issuer";
|
|
|
3085
3085
|
var TICKER_SYMBOL_LABEL = "Ticker symbol";
|
|
3086
3086
|
var ISIN_LABEL = "ISIN";
|
|
3087
3087
|
var ASSET_TYPE_LABEL = "Asset type";
|
|
3088
|
+
var LISTING_VENUE_LABEL = "Listing venue";
|
|
3088
3089
|
var NETWORK_LABEL = "Network";
|
|
3089
3090
|
var PRICE_UNAVAILABLE = "-";
|
|
3090
3091
|
function OndoSidebarView({
|
|
@@ -3116,6 +3117,7 @@ function detailRows2(state) {
|
|
|
3116
3117
|
{ label: TICKER_SYMBOL_LABEL, value: state.tickerSymbol },
|
|
3117
3118
|
{ label: ISIN_LABEL, value: state.isin },
|
|
3118
3119
|
{ label: ASSET_TYPE_LABEL, value: state.assetType },
|
|
3120
|
+
{ label: LISTING_VENUE_LABEL, value: state.listingVenue },
|
|
3119
3121
|
{ label: NETWORK_LABEL, value: state.networkName }
|
|
3120
3122
|
];
|
|
3121
3123
|
}
|
|
@@ -5419,7 +5421,7 @@ function ErrorView4({
|
|
|
5419
5421
|
}
|
|
5420
5422
|
|
|
5421
5423
|
// src/client/hooks/checkout/ondo/buy/useOndoBuyCheckoutViewModel.ts
|
|
5422
|
-
import { useState as
|
|
5424
|
+
import { useState as useState11 } from "react";
|
|
5423
5425
|
|
|
5424
5426
|
// src/client/hooks/checkout/ondo/buy/amount/useOndoBuyAmountViewModel.ts
|
|
5425
5427
|
import { useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
@@ -5446,6 +5448,26 @@ function stablecoinIconUrl(symbol) {
|
|
|
5446
5448
|
function offerIconUrl(offer) {
|
|
5447
5449
|
return offer.logoUrl === "" ? null : AssetIconUrl(offer.logoUrl);
|
|
5448
5450
|
}
|
|
5451
|
+
function tokenLogoUrl(logo, minWidth = 40) {
|
|
5452
|
+
switch (logo.kind) {
|
|
5453
|
+
case "VECTOR":
|
|
5454
|
+
return AssetIconUrl(logo.url);
|
|
5455
|
+
case "RASTER": {
|
|
5456
|
+
const chosen = logo.variants.reduce(
|
|
5457
|
+
(smallest, variant) => variant.width >= minWidth && (smallest === null || variant.width < smallest.width) ? variant : smallest,
|
|
5458
|
+
null
|
|
5459
|
+
);
|
|
5460
|
+
return AssetIconUrl((chosen ?? logo.original).url);
|
|
5461
|
+
}
|
|
5462
|
+
default: {
|
|
5463
|
+
const exhaustive = logo;
|
|
5464
|
+
return exhaustive;
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
}
|
|
5468
|
+
function offerAssetIconUrl(offer, tokenMetadata) {
|
|
5469
|
+
return (tokenMetadata ? tokenLogoUrl(tokenMetadata.logo) : null) ?? offerIconUrl(offer);
|
|
5470
|
+
}
|
|
5449
5471
|
|
|
5450
5472
|
// src/client/hooks/checkout/shared/checkout-ui.types.ts
|
|
5451
5473
|
var CheckoutAssetUi = {
|
|
@@ -5454,10 +5476,10 @@ var CheckoutAssetUi = {
|
|
|
5454
5476
|
* name and symbol, the caller supplies the chain it is being traded on and
|
|
5455
5477
|
* whatever icon it has for it.
|
|
5456
5478
|
*
|
|
5457
|
-
* `iconUrl` is a caller's parameter rather than the token's own because
|
|
5458
|
-
*
|
|
5459
|
-
*
|
|
5460
|
-
*
|
|
5479
|
+
* `iconUrl` is a caller's parameter rather than the token's own because an
|
|
5480
|
+
* `Erc20Asset` does not carry one, and which source supplies it is the
|
|
5481
|
+
* caller's to decide. Which is also why it defaults to `null`: the input
|
|
5482
|
+
* asset a user pays with has no offer behind it.
|
|
5461
5483
|
*
|
|
5462
5484
|
* An asset sourced from the offer rather than from a token has its own
|
|
5463
5485
|
* companion, {@link fromOffer}. One companion per source, not one per call
|
|
@@ -5474,7 +5496,7 @@ var CheckoutAssetUi = {
|
|
|
5474
5496
|
}),
|
|
5475
5497
|
/**
|
|
5476
5498
|
* The view of the asset an offer sells: the offer supplies its name and the
|
|
5477
|
-
*
|
|
5499
|
+
* fallback artwork, the caller supplies the symbol and the chain.
|
|
5478
5500
|
*
|
|
5479
5501
|
* `symbol` is a parameter rather than `offer.asset.code` because the symbol a
|
|
5480
5502
|
* provider trades under is the provider's, not the catalogue's - Ondo's
|
|
@@ -5482,14 +5504,26 @@ var CheckoutAssetUi = {
|
|
|
5482
5504
|
* asset stands in. Keeping it out here is what lets one companion serve every
|
|
5483
5505
|
* provider instead of forking per provider.
|
|
5484
5506
|
*
|
|
5507
|
+
* The icon is resolved from the public token registry when `tokenMetadata`
|
|
5508
|
+
* carries a listed token — `useCheckoutOfferTokenMetadata` fetches it,
|
|
5509
|
+
* keyed by the token `OfferDetail.tokens` lists for this chain — and falls
|
|
5510
|
+
* back to the offer's own logo otherwise. `null` covers every way the
|
|
5511
|
+
* registry answer can be absent (unlisted, not settled, lookup failed);
|
|
5512
|
+
* which one it is stays the concern of the hook's state machine, not of
|
|
5513
|
+
* this model, because the icon is the same either way.
|
|
5514
|
+
*
|
|
5485
5515
|
* Deliberately no decimals. An offer names an asset; it does not answer for
|
|
5486
5516
|
* the scale of any particular quantity, and every amount a checkout renders
|
|
5487
5517
|
* arrives as a `BlockchainAmount` carrying its own.
|
|
5488
5518
|
*/
|
|
5489
|
-
fromOffer: (offer, {
|
|
5519
|
+
fromOffer: (offer, {
|
|
5520
|
+
symbol,
|
|
5521
|
+
networkName,
|
|
5522
|
+
tokenMetadata
|
|
5523
|
+
}) => ({
|
|
5490
5524
|
name: offer.name,
|
|
5491
5525
|
symbol,
|
|
5492
|
-
iconUrl:
|
|
5526
|
+
iconUrl: offerAssetIconUrl(offer, tokenMetadata),
|
|
5493
5527
|
network: { name: networkName, iconUrl: null }
|
|
5494
5528
|
})
|
|
5495
5529
|
};
|
|
@@ -6010,6 +6044,7 @@ function useOndoBuyReviewViewModel({
|
|
|
6010
6044
|
ondoSymbol,
|
|
6011
6045
|
chain,
|
|
6012
6046
|
offer,
|
|
6047
|
+
outputTokenMetadata,
|
|
6013
6048
|
enabled = true,
|
|
6014
6049
|
onComplete
|
|
6015
6050
|
}) {
|
|
@@ -6062,7 +6097,8 @@ function useOndoBuyReviewViewModel({
|
|
|
6062
6097
|
type: "active",
|
|
6063
6098
|
outputAsset: CheckoutAssetUi.fromOffer(offer, {
|
|
6064
6099
|
symbol: ondoSymbol,
|
|
6065
|
-
networkName: getNetworkName(chain)
|
|
6100
|
+
networkName: getNetworkName(chain),
|
|
6101
|
+
tokenMetadata: outputTokenMetadata
|
|
6066
6102
|
}),
|
|
6067
6103
|
outputAmount: assetAmount(
|
|
6068
6104
|
formatAmount(built.receiveOutputAmount, locale),
|
|
@@ -6393,6 +6429,7 @@ function useOndoSidebarViewModel({
|
|
|
6393
6429
|
offer,
|
|
6394
6430
|
ondoSymbol,
|
|
6395
6431
|
chain,
|
|
6432
|
+
tokenMetadata,
|
|
6396
6433
|
priceState,
|
|
6397
6434
|
tradingStatusState
|
|
6398
6435
|
}) {
|
|
@@ -6400,14 +6437,17 @@ function useOndoSidebarViewModel({
|
|
|
6400
6437
|
const state = {
|
|
6401
6438
|
asset: CheckoutAssetUi.fromOffer(offer, {
|
|
6402
6439
|
symbol: ondoSymbol,
|
|
6403
|
-
networkName: getNetworkName(chain)
|
|
6440
|
+
networkName: getNetworkName(chain),
|
|
6441
|
+
tokenMetadata
|
|
6404
6442
|
}),
|
|
6405
|
-
//
|
|
6406
|
-
// drops a null row rather
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6443
|
+
// Reference data for the security the token tracks. Each is null on an
|
|
6444
|
+
// offer that tokenizes none, and the detail list drops a null row rather
|
|
6445
|
+
// than dashing it.
|
|
6446
|
+
issuer: offer.issuer,
|
|
6447
|
+
tickerSymbol: offer.ticker,
|
|
6448
|
+
isin: offer.isin,
|
|
6449
|
+
assetType: offer.instrumentType,
|
|
6450
|
+
listingVenue: offer.listingVenue,
|
|
6411
6451
|
networkName: getNetworkName(chain),
|
|
6412
6452
|
price: toPriceUi(priceState, tradingStatusState, locale)
|
|
6413
6453
|
};
|
|
@@ -6590,6 +6630,99 @@ function toConfirmedWalletUi(wallets, wallet) {
|
|
|
6590
6630
|
};
|
|
6591
6631
|
}
|
|
6592
6632
|
|
|
6633
|
+
// src/client/hooks/shared/useTokenMetadata.ts
|
|
6634
|
+
import { useCallback as useCallback3, useEffect as useEffect10, useState as useState10 } from "react";
|
|
6635
|
+
var DISABLED_STATE = { type: "DISABLED" };
|
|
6636
|
+
var LOADING_STATE = { type: "LOADING" };
|
|
6637
|
+
function useTokenMetadata(options) {
|
|
6638
|
+
const { chain, address, data, enabled = true } = options;
|
|
6639
|
+
const { coinlist, isReady } = useCoinList();
|
|
6640
|
+
const log = useLogger("useTokenMetadata");
|
|
6641
|
+
const [state, setState] = useState10(
|
|
6642
|
+
() => data !== void 0 ? { type: "CONTENT", tokenMetadata: data } : LOADING_STATE
|
|
6643
|
+
);
|
|
6644
|
+
const [refetchCount, setRefetchCount] = useState10(0);
|
|
6645
|
+
const refetch = useCallback3(() => {
|
|
6646
|
+
setRefetchCount((count) => count + 1);
|
|
6647
|
+
}, []);
|
|
6648
|
+
useEffect10(() => {
|
|
6649
|
+
let isCancelled = false;
|
|
6650
|
+
const seedActive = data !== void 0 && refetchCount === 0;
|
|
6651
|
+
if (!isReady || !enabled || seedActive) {
|
|
6652
|
+
return () => {
|
|
6653
|
+
isCancelled = true;
|
|
6654
|
+
};
|
|
6655
|
+
}
|
|
6656
|
+
setState(LOADING_STATE);
|
|
6657
|
+
coinlist.tokens.get({ chain, address }).then((tokenMetadata) => {
|
|
6658
|
+
if (!isCancelled) {
|
|
6659
|
+
log.debug(() => ({
|
|
6660
|
+
msg: "settled",
|
|
6661
|
+
fields: {
|
|
6662
|
+
state: "CONTENT",
|
|
6663
|
+
listed: tokenMetadata !== null,
|
|
6664
|
+
symbol: tokenMetadata?.symbol ?? null
|
|
6665
|
+
}
|
|
6666
|
+
}));
|
|
6667
|
+
setState({ type: "CONTENT", tokenMetadata });
|
|
6668
|
+
}
|
|
6669
|
+
}).catch((error) => {
|
|
6670
|
+
if (!isCancelled) {
|
|
6671
|
+
log.failure(
|
|
6672
|
+
() => ({
|
|
6673
|
+
msg: "settled",
|
|
6674
|
+
fields: { state: "ERROR", reason: "generic-error" }
|
|
6675
|
+
}),
|
|
6676
|
+
error
|
|
6677
|
+
);
|
|
6678
|
+
setState({ type: "ERROR", reason: "generic-error" });
|
|
6679
|
+
}
|
|
6680
|
+
});
|
|
6681
|
+
return () => {
|
|
6682
|
+
isCancelled = true;
|
|
6683
|
+
};
|
|
6684
|
+
}, [coinlist, isReady, enabled, chain, address, data, refetchCount, log]);
|
|
6685
|
+
return {
|
|
6686
|
+
// LOADING would be a lie while disabled: nothing is in flight and nothing
|
|
6687
|
+
// will replace it. Settled states (a seed, a previous answer) survive.
|
|
6688
|
+
state: !enabled && state.type === "LOADING" ? DISABLED_STATE : state,
|
|
6689
|
+
refetch
|
|
6690
|
+
};
|
|
6691
|
+
}
|
|
6692
|
+
|
|
6693
|
+
// src/client/hooks/checkout/shared/data/useCheckoutOfferTokenMetadata.ts
|
|
6694
|
+
var NO_TOKEN_ADDRESS = EvmContractAddress(
|
|
6695
|
+
"0x0000000000000000000000000000000000000000"
|
|
6696
|
+
);
|
|
6697
|
+
function offerTokenIdentifier(offer, chain) {
|
|
6698
|
+
const byChain = offer.tokens.filter((token) => token.chain === chain);
|
|
6699
|
+
const asset = byChain.find((token) => token.role === "swap") ?? byChain.find((token) => token.role === "distribution");
|
|
6700
|
+
return asset === void 0 ? null : { chain, address: asset.address };
|
|
6701
|
+
}
|
|
6702
|
+
function tokenMetadataOf(state) {
|
|
6703
|
+
return state.type === "CONTENT" ? state.tokenMetadata : null;
|
|
6704
|
+
}
|
|
6705
|
+
function useCheckoutOfferTokenMetadata({
|
|
6706
|
+
offer,
|
|
6707
|
+
chain,
|
|
6708
|
+
data,
|
|
6709
|
+
enabled = true
|
|
6710
|
+
}) {
|
|
6711
|
+
const identifier = offerTokenIdentifier(offer, chain);
|
|
6712
|
+
const { state } = useTokenMetadata({
|
|
6713
|
+
// Primitive keys, not the identifier object: the underlying hook re-fetches
|
|
6714
|
+
// only when `(chain, address)` changes, so a host that rebuilds the offer
|
|
6715
|
+
// object per render does not refetch the registry per render.
|
|
6716
|
+
chain: identifier?.chain ?? chain,
|
|
6717
|
+
address: identifier?.address ?? NO_TOKEN_ADDRESS,
|
|
6718
|
+
// Nothing to look up when the offer lists no token here: seed "not
|
|
6719
|
+
// listed" and never fire a request against the placeholder address.
|
|
6720
|
+
enabled: enabled && identifier !== null,
|
|
6721
|
+
data: data !== void 0 ? data : identifier === null ? null : void 0
|
|
6722
|
+
});
|
|
6723
|
+
return { state };
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6593
6726
|
// src/client/hooks/checkout/ondo/buy/useOndoBuyCheckoutViewModel.ts
|
|
6594
6727
|
function useOndoBuyCheckoutViewModel({
|
|
6595
6728
|
offer,
|
|
@@ -6600,8 +6733,8 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6600
6733
|
onOrderConfirmed
|
|
6601
6734
|
}) {
|
|
6602
6735
|
const locale = useLocale();
|
|
6603
|
-
const [step, setStep] =
|
|
6604
|
-
const [orderConfirmed, setOrderConfirmed] =
|
|
6736
|
+
const [step, setStep] = useState11({ type: "wallet" });
|
|
6737
|
+
const [orderConfirmed, setOrderConfirmed] = useState11(null);
|
|
6605
6738
|
const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
|
|
6606
6739
|
const live = enabled && swappableHere;
|
|
6607
6740
|
const { state: priceState } = useOndoPrice({
|
|
@@ -6617,6 +6750,20 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6617
6750
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
6618
6751
|
enabled: live
|
|
6619
6752
|
});
|
|
6753
|
+
const { state: outputTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
6754
|
+
offer,
|
|
6755
|
+
chain,
|
|
6756
|
+
enabled: live
|
|
6757
|
+
});
|
|
6758
|
+
const outputTokenMetadata = tokenMetadataOf(outputTokenMetadataState);
|
|
6759
|
+
const orderConfirmedUi = (order) => order === null ? { type: "hidden" } : toOrderConfirmedUi({
|
|
6760
|
+
order,
|
|
6761
|
+
chain,
|
|
6762
|
+
locale,
|
|
6763
|
+
offer,
|
|
6764
|
+
ondoSymbol,
|
|
6765
|
+
outputTokenMetadata
|
|
6766
|
+
});
|
|
6620
6767
|
const { state: walletState, onEvent: onWalletEvent } = useOndoWalletSelectViewModel({
|
|
6621
6768
|
stepInput: walletStepInput(step),
|
|
6622
6769
|
wallets,
|
|
@@ -6663,11 +6810,10 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6663
6810
|
ondoSymbol,
|
|
6664
6811
|
chain,
|
|
6665
6812
|
offer,
|
|
6813
|
+
outputTokenMetadata,
|
|
6666
6814
|
enabled: live,
|
|
6667
6815
|
onComplete: (order) => {
|
|
6668
|
-
setOrderConfirmed(
|
|
6669
|
-
toOrderConfirmedUi({ order, chain, locale, offer, ondoSymbol })
|
|
6670
|
-
);
|
|
6816
|
+
setOrderConfirmed(order);
|
|
6671
6817
|
setStep({ type: "wallet" });
|
|
6672
6818
|
onOrderConfirmed?.(order);
|
|
6673
6819
|
}
|
|
@@ -6676,6 +6822,7 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6676
6822
|
offer,
|
|
6677
6823
|
ondoSymbol,
|
|
6678
6824
|
chain,
|
|
6825
|
+
tokenMetadata: outputTokenMetadata,
|
|
6679
6826
|
priceState,
|
|
6680
6827
|
tradingStatusState
|
|
6681
6828
|
});
|
|
@@ -6685,7 +6832,7 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6685
6832
|
amount: amountState,
|
|
6686
6833
|
review: reviewState,
|
|
6687
6834
|
sidebar: sidebarState,
|
|
6688
|
-
orderConfirmed
|
|
6835
|
+
orderConfirmed: orderConfirmedUi(orderConfirmed)
|
|
6689
6836
|
};
|
|
6690
6837
|
const onEvent = (event) => {
|
|
6691
6838
|
switch (event.type) {
|
|
@@ -6709,7 +6856,7 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6709
6856
|
onReviewEvent(event);
|
|
6710
6857
|
return;
|
|
6711
6858
|
case "ON_CLOSE_ORDER_CONFIRMED":
|
|
6712
|
-
setOrderConfirmed(
|
|
6859
|
+
setOrderConfirmed(null);
|
|
6713
6860
|
return;
|
|
6714
6861
|
default: {
|
|
6715
6862
|
const exhaustive = event;
|
|
@@ -6763,14 +6910,16 @@ function toOrderConfirmedUi({
|
|
|
6763
6910
|
chain,
|
|
6764
6911
|
locale,
|
|
6765
6912
|
offer,
|
|
6766
|
-
ondoSymbol
|
|
6913
|
+
ondoSymbol,
|
|
6914
|
+
outputTokenMetadata
|
|
6767
6915
|
}) {
|
|
6768
6916
|
const inputSymbol = TOKEN_REGISTRY.erc20(order.inputAsset).symbol;
|
|
6769
6917
|
return {
|
|
6770
6918
|
type: "visible",
|
|
6771
6919
|
outputAsset: CheckoutAssetUi.fromOffer(offer, {
|
|
6772
6920
|
symbol: ondoSymbol,
|
|
6773
|
-
networkName: getNetworkName(chain)
|
|
6921
|
+
networkName: getNetworkName(chain),
|
|
6922
|
+
tokenMetadata: outputTokenMetadata
|
|
6774
6923
|
}),
|
|
6775
6924
|
outputAmount: assetAmount(
|
|
6776
6925
|
formatAmount(order.transaction.receiveOutputAmount, locale),
|
|
@@ -6790,13 +6939,13 @@ function toOrderConfirmedUi({
|
|
|
6790
6939
|
}
|
|
6791
6940
|
|
|
6792
6941
|
// src/client/hooks/checkout/ondo/sell/useOndoSellCheckoutViewModel.ts
|
|
6793
|
-
import { useState as
|
|
6942
|
+
import { useState as useState16 } from "react";
|
|
6794
6943
|
|
|
6795
6944
|
// src/client/hooks/checkout/ondo/sell/amount/useOndoSellAmountViewModel.ts
|
|
6796
|
-
import { useEffect as
|
|
6945
|
+
import { useEffect as useEffect12, useRef as useRef9, useState as useState13 } from "react";
|
|
6797
6946
|
|
|
6798
6947
|
// src/client/hooks/shared/erc20/useErc20Balance.ts
|
|
6799
|
-
import { useEffect as
|
|
6948
|
+
import { useEffect as useEffect11, useRef as useRef8, useState as useState12 } from "react";
|
|
6800
6949
|
function useErc20Balance(options) {
|
|
6801
6950
|
const {
|
|
6802
6951
|
tokenAddress,
|
|
@@ -6807,12 +6956,12 @@ function useErc20Balance(options) {
|
|
|
6807
6956
|
} = options;
|
|
6808
6957
|
const { coinlist, isReady } = useCoinList();
|
|
6809
6958
|
const log = useLogger("useErc20Balance");
|
|
6810
|
-
const [balance, setBalance] =
|
|
6811
|
-
const [isLoading, setIsLoading] =
|
|
6959
|
+
const [balance, setBalance] = useState12(null);
|
|
6960
|
+
const [isLoading, setIsLoading] = useState12(true);
|
|
6812
6961
|
const fetchIdRef = useRef8(0);
|
|
6813
6962
|
const isFetchingRef = useRef8(false);
|
|
6814
6963
|
const hasReadRef = useRef8(false);
|
|
6815
|
-
|
|
6964
|
+
useEffect11(() => {
|
|
6816
6965
|
if (!isReady) return;
|
|
6817
6966
|
setBalance(null);
|
|
6818
6967
|
hasReadRef.current = false;
|
|
@@ -6889,15 +7038,16 @@ function useOndoSellAmountViewModel({
|
|
|
6889
7038
|
ondoSymbol,
|
|
6890
7039
|
chain,
|
|
6891
7040
|
offer,
|
|
7041
|
+
inputTokenMetadata,
|
|
6892
7042
|
enabled = true,
|
|
6893
7043
|
onComplete,
|
|
6894
7044
|
onEdit
|
|
6895
7045
|
}) {
|
|
6896
7046
|
const { coinlist } = useCoinList();
|
|
6897
7047
|
const locale = useLocale();
|
|
6898
|
-
const [amountInput, setAmountInput] =
|
|
6899
|
-
const [error, setError] =
|
|
6900
|
-
const [phase, setPhase] =
|
|
7048
|
+
const [amountInput, setAmountInput] = useState13("");
|
|
7049
|
+
const [error, setError] = useState13(null);
|
|
7050
|
+
const [phase, setPhase] = useState13(null);
|
|
6901
7051
|
const preparationIdRef = useRef9(0);
|
|
6902
7052
|
const isActive = stepInput.type === "active";
|
|
6903
7053
|
const networkName = getNetworkName(chain);
|
|
@@ -6909,7 +7059,7 @@ function useOndoSellAmountViewModel({
|
|
|
6909
7059
|
chain,
|
|
6910
7060
|
enabled: enabled && isActive && sellAsset2 !== null
|
|
6911
7061
|
});
|
|
6912
|
-
|
|
7062
|
+
useEffect12(() => {
|
|
6913
7063
|
if (stepInput.type === "incomplete") {
|
|
6914
7064
|
++preparationIdRef.current;
|
|
6915
7065
|
setAmountInput("");
|
|
@@ -6935,7 +7085,8 @@ function useOndoSellAmountViewModel({
|
|
|
6935
7085
|
type: "complete",
|
|
6936
7086
|
asset: CheckoutAssetUi.fromOffer(offer, {
|
|
6937
7087
|
symbol: stepInput.inputAsset,
|
|
6938
|
-
networkName
|
|
7088
|
+
networkName,
|
|
7089
|
+
tokenMetadata: inputTokenMetadata
|
|
6939
7090
|
}),
|
|
6940
7091
|
amountFormatted: assetAmount(
|
|
6941
7092
|
formatAmount(stepInput.amount, locale),
|
|
@@ -6957,7 +7108,8 @@ function useOndoSellAmountViewModel({
|
|
|
6957
7108
|
return {
|
|
6958
7109
|
asset: CheckoutAssetUi.fromOffer(offer, {
|
|
6959
7110
|
symbol: ondoSymbol,
|
|
6960
|
-
networkName
|
|
7111
|
+
networkName,
|
|
7112
|
+
tokenMetadata: inputTokenMetadata
|
|
6961
7113
|
}),
|
|
6962
7114
|
balance: assetAmount(formatAmount(amount, locale), ondoSymbol),
|
|
6963
7115
|
rawBalance: balance
|
|
@@ -7144,15 +7296,15 @@ function preparationErrorMessage2(error) {
|
|
|
7144
7296
|
}
|
|
7145
7297
|
|
|
7146
7298
|
// src/client/hooks/checkout/ondo/sell/review/useOndoSellReviewViewModel.ts
|
|
7147
|
-
import { useEffect as
|
|
7299
|
+
import { useEffect as useEffect14, useRef as useRef11, useState as useState15 } from "react";
|
|
7148
7300
|
|
|
7149
7301
|
// src/client/hooks/checkout/ondo/sell/data/useOndoSellTransaction.ts
|
|
7150
|
-
import { useCallback as
|
|
7302
|
+
import { useCallback as useCallback4, useEffect as useEffect13, useRef as useRef10, useState as useState14 } from "react";
|
|
7151
7303
|
function useOndoSellTransaction(options) {
|
|
7152
7304
|
const { request, data, enabled } = options;
|
|
7153
7305
|
const { coinlist, isReady } = useCoinList();
|
|
7154
7306
|
const log = useLogger("useOndoSellTransaction");
|
|
7155
|
-
const [state, setState] =
|
|
7307
|
+
const [state, setState] = useState14(
|
|
7156
7308
|
() => data === void 0 ? { type: "LOADING" } : {
|
|
7157
7309
|
type: "CONTENT",
|
|
7158
7310
|
transaction: data,
|
|
@@ -7165,7 +7317,7 @@ function useOndoSellTransaction(options) {
|
|
|
7165
7317
|
const requestKey = request === null ? null : stableKey2(request);
|
|
7166
7318
|
const requestRef = useRef10(request);
|
|
7167
7319
|
requestRef.current = request;
|
|
7168
|
-
const build =
|
|
7320
|
+
const build = useCallback4(async () => {
|
|
7169
7321
|
const params = requestRef.current;
|
|
7170
7322
|
if (!isReady || !enabled || params === null) return;
|
|
7171
7323
|
if (isFetchingRef.current) return;
|
|
@@ -7201,7 +7353,7 @@ function useOndoSellTransaction(options) {
|
|
|
7201
7353
|
isFetchingRef.current = false;
|
|
7202
7354
|
}
|
|
7203
7355
|
}, [coinlist, isReady, enabled, log]);
|
|
7204
|
-
|
|
7356
|
+
useEffect13(() => {
|
|
7205
7357
|
if (data === void 0) return;
|
|
7206
7358
|
++fetchIdRef.current;
|
|
7207
7359
|
setState({
|
|
@@ -7212,14 +7364,14 @@ function useOndoSellTransaction(options) {
|
|
|
7212
7364
|
});
|
|
7213
7365
|
}, [data]);
|
|
7214
7366
|
const hasSeed = data !== void 0;
|
|
7215
|
-
|
|
7367
|
+
useEffect13(() => {
|
|
7216
7368
|
if (hasSeed || requestKey === null) return;
|
|
7217
7369
|
build();
|
|
7218
7370
|
return () => {
|
|
7219
7371
|
++fetchIdRef.current;
|
|
7220
7372
|
};
|
|
7221
7373
|
}, [build, requestKey, hasSeed]);
|
|
7222
|
-
const refetch =
|
|
7374
|
+
const refetch = useCallback4(() => {
|
|
7223
7375
|
build();
|
|
7224
7376
|
}, [build]);
|
|
7225
7377
|
return { state, refetch };
|
|
@@ -7244,8 +7396,8 @@ function useOndoSellReviewViewModel({
|
|
|
7244
7396
|
}) {
|
|
7245
7397
|
const { coinlist } = useCoinList();
|
|
7246
7398
|
const locale = useLocale();
|
|
7247
|
-
const [phase, setPhase] =
|
|
7248
|
-
const [error, setError] =
|
|
7399
|
+
const [phase, setPhase] = useState15(null);
|
|
7400
|
+
const [error, setError] = useState15(null);
|
|
7249
7401
|
const isActive = stepInput.type === "active";
|
|
7250
7402
|
const { state: transactionState, refetch } = useOndoSellTransaction({
|
|
7251
7403
|
request: isActive ? {
|
|
@@ -7258,7 +7410,7 @@ function useOndoSellReviewViewModel({
|
|
|
7258
7410
|
enabled: enabled && isActive
|
|
7259
7411
|
});
|
|
7260
7412
|
const executionIdRef = useRef11(0);
|
|
7261
|
-
|
|
7413
|
+
useEffect14(() => {
|
|
7262
7414
|
if (stepInput.type === "incomplete") {
|
|
7263
7415
|
++executionIdRef.current;
|
|
7264
7416
|
setError(null);
|
|
@@ -7468,12 +7620,12 @@ function useOndoSellCheckoutViewModel({
|
|
|
7468
7620
|
onOrderConfirmed
|
|
7469
7621
|
}) {
|
|
7470
7622
|
const locale = useLocale();
|
|
7471
|
-
const [initialStep] =
|
|
7623
|
+
const [initialStep] = useState16(
|
|
7472
7624
|
() => wallets.preselected === null ? { type: "wallet" } : { type: "amount", wallet: wallets.preselected }
|
|
7473
7625
|
);
|
|
7474
|
-
const [step, setStep] =
|
|
7626
|
+
const [step, setStep] = useState16(initialStep);
|
|
7475
7627
|
const hasWalletStep = initialStep.type === "wallet";
|
|
7476
|
-
const [orderConfirmed, setOrderConfirmed] =
|
|
7628
|
+
const [orderConfirmed, setOrderConfirmed] = useState16(null);
|
|
7477
7629
|
const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
|
|
7478
7630
|
const live = enabled && swappableHere;
|
|
7479
7631
|
const { state: priceState } = useOndoPrice({
|
|
@@ -7489,6 +7641,20 @@ function useOndoSellCheckoutViewModel({
|
|
|
7489
7641
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
7490
7642
|
enabled: live
|
|
7491
7643
|
});
|
|
7644
|
+
const { state: inputTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
7645
|
+
offer,
|
|
7646
|
+
chain,
|
|
7647
|
+
enabled: live
|
|
7648
|
+
});
|
|
7649
|
+
const inputTokenMetadata = tokenMetadataOf(inputTokenMetadataState);
|
|
7650
|
+
const orderConfirmedUi = (order) => order === null ? { type: "hidden" } : toOrderConfirmedUi2({
|
|
7651
|
+
order,
|
|
7652
|
+
chain,
|
|
7653
|
+
locale,
|
|
7654
|
+
offer,
|
|
7655
|
+
ondoSymbol,
|
|
7656
|
+
inputTokenMetadata
|
|
7657
|
+
});
|
|
7492
7658
|
const { state: walletState, onEvent: onWalletEvent } = useOndoWalletSelectViewModel({
|
|
7493
7659
|
stepInput: walletStepInput2(step),
|
|
7494
7660
|
wallets,
|
|
@@ -7505,6 +7671,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7505
7671
|
ondoSymbol,
|
|
7506
7672
|
chain,
|
|
7507
7673
|
offer,
|
|
7674
|
+
inputTokenMetadata,
|
|
7508
7675
|
enabled: live,
|
|
7509
7676
|
// Both transitions read the step through the updater rather than the one
|
|
7510
7677
|
// this render closed over. Preparing an amount takes an approval to mine,
|
|
@@ -7537,9 +7704,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7537
7704
|
chain,
|
|
7538
7705
|
enabled: live,
|
|
7539
7706
|
onComplete: (order) => {
|
|
7540
|
-
setOrderConfirmed(
|
|
7541
|
-
toOrderConfirmedUi2({ order, chain, locale, offer, ondoSymbol })
|
|
7542
|
-
);
|
|
7707
|
+
setOrderConfirmed(order);
|
|
7543
7708
|
setStep(initialStep);
|
|
7544
7709
|
onOrderConfirmed?.(order);
|
|
7545
7710
|
}
|
|
@@ -7548,6 +7713,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7548
7713
|
offer,
|
|
7549
7714
|
ondoSymbol,
|
|
7550
7715
|
chain,
|
|
7716
|
+
tokenMetadata: inputTokenMetadata,
|
|
7551
7717
|
priceState,
|
|
7552
7718
|
tradingStatusState
|
|
7553
7719
|
});
|
|
@@ -7557,7 +7723,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7557
7723
|
amount: amountState,
|
|
7558
7724
|
review: reviewState,
|
|
7559
7725
|
sidebar: sidebarState,
|
|
7560
|
-
orderConfirmed
|
|
7726
|
+
orderConfirmed: orderConfirmedUi(orderConfirmed)
|
|
7561
7727
|
};
|
|
7562
7728
|
const onEvent = (event) => {
|
|
7563
7729
|
switch (event.type) {
|
|
@@ -7581,7 +7747,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7581
7747
|
onReviewEvent(event);
|
|
7582
7748
|
return;
|
|
7583
7749
|
case "ON_CLOSE_SELL_ORDER_CONFIRMED":
|
|
7584
|
-
setOrderConfirmed(
|
|
7750
|
+
setOrderConfirmed(null);
|
|
7585
7751
|
return;
|
|
7586
7752
|
default: {
|
|
7587
7753
|
const exhaustive = event;
|
|
@@ -7649,14 +7815,16 @@ function toOrderConfirmedUi2({
|
|
|
7649
7815
|
chain,
|
|
7650
7816
|
locale,
|
|
7651
7817
|
offer,
|
|
7652
|
-
ondoSymbol
|
|
7818
|
+
ondoSymbol,
|
|
7819
|
+
inputTokenMetadata
|
|
7653
7820
|
}) {
|
|
7654
7821
|
const settlementSymbol = TOKEN_REGISTRY.erc20(ONDO_SETTLEMENT_ASSET).symbol;
|
|
7655
7822
|
return {
|
|
7656
7823
|
type: "visible",
|
|
7657
7824
|
soldAsset: CheckoutAssetUi.fromOffer(offer, {
|
|
7658
7825
|
symbol: ondoSymbol,
|
|
7659
|
-
networkName: getNetworkName(chain)
|
|
7826
|
+
networkName: getNetworkName(chain),
|
|
7827
|
+
tokenMetadata: inputTokenMetadata
|
|
7660
7828
|
}),
|
|
7661
7829
|
soldAmount: assetAmount(
|
|
7662
7830
|
formatAmount(order.transaction.spendInputAmount, locale),
|
|
@@ -7680,10 +7848,10 @@ function toOrderConfirmedUi2({
|
|
|
7680
7848
|
}
|
|
7681
7849
|
|
|
7682
7850
|
// src/client/hooks/checkout/superstate/swap/useSuperstateSwapCheckoutViewModel.ts
|
|
7683
|
-
import { useState as
|
|
7851
|
+
import { useState as useState22 } from "react";
|
|
7684
7852
|
|
|
7685
7853
|
// src/client/hooks/checkout/superstate/swap/amount/useSuperstateAmountViewModel.ts
|
|
7686
|
-
import { useEffect as
|
|
7854
|
+
import { useEffect as useEffect15, useState as useState17 } from "react";
|
|
7687
7855
|
var NO_WALLET3 = EvmWalletAddress(
|
|
7688
7856
|
"0x0000000000000000000000000000000000000000"
|
|
7689
7857
|
);
|
|
@@ -7697,11 +7865,11 @@ function useSuperstateAmountViewModel({
|
|
|
7697
7865
|
enabled = true
|
|
7698
7866
|
}) {
|
|
7699
7867
|
const locale = useLocale();
|
|
7700
|
-
const [amountInput, setAmountInput] =
|
|
7701
|
-
const [selectedAsset, setSelectedAsset] =
|
|
7868
|
+
const [amountInput, setAmountInput] = useState17("");
|
|
7869
|
+
const [selectedAsset, setSelectedAsset] = useState17(
|
|
7702
7870
|
SUPERSTATE_SUPPORTED_INPUT_ASSETS[0]
|
|
7703
7871
|
);
|
|
7704
|
-
const [error, setError] =
|
|
7872
|
+
const [error, setError] = useState17(null);
|
|
7705
7873
|
const isActive = stepInput.type === "active";
|
|
7706
7874
|
const networkName = getNetworkName(chain);
|
|
7707
7875
|
const { balances, isLoading: balancesLoading } = useErc20TokenBalances({
|
|
@@ -7714,7 +7882,7 @@ function useSuperstateAmountViewModel({
|
|
|
7714
7882
|
// on this step satisfies the first and not the second.
|
|
7715
7883
|
enabled: enabled && isActive
|
|
7716
7884
|
});
|
|
7717
|
-
|
|
7885
|
+
useEffect15(() => {
|
|
7718
7886
|
if (stepInput.type === "incomplete") {
|
|
7719
7887
|
setAmountInput("");
|
|
7720
7888
|
setSelectedAsset(SUPERSTATE_SUPPORTED_INPUT_ASSETS[0]);
|
|
@@ -7885,20 +8053,20 @@ function toInputAssetUi2({
|
|
|
7885
8053
|
}
|
|
7886
8054
|
|
|
7887
8055
|
// src/client/hooks/checkout/superstate/swap/data/useSwapOutputToken.ts
|
|
7888
|
-
import { useCallback as
|
|
7889
|
-
var
|
|
8056
|
+
import { useCallback as useCallback5, useEffect as useEffect16, useRef as useRef12, useState as useState18 } from "react";
|
|
8057
|
+
var LOADING_STATE2 = { type: "LOADING" };
|
|
7890
8058
|
function useSwapOutputToken(options) {
|
|
7891
8059
|
const { contractAddress, chain, enabled } = options;
|
|
7892
8060
|
const { coinlist, isReady } = useCoinList();
|
|
7893
8061
|
const log = useLogger("useSwapOutputToken");
|
|
7894
|
-
const [outputTokenState, setOutputTokenState] =
|
|
7895
|
-
const [retryCount, setRetryCount] =
|
|
8062
|
+
const [outputTokenState, setOutputTokenState] = useState18(LOADING_STATE2);
|
|
8063
|
+
const [retryCount, setRetryCount] = useState18(0);
|
|
7896
8064
|
const fetchIdRef = useRef12(0);
|
|
7897
|
-
const refetch =
|
|
7898
|
-
setOutputTokenState(
|
|
8065
|
+
const refetch = useCallback5(() => {
|
|
8066
|
+
setOutputTokenState(LOADING_STATE2);
|
|
7899
8067
|
setRetryCount((count) => count + 1);
|
|
7900
8068
|
}, []);
|
|
7901
|
-
|
|
8069
|
+
useEffect16(() => {
|
|
7902
8070
|
if (!enabled || !isReady) return;
|
|
7903
8071
|
const currentFetchId = ++fetchIdRef.current;
|
|
7904
8072
|
const load = async () => {
|
|
@@ -7931,7 +8099,7 @@ function useSwapOutputToken(options) {
|
|
|
7931
8099
|
}
|
|
7932
8100
|
|
|
7933
8101
|
// src/client/hooks/checkout/superstate/swap/data/useSwapQuote.ts
|
|
7934
|
-
import { useEffect as
|
|
8102
|
+
import { useEffect as useEffect17, useRef as useRef13, useState as useState19 } from "react";
|
|
7935
8103
|
function useSwapQuote(options) {
|
|
7936
8104
|
const {
|
|
7937
8105
|
contractAddress,
|
|
@@ -7944,13 +8112,13 @@ function useSwapQuote(options) {
|
|
|
7944
8112
|
} = options;
|
|
7945
8113
|
const { coinlist, isReady } = useCoinList();
|
|
7946
8114
|
const log = useLogger("useSwapQuote");
|
|
7947
|
-
const [quote, setQuote] =
|
|
7948
|
-
const [isLoading, setIsLoading] =
|
|
7949
|
-
const [isRefreshing, setIsRefreshing] =
|
|
8115
|
+
const [quote, setQuote] = useState19(null);
|
|
8116
|
+
const [isLoading, setIsLoading] = useState19(true);
|
|
8117
|
+
const [isRefreshing, setIsRefreshing] = useState19(false);
|
|
7950
8118
|
const isFetchingRef = useRef13(false);
|
|
7951
8119
|
const hasQuoteRef = useRef13(false);
|
|
7952
8120
|
const fetchIdRef = useRef13(0);
|
|
7953
|
-
|
|
8121
|
+
useEffect17(() => {
|
|
7954
8122
|
if (!isReady) return;
|
|
7955
8123
|
if (!enabled) {
|
|
7956
8124
|
setIsLoading(false);
|
|
@@ -8020,7 +8188,7 @@ function useSwapQuote(options) {
|
|
|
8020
8188
|
}
|
|
8021
8189
|
|
|
8022
8190
|
// src/client/hooks/checkout/superstate/swap/review/useSuperstateReviewViewModel.ts
|
|
8023
|
-
import { useEffect as
|
|
8191
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
|
8024
8192
|
function useSuperstateReviewViewModel({
|
|
8025
8193
|
stepInput,
|
|
8026
8194
|
contractAddress,
|
|
@@ -8030,11 +8198,11 @@ function useSuperstateReviewViewModel({
|
|
|
8030
8198
|
}) {
|
|
8031
8199
|
const { coinlist, isReady } = useCoinList();
|
|
8032
8200
|
const locale = useLocale();
|
|
8033
|
-
const [slippageBps, setSlippageBps] =
|
|
8034
|
-
const [slippageExpanded, setSlippageExpanded] =
|
|
8035
|
-
const [phase, setPhase] =
|
|
8036
|
-
const [error, setError] =
|
|
8037
|
-
|
|
8201
|
+
const [slippageBps, setSlippageBps] = useState20(DEFAULT_SLIPPAGE_BPS);
|
|
8202
|
+
const [slippageExpanded, setSlippageExpanded] = useState20(false);
|
|
8203
|
+
const [phase, setPhase] = useState20(null);
|
|
8204
|
+
const [error, setError] = useState20(null);
|
|
8205
|
+
useEffect18(() => {
|
|
8038
8206
|
if (stepInput.type === "incomplete") {
|
|
8039
8207
|
setSlippageBps(DEFAULT_SLIPPAGE_BPS);
|
|
8040
8208
|
setSlippageExpanded(false);
|
|
@@ -8363,7 +8531,7 @@ function priceUi(quote, outputToken, locale) {
|
|
|
8363
8531
|
}
|
|
8364
8532
|
|
|
8365
8533
|
// src/client/hooks/checkout/superstate/swap/wallet/useSuperstateWalletViewModel.ts
|
|
8366
|
-
import { useEffect as
|
|
8534
|
+
import { useEffect as useEffect19, useState as useState21 } from "react";
|
|
8367
8535
|
var CONNECT_FAILED2 = "Could not connect that wallet. Please try again.";
|
|
8368
8536
|
function useSuperstateWalletViewModel({
|
|
8369
8537
|
stepInput,
|
|
@@ -8376,12 +8544,12 @@ function useSuperstateWalletViewModel({
|
|
|
8376
8544
|
}) {
|
|
8377
8545
|
const { coinlist, isReady } = useCoinList();
|
|
8378
8546
|
const log = useLogger("useSuperstateWalletViewModel");
|
|
8379
|
-
const [selected, setSelected] =
|
|
8380
|
-
const [phase, setPhase] =
|
|
8381
|
-
const [error, setError] =
|
|
8547
|
+
const [selected, setSelected] = useState21(null);
|
|
8548
|
+
const [phase, setPhase] = useState21(null);
|
|
8549
|
+
const [error, setError] = useState21(null);
|
|
8382
8550
|
const networkName = getNetworkName(chain);
|
|
8383
8551
|
const selectedWallet = resolveWallet2(wallets, selected);
|
|
8384
|
-
|
|
8552
|
+
useEffect19(() => {
|
|
8385
8553
|
if (stepInput.type === "completed") {
|
|
8386
8554
|
setPhase(null);
|
|
8387
8555
|
setError(null);
|
|
@@ -8600,12 +8768,20 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8600
8768
|
}) {
|
|
8601
8769
|
const locale = useLocale();
|
|
8602
8770
|
const contractAddress = superstateSwapContractAddress(chain);
|
|
8603
|
-
const
|
|
8604
|
-
const [
|
|
8605
|
-
const [orderConfirmed, setOrderConfirmed] = useState21({ type: "hidden" });
|
|
8771
|
+
const [step, setStep] = useState22({ type: "wallet" });
|
|
8772
|
+
const [orderConfirmed, setOrderConfirmed] = useState22(null);
|
|
8606
8773
|
const { inputAmount, inputTokenAddress } = quoteInput(step, chain);
|
|
8607
8774
|
const live = enabled && contractAddress !== null;
|
|
8608
8775
|
const contract = contractAddress ?? NO_CONTRACT;
|
|
8776
|
+
const { state: offerTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
8777
|
+
offer,
|
|
8778
|
+
chain,
|
|
8779
|
+
enabled: live
|
|
8780
|
+
});
|
|
8781
|
+
const assetIconUrl = offerAssetIconUrl(
|
|
8782
|
+
offer,
|
|
8783
|
+
tokenMetadataOf(offerTokenMetadataState)
|
|
8784
|
+
);
|
|
8609
8785
|
const { outputTokenState, refetch: refetchOutputToken } = useSwapOutputToken({
|
|
8610
8786
|
contractAddress: contract,
|
|
8611
8787
|
chain,
|
|
@@ -8662,9 +8838,7 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8662
8838
|
chain,
|
|
8663
8839
|
assetIconUrl,
|
|
8664
8840
|
onComplete: (order) => {
|
|
8665
|
-
setOrderConfirmed(
|
|
8666
|
-
toOrderConfirmedUi3({ order, chain, locale, assetIconUrl })
|
|
8667
|
-
);
|
|
8841
|
+
setOrderConfirmed(order);
|
|
8668
8842
|
setStep({ type: "wallet" });
|
|
8669
8843
|
onOrderConfirmed?.(order);
|
|
8670
8844
|
}
|
|
@@ -8690,7 +8864,15 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8690
8864
|
amount: amountState,
|
|
8691
8865
|
review: reviewState,
|
|
8692
8866
|
sidebar: sidebarState,
|
|
8693
|
-
|
|
8867
|
+
// Derived here rather than in the review completion callback, so a
|
|
8868
|
+
// registry lookup that settles while the order is being placed still
|
|
8869
|
+
// reaches the dialog instead of the fallback icon that closure captured.
|
|
8870
|
+
orderConfirmed: orderConfirmed === null ? { type: "hidden" } : toOrderConfirmedUi3({
|
|
8871
|
+
order: orderConfirmed,
|
|
8872
|
+
chain,
|
|
8873
|
+
locale,
|
|
8874
|
+
assetIconUrl
|
|
8875
|
+
})
|
|
8694
8876
|
};
|
|
8695
8877
|
};
|
|
8696
8878
|
const onEvent = (event) => {
|
|
@@ -8715,7 +8897,7 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8715
8897
|
onReviewEvent(event);
|
|
8716
8898
|
return;
|
|
8717
8899
|
case "ON_CLOSE_ORDER_CONFIRMED":
|
|
8718
|
-
setOrderConfirmed(
|
|
8900
|
+
setOrderConfirmed(null);
|
|
8719
8901
|
return;
|
|
8720
8902
|
case "ON_RETRY_LOAD":
|
|
8721
8903
|
refetchOutputToken();
|
|
@@ -8830,7 +9012,7 @@ function CheckoutContainer({
|
|
|
8830
9012
|
enabled = true,
|
|
8831
9013
|
className
|
|
8832
9014
|
}) {
|
|
8833
|
-
const [side] =
|
|
9015
|
+
const [side] = useState23(() => config["ondo::swap"].side());
|
|
8834
9016
|
const isOndo = offer.type === "ondo::swap";
|
|
8835
9017
|
const ondoSymbol = config["ondo::swap"].symbol(offer);
|
|
8836
9018
|
const ondoBuy = useOndoBuyCheckoutViewModel({
|
|
@@ -9403,23 +9585,23 @@ function EmptyState() {
|
|
|
9403
9585
|
}
|
|
9404
9586
|
|
|
9405
9587
|
// src/client/hooks/offers/grid/useOffersGridViewModel.ts
|
|
9406
|
-
import { useCallback as
|
|
9588
|
+
import { useCallback as useCallback6, useMemo as useMemo4 } from "react";
|
|
9407
9589
|
|
|
9408
9590
|
// src/client/hooks/offers/data/useOffers.ts
|
|
9409
|
-
import { useEffect as
|
|
9410
|
-
var
|
|
9591
|
+
import { useEffect as useEffect20, useState as useState24 } from "react";
|
|
9592
|
+
var LOADING_STATE3 = { type: "LOADING" };
|
|
9411
9593
|
function useOffers(options = {}) {
|
|
9412
9594
|
const { coinlist, isReady } = useCoinList();
|
|
9413
9595
|
const log = useLogger("useOffers");
|
|
9414
9596
|
const { data: serverOffers } = options;
|
|
9415
|
-
const [offersState, setOffersState] =
|
|
9416
|
-
serverOffers !== void 0 ? { type: "CONTENT", offers: serverOffers } :
|
|
9597
|
+
const [offersState, setOffersState] = useState24(
|
|
9598
|
+
serverOffers !== void 0 ? { type: "CONTENT", offers: serverOffers } : LOADING_STATE3
|
|
9417
9599
|
);
|
|
9418
|
-
|
|
9600
|
+
useEffect20(() => {
|
|
9419
9601
|
let isCancelled = false;
|
|
9420
9602
|
if (!isReady) {
|
|
9421
9603
|
if (serverOffers === void 0) {
|
|
9422
|
-
setOffersState(
|
|
9604
|
+
setOffersState(LOADING_STATE3);
|
|
9423
9605
|
}
|
|
9424
9606
|
return () => {
|
|
9425
9607
|
isCancelled = true;
|
|
@@ -9430,7 +9612,7 @@ function useOffers(options = {}) {
|
|
|
9430
9612
|
isCancelled = true;
|
|
9431
9613
|
};
|
|
9432
9614
|
}
|
|
9433
|
-
setOffersState(
|
|
9615
|
+
setOffersState(LOADING_STATE3);
|
|
9434
9616
|
coinlist.offers.list().then((offers) => {
|
|
9435
9617
|
if (!isCancelled) {
|
|
9436
9618
|
log.debug(() => ({
|
|
@@ -9485,7 +9667,7 @@ function useOffersGridViewModel(options = {}) {
|
|
|
9485
9667
|
() => toUiState(offersState, onOfferClick !== void 0),
|
|
9486
9668
|
[offersState, onOfferClick]
|
|
9487
9669
|
);
|
|
9488
|
-
const onEvent =
|
|
9670
|
+
const onEvent = useCallback6(
|
|
9489
9671
|
(event) => {
|
|
9490
9672
|
switch (event.type) {
|
|
9491
9673
|
case "ON_OFFER_CLICK": {
|
|
@@ -9545,14 +9727,14 @@ function OffersGridContainer({
|
|
|
9545
9727
|
return /* @__PURE__ */ jsx55(OffersGridView, { state, onEvent, ...viewProps });
|
|
9546
9728
|
}
|
|
9547
9729
|
|
|
9548
|
-
// src/client/components/requirements/
|
|
9549
|
-
import { useState as
|
|
9730
|
+
// src/client/components/requirements/ConnectedWalletList.tsx
|
|
9731
|
+
import { useState as useState25 } from "react";
|
|
9550
9732
|
import { jsx as jsx56, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
9551
9733
|
function ConnectedWalletRow({
|
|
9552
9734
|
wallet,
|
|
9553
9735
|
onRemove
|
|
9554
9736
|
}) {
|
|
9555
|
-
const [state, setState] =
|
|
9737
|
+
const [state, setState] = useState25("idle");
|
|
9556
9738
|
const remove = async () => {
|
|
9557
9739
|
if (!onRemove) return;
|
|
9558
9740
|
setState("removing");
|
|
@@ -9661,106 +9843,322 @@ function ConnectedWalletListBody({
|
|
|
9661
9843
|
);
|
|
9662
9844
|
}
|
|
9663
9845
|
|
|
9664
|
-
// src/client/components/requirements/
|
|
9665
|
-
import
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
9670
|
-
var statusConfig = {
|
|
9671
|
-
required: {
|
|
9672
|
-
Icon: Info5,
|
|
9673
|
-
colorClass: "clcosdk:text-warning",
|
|
9674
|
-
fillClass: "clcosdk:[&_circle]:fill-warning-subtle"
|
|
9675
|
-
},
|
|
9676
|
-
pending: {
|
|
9677
|
-
Icon: Info5,
|
|
9678
|
-
colorClass: "clcosdk:text-warning",
|
|
9679
|
-
fillClass: "clcosdk:[&_circle]:fill-warning-subtle"
|
|
9680
|
-
},
|
|
9681
|
-
completed: {
|
|
9682
|
-
Icon: CircleCheck2,
|
|
9683
|
-
colorClass: "clcosdk:text-success",
|
|
9684
|
-
fillClass: "clcosdk:[&_circle]:fill-success-subtle"
|
|
9685
|
-
},
|
|
9686
|
-
rejected: {
|
|
9687
|
-
Icon: CircleX,
|
|
9688
|
-
colorClass: "clcosdk:text-error",
|
|
9689
|
-
fillClass: "clcosdk:[&_circle]:fill-error-subtle"
|
|
9690
|
-
}
|
|
9691
|
-
};
|
|
9692
|
-
function StepStatusIcon({ status, className }) {
|
|
9693
|
-
const { Icon, colorClass, fillClass } = statusConfig[status];
|
|
9694
|
-
return /* @__PURE__ */ jsx57(
|
|
9695
|
-
Icon,
|
|
9696
|
-
{
|
|
9697
|
-
className: cn(
|
|
9698
|
-
"clcosdk:h-6 clcosdk:w-6 clcosdk:shrink-0",
|
|
9699
|
-
colorClass,
|
|
9700
|
-
fillClass,
|
|
9701
|
-
className
|
|
9702
|
-
),
|
|
9703
|
-
"aria-hidden": "true"
|
|
9704
|
-
}
|
|
9705
|
-
);
|
|
9846
|
+
// src/client/components/requirements/identity-verification/IdentityVerificationView.tsx
|
|
9847
|
+
import SumsubWebSdk from "@sumsub/websdk-react";
|
|
9848
|
+
import { jsx as jsx57, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
9849
|
+
function IdentityVerificationView(props) {
|
|
9850
|
+
return /* @__PURE__ */ jsx57(CoinListStyleScope, { children: /* @__PURE__ */ jsx57(IdentityVerificationViewBody, { ...props }) });
|
|
9706
9851
|
}
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
status,
|
|
9712
|
-
onAction,
|
|
9713
|
-
onContactSupport
|
|
9852
|
+
function IdentityVerificationViewBody({
|
|
9853
|
+
state,
|
|
9854
|
+
onEvent,
|
|
9855
|
+
className
|
|
9714
9856
|
}) {
|
|
9715
|
-
switch (
|
|
9716
|
-
case "
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
case "pending":
|
|
9720
|
-
return /* @__PURE__ */ jsx58(
|
|
9721
|
-
AlertBanner,
|
|
9857
|
+
switch (state.type) {
|
|
9858
|
+
case "loading":
|
|
9859
|
+
return /* @__PURE__ */ jsx57(
|
|
9860
|
+
"output",
|
|
9722
9861
|
{
|
|
9723
|
-
|
|
9724
|
-
|
|
9862
|
+
"aria-live": "polite",
|
|
9863
|
+
className: cn(
|
|
9864
|
+
"clcosdk:flex clcosdk:min-h-40 clcosdk:items-center clcosdk:justify-center",
|
|
9865
|
+
className
|
|
9866
|
+
),
|
|
9867
|
+
children: /* @__PURE__ */ jsx57("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: "Loading identity verification..." })
|
|
9725
9868
|
}
|
|
9726
9869
|
);
|
|
9727
|
-
case "
|
|
9728
|
-
return /* @__PURE__ */
|
|
9729
|
-
|
|
9730
|
-
return /* @__PURE__ */ jsx58(
|
|
9731
|
-
AlertBanner,
|
|
9870
|
+
case "error":
|
|
9871
|
+
return /* @__PURE__ */ jsxs41(
|
|
9872
|
+
"div",
|
|
9732
9873
|
{
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
onClick: onContactSupport,
|
|
9742
|
-
className: "clcosdk:underline",
|
|
9743
|
-
children: "Contact support"
|
|
9744
|
-
}
|
|
9745
|
-
),
|
|
9746
|
-
"."
|
|
9747
|
-
] })
|
|
9874
|
+
className: cn(
|
|
9875
|
+
"clcosdk:flex clcosdk:flex-col clcosdk:gap-4",
|
|
9876
|
+
className
|
|
9877
|
+
),
|
|
9878
|
+
children: [
|
|
9879
|
+
/* @__PURE__ */ jsx57(AlertBanner, { variant: "error", icon: true, content: state.message }),
|
|
9880
|
+
state.retryable && /* @__PURE__ */ jsx57(ClButton, { size: "sm", onClick: () => onEvent({ type: "ON_RETRY" }), children: "Try again" })
|
|
9881
|
+
]
|
|
9748
9882
|
}
|
|
9749
9883
|
);
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9884
|
+
case "ready":
|
|
9885
|
+
return /* @__PURE__ */ jsx57("div", { className: cn("clcosdk:w-full", className), children: /* @__PURE__ */ jsx57(
|
|
9886
|
+
SumsubWebSdk,
|
|
9887
|
+
{
|
|
9888
|
+
accessToken: state.accessToken,
|
|
9889
|
+
expirationHandler: state.refreshToken,
|
|
9890
|
+
config: state.locale === void 0 ? {} : { lang: state.locale },
|
|
9891
|
+
options: { addViewportTag: false, adaptIframeHeight: true },
|
|
9892
|
+
onMessage: (type, payload) => {
|
|
9893
|
+
onSumsubMessage(type, payload, onEvent);
|
|
9894
|
+
},
|
|
9895
|
+
onError: (error) => {
|
|
9896
|
+
onEvent({ type: "ON_ERROR", error: toError(error) });
|
|
9897
|
+
}
|
|
9898
|
+
}
|
|
9899
|
+
) });
|
|
9900
|
+
default: {
|
|
9901
|
+
const exhaustive = state;
|
|
9902
|
+
return exhaustive;
|
|
9903
|
+
}
|
|
9904
|
+
}
|
|
9905
|
+
}
|
|
9906
|
+
function onSumsubMessage(type, payload, onEvent) {
|
|
9907
|
+
switch (type) {
|
|
9908
|
+
case "idCheck.onApplicantSubmitted":
|
|
9909
|
+
onEvent({ type: "ON_SUBMITTED" });
|
|
9910
|
+
return;
|
|
9911
|
+
case "idCheck.onError": {
|
|
9912
|
+
const message = payload?.message ?? "Verification error";
|
|
9913
|
+
onEvent({ type: "ON_ERROR", error: new Error(message) });
|
|
9914
|
+
return;
|
|
9915
|
+
}
|
|
9916
|
+
default:
|
|
9917
|
+
return;
|
|
9918
|
+
}
|
|
9919
|
+
}
|
|
9920
|
+
function toError(error) {
|
|
9921
|
+
return error instanceof Error ? error : new Error("Verification error");
|
|
9922
|
+
}
|
|
9923
|
+
|
|
9924
|
+
// src/client/hooks/requirements/identity-verification/useIdentityVerificationViewModel.ts
|
|
9925
|
+
import { useCallback as useCallback8, useEffect as useEffect22, useMemo as useMemo5, useRef as useRef15 } from "react";
|
|
9926
|
+
|
|
9927
|
+
// src/client/hooks/requirements/data/useKycToken.ts
|
|
9928
|
+
import { useCallback as useCallback7, useEffect as useEffect21, useRef as useRef14, useState as useState26 } from "react";
|
|
9929
|
+
var IDLE_STATE = { type: "IDLE" };
|
|
9930
|
+
var LOADING_STATE4 = { type: "LOADING" };
|
|
9931
|
+
function useKycToken(levelName, reset) {
|
|
9932
|
+
const { coinlist } = useCoinList();
|
|
9933
|
+
const log = useLogger("useKycToken");
|
|
9934
|
+
const [kycTokenState, setKycTokenState] = useState26(IDLE_STATE);
|
|
9935
|
+
const resetPendingRef = useRef14(reset === true);
|
|
9936
|
+
const tokenIssuedRef = useRef14(false);
|
|
9937
|
+
useEffect21(() => {
|
|
9938
|
+
if (!tokenIssuedRef.current) {
|
|
9939
|
+
resetPendingRef.current = reset === true;
|
|
9940
|
+
}
|
|
9941
|
+
}, [reset]);
|
|
9942
|
+
const fetchToken = useCallback7(async () => {
|
|
9943
|
+
setKycTokenState(LOADING_STATE4);
|
|
9944
|
+
try {
|
|
9945
|
+
const kycToken = await coinlist.requirements.createKycToken({
|
|
9946
|
+
levelName,
|
|
9947
|
+
reset: resetPendingRef.current
|
|
9948
|
+
});
|
|
9949
|
+
resetPendingRef.current = false;
|
|
9950
|
+
tokenIssuedRef.current = true;
|
|
9951
|
+
log.debug(() => ({
|
|
9952
|
+
msg: "settled",
|
|
9953
|
+
fields: { state: "CONTENT" }
|
|
9954
|
+
}));
|
|
9955
|
+
setKycTokenState({ type: "CONTENT", token: kycToken.token });
|
|
9956
|
+
return kycToken.token;
|
|
9957
|
+
} catch (error) {
|
|
9958
|
+
const reason = error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
|
|
9959
|
+
log.failure(
|
|
9960
|
+
() => ({ msg: "settled", fields: { state: "ERROR", reason } }),
|
|
9961
|
+
error
|
|
9962
|
+
);
|
|
9963
|
+
setKycTokenState({ type: "ERROR", reason });
|
|
9964
|
+
throw error;
|
|
9965
|
+
}
|
|
9966
|
+
}, [coinlist, levelName, log]);
|
|
9967
|
+
return { kycTokenState, fetchToken };
|
|
9968
|
+
}
|
|
9969
|
+
|
|
9970
|
+
// src/client/hooks/requirements/identity-verification/useIdentityVerificationViewModel.ts
|
|
9971
|
+
var NOT_AUTHENTICATED_MESSAGE2 = "Sign in to verify your identity.";
|
|
9972
|
+
var GENERIC_ERROR_MESSAGE2 = "Unable to start identity verification right now. Please try again.";
|
|
9973
|
+
function useIdentityVerificationViewModel(options = {}) {
|
|
9974
|
+
const { levelName, reset, locale, onSubmitted, onError } = options;
|
|
9975
|
+
const { kycTokenState, fetchToken } = useKycToken(levelName, reset);
|
|
9976
|
+
const fetchedRef = useRef15(false);
|
|
9977
|
+
useEffect22(() => {
|
|
9978
|
+
if (fetchedRef.current) {
|
|
9979
|
+
return;
|
|
9980
|
+
}
|
|
9981
|
+
fetchedRef.current = true;
|
|
9982
|
+
fetchToken().catch(() => {
|
|
9983
|
+
});
|
|
9984
|
+
}, [fetchToken]);
|
|
9985
|
+
const state = useMemo5(() => {
|
|
9986
|
+
switch (kycTokenState.type) {
|
|
9987
|
+
case "IDLE":
|
|
9988
|
+
case "LOADING":
|
|
9989
|
+
return { type: "loading" };
|
|
9990
|
+
case "ERROR": {
|
|
9991
|
+
const notAuthenticated = kycTokenState.reason === "not-authenticated";
|
|
9992
|
+
return {
|
|
9993
|
+
type: "error",
|
|
9994
|
+
message: notAuthenticated ? NOT_AUTHENTICATED_MESSAGE2 : GENERIC_ERROR_MESSAGE2,
|
|
9995
|
+
retryable: !notAuthenticated
|
|
9996
|
+
};
|
|
9997
|
+
}
|
|
9998
|
+
case "CONTENT":
|
|
9999
|
+
return {
|
|
10000
|
+
type: "ready",
|
|
10001
|
+
accessToken: kycTokenState.token,
|
|
10002
|
+
locale,
|
|
10003
|
+
refreshToken: fetchToken
|
|
10004
|
+
};
|
|
10005
|
+
default: {
|
|
10006
|
+
const exhaustive = kycTokenState;
|
|
10007
|
+
return exhaustive;
|
|
10008
|
+
}
|
|
10009
|
+
}
|
|
10010
|
+
}, [kycTokenState, locale, fetchToken]);
|
|
10011
|
+
const onEvent = useCallback8(
|
|
10012
|
+
(event) => {
|
|
10013
|
+
switch (event.type) {
|
|
10014
|
+
case "ON_RETRY":
|
|
10015
|
+
fetchToken().catch(() => {
|
|
10016
|
+
});
|
|
10017
|
+
return;
|
|
10018
|
+
case "ON_SUBMITTED":
|
|
10019
|
+
onSubmitted?.();
|
|
10020
|
+
return;
|
|
10021
|
+
case "ON_ERROR":
|
|
10022
|
+
onError?.(event.error);
|
|
10023
|
+
return;
|
|
10024
|
+
default: {
|
|
10025
|
+
const exhaustive = event;
|
|
10026
|
+
return exhaustive;
|
|
10027
|
+
}
|
|
10028
|
+
}
|
|
10029
|
+
},
|
|
10030
|
+
[fetchToken, onSubmitted, onError]
|
|
10031
|
+
);
|
|
10032
|
+
return { state, onEvent };
|
|
10033
|
+
}
|
|
10034
|
+
|
|
10035
|
+
// src/client/components/requirements/identity-verification/IdentityVerificationContainer.tsx
|
|
10036
|
+
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
10037
|
+
function IdentityVerificationContainer({
|
|
10038
|
+
levelName,
|
|
10039
|
+
reset,
|
|
10040
|
+
locale,
|
|
10041
|
+
onSubmitted,
|
|
10042
|
+
onError,
|
|
10043
|
+
className
|
|
10044
|
+
}) {
|
|
10045
|
+
const { state, onEvent } = useIdentityVerificationViewModel({
|
|
10046
|
+
levelName,
|
|
10047
|
+
reset,
|
|
10048
|
+
locale,
|
|
10049
|
+
onSubmitted,
|
|
10050
|
+
onError
|
|
10051
|
+
});
|
|
10052
|
+
return /* @__PURE__ */ jsx58(
|
|
10053
|
+
IdentityVerificationView,
|
|
10054
|
+
{
|
|
10055
|
+
state,
|
|
10056
|
+
onEvent,
|
|
10057
|
+
className
|
|
10058
|
+
}
|
|
10059
|
+
);
|
|
10060
|
+
}
|
|
10061
|
+
|
|
10062
|
+
// src/client/components/requirements/RequirementItem.tsx
|
|
10063
|
+
import { ChevronRight } from "lucide-react";
|
|
10064
|
+
|
|
10065
|
+
// src/client/components/design-system/StepStatusIcon.tsx
|
|
10066
|
+
import { CircleCheck as CircleCheck2, CircleX, Info as Info5 } from "lucide-react";
|
|
10067
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
10068
|
+
var statusConfig = {
|
|
10069
|
+
required: {
|
|
10070
|
+
Icon: Info5,
|
|
10071
|
+
colorClass: "clcosdk:text-warning",
|
|
10072
|
+
fillClass: "clcosdk:[&_circle]:fill-warning-subtle"
|
|
10073
|
+
},
|
|
10074
|
+
pending: {
|
|
10075
|
+
Icon: Info5,
|
|
10076
|
+
colorClass: "clcosdk:text-warning",
|
|
10077
|
+
fillClass: "clcosdk:[&_circle]:fill-warning-subtle"
|
|
10078
|
+
},
|
|
10079
|
+
completed: {
|
|
10080
|
+
Icon: CircleCheck2,
|
|
10081
|
+
colorClass: "clcosdk:text-success",
|
|
10082
|
+
fillClass: "clcosdk:[&_circle]:fill-success-subtle"
|
|
10083
|
+
},
|
|
10084
|
+
rejected: {
|
|
10085
|
+
Icon: CircleX,
|
|
10086
|
+
colorClass: "clcosdk:text-error",
|
|
10087
|
+
fillClass: "clcosdk:[&_circle]:fill-error-subtle"
|
|
10088
|
+
}
|
|
10089
|
+
};
|
|
10090
|
+
function StepStatusIcon({ status, className }) {
|
|
10091
|
+
const { Icon, colorClass, fillClass } = statusConfig[status];
|
|
10092
|
+
return /* @__PURE__ */ jsx59(
|
|
10093
|
+
Icon,
|
|
10094
|
+
{
|
|
10095
|
+
className: cn(
|
|
10096
|
+
"clcosdk:h-6 clcosdk:w-6 clcosdk:shrink-0",
|
|
10097
|
+
colorClass,
|
|
10098
|
+
fillClass,
|
|
10099
|
+
className
|
|
10100
|
+
),
|
|
10101
|
+
"aria-hidden": "true"
|
|
10102
|
+
}
|
|
10103
|
+
);
|
|
10104
|
+
}
|
|
10105
|
+
|
|
10106
|
+
// src/client/components/requirements/RequirementItem.tsx
|
|
10107
|
+
import { Fragment as Fragment9, jsx as jsx60, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
10108
|
+
function VerificationActionZone({
|
|
10109
|
+
status,
|
|
10110
|
+
onAction,
|
|
10111
|
+
onContactSupport
|
|
10112
|
+
}) {
|
|
10113
|
+
switch (status) {
|
|
10114
|
+
case "required":
|
|
10115
|
+
if (onAction === null) return null;
|
|
10116
|
+
return /* @__PURE__ */ jsx60(ClButton, { size: "sm", onClick: onAction, children: "Continue" });
|
|
10117
|
+
case "pending":
|
|
10118
|
+
return /* @__PURE__ */ jsx60(
|
|
10119
|
+
AlertBanner,
|
|
10120
|
+
{
|
|
10121
|
+
variant: "warning",
|
|
10122
|
+
content: "Under review. We'll notify you when complete."
|
|
10123
|
+
}
|
|
10124
|
+
);
|
|
10125
|
+
case "completed":
|
|
10126
|
+
return /* @__PURE__ */ jsx60(AlertBanner, { variant: "success", content: "Identity verified." });
|
|
10127
|
+
case "rejected":
|
|
10128
|
+
return /* @__PURE__ */ jsx60(
|
|
10129
|
+
AlertBanner,
|
|
10130
|
+
{
|
|
10131
|
+
variant: "error",
|
|
10132
|
+
content: onContactSupport === null ? "Verification rejected." : /* @__PURE__ */ jsxs42(Fragment9, { children: [
|
|
10133
|
+
"Verification rejected.",
|
|
10134
|
+
" ",
|
|
10135
|
+
/* @__PURE__ */ jsx60(
|
|
10136
|
+
"button",
|
|
10137
|
+
{
|
|
10138
|
+
type: "button",
|
|
10139
|
+
onClick: onContactSupport,
|
|
10140
|
+
className: "clcosdk:underline",
|
|
10141
|
+
children: "Contact support"
|
|
10142
|
+
}
|
|
10143
|
+
),
|
|
10144
|
+
"."
|
|
10145
|
+
] })
|
|
10146
|
+
}
|
|
10147
|
+
);
|
|
10148
|
+
}
|
|
10149
|
+
}
|
|
10150
|
+
function WalletActionZone({
|
|
10151
|
+
status,
|
|
10152
|
+
multiWallet,
|
|
10153
|
+
connectedWallets,
|
|
10154
|
+
walletsStatus,
|
|
10155
|
+
onAction,
|
|
10156
|
+
onRemoveWallet
|
|
10157
|
+
}) {
|
|
10158
|
+
if (multiWallet) {
|
|
10159
|
+
return /* @__PURE__ */ jsxs42(Fragment9, { children: [
|
|
10160
|
+
/* @__PURE__ */ jsx60(
|
|
10161
|
+
ConnectedWalletList,
|
|
9764
10162
|
{
|
|
9765
10163
|
wallets: connectedWallets,
|
|
9766
10164
|
onRemove: onRemoveWallet,
|
|
@@ -9768,7 +10166,7 @@ function WalletActionZone({
|
|
|
9768
10166
|
status: walletsStatus
|
|
9769
10167
|
}
|
|
9770
10168
|
),
|
|
9771
|
-
status === "rejected" && /* @__PURE__ */
|
|
10169
|
+
status === "rejected" && /* @__PURE__ */ jsx60(
|
|
9772
10170
|
AlertBanner,
|
|
9773
10171
|
{
|
|
9774
10172
|
variant: "error",
|
|
@@ -9779,21 +10177,21 @@ function WalletActionZone({
|
|
|
9779
10177
|
}
|
|
9780
10178
|
if (status === "completed") {
|
|
9781
10179
|
const connected = connectedWallets[0];
|
|
9782
|
-
return /* @__PURE__ */
|
|
9783
|
-
onAction !== null && /* @__PURE__ */
|
|
9784
|
-
walletsStatus === "loading" ? /* @__PURE__ */
|
|
10180
|
+
return /* @__PURE__ */ jsxs42(Fragment9, { children: [
|
|
10181
|
+
onAction !== null && /* @__PURE__ */ jsx60(ClButton, { size: "sm", variant: "secondary", onClick: onAction, children: "Change wallet" }),
|
|
10182
|
+
walletsStatus === "loading" ? /* @__PURE__ */ jsx60(
|
|
9785
10183
|
AlertBanner,
|
|
9786
10184
|
{
|
|
9787
10185
|
variant: "info",
|
|
9788
10186
|
content: "Loading your connected wallet\u2026"
|
|
9789
10187
|
}
|
|
9790
|
-
) : walletsStatus === "error" ? /* @__PURE__ */
|
|
10188
|
+
) : walletsStatus === "error" ? /* @__PURE__ */ jsx60(
|
|
9791
10189
|
AlertBanner,
|
|
9792
10190
|
{
|
|
9793
10191
|
variant: "error",
|
|
9794
10192
|
content: "Couldn't load your connected wallet."
|
|
9795
10193
|
}
|
|
9796
|
-
) : /* @__PURE__ */
|
|
10194
|
+
) : /* @__PURE__ */ jsx60(
|
|
9797
10195
|
AlertBanner,
|
|
9798
10196
|
{
|
|
9799
10197
|
variant: "success",
|
|
@@ -9803,9 +10201,9 @@ function WalletActionZone({
|
|
|
9803
10201
|
] });
|
|
9804
10202
|
}
|
|
9805
10203
|
if (status === "rejected") {
|
|
9806
|
-
return /* @__PURE__ */
|
|
9807
|
-
onAction !== null && /* @__PURE__ */
|
|
9808
|
-
/* @__PURE__ */
|
|
10204
|
+
return /* @__PURE__ */ jsxs42(Fragment9, { children: [
|
|
10205
|
+
onAction !== null && /* @__PURE__ */ jsx60(ClButton, { size: "sm", onClick: onAction, children: "Connect wallet" }),
|
|
10206
|
+
/* @__PURE__ */ jsx60(
|
|
9809
10207
|
AlertBanner,
|
|
9810
10208
|
{
|
|
9811
10209
|
variant: "error",
|
|
@@ -9815,7 +10213,7 @@ function WalletActionZone({
|
|
|
9815
10213
|
] });
|
|
9816
10214
|
}
|
|
9817
10215
|
if (onAction === null) return null;
|
|
9818
|
-
return /* @__PURE__ */
|
|
10216
|
+
return /* @__PURE__ */ jsx60(ClButton, { size: "sm", onClick: onAction, children: "Connect wallet" });
|
|
9819
10217
|
}
|
|
9820
10218
|
function RequirementItem({
|
|
9821
10219
|
ui,
|
|
@@ -9827,7 +10225,7 @@ function RequirementItem({
|
|
|
9827
10225
|
walletsStatus,
|
|
9828
10226
|
onContactSupport
|
|
9829
10227
|
}) {
|
|
9830
|
-
return /* @__PURE__ */
|
|
10228
|
+
return /* @__PURE__ */ jsx60(CoinListStyleScope, { children: /* @__PURE__ */ jsxs42(
|
|
9831
10229
|
"div",
|
|
9832
10230
|
{
|
|
9833
10231
|
className: cn(
|
|
@@ -9835,7 +10233,7 @@ function RequirementItem({
|
|
|
9835
10233
|
className
|
|
9836
10234
|
),
|
|
9837
10235
|
children: [
|
|
9838
|
-
/* @__PURE__ */
|
|
10236
|
+
/* @__PURE__ */ jsxs42(
|
|
9839
10237
|
"button",
|
|
9840
10238
|
{
|
|
9841
10239
|
type: "button",
|
|
@@ -9843,9 +10241,9 @@ function RequirementItem({
|
|
|
9843
10241
|
"aria-expanded": expanded,
|
|
9844
10242
|
className: "clcosdk:flex clcosdk:h-14 clcosdk:w-full clcosdk:cursor-pointer clcosdk:items-center clcosdk:justify-between clcosdk:rounded-2xl clcosdk:px-2 clcosdk:transition-colors clcosdk:hover:bg-surface",
|
|
9845
10243
|
children: [
|
|
9846
|
-
/* @__PURE__ */
|
|
9847
|
-
/* @__PURE__ */
|
|
9848
|
-
/* @__PURE__ */
|
|
10244
|
+
/* @__PURE__ */ jsxs42("div", { className: "clcosdk:flex clcosdk:items-center clcosdk:gap-3", children: [
|
|
10245
|
+
/* @__PURE__ */ jsx60(StepStatusIcon, { status: ui.status }),
|
|
10246
|
+
/* @__PURE__ */ jsx60(
|
|
9849
10247
|
"span",
|
|
9850
10248
|
{
|
|
9851
10249
|
className: cn(
|
|
@@ -9856,7 +10254,7 @@ function RequirementItem({
|
|
|
9856
10254
|
}
|
|
9857
10255
|
)
|
|
9858
10256
|
] }),
|
|
9859
|
-
/* @__PURE__ */
|
|
10257
|
+
/* @__PURE__ */ jsx60(
|
|
9860
10258
|
ChevronRight,
|
|
9861
10259
|
{
|
|
9862
10260
|
className: cn(
|
|
@@ -9869,15 +10267,15 @@ function RequirementItem({
|
|
|
9869
10267
|
]
|
|
9870
10268
|
}
|
|
9871
10269
|
),
|
|
9872
|
-
/* @__PURE__ */
|
|
10270
|
+
/* @__PURE__ */ jsx60(
|
|
9873
10271
|
"div",
|
|
9874
10272
|
{
|
|
9875
10273
|
className: cn(
|
|
9876
10274
|
"clcosdk:grid clcosdk:transition-[grid-template-rows] clcosdk:duration-300 clcosdk:ease-in-out",
|
|
9877
10275
|
expanded ? "clcosdk:grid-rows-[1fr]" : "clcosdk:grid-rows-[0fr]"
|
|
9878
10276
|
),
|
|
9879
|
-
children: /* @__PURE__ */
|
|
9880
|
-
/* @__PURE__ */
|
|
10277
|
+
children: /* @__PURE__ */ jsx60("div", { className: "clcosdk:min-h-0 clcosdk:overflow-hidden", children: /* @__PURE__ */ jsxs42("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-4 clcosdk:px-2 clcosdk:pb-4", children: [
|
|
10278
|
+
/* @__PURE__ */ jsx60(
|
|
9881
10279
|
"p",
|
|
9882
10280
|
{
|
|
9883
10281
|
className: cn(
|
|
@@ -9887,14 +10285,14 @@ function RequirementItem({
|
|
|
9887
10285
|
children: ui.description
|
|
9888
10286
|
}
|
|
9889
10287
|
),
|
|
9890
|
-
ui.variant === "verification" ? /* @__PURE__ */
|
|
10288
|
+
ui.variant === "verification" ? /* @__PURE__ */ jsx60(
|
|
9891
10289
|
VerificationActionZone,
|
|
9892
10290
|
{
|
|
9893
10291
|
status: ui.status,
|
|
9894
10292
|
onAction,
|
|
9895
10293
|
onContactSupport
|
|
9896
10294
|
}
|
|
9897
|
-
) : /* @__PURE__ */
|
|
10295
|
+
) : /* @__PURE__ */ jsx60(
|
|
9898
10296
|
WalletActionZone,
|
|
9899
10297
|
{
|
|
9900
10298
|
status: ui.status,
|
|
@@ -9913,10 +10311,10 @@ function RequirementItem({
|
|
|
9913
10311
|
) });
|
|
9914
10312
|
}
|
|
9915
10313
|
|
|
9916
|
-
// src/client/components/requirements/
|
|
9917
|
-
import { jsx as
|
|
10314
|
+
// src/client/components/requirements/RequirementsChecklistView.tsx
|
|
10315
|
+
import { jsx as jsx61, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
9918
10316
|
function RequirementsChecklistView(props) {
|
|
9919
|
-
return /* @__PURE__ */
|
|
10317
|
+
return /* @__PURE__ */ jsx61(CoinListStyleScope, { children: /* @__PURE__ */ jsx61(RequirementsChecklistViewBody, { ...props }) });
|
|
9920
10318
|
}
|
|
9921
10319
|
function RequirementsChecklistViewBody({
|
|
9922
10320
|
state,
|
|
@@ -9928,11 +10326,11 @@ function RequirementsChecklistViewBody({
|
|
|
9928
10326
|
}) {
|
|
9929
10327
|
switch (state.type) {
|
|
9930
10328
|
case "loading":
|
|
9931
|
-
return loading ?? /* @__PURE__ */
|
|
10329
|
+
return loading ?? /* @__PURE__ */ jsx61(LoadingState2, {});
|
|
9932
10330
|
case "not-authenticated":
|
|
9933
10331
|
return unauthenticatedState ?? null;
|
|
9934
10332
|
case "error":
|
|
9935
|
-
return error ?? /* @__PURE__ */
|
|
10333
|
+
return error ?? /* @__PURE__ */ jsx61(
|
|
9936
10334
|
AlertBanner,
|
|
9937
10335
|
{
|
|
9938
10336
|
variant: "error",
|
|
@@ -9942,7 +10340,7 @@ function RequirementsChecklistViewBody({
|
|
|
9942
10340
|
}
|
|
9943
10341
|
);
|
|
9944
10342
|
case "content":
|
|
9945
|
-
return /* @__PURE__ */
|
|
10343
|
+
return /* @__PURE__ */ jsxs43(
|
|
9946
10344
|
"div",
|
|
9947
10345
|
{
|
|
9948
10346
|
className: cn(
|
|
@@ -9950,11 +10348,11 @@ function RequirementsChecklistViewBody({
|
|
|
9950
10348
|
className
|
|
9951
10349
|
),
|
|
9952
10350
|
children: [
|
|
9953
|
-
/* @__PURE__ */
|
|
9954
|
-
/* @__PURE__ */
|
|
9955
|
-
/* @__PURE__ */
|
|
10351
|
+
/* @__PURE__ */ jsxs43("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-2", children: [
|
|
10352
|
+
/* @__PURE__ */ jsx61("h3", { className: cn(typeClasses.h3, "clcosdk:text-text-primary"), children: state.title }),
|
|
10353
|
+
/* @__PURE__ */ jsx61("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: state.description })
|
|
9956
10354
|
] }),
|
|
9957
|
-
/* @__PURE__ */
|
|
10355
|
+
/* @__PURE__ */ jsx61("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:divide-y clcosdk:divide-divider", children: state.items.map((row) => /* @__PURE__ */ jsx61(
|
|
9958
10356
|
RequirementItem,
|
|
9959
10357
|
{
|
|
9960
10358
|
ui: row.item,
|
|
@@ -9973,7 +10371,7 @@ function RequirementsChecklistViewBody({
|
|
|
9973
10371
|
},
|
|
9974
10372
|
row.id
|
|
9975
10373
|
)) }),
|
|
9976
|
-
state.ineligible && /* @__PURE__ */
|
|
10374
|
+
state.ineligible && /* @__PURE__ */ jsx61(
|
|
9977
10375
|
AlertBanner,
|
|
9978
10376
|
{
|
|
9979
10377
|
variant: "error",
|
|
@@ -9981,7 +10379,7 @@ function RequirementsChecklistViewBody({
|
|
|
9981
10379
|
content: "You are not eligible to participate."
|
|
9982
10380
|
}
|
|
9983
10381
|
),
|
|
9984
|
-
state.continueAction && /* @__PURE__ */
|
|
10382
|
+
state.continueAction && /* @__PURE__ */ jsx61(
|
|
9985
10383
|
ClButton,
|
|
9986
10384
|
{
|
|
9987
10385
|
fullWidth: true,
|
|
@@ -9993,274 +10391,25 @@ function RequirementsChecklistViewBody({
|
|
|
9993
10391
|
]
|
|
9994
10392
|
}
|
|
9995
10393
|
);
|
|
9996
|
-
default: {
|
|
9997
|
-
const exhaustive = state;
|
|
9998
|
-
return exhaustive;
|
|
9999
|
-
}
|
|
10000
|
-
}
|
|
10001
|
-
}
|
|
10002
|
-
function LoadingState2() {
|
|
10003
|
-
return /* @__PURE__ */ jsx59(
|
|
10004
|
-
"output",
|
|
10005
|
-
{
|
|
10006
|
-
"aria-live": "polite",
|
|
10007
|
-
className: "clcosdk:flex clcosdk:min-h-40 clcosdk:items-center clcosdk:justify-center clcosdk:rounded-2xl clcosdk:border clcosdk:border-border clcosdk:bg-background clcosdk:p-6",
|
|
10008
|
-
children: /* @__PURE__ */ jsx59("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: "Loading requirements..." })
|
|
10009
|
-
}
|
|
10010
|
-
);
|
|
10011
|
-
}
|
|
10012
|
-
|
|
10013
|
-
// src/client/components/requirements/checklist/VerificationOverlay.tsx
|
|
10014
|
-
import { jsx as jsx60, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
10015
|
-
function VerificationOverlay({
|
|
10016
|
-
onClose,
|
|
10017
|
-
children
|
|
10018
|
-
}) {
|
|
10019
|
-
return /* @__PURE__ */ jsx60(CoinListStyleScope, { children: /* @__PURE__ */ jsx60(VerificationOverlayBody, { onClose, children }) });
|
|
10020
|
-
}
|
|
10021
|
-
function VerificationOverlayBody({
|
|
10022
|
-
onClose,
|
|
10023
|
-
children
|
|
10024
|
-
}) {
|
|
10025
|
-
return /* @__PURE__ */ jsx60(
|
|
10026
|
-
"div",
|
|
10027
|
-
{
|
|
10028
|
-
role: "dialog",
|
|
10029
|
-
"aria-modal": "true",
|
|
10030
|
-
"aria-label": "Identity verification",
|
|
10031
|
-
className: "clcosdk:fixed clcosdk:inset-0 clcosdk:z-50 clcosdk:flex clcosdk:items-center clcosdk:justify-center clcosdk:bg-overlay clcosdk:p-4",
|
|
10032
|
-
children: /* @__PURE__ */ jsxs43("div", { className: "clcosdk:relative clcosdk:flex clcosdk:max-h-[92vh] clcosdk:w-full clcosdk:max-w-[760px] clcosdk:flex-col clcosdk:overflow-y-auto clcosdk:rounded-2xl clcosdk:bg-background clcosdk:p-6 clcosdk:pt-14", children: [
|
|
10033
|
-
/* @__PURE__ */ jsx60(
|
|
10034
|
-
CloseButton,
|
|
10035
|
-
{
|
|
10036
|
-
onClick: onClose,
|
|
10037
|
-
className: "clcosdk:absolute clcosdk:top-4 clcosdk:right-4"
|
|
10038
|
-
}
|
|
10039
|
-
),
|
|
10040
|
-
children
|
|
10041
|
-
] })
|
|
10042
|
-
}
|
|
10043
|
-
);
|
|
10044
|
-
}
|
|
10045
|
-
|
|
10046
|
-
// src/client/components/requirements/identity-verification/IdentityVerificationView.tsx
|
|
10047
|
-
import SumsubWebSdk from "@sumsub/websdk-react";
|
|
10048
|
-
import { jsx as jsx61, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
10049
|
-
function IdentityVerificationView(props) {
|
|
10050
|
-
return /* @__PURE__ */ jsx61(CoinListStyleScope, { children: /* @__PURE__ */ jsx61(IdentityVerificationViewBody, { ...props }) });
|
|
10051
|
-
}
|
|
10052
|
-
function IdentityVerificationViewBody({
|
|
10053
|
-
state,
|
|
10054
|
-
onEvent,
|
|
10055
|
-
className
|
|
10056
|
-
}) {
|
|
10057
|
-
switch (state.type) {
|
|
10058
|
-
case "loading":
|
|
10059
|
-
return /* @__PURE__ */ jsx61(
|
|
10060
|
-
"output",
|
|
10061
|
-
{
|
|
10062
|
-
"aria-live": "polite",
|
|
10063
|
-
className: cn(
|
|
10064
|
-
"clcosdk:flex clcosdk:min-h-40 clcosdk:items-center clcosdk:justify-center",
|
|
10065
|
-
className
|
|
10066
|
-
),
|
|
10067
|
-
children: /* @__PURE__ */ jsx61("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: "Loading identity verification..." })
|
|
10068
|
-
}
|
|
10069
|
-
);
|
|
10070
|
-
case "error":
|
|
10071
|
-
return /* @__PURE__ */ jsxs44(
|
|
10072
|
-
"div",
|
|
10073
|
-
{
|
|
10074
|
-
className: cn(
|
|
10075
|
-
"clcosdk:flex clcosdk:flex-col clcosdk:gap-4",
|
|
10076
|
-
className
|
|
10077
|
-
),
|
|
10078
|
-
children: [
|
|
10079
|
-
/* @__PURE__ */ jsx61(AlertBanner, { variant: "error", icon: true, content: state.message }),
|
|
10080
|
-
state.retryable && /* @__PURE__ */ jsx61(ClButton, { size: "sm", onClick: () => onEvent({ type: "ON_RETRY" }), children: "Try again" })
|
|
10081
|
-
]
|
|
10082
|
-
}
|
|
10083
|
-
);
|
|
10084
|
-
case "ready":
|
|
10085
|
-
return /* @__PURE__ */ jsx61("div", { className: cn("clcosdk:w-full", className), children: /* @__PURE__ */ jsx61(
|
|
10086
|
-
SumsubWebSdk,
|
|
10087
|
-
{
|
|
10088
|
-
accessToken: state.accessToken,
|
|
10089
|
-
expirationHandler: state.refreshToken,
|
|
10090
|
-
config: state.locale === void 0 ? {} : { lang: state.locale },
|
|
10091
|
-
options: { addViewportTag: false, adaptIframeHeight: true },
|
|
10092
|
-
onMessage: (type, payload) => {
|
|
10093
|
-
onSumsubMessage(type, payload, onEvent);
|
|
10094
|
-
},
|
|
10095
|
-
onError: (error) => {
|
|
10096
|
-
onEvent({ type: "ON_ERROR", error: toError(error) });
|
|
10097
|
-
}
|
|
10098
|
-
}
|
|
10099
|
-
) });
|
|
10100
|
-
default: {
|
|
10101
|
-
const exhaustive = state;
|
|
10102
|
-
return exhaustive;
|
|
10103
|
-
}
|
|
10104
|
-
}
|
|
10105
|
-
}
|
|
10106
|
-
function onSumsubMessage(type, payload, onEvent) {
|
|
10107
|
-
switch (type) {
|
|
10108
|
-
case "idCheck.onApplicantSubmitted":
|
|
10109
|
-
onEvent({ type: "ON_SUBMITTED" });
|
|
10110
|
-
return;
|
|
10111
|
-
case "idCheck.onError": {
|
|
10112
|
-
const message = payload?.message ?? "Verification error";
|
|
10113
|
-
onEvent({ type: "ON_ERROR", error: new Error(message) });
|
|
10114
|
-
return;
|
|
10115
|
-
}
|
|
10116
|
-
default:
|
|
10117
|
-
return;
|
|
10118
|
-
}
|
|
10119
|
-
}
|
|
10120
|
-
function toError(error) {
|
|
10121
|
-
return error instanceof Error ? error : new Error("Verification error");
|
|
10122
|
-
}
|
|
10123
|
-
|
|
10124
|
-
// src/client/hooks/requirements/identity-verification/useIdentityVerificationViewModel.ts
|
|
10125
|
-
import { useCallback as useCallback7, useEffect as useEffect21, useMemo as useMemo5, useRef as useRef15 } from "react";
|
|
10126
|
-
|
|
10127
|
-
// src/client/hooks/requirements/data/useKycToken.ts
|
|
10128
|
-
import { useCallback as useCallback6, useEffect as useEffect20, useRef as useRef14, useState as useState25 } from "react";
|
|
10129
|
-
var IDLE_STATE = { type: "IDLE" };
|
|
10130
|
-
var LOADING_STATE3 = { type: "LOADING" };
|
|
10131
|
-
function useKycToken(levelName, reset) {
|
|
10132
|
-
const { coinlist } = useCoinList();
|
|
10133
|
-
const log = useLogger("useKycToken");
|
|
10134
|
-
const [kycTokenState, setKycTokenState] = useState25(IDLE_STATE);
|
|
10135
|
-
const resetPendingRef = useRef14(reset === true);
|
|
10136
|
-
const tokenIssuedRef = useRef14(false);
|
|
10137
|
-
useEffect20(() => {
|
|
10138
|
-
if (!tokenIssuedRef.current) {
|
|
10139
|
-
resetPendingRef.current = reset === true;
|
|
10140
|
-
}
|
|
10141
|
-
}, [reset]);
|
|
10142
|
-
const fetchToken = useCallback6(async () => {
|
|
10143
|
-
setKycTokenState(LOADING_STATE3);
|
|
10144
|
-
try {
|
|
10145
|
-
const kycToken = await coinlist.requirements.createKycToken({
|
|
10146
|
-
levelName,
|
|
10147
|
-
reset: resetPendingRef.current
|
|
10148
|
-
});
|
|
10149
|
-
resetPendingRef.current = false;
|
|
10150
|
-
tokenIssuedRef.current = true;
|
|
10151
|
-
log.debug(() => ({
|
|
10152
|
-
msg: "settled",
|
|
10153
|
-
fields: { state: "CONTENT" }
|
|
10154
|
-
}));
|
|
10155
|
-
setKycTokenState({ type: "CONTENT", token: kycToken.token });
|
|
10156
|
-
return kycToken.token;
|
|
10157
|
-
} catch (error) {
|
|
10158
|
-
const reason = error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
|
|
10159
|
-
log.failure(
|
|
10160
|
-
() => ({ msg: "settled", fields: { state: "ERROR", reason } }),
|
|
10161
|
-
error
|
|
10162
|
-
);
|
|
10163
|
-
setKycTokenState({ type: "ERROR", reason });
|
|
10164
|
-
throw error;
|
|
10165
|
-
}
|
|
10166
|
-
}, [coinlist, levelName, log]);
|
|
10167
|
-
return { kycTokenState, fetchToken };
|
|
10168
|
-
}
|
|
10169
|
-
|
|
10170
|
-
// src/client/hooks/requirements/identity-verification/useIdentityVerificationViewModel.ts
|
|
10171
|
-
var NOT_AUTHENTICATED_MESSAGE2 = "Sign in to verify your identity.";
|
|
10172
|
-
var GENERIC_ERROR_MESSAGE2 = "Unable to start identity verification right now. Please try again.";
|
|
10173
|
-
function useIdentityVerificationViewModel(options = {}) {
|
|
10174
|
-
const { levelName, reset, locale, onSubmitted, onError } = options;
|
|
10175
|
-
const { kycTokenState, fetchToken } = useKycToken(levelName, reset);
|
|
10176
|
-
const fetchedRef = useRef15(false);
|
|
10177
|
-
useEffect21(() => {
|
|
10178
|
-
if (fetchedRef.current) {
|
|
10179
|
-
return;
|
|
10180
|
-
}
|
|
10181
|
-
fetchedRef.current = true;
|
|
10182
|
-
fetchToken().catch(() => {
|
|
10183
|
-
});
|
|
10184
|
-
}, [fetchToken]);
|
|
10185
|
-
const state = useMemo5(() => {
|
|
10186
|
-
switch (kycTokenState.type) {
|
|
10187
|
-
case "IDLE":
|
|
10188
|
-
case "LOADING":
|
|
10189
|
-
return { type: "loading" };
|
|
10190
|
-
case "ERROR": {
|
|
10191
|
-
const notAuthenticated = kycTokenState.reason === "not-authenticated";
|
|
10192
|
-
return {
|
|
10193
|
-
type: "error",
|
|
10194
|
-
message: notAuthenticated ? NOT_AUTHENTICATED_MESSAGE2 : GENERIC_ERROR_MESSAGE2,
|
|
10195
|
-
retryable: !notAuthenticated
|
|
10196
|
-
};
|
|
10197
|
-
}
|
|
10198
|
-
case "CONTENT":
|
|
10199
|
-
return {
|
|
10200
|
-
type: "ready",
|
|
10201
|
-
accessToken: kycTokenState.token,
|
|
10202
|
-
locale,
|
|
10203
|
-
refreshToken: fetchToken
|
|
10204
|
-
};
|
|
10205
|
-
default: {
|
|
10206
|
-
const exhaustive = kycTokenState;
|
|
10207
|
-
return exhaustive;
|
|
10208
|
-
}
|
|
10209
|
-
}
|
|
10210
|
-
}, [kycTokenState, locale, fetchToken]);
|
|
10211
|
-
const onEvent = useCallback7(
|
|
10212
|
-
(event) => {
|
|
10213
|
-
switch (event.type) {
|
|
10214
|
-
case "ON_RETRY":
|
|
10215
|
-
fetchToken().catch(() => {
|
|
10216
|
-
});
|
|
10217
|
-
return;
|
|
10218
|
-
case "ON_SUBMITTED":
|
|
10219
|
-
onSubmitted?.();
|
|
10220
|
-
return;
|
|
10221
|
-
case "ON_ERROR":
|
|
10222
|
-
onError?.(event.error);
|
|
10223
|
-
return;
|
|
10224
|
-
default: {
|
|
10225
|
-
const exhaustive = event;
|
|
10226
|
-
return exhaustive;
|
|
10227
|
-
}
|
|
10228
|
-
}
|
|
10229
|
-
},
|
|
10230
|
-
[fetchToken, onSubmitted, onError]
|
|
10231
|
-
);
|
|
10232
|
-
return { state, onEvent };
|
|
10394
|
+
default: {
|
|
10395
|
+
const exhaustive = state;
|
|
10396
|
+
return exhaustive;
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10233
10399
|
}
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
function IdentityVerificationContainer({
|
|
10238
|
-
levelName,
|
|
10239
|
-
reset,
|
|
10240
|
-
locale,
|
|
10241
|
-
onSubmitted,
|
|
10242
|
-
onError,
|
|
10243
|
-
className
|
|
10244
|
-
}) {
|
|
10245
|
-
const { state, onEvent } = useIdentityVerificationViewModel({
|
|
10246
|
-
levelName,
|
|
10247
|
-
reset,
|
|
10248
|
-
locale,
|
|
10249
|
-
onSubmitted,
|
|
10250
|
-
onError
|
|
10251
|
-
});
|
|
10252
|
-
return /* @__PURE__ */ jsx62(
|
|
10253
|
-
IdentityVerificationView,
|
|
10400
|
+
function LoadingState2() {
|
|
10401
|
+
return /* @__PURE__ */ jsx61(
|
|
10402
|
+
"output",
|
|
10254
10403
|
{
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
className
|
|
10404
|
+
"aria-live": "polite",
|
|
10405
|
+
className: "clcosdk:flex clcosdk:min-h-40 clcosdk:items-center clcosdk:justify-center clcosdk:rounded-2xl clcosdk:border clcosdk:border-border clcosdk:bg-background clcosdk:p-6",
|
|
10406
|
+
children: /* @__PURE__ */ jsx61("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: "Loading requirements..." })
|
|
10258
10407
|
}
|
|
10259
10408
|
);
|
|
10260
10409
|
}
|
|
10261
10410
|
|
|
10262
10411
|
// src/client/components/requirements/tax-document/TaxDocumentModalView.tsx
|
|
10263
|
-
import { jsx as
|
|
10412
|
+
import { jsx as jsx62, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
10264
10413
|
function TaxDocumentModalView({
|
|
10265
10414
|
state,
|
|
10266
10415
|
onEvent,
|
|
@@ -10269,7 +10418,7 @@ function TaxDocumentModalView({
|
|
|
10269
10418
|
if (state.type === "hidden") {
|
|
10270
10419
|
return null;
|
|
10271
10420
|
}
|
|
10272
|
-
return /* @__PURE__ */
|
|
10421
|
+
return /* @__PURE__ */ jsx62(CoinListStyleScope, { children: /* @__PURE__ */ jsx62("div", { className: "clcosdk:fixed clcosdk:inset-0 clcosdk:z-50 clcosdk:flex clcosdk:items-center clcosdk:justify-center clcosdk:bg-black/50 clcosdk:p-4", children: /* @__PURE__ */ jsxs44(
|
|
10273
10422
|
"div",
|
|
10274
10423
|
{
|
|
10275
10424
|
className: cn(
|
|
@@ -10277,11 +10426,11 @@ function TaxDocumentModalView({
|
|
|
10277
10426
|
className
|
|
10278
10427
|
),
|
|
10279
10428
|
children: [
|
|
10280
|
-
/* @__PURE__ */
|
|
10281
|
-
/* @__PURE__ */
|
|
10282
|
-
/* @__PURE__ */
|
|
10429
|
+
/* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:items-start clcosdk:justify-between clcosdk:gap-4", children: [
|
|
10430
|
+
/* @__PURE__ */ jsx62("h3", { className: cn(typeClasses.h3, "clcosdk:text-text-primary"), children: state.title }),
|
|
10431
|
+
/* @__PURE__ */ jsx62(CloseButton, { onClick: () => onEvent({ type: "ON_CLOSE" }) })
|
|
10283
10432
|
] }),
|
|
10284
|
-
/* @__PURE__ */
|
|
10433
|
+
/* @__PURE__ */ jsx62(Screen, { screen: state.screen, onEvent })
|
|
10285
10434
|
]
|
|
10286
10435
|
}
|
|
10287
10436
|
) }) });
|
|
@@ -10292,11 +10441,11 @@ function Screen({
|
|
|
10292
10441
|
}) {
|
|
10293
10442
|
switch (screen.type) {
|
|
10294
10443
|
case "loading":
|
|
10295
|
-
return /* @__PURE__ */
|
|
10444
|
+
return /* @__PURE__ */ jsx62(LoadingScreen, {});
|
|
10296
10445
|
case "error":
|
|
10297
|
-
return /* @__PURE__ */
|
|
10446
|
+
return /* @__PURE__ */ jsx62(AlertBanner, { variant: "error", icon: true, content: screen.message });
|
|
10298
10447
|
case "review":
|
|
10299
|
-
return /* @__PURE__ */
|
|
10448
|
+
return /* @__PURE__ */ jsx62(
|
|
10300
10449
|
ReviewScreen,
|
|
10301
10450
|
{
|
|
10302
10451
|
fields: screen.fields,
|
|
@@ -10307,9 +10456,9 @@ function Screen({
|
|
|
10307
10456
|
}
|
|
10308
10457
|
);
|
|
10309
10458
|
case "editing":
|
|
10310
|
-
return /* @__PURE__ */
|
|
10459
|
+
return /* @__PURE__ */ jsx62(EditScreen, { fields: screen.fields, onEvent });
|
|
10311
10460
|
case "sign-only":
|
|
10312
|
-
return /* @__PURE__ */
|
|
10461
|
+
return /* @__PURE__ */ jsx62(
|
|
10313
10462
|
SignOnlyScreen,
|
|
10314
10463
|
{
|
|
10315
10464
|
signing: screen.signing,
|
|
@@ -10324,14 +10473,14 @@ function Screen({
|
|
|
10324
10473
|
}
|
|
10325
10474
|
}
|
|
10326
10475
|
function LoadingScreen() {
|
|
10327
|
-
return /* @__PURE__ */
|
|
10476
|
+
return /* @__PURE__ */ jsx62(
|
|
10328
10477
|
"output",
|
|
10329
10478
|
{
|
|
10330
10479
|
"aria-live": "polite",
|
|
10331
10480
|
className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-4",
|
|
10332
|
-
children: [0, 1, 2, 3, 4].map((row) => /* @__PURE__ */
|
|
10333
|
-
/* @__PURE__ */
|
|
10334
|
-
/* @__PURE__ */
|
|
10481
|
+
children: [0, 1, 2, 3, 4].map((row) => /* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-1", children: [
|
|
10482
|
+
/* @__PURE__ */ jsx62("div", { className: "clcosdk:h-3 clcosdk:w-28 clcosdk:animate-pulse clcosdk:rounded clcosdk:bg-surface" }),
|
|
10483
|
+
/* @__PURE__ */ jsx62("div", { className: "clcosdk:h-5 clcosdk:w-48 clcosdk:animate-pulse clcosdk:rounded clcosdk:bg-surface" })
|
|
10335
10484
|
] }, row))
|
|
10336
10485
|
}
|
|
10337
10486
|
);
|
|
@@ -10343,9 +10492,9 @@ function ReviewScreen({
|
|
|
10343
10492
|
signError,
|
|
10344
10493
|
onEvent
|
|
10345
10494
|
}) {
|
|
10346
|
-
return /* @__PURE__ */
|
|
10347
|
-
/* @__PURE__ */
|
|
10348
|
-
piiUnavailable && /* @__PURE__ */
|
|
10495
|
+
return /* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-6", children: [
|
|
10496
|
+
/* @__PURE__ */ jsx62("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: "Review your information below. If anything looks incorrect, edit before signing." }),
|
|
10497
|
+
piiUnavailable && /* @__PURE__ */ jsx62(
|
|
10349
10498
|
AlertBanner,
|
|
10350
10499
|
{
|
|
10351
10500
|
variant: "info",
|
|
@@ -10353,27 +10502,27 @@ function ReviewScreen({
|
|
|
10353
10502
|
content: "We don't have this information on file yet \u2014 please fill it in below."
|
|
10354
10503
|
}
|
|
10355
10504
|
),
|
|
10356
|
-
/* @__PURE__ */
|
|
10505
|
+
/* @__PURE__ */ jsx62("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-4 clcosdk:border-t clcosdk:border-divider clcosdk:pt-4", children: fields.map(({ field, label, displayValue }) => /* @__PURE__ */ jsxs44(
|
|
10357
10506
|
"div",
|
|
10358
10507
|
{
|
|
10359
10508
|
className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-1",
|
|
10360
10509
|
children: [
|
|
10361
|
-
/* @__PURE__ */
|
|
10510
|
+
/* @__PURE__ */ jsx62(
|
|
10362
10511
|
"span",
|
|
10363
10512
|
{
|
|
10364
10513
|
className: cn(typeClasses.label, "clcosdk:text-text-secondary"),
|
|
10365
10514
|
children: label
|
|
10366
10515
|
}
|
|
10367
10516
|
),
|
|
10368
|
-
/* @__PURE__ */
|
|
10517
|
+
/* @__PURE__ */ jsx62("span", { className: cn(typeClasses.body, "clcosdk:text-text-primary"), children: displayValue })
|
|
10369
10518
|
]
|
|
10370
10519
|
},
|
|
10371
10520
|
field
|
|
10372
10521
|
)) }),
|
|
10373
|
-
/* @__PURE__ */
|
|
10374
|
-
signError && /* @__PURE__ */
|
|
10375
|
-
/* @__PURE__ */
|
|
10376
|
-
/* @__PURE__ */
|
|
10522
|
+
/* @__PURE__ */ jsx62("p", { className: cn(typeClasses.caption, "clcosdk:text-text-secondary"), children: "By signing, you certify that the information above is accurate and that you are the beneficial owner of the income this form relates to. This document cannot be edited once signed." }),
|
|
10523
|
+
signError && /* @__PURE__ */ jsx62(AlertBanner, { variant: "error", icon: true, content: signError }),
|
|
10524
|
+
/* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-2", children: [
|
|
10525
|
+
/* @__PURE__ */ jsx62(
|
|
10377
10526
|
ClButton,
|
|
10378
10527
|
{
|
|
10379
10528
|
fullWidth: true,
|
|
@@ -10383,7 +10532,7 @@ function ReviewScreen({
|
|
|
10383
10532
|
children: "Sign W-8BEN"
|
|
10384
10533
|
}
|
|
10385
10534
|
),
|
|
10386
|
-
/* @__PURE__ */
|
|
10535
|
+
/* @__PURE__ */ jsx62(
|
|
10387
10536
|
ClButton,
|
|
10388
10537
|
{
|
|
10389
10538
|
fullWidth: true,
|
|
@@ -10400,20 +10549,20 @@ function EditScreen({
|
|
|
10400
10549
|
fields,
|
|
10401
10550
|
onEvent
|
|
10402
10551
|
}) {
|
|
10403
|
-
return /* @__PURE__ */
|
|
10404
|
-
/* @__PURE__ */
|
|
10552
|
+
return /* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-6", children: [
|
|
10553
|
+
/* @__PURE__ */ jsx62("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-4 clcosdk:border-t clcosdk:border-divider clcosdk:pt-4", children: fields.map(({ field, label, placeholder, value }) => /* @__PURE__ */ jsxs44(
|
|
10405
10554
|
"label",
|
|
10406
10555
|
{
|
|
10407
10556
|
className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-1",
|
|
10408
10557
|
children: [
|
|
10409
|
-
/* @__PURE__ */
|
|
10558
|
+
/* @__PURE__ */ jsx62(
|
|
10410
10559
|
"span",
|
|
10411
10560
|
{
|
|
10412
10561
|
className: cn(typeClasses.label, "clcosdk:text-text-secondary"),
|
|
10413
10562
|
children: label
|
|
10414
10563
|
}
|
|
10415
10564
|
),
|
|
10416
|
-
/* @__PURE__ */
|
|
10565
|
+
/* @__PURE__ */ jsx62(
|
|
10417
10566
|
"input",
|
|
10418
10567
|
{
|
|
10419
10568
|
type: "text",
|
|
@@ -10434,9 +10583,9 @@ function EditScreen({
|
|
|
10434
10583
|
},
|
|
10435
10584
|
field
|
|
10436
10585
|
)) }),
|
|
10437
|
-
/* @__PURE__ */
|
|
10438
|
-
/* @__PURE__ */
|
|
10439
|
-
/* @__PURE__ */
|
|
10586
|
+
/* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-2", children: [
|
|
10587
|
+
/* @__PURE__ */ jsx62(ClButton, { fullWidth: true, onClick: () => onEvent({ type: "ON_SAVE_EDIT" }), children: "Save & review" }),
|
|
10588
|
+
/* @__PURE__ */ jsx62(
|
|
10440
10589
|
ClButton,
|
|
10441
10590
|
{
|
|
10442
10591
|
fullWidth: true,
|
|
@@ -10453,10 +10602,10 @@ function SignOnlyScreen({
|
|
|
10453
10602
|
signError,
|
|
10454
10603
|
onEvent
|
|
10455
10604
|
}) {
|
|
10456
|
-
return /* @__PURE__ */
|
|
10457
|
-
/* @__PURE__ */
|
|
10458
|
-
signError && /* @__PURE__ */
|
|
10459
|
-
/* @__PURE__ */
|
|
10605
|
+
return /* @__PURE__ */ jsxs44("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-6", children: [
|
|
10606
|
+
/* @__PURE__ */ jsx62("p", { className: cn(typeClasses.body, "clcosdk:text-text-secondary"), children: "As an entity investor, you must complete a W-8BEN-E to confirm your foreign tax status and claim applicable treaty benefits. You'll receive an email to complete the signing." }),
|
|
10607
|
+
signError && /* @__PURE__ */ jsx62(AlertBanner, { variant: "error", icon: true, content: signError }),
|
|
10608
|
+
/* @__PURE__ */ jsx62(
|
|
10460
10609
|
ClButton,
|
|
10461
10610
|
{
|
|
10462
10611
|
fullWidth: true,
|
|
@@ -10470,12 +10619,12 @@ function SignOnlyScreen({
|
|
|
10470
10619
|
}
|
|
10471
10620
|
|
|
10472
10621
|
// src/client/hooks/requirements/tax-document/useTaxDocumentModalViewModel.ts
|
|
10473
|
-
import { useCallback as
|
|
10622
|
+
import { useCallback as useCallback10, useEffect as useEffect24, useMemo as useMemo6 } from "react";
|
|
10474
10623
|
|
|
10475
10624
|
// src/client/hooks/requirements/data/useTaxDocument.ts
|
|
10476
|
-
import { useCallback as
|
|
10625
|
+
import { useCallback as useCallback9, useEffect as useEffect23, useState as useState27 } from "react";
|
|
10477
10626
|
var IDLE_SIGN = { type: "idle", error: null };
|
|
10478
|
-
var
|
|
10627
|
+
var LOADING_STATE5 = { type: "LOADING" };
|
|
10479
10628
|
var SIGN_FAILED_MESSAGE = "Unable to sign document. Please try again.";
|
|
10480
10629
|
var DOB_INVALID_MESSAGE = "Enter your date of birth as MM/DD/YYYY.";
|
|
10481
10630
|
var FIELD_KEYS = {
|
|
@@ -10548,8 +10697,8 @@ function useTaxDocument({
|
|
|
10548
10697
|
}) {
|
|
10549
10698
|
const { coinlist, isReady } = useCoinList();
|
|
10550
10699
|
const log = useLogger("useTaxDocument");
|
|
10551
|
-
const [state, setState] =
|
|
10552
|
-
|
|
10700
|
+
const [state, setState] = useState27(LOADING_STATE5);
|
|
10701
|
+
useEffect23(() => {
|
|
10553
10702
|
let isCancelled = false;
|
|
10554
10703
|
if (!isOpen) {
|
|
10555
10704
|
return () => {
|
|
@@ -10557,12 +10706,12 @@ function useTaxDocument({
|
|
|
10557
10706
|
};
|
|
10558
10707
|
}
|
|
10559
10708
|
if (!isReady) {
|
|
10560
|
-
setState(
|
|
10709
|
+
setState(LOADING_STATE5);
|
|
10561
10710
|
return () => {
|
|
10562
10711
|
isCancelled = true;
|
|
10563
10712
|
};
|
|
10564
10713
|
}
|
|
10565
|
-
setState(
|
|
10714
|
+
setState(LOADING_STATE5);
|
|
10566
10715
|
coinlist.requirements.getPii().then((pii) => {
|
|
10567
10716
|
if (isCancelled) return;
|
|
10568
10717
|
if (pii.kind === "company") {
|
|
@@ -10590,7 +10739,7 @@ function useTaxDocument({
|
|
|
10590
10739
|
isCancelled = true;
|
|
10591
10740
|
};
|
|
10592
10741
|
}, [coinlist, isReady, isOpen, log]);
|
|
10593
|
-
const onEditField =
|
|
10742
|
+
const onEditField = useCallback9(
|
|
10594
10743
|
(field, value) => {
|
|
10595
10744
|
setState(
|
|
10596
10745
|
(prev) => prev.type === "EDITING" ? { ...prev, fields: { ...prev.fields, [field]: value } } : prev
|
|
@@ -10598,7 +10747,7 @@ function useTaxDocument({
|
|
|
10598
10747
|
},
|
|
10599
10748
|
[]
|
|
10600
10749
|
);
|
|
10601
|
-
const onStartEdit =
|
|
10750
|
+
const onStartEdit = useCallback9(() => {
|
|
10602
10751
|
setState(
|
|
10603
10752
|
(prev) => prev.type === "REVIEW" ? {
|
|
10604
10753
|
type: "EDITING",
|
|
@@ -10609,7 +10758,7 @@ function useTaxDocument({
|
|
|
10609
10758
|
} : prev
|
|
10610
10759
|
);
|
|
10611
10760
|
}, []);
|
|
10612
|
-
const onSaveEdit =
|
|
10761
|
+
const onSaveEdit = useCallback9(() => {
|
|
10613
10762
|
setState(
|
|
10614
10763
|
(prev) => prev.type === "EDITING" ? {
|
|
10615
10764
|
type: "REVIEW",
|
|
@@ -10620,7 +10769,7 @@ function useTaxDocument({
|
|
|
10620
10769
|
} : prev
|
|
10621
10770
|
);
|
|
10622
10771
|
}, []);
|
|
10623
|
-
const onCancelEdit =
|
|
10772
|
+
const onCancelEdit = useCallback9(() => {
|
|
10624
10773
|
setState(
|
|
10625
10774
|
(prev) => prev.type === "EDITING" ? {
|
|
10626
10775
|
type: "REVIEW",
|
|
@@ -10631,7 +10780,7 @@ function useTaxDocument({
|
|
|
10631
10780
|
} : prev
|
|
10632
10781
|
);
|
|
10633
10782
|
}, []);
|
|
10634
|
-
const onSign =
|
|
10783
|
+
const onSign = useCallback9(() => {
|
|
10635
10784
|
if (state.type !== "REVIEW" && state.type !== "SIGN_ONLY") return;
|
|
10636
10785
|
if (state.type === "REVIEW" && state.fields.dob.trim() !== "" && !isValidUsDate(state.fields.dob)) {
|
|
10637
10786
|
setState({
|
|
@@ -10673,7 +10822,7 @@ function useTaxDocumentModalViewModel({
|
|
|
10673
10822
|
onSubmitted
|
|
10674
10823
|
}) {
|
|
10675
10824
|
const { state, onEditField, onStartEdit, onSaveEdit, onCancelEdit, onSign } = useTaxDocument({ isOpen });
|
|
10676
|
-
|
|
10825
|
+
useEffect24(() => {
|
|
10677
10826
|
if (state.type === "SUBMITTED") {
|
|
10678
10827
|
onSubmitted?.(state.submission);
|
|
10679
10828
|
onClose();
|
|
@@ -10685,7 +10834,7 @@ function useTaxDocumentModalViewModel({
|
|
|
10685
10834
|
}
|
|
10686
10835
|
return { type: "content", title: toTitle(state), screen: toScreen(state) };
|
|
10687
10836
|
}, [isOpen, state]);
|
|
10688
|
-
const onEvent =
|
|
10837
|
+
const onEvent = useCallback10(
|
|
10689
10838
|
(event) => {
|
|
10690
10839
|
switch (event.type) {
|
|
10691
10840
|
case "ON_CLOSE":
|
|
@@ -10768,7 +10917,7 @@ function toFieldsUi(fields) {
|
|
|
10768
10917
|
}
|
|
10769
10918
|
|
|
10770
10919
|
// src/client/components/requirements/tax-document/TaxDocumentModalContainer.tsx
|
|
10771
|
-
import { jsx as
|
|
10920
|
+
import { jsx as jsx63 } from "react/jsx-runtime";
|
|
10772
10921
|
function TaxDocumentModalContainer({
|
|
10773
10922
|
isOpen,
|
|
10774
10923
|
onClose,
|
|
@@ -10780,7 +10929,7 @@ function TaxDocumentModalContainer({
|
|
|
10780
10929
|
onClose,
|
|
10781
10930
|
onSubmitted
|
|
10782
10931
|
});
|
|
10783
|
-
return /* @__PURE__ */
|
|
10932
|
+
return /* @__PURE__ */ jsx63(
|
|
10784
10933
|
TaxDocumentModalView,
|
|
10785
10934
|
{
|
|
10786
10935
|
state,
|
|
@@ -10790,6 +10939,39 @@ function TaxDocumentModalContainer({
|
|
|
10790
10939
|
);
|
|
10791
10940
|
}
|
|
10792
10941
|
|
|
10942
|
+
// src/client/components/requirements/VerificationOverlay.tsx
|
|
10943
|
+
import { jsx as jsx64, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
10944
|
+
function VerificationOverlay({
|
|
10945
|
+
onClose,
|
|
10946
|
+
children
|
|
10947
|
+
}) {
|
|
10948
|
+
return /* @__PURE__ */ jsx64(CoinListStyleScope, { children: /* @__PURE__ */ jsx64(VerificationOverlayBody, { onClose, children }) });
|
|
10949
|
+
}
|
|
10950
|
+
function VerificationOverlayBody({
|
|
10951
|
+
onClose,
|
|
10952
|
+
children
|
|
10953
|
+
}) {
|
|
10954
|
+
return /* @__PURE__ */ jsx64(
|
|
10955
|
+
"div",
|
|
10956
|
+
{
|
|
10957
|
+
role: "dialog",
|
|
10958
|
+
"aria-modal": "true",
|
|
10959
|
+
"aria-label": "Identity verification",
|
|
10960
|
+
className: "clcosdk:fixed clcosdk:inset-0 clcosdk:z-50 clcosdk:flex clcosdk:items-center clcosdk:justify-center clcosdk:bg-overlay clcosdk:p-4",
|
|
10961
|
+
children: /* @__PURE__ */ jsxs45("div", { className: "clcosdk:relative clcosdk:flex clcosdk:max-h-[92vh] clcosdk:w-full clcosdk:max-w-[760px] clcosdk:flex-col clcosdk:overflow-y-auto clcosdk:rounded-2xl clcosdk:bg-background clcosdk:p-6 clcosdk:pt-14", children: [
|
|
10962
|
+
/* @__PURE__ */ jsx64(
|
|
10963
|
+
CloseButton,
|
|
10964
|
+
{
|
|
10965
|
+
onClick: onClose,
|
|
10966
|
+
className: "clcosdk:absolute clcosdk:top-4 clcosdk:right-4"
|
|
10967
|
+
}
|
|
10968
|
+
),
|
|
10969
|
+
children
|
|
10970
|
+
] })
|
|
10971
|
+
}
|
|
10972
|
+
);
|
|
10973
|
+
}
|
|
10974
|
+
|
|
10793
10975
|
// src/client/components/requirements/wallet/ConnectWalletModalView.tsx
|
|
10794
10976
|
import { useId as useId5 } from "react";
|
|
10795
10977
|
import { jsx as jsx65, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
@@ -10901,10 +11083,10 @@ function Screen2({
|
|
|
10901
11083
|
}
|
|
10902
11084
|
|
|
10903
11085
|
// src/client/hooks/requirements/wallet/useConnectWalletModalViewModel.ts
|
|
10904
|
-
import { useCallback as
|
|
11086
|
+
import { useCallback as useCallback12, useEffect as useEffect26, useMemo as useMemo7 } from "react";
|
|
10905
11087
|
|
|
10906
11088
|
// src/client/hooks/requirements/data/useConnectWallet.ts
|
|
10907
|
-
import { useCallback as
|
|
11089
|
+
import { useCallback as useCallback11, useEffect as useEffect25, useRef as useRef16, useState as useState28 } from "react";
|
|
10908
11090
|
|
|
10909
11091
|
// src/client/core/wallets/connect-external-wallet.ts
|
|
10910
11092
|
var DEFAULT_STATEMENT = "Sign this message to prove you own this wallet. This does not cost gas or move funds.";
|
|
@@ -11035,24 +11217,24 @@ function useConnectWallet({
|
|
|
11035
11217
|
statement
|
|
11036
11218
|
}) {
|
|
11037
11219
|
const { coinlist } = useCoinList();
|
|
11038
|
-
const [state, setState] =
|
|
11220
|
+
const [state, setState] = useState28(
|
|
11039
11221
|
() => wallet ? { type: "READY", address: wallet.address, sign: IDLE_SIGN2 } : { type: "NEEDS_WALLET" }
|
|
11040
11222
|
);
|
|
11041
11223
|
const attempt = useRef16(0);
|
|
11042
|
-
|
|
11224
|
+
useEffect25(() => {
|
|
11043
11225
|
attempt.current += 1;
|
|
11044
11226
|
if (!isOpen) return;
|
|
11045
11227
|
setState(
|
|
11046
11228
|
wallet ? { type: "READY", address: wallet.address, sign: IDLE_SIGN2 } : { type: "NEEDS_WALLET" }
|
|
11047
11229
|
);
|
|
11048
11230
|
}, [isOpen, wallet?.address]);
|
|
11049
|
-
|
|
11231
|
+
useEffect25(
|
|
11050
11232
|
() => () => {
|
|
11051
11233
|
attempt.current += 1;
|
|
11052
11234
|
},
|
|
11053
11235
|
[]
|
|
11054
11236
|
);
|
|
11055
|
-
const onSign =
|
|
11237
|
+
const onSign = useCallback11(() => {
|
|
11056
11238
|
if (!wallet || state.type !== "READY") return;
|
|
11057
11239
|
attempt.current += 1;
|
|
11058
11240
|
const gen = attempt.current;
|
|
@@ -11114,7 +11296,7 @@ function useConnectWalletModalViewModel({
|
|
|
11114
11296
|
challengeType,
|
|
11115
11297
|
statement
|
|
11116
11298
|
});
|
|
11117
|
-
|
|
11299
|
+
useEffect26(() => {
|
|
11118
11300
|
if (state.type === "CONNECTED") {
|
|
11119
11301
|
onConnected?.(state.binding);
|
|
11120
11302
|
onClose();
|
|
@@ -11145,7 +11327,7 @@ function useConnectWalletModalViewModel({
|
|
|
11145
11327
|
canRequestConnect
|
|
11146
11328
|
};
|
|
11147
11329
|
}, [isOpen, state, onRequestConnect]);
|
|
11148
|
-
const onEvent =
|
|
11330
|
+
const onEvent = useCallback12(
|
|
11149
11331
|
(event) => {
|
|
11150
11332
|
switch (event.type) {
|
|
11151
11333
|
case "ON_CLOSE":
|
|
@@ -11185,63 +11367,12 @@ function ConnectWalletModalContainer({
|
|
|
11185
11367
|
);
|
|
11186
11368
|
}
|
|
11187
11369
|
|
|
11188
|
-
// src/client/hooks/requirements/
|
|
11189
|
-
import { useCallback as
|
|
11190
|
-
|
|
11191
|
-
// src/client/hooks/requirements/checklist/useRequirementsChecklistViewModel.types.ts
|
|
11192
|
-
var RequirementItemUi = {
|
|
11193
|
-
fromDomain(req, statusInfo, label, description2, addresses = []) {
|
|
11194
|
-
return {
|
|
11195
|
-
variant: RequirementVariant.fromType(req.type),
|
|
11196
|
-
status: statusInfo ? RequirementStatus.fromStatusValue(statusInfo.status) : "required",
|
|
11197
|
-
label,
|
|
11198
|
-
description: description2,
|
|
11199
|
-
multiWallet: req.type === "whitelisted_wallet",
|
|
11200
|
-
connectedWallets: addresses.map((address) => ({
|
|
11201
|
-
id: address.id,
|
|
11202
|
-
address: address.address,
|
|
11203
|
-
shortAddress: shortenAddress(address.address)
|
|
11204
|
-
}))
|
|
11205
|
-
};
|
|
11206
|
-
}
|
|
11207
|
-
};
|
|
11208
|
-
var RequirementVariant = {
|
|
11209
|
-
fromType(type) {
|
|
11210
|
-
switch (type) {
|
|
11211
|
-
case "external_wallet":
|
|
11212
|
-
case "whitelisted_wallet":
|
|
11213
|
-
return "wallet";
|
|
11214
|
-
default:
|
|
11215
|
-
return "verification";
|
|
11216
|
-
}
|
|
11217
|
-
}
|
|
11218
|
-
};
|
|
11219
|
-
var RequirementStatus = {
|
|
11220
|
-
fromStatusValue(status) {
|
|
11221
|
-
switch (status) {
|
|
11222
|
-
case "not_started":
|
|
11223
|
-
case "action_needed":
|
|
11224
|
-
return "required";
|
|
11225
|
-
case "in_progress":
|
|
11226
|
-
return "pending";
|
|
11227
|
-
case "completed":
|
|
11228
|
-
return "completed";
|
|
11229
|
-
case "rejected":
|
|
11230
|
-
return "rejected";
|
|
11231
|
-
}
|
|
11232
|
-
}
|
|
11233
|
-
};
|
|
11234
|
-
var ChecklistStatus = {
|
|
11235
|
-
derive(statuses) {
|
|
11236
|
-
if (statuses.some((s) => s.status === "rejected")) return "ineligible";
|
|
11237
|
-
if (statuses.every((s) => s.status === "completed")) return "eligible";
|
|
11238
|
-
return "inProgress";
|
|
11239
|
-
}
|
|
11240
|
-
};
|
|
11370
|
+
// src/client/hooks/requirements/useRequirementsChecklistViewModel.ts
|
|
11371
|
+
import { useCallback as useCallback15, useEffect as useEffect29, useMemo as useMemo8, useRef as useRef17, useState as useState31 } from "react";
|
|
11241
11372
|
|
|
11242
11373
|
// src/client/hooks/requirements/data/useOptionAddresses.ts
|
|
11243
|
-
import { useCallback as
|
|
11244
|
-
var
|
|
11374
|
+
import { useCallback as useCallback13, useEffect as useEffect27, useState as useState29 } from "react";
|
|
11375
|
+
var LOADING_STATE6 = { type: "LOADING" };
|
|
11245
11376
|
var EMPTY_STATE = {
|
|
11246
11377
|
type: "CONTENT",
|
|
11247
11378
|
addresses: []
|
|
@@ -11250,19 +11381,19 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11250
11381
|
const { coinlist, isReady } = useCoinList();
|
|
11251
11382
|
const log = useLogger("useOptionAddresses");
|
|
11252
11383
|
const { data, enabled = true } = options;
|
|
11253
|
-
const [addressesState, setAddressesState] =
|
|
11254
|
-
data !== void 0 ? { type: "CONTENT", addresses: data } :
|
|
11384
|
+
const [addressesState, setAddressesState] = useState29(
|
|
11385
|
+
data !== void 0 ? { type: "CONTENT", addresses: data } : LOADING_STATE6
|
|
11255
11386
|
);
|
|
11256
|
-
const [fetchKey, setFetchKey] =
|
|
11257
|
-
const refetch =
|
|
11258
|
-
const disconnect =
|
|
11387
|
+
const [fetchKey, setFetchKey] = useState29(0);
|
|
11388
|
+
const refetch = useCallback13(() => setFetchKey((k) => k + 1), []);
|
|
11389
|
+
const disconnect = useCallback13(
|
|
11259
11390
|
async (addressId) => {
|
|
11260
11391
|
await coinlist.wallets.remove({ offerId, addressId });
|
|
11261
11392
|
refetch();
|
|
11262
11393
|
},
|
|
11263
11394
|
[coinlist, offerId, refetch]
|
|
11264
11395
|
);
|
|
11265
|
-
|
|
11396
|
+
useEffect27(() => {
|
|
11266
11397
|
let isCancelled = false;
|
|
11267
11398
|
if (!enabled) {
|
|
11268
11399
|
setAddressesState(
|
|
@@ -11274,7 +11405,7 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11274
11405
|
}
|
|
11275
11406
|
if (!isReady) {
|
|
11276
11407
|
if (data === void 0) {
|
|
11277
|
-
setAddressesState(
|
|
11408
|
+
setAddressesState(LOADING_STATE6);
|
|
11278
11409
|
}
|
|
11279
11410
|
return () => {
|
|
11280
11411
|
isCancelled = true;
|
|
@@ -11291,7 +11422,7 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11291
11422
|
isCancelled = true;
|
|
11292
11423
|
};
|
|
11293
11424
|
}
|
|
11294
|
-
setAddressesState(
|
|
11425
|
+
setAddressesState(LOADING_STATE6);
|
|
11295
11426
|
coinlist.wallets.list({ offerId, offerOptionId }).then((addresses) => {
|
|
11296
11427
|
if (!isCancelled) {
|
|
11297
11428
|
log.debug(() => ({
|
|
@@ -11318,22 +11449,22 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11318
11449
|
}
|
|
11319
11450
|
|
|
11320
11451
|
// src/client/hooks/requirements/data/useRequirements.ts
|
|
11321
|
-
import { useCallback as
|
|
11322
|
-
var
|
|
11452
|
+
import { useCallback as useCallback14, useEffect as useEffect28, useState as useState30 } from "react";
|
|
11453
|
+
var LOADING_STATE7 = { type: "LOADING" };
|
|
11323
11454
|
function useRequirements(offerId, options = {}) {
|
|
11324
11455
|
const { coinlist, isReady } = useCoinList();
|
|
11325
11456
|
const log = useLogger("useRequirements");
|
|
11326
11457
|
const { data } = options;
|
|
11327
|
-
const [requirementsState, setRequirementsState] =
|
|
11328
|
-
data !== void 0 ? { type: "CONTENT", ...data } :
|
|
11458
|
+
const [requirementsState, setRequirementsState] = useState30(
|
|
11459
|
+
data !== void 0 ? { type: "CONTENT", ...data } : LOADING_STATE7
|
|
11329
11460
|
);
|
|
11330
|
-
const [fetchKey, setFetchKey] =
|
|
11331
|
-
const refetch =
|
|
11332
|
-
|
|
11461
|
+
const [fetchKey, setFetchKey] = useState30(0);
|
|
11462
|
+
const refetch = useCallback14(() => setFetchKey((k) => k + 1), []);
|
|
11463
|
+
useEffect28(() => {
|
|
11333
11464
|
let isCancelled = false;
|
|
11334
11465
|
if (!isReady) {
|
|
11335
11466
|
if (data === void 0) {
|
|
11336
|
-
setRequirementsState(
|
|
11467
|
+
setRequirementsState(LOADING_STATE7);
|
|
11337
11468
|
}
|
|
11338
11469
|
return () => {
|
|
11339
11470
|
isCancelled = true;
|
|
@@ -11350,7 +11481,7 @@ function useRequirements(offerId, options = {}) {
|
|
|
11350
11481
|
isCancelled = true;
|
|
11351
11482
|
};
|
|
11352
11483
|
}
|
|
11353
|
-
setRequirementsState(
|
|
11484
|
+
setRequirementsState(LOADING_STATE7);
|
|
11354
11485
|
Promise.all([
|
|
11355
11486
|
coinlist.requirements.forOffer(offerId),
|
|
11356
11487
|
coinlist.requirements.statuses(offerId)
|
|
@@ -11387,7 +11518,58 @@ function useRequirements(offerId, options = {}) {
|
|
|
11387
11518
|
return { requirementsState, refetch };
|
|
11388
11519
|
}
|
|
11389
11520
|
|
|
11390
|
-
// src/client/hooks/requirements/
|
|
11521
|
+
// src/client/hooks/requirements/useRequirementsChecklistViewModel.types.ts
|
|
11522
|
+
var RequirementItemUi = {
|
|
11523
|
+
fromDomain(req, statusInfo, label, description2, addresses = []) {
|
|
11524
|
+
return {
|
|
11525
|
+
variant: RequirementVariant.fromType(req.type),
|
|
11526
|
+
status: statusInfo ? RequirementStatus.fromStatusValue(statusInfo.status) : "required",
|
|
11527
|
+
label,
|
|
11528
|
+
description: description2,
|
|
11529
|
+
multiWallet: req.type === "whitelisted_wallet",
|
|
11530
|
+
connectedWallets: addresses.map((address) => ({
|
|
11531
|
+
id: address.id,
|
|
11532
|
+
address: address.address,
|
|
11533
|
+
shortAddress: shortenAddress(address.address)
|
|
11534
|
+
}))
|
|
11535
|
+
};
|
|
11536
|
+
}
|
|
11537
|
+
};
|
|
11538
|
+
var RequirementVariant = {
|
|
11539
|
+
fromType(type) {
|
|
11540
|
+
switch (type) {
|
|
11541
|
+
case "external_wallet":
|
|
11542
|
+
case "whitelisted_wallet":
|
|
11543
|
+
return "wallet";
|
|
11544
|
+
default:
|
|
11545
|
+
return "verification";
|
|
11546
|
+
}
|
|
11547
|
+
}
|
|
11548
|
+
};
|
|
11549
|
+
var RequirementStatus = {
|
|
11550
|
+
fromStatusValue(status) {
|
|
11551
|
+
switch (status) {
|
|
11552
|
+
case "not_started":
|
|
11553
|
+
case "action_needed":
|
|
11554
|
+
return "required";
|
|
11555
|
+
case "in_progress":
|
|
11556
|
+
return "pending";
|
|
11557
|
+
case "completed":
|
|
11558
|
+
return "completed";
|
|
11559
|
+
case "rejected":
|
|
11560
|
+
return "rejected";
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11563
|
+
};
|
|
11564
|
+
var ChecklistStatus = {
|
|
11565
|
+
derive(statuses) {
|
|
11566
|
+
if (statuses.some((s) => s.status === "rejected")) return "ineligible";
|
|
11567
|
+
if (statuses.every((s) => s.status === "completed")) return "eligible";
|
|
11568
|
+
return "inProgress";
|
|
11569
|
+
}
|
|
11570
|
+
};
|
|
11571
|
+
|
|
11572
|
+
// src/client/hooks/requirements/useRequirementsChecklistViewModel.ts
|
|
11391
11573
|
var DEFAULT_LABELS = {
|
|
11392
11574
|
kyc_approved: "KYC Verification",
|
|
11393
11575
|
external_wallet: "External Wallet",
|
|
@@ -11429,19 +11611,19 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11429
11611
|
const log = useLogger("useRequirementsChecklistViewModel");
|
|
11430
11612
|
const { coinlist } = useCoinList();
|
|
11431
11613
|
const { requirementsState, refetch } = useRequirements(offerId, { data });
|
|
11432
|
-
const [expandedId, setExpandedId] =
|
|
11433
|
-
const [taxDocumentOpen, setTaxDocumentOpen] =
|
|
11434
|
-
const [connectWalletOpen, setConnectWalletOpen] =
|
|
11435
|
-
const [verifyingRequirementId, setVerifyingRequirementId] =
|
|
11614
|
+
const [expandedId, setExpandedId] = useState31(null);
|
|
11615
|
+
const [taxDocumentOpen, setTaxDocumentOpen] = useState31(false);
|
|
11616
|
+
const [connectWalletOpen, setConnectWalletOpen] = useState31(false);
|
|
11617
|
+
const [verifyingRequirementId, setVerifyingRequirementId] = useState31(null);
|
|
11436
11618
|
const isMountedRef = useRef17(true);
|
|
11437
|
-
|
|
11619
|
+
useEffect29(() => {
|
|
11438
11620
|
isMountedRef.current = true;
|
|
11439
11621
|
return () => {
|
|
11440
11622
|
isMountedRef.current = false;
|
|
11441
11623
|
};
|
|
11442
11624
|
}, []);
|
|
11443
|
-
const [hasWalletRequirement, setHasWalletRequirement] =
|
|
11444
|
-
|
|
11625
|
+
const [hasWalletRequirement, setHasWalletRequirement] = useState31(false);
|
|
11626
|
+
useEffect29(() => {
|
|
11445
11627
|
if (requirementsState.type === "CONTENT") {
|
|
11446
11628
|
setHasWalletRequirement(
|
|
11447
11629
|
(requirementsState.requirements[optionId] ?? []).some(
|
|
@@ -11457,14 +11639,14 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11457
11639
|
} = useOptionAddresses(offerId, optionId, {
|
|
11458
11640
|
enabled: hasWalletRequirement
|
|
11459
11641
|
});
|
|
11460
|
-
const removeWallet =
|
|
11642
|
+
const removeWallet = useCallback15(
|
|
11461
11643
|
async (addressId) => {
|
|
11462
11644
|
await disconnect(OfferOptionAddressId(addressId));
|
|
11463
11645
|
refetch();
|
|
11464
11646
|
},
|
|
11465
11647
|
[disconnect, refetch]
|
|
11466
11648
|
);
|
|
11467
|
-
const awaitVerificationResult =
|
|
11649
|
+
const awaitVerificationResult = useCallback15(
|
|
11468
11650
|
(requirementId, statusBeforeSubmit) => {
|
|
11469
11651
|
void (async () => {
|
|
11470
11652
|
const deadline = Date.now() + VERIFICATION_POLL_TIMEOUT_MS;
|
|
@@ -11573,7 +11755,7 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11573
11755
|
identityVerificationOptions,
|
|
11574
11756
|
removeWallet
|
|
11575
11757
|
]);
|
|
11576
|
-
const handleRequirementAction =
|
|
11758
|
+
const handleRequirementAction = useCallback15(
|
|
11577
11759
|
(requirement) => {
|
|
11578
11760
|
const inlineVerification = statusById.get(requirement.id)?.kycLevel !== void 0 && onRequirementActionOverride === void 0;
|
|
11579
11761
|
if (inlineVerification) {
|
|
@@ -11605,7 +11787,7 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11605
11787
|
coinlist
|
|
11606
11788
|
]
|
|
11607
11789
|
);
|
|
11608
|
-
const onEvent =
|
|
11790
|
+
const onEvent = useCallback15(
|
|
11609
11791
|
(event) => {
|
|
11610
11792
|
switch (event.type) {
|
|
11611
11793
|
case "ON_TOGGLE_ITEM":
|
|
@@ -11702,7 +11884,7 @@ function toVerificationUi(verifyingRequirementId, statusById, identityVerificati
|
|
|
11702
11884
|
};
|
|
11703
11885
|
}
|
|
11704
11886
|
|
|
11705
|
-
// src/client/components/requirements/
|
|
11887
|
+
// src/client/components/requirements/RequirementsChecklistContainer.tsx
|
|
11706
11888
|
import { Fragment as Fragment10, jsx as jsx67, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
11707
11889
|
function RequirementsChecklistContainer({
|
|
11708
11890
|
loading,
|
|
@@ -11768,7 +11950,7 @@ function RequirementsChecklistContainer({
|
|
|
11768
11950
|
] });
|
|
11769
11951
|
}
|
|
11770
11952
|
|
|
11771
|
-
// src/client/core/observability/pino-client-logger.ts
|
|
11953
|
+
// src/client/core/shared/observability/pino-client-logger.ts
|
|
11772
11954
|
import { pino } from "pino";
|
|
11773
11955
|
function pinoClientLogger(options) {
|
|
11774
11956
|
return loggerOverPino(
|
|
@@ -11785,7 +11967,7 @@ function pinoClientLogger(options) {
|
|
|
11785
11967
|
}
|
|
11786
11968
|
|
|
11787
11969
|
// src/client/hooks/auth/useCompleteOAuth.ts
|
|
11788
|
-
import { useEffect as
|
|
11970
|
+
import { useEffect as useEffect30, useRef as useRef18 } from "react";
|
|
11789
11971
|
function useCompleteOAuth(options) {
|
|
11790
11972
|
const { coinlist } = useCoinList();
|
|
11791
11973
|
const log = useLogger("useCompleteOAuth");
|
|
@@ -11796,7 +11978,7 @@ function useCompleteOAuth(options) {
|
|
|
11796
11978
|
onFailureRef.current = options.onFailure;
|
|
11797
11979
|
onSuccessRef.current = options.onSuccess;
|
|
11798
11980
|
const hasStartedExchangeRef = useRef18(false);
|
|
11799
|
-
|
|
11981
|
+
useEffect30(() => {
|
|
11800
11982
|
if (typeof window === "undefined") return;
|
|
11801
11983
|
const params = new URLSearchParams(window.location.search);
|
|
11802
11984
|
if (!params.has("code") && !params.has("error")) return;
|
|
@@ -11860,20 +12042,20 @@ function useCompleteOAuth(options) {
|
|
|
11860
12042
|
}
|
|
11861
12043
|
|
|
11862
12044
|
// src/client/hooks/checkout/coin-list/token-sale/data/useParticipations.ts
|
|
11863
|
-
import { useEffect as
|
|
11864
|
-
var
|
|
12045
|
+
import { useEffect as useEffect31, useState as useState32 } from "react";
|
|
12046
|
+
var LOADING_STATE8 = { type: "LOADING" };
|
|
11865
12047
|
function useParticipations(offerId, options = {}) {
|
|
11866
12048
|
const { coinlist, isReady } = useCoinList();
|
|
11867
12049
|
const log = useLogger("useParticipations");
|
|
11868
12050
|
const { data } = options;
|
|
11869
|
-
const [participationsState, setParticipationsState] =
|
|
11870
|
-
data !== void 0 ? { type: "CONTENT", participations: data } :
|
|
12051
|
+
const [participationsState, setParticipationsState] = useState32(
|
|
12052
|
+
data !== void 0 ? { type: "CONTENT", participations: data } : LOADING_STATE8
|
|
11871
12053
|
);
|
|
11872
|
-
|
|
12054
|
+
useEffect31(() => {
|
|
11873
12055
|
let isCancelled = false;
|
|
11874
12056
|
if (!isReady) {
|
|
11875
12057
|
if (data === void 0) {
|
|
11876
|
-
setParticipationsState(
|
|
12058
|
+
setParticipationsState(LOADING_STATE8);
|
|
11877
12059
|
}
|
|
11878
12060
|
return () => {
|
|
11879
12061
|
isCancelled = true;
|
|
@@ -11884,7 +12066,7 @@ function useParticipations(offerId, options = {}) {
|
|
|
11884
12066
|
isCancelled = true;
|
|
11885
12067
|
};
|
|
11886
12068
|
}
|
|
11887
|
-
setParticipationsState(
|
|
12069
|
+
setParticipationsState(LOADING_STATE8);
|
|
11888
12070
|
coinlist.tokenSale.list(offerId).then((participations) => {
|
|
11889
12071
|
if (!isCancelled) {
|
|
11890
12072
|
log.debug(() => ({
|
|
@@ -11911,20 +12093,20 @@ function useParticipations(offerId, options = {}) {
|
|
|
11911
12093
|
}
|
|
11912
12094
|
|
|
11913
12095
|
// src/client/hooks/offers/data/useOfferDetails.ts
|
|
11914
|
-
import { useEffect as
|
|
11915
|
-
var
|
|
12096
|
+
import { useEffect as useEffect32, useState as useState33 } from "react";
|
|
12097
|
+
var LOADING_STATE9 = { type: "LOADING" };
|
|
11916
12098
|
function useOfferDetails(offerId, options = {}) {
|
|
11917
12099
|
const { coinlist, isReady } = useCoinList();
|
|
11918
12100
|
const log = useLogger("useOfferDetails");
|
|
11919
12101
|
const { data } = options;
|
|
11920
|
-
const [offerDetailsState, setOfferDetailsState] =
|
|
11921
|
-
data !== void 0 ? { type: "CONTENT", offerDetail: data } :
|
|
12102
|
+
const [offerDetailsState, setOfferDetailsState] = useState33(
|
|
12103
|
+
data !== void 0 ? { type: "CONTENT", offerDetail: data } : LOADING_STATE9
|
|
11922
12104
|
);
|
|
11923
|
-
|
|
12105
|
+
useEffect32(() => {
|
|
11924
12106
|
let isCancelled = false;
|
|
11925
12107
|
if (!isReady) {
|
|
11926
12108
|
if (data === void 0) {
|
|
11927
|
-
setOfferDetailsState(
|
|
12109
|
+
setOfferDetailsState(LOADING_STATE9);
|
|
11928
12110
|
}
|
|
11929
12111
|
return () => {
|
|
11930
12112
|
isCancelled = true;
|
|
@@ -11935,7 +12117,7 @@ function useOfferDetails(offerId, options = {}) {
|
|
|
11935
12117
|
isCancelled = true;
|
|
11936
12118
|
};
|
|
11937
12119
|
}
|
|
11938
|
-
setOfferDetailsState(
|
|
12120
|
+
setOfferDetailsState(LOADING_STATE9);
|
|
11939
12121
|
coinlist.offers.get(offerId).then((offerDetail) => {
|
|
11940
12122
|
if (!isCancelled) {
|
|
11941
12123
|
log.debug(() => ({
|
|
@@ -11975,66 +12157,6 @@ var OfferAssetCardUi = {
|
|
|
11975
12157
|
})
|
|
11976
12158
|
};
|
|
11977
12159
|
|
|
11978
|
-
// src/client/hooks/tokens/data/useTokenMetadata.ts
|
|
11979
|
-
import { useCallback as useCallback15, useEffect as useEffect32, useState as useState33 } from "react";
|
|
11980
|
-
var DISABLED_STATE = { type: "DISABLED" };
|
|
11981
|
-
var LOADING_STATE9 = { type: "LOADING" };
|
|
11982
|
-
function useTokenMetadata(options) {
|
|
11983
|
-
const { chain, address, data, enabled = true } = options;
|
|
11984
|
-
const { coinlist, isReady } = useCoinList();
|
|
11985
|
-
const log = useLogger("useTokenMetadata");
|
|
11986
|
-
const [state, setState] = useState33(
|
|
11987
|
-
() => data !== void 0 ? { type: "CONTENT", tokenMetadata: data } : LOADING_STATE9
|
|
11988
|
-
);
|
|
11989
|
-
const [refetchCount, setRefetchCount] = useState33(0);
|
|
11990
|
-
const refetch = useCallback15(() => {
|
|
11991
|
-
setRefetchCount((count) => count + 1);
|
|
11992
|
-
}, []);
|
|
11993
|
-
useEffect32(() => {
|
|
11994
|
-
let isCancelled = false;
|
|
11995
|
-
const seedActive = data !== void 0 && refetchCount === 0;
|
|
11996
|
-
if (!isReady || !enabled || seedActive) {
|
|
11997
|
-
return () => {
|
|
11998
|
-
isCancelled = true;
|
|
11999
|
-
};
|
|
12000
|
-
}
|
|
12001
|
-
setState(LOADING_STATE9);
|
|
12002
|
-
coinlist.tokens.get({ chain, address }).then((tokenMetadata) => {
|
|
12003
|
-
if (!isCancelled) {
|
|
12004
|
-
log.debug(() => ({
|
|
12005
|
-
msg: "settled",
|
|
12006
|
-
fields: {
|
|
12007
|
-
state: "CONTENT",
|
|
12008
|
-
listed: tokenMetadata !== null,
|
|
12009
|
-
symbol: tokenMetadata?.symbol ?? null
|
|
12010
|
-
}
|
|
12011
|
-
}));
|
|
12012
|
-
setState({ type: "CONTENT", tokenMetadata });
|
|
12013
|
-
}
|
|
12014
|
-
}).catch((error) => {
|
|
12015
|
-
if (!isCancelled) {
|
|
12016
|
-
log.failure(
|
|
12017
|
-
() => ({
|
|
12018
|
-
msg: "settled",
|
|
12019
|
-
fields: { state: "ERROR", reason: "generic-error" }
|
|
12020
|
-
}),
|
|
12021
|
-
error
|
|
12022
|
-
);
|
|
12023
|
-
setState({ type: "ERROR", reason: "generic-error" });
|
|
12024
|
-
}
|
|
12025
|
-
});
|
|
12026
|
-
return () => {
|
|
12027
|
-
isCancelled = true;
|
|
12028
|
-
};
|
|
12029
|
-
}, [coinlist, isReady, enabled, chain, address, data, refetchCount, log]);
|
|
12030
|
-
return {
|
|
12031
|
-
// LOADING would be a lie while disabled: nothing is in flight and nothing
|
|
12032
|
-
// will replace it. Settled states (a seed, a previous answer) survive.
|
|
12033
|
-
state: !enabled && state.type === "LOADING" ? DISABLED_STATE : state,
|
|
12034
|
-
refetch
|
|
12035
|
-
};
|
|
12036
|
-
}
|
|
12037
|
-
|
|
12038
12160
|
// src/client/ui/format/date.ts
|
|
12039
12161
|
function formatMonthYear(date, locale) {
|
|
12040
12162
|
return new Intl.DateTimeFormat(locale, {
|
|
@@ -12123,7 +12245,9 @@ export {
|
|
|
12123
12245
|
formatCountdown,
|
|
12124
12246
|
formatMonthYear,
|
|
12125
12247
|
formatSaleCardCountdown,
|
|
12248
|
+
offerAssetIconUrl,
|
|
12126
12249
|
offerIconUrl,
|
|
12250
|
+
offerTokenIdentifier,
|
|
12127
12251
|
ondoLoadErrorReason,
|
|
12128
12252
|
pinoClientLogger,
|
|
12129
12253
|
prepareOndoBuy,
|
|
@@ -12132,6 +12256,9 @@ export {
|
|
|
12132
12256
|
quoteOverAsks,
|
|
12133
12257
|
stablecoinIconUrl,
|
|
12134
12258
|
submitErc20Approval,
|
|
12259
|
+
tokenLogoUrl,
|
|
12260
|
+
tokenMetadataOf,
|
|
12261
|
+
useCheckoutOfferTokenMetadata,
|
|
12135
12262
|
useCoinList,
|
|
12136
12263
|
useCoinListSignInCardViewModel,
|
|
12137
12264
|
useCompleteOAuth,
|