@coinlist-co/react 0.12.1-rc.14ac67e → 0.12.1-rc.a230abc
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-3ATIDGVR.js → chunk-GFLU5OMP.js} +19 -5
- package/dist/chunk-GFLU5OMP.js.map +1 -0
- package/dist/{chunk-SOMNMOBU.js → chunk-HLL7IBIS.js} +2 -2
- package/dist/{chunk-2XBPKC4C.js → chunk-RPE7XIBV.js} +2 -2
- package/dist/client/index.cjs +414 -273
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +212 -85
- package/dist/client/index.d.ts +212 -85
- package/dist/client/index.js +365 -242
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-DNbBE6Pk.d.cts → collections-CAfs2Eww.d.cts} +1 -1
- package/dist/{collections-DVCh4jUp.d.ts → collections-DZZFrizd.d.ts} +1 -1
- package/dist/{config-DFYAM0GD.d.cts → config-D19ktBr0.d.cts} +19 -1
- package/dist/{config-DFYAM0GD.d.ts → config-D19ktBr0.d.ts} +19 -1
- package/dist/server/index.cjs +17 -4
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -2
- package/dist/shared/index.cjs +19 -4
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +4 -4
- package/dist/shared/index.d.ts +4 -4
- package/dist/shared/index.js +4 -2
- package/package.json +1 -1
- package/dist/chunk-3ATIDGVR.js.map +0 -1
- /package/dist/{chunk-SOMNMOBU.js.map → chunk-HLL7IBIS.js.map} +0 -0
- /package/dist/{chunk-2XBPKC4C.js.map → chunk-RPE7XIBV.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-HLL7IBIS.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-RPE7XIBV.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-GFLU5OMP.js";
|
|
89
89
|
|
|
90
90
|
// src/client/CoinListProvider.tsx
|
|
91
91
|
import {
|
|
@@ -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";
|
|
@@ -5419,7 +5419,7 @@ function ErrorView4({
|
|
|
5419
5419
|
}
|
|
5420
5420
|
|
|
5421
5421
|
// src/client/hooks/checkout/ondo/buy/useOndoBuyCheckoutViewModel.ts
|
|
5422
|
-
import { useState as
|
|
5422
|
+
import { useState as useState11 } from "react";
|
|
5423
5423
|
|
|
5424
5424
|
// src/client/hooks/checkout/ondo/buy/amount/useOndoBuyAmountViewModel.ts
|
|
5425
5425
|
import { useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
@@ -5446,6 +5446,26 @@ function stablecoinIconUrl(symbol) {
|
|
|
5446
5446
|
function offerIconUrl(offer) {
|
|
5447
5447
|
return offer.logoUrl === "" ? null : AssetIconUrl(offer.logoUrl);
|
|
5448
5448
|
}
|
|
5449
|
+
function tokenLogoUrl(logo, minWidth = 40) {
|
|
5450
|
+
switch (logo.kind) {
|
|
5451
|
+
case "VECTOR":
|
|
5452
|
+
return AssetIconUrl(logo.url);
|
|
5453
|
+
case "RASTER": {
|
|
5454
|
+
const chosen = logo.variants.reduce(
|
|
5455
|
+
(smallest, variant) => variant.width >= minWidth && (smallest === null || variant.width < smallest.width) ? variant : smallest,
|
|
5456
|
+
null
|
|
5457
|
+
);
|
|
5458
|
+
return AssetIconUrl((chosen ?? logo.original).url);
|
|
5459
|
+
}
|
|
5460
|
+
default: {
|
|
5461
|
+
const exhaustive = logo;
|
|
5462
|
+
return exhaustive;
|
|
5463
|
+
}
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
function offerAssetIconUrl(offer, tokenMetadata) {
|
|
5467
|
+
return (tokenMetadata ? tokenLogoUrl(tokenMetadata.logo) : null) ?? offerIconUrl(offer);
|
|
5468
|
+
}
|
|
5449
5469
|
|
|
5450
5470
|
// src/client/hooks/checkout/shared/checkout-ui.types.ts
|
|
5451
5471
|
var CheckoutAssetUi = {
|
|
@@ -5454,10 +5474,10 @@ var CheckoutAssetUi = {
|
|
|
5454
5474
|
* name and symbol, the caller supplies the chain it is being traded on and
|
|
5455
5475
|
* whatever icon it has for it.
|
|
5456
5476
|
*
|
|
5457
|
-
* `iconUrl` is a caller's parameter rather than the token's own because
|
|
5458
|
-
*
|
|
5459
|
-
*
|
|
5460
|
-
*
|
|
5477
|
+
* `iconUrl` is a caller's parameter rather than the token's own because an
|
|
5478
|
+
* `Erc20Asset` does not carry one, and which source supplies it is the
|
|
5479
|
+
* caller's to decide. Which is also why it defaults to `null`: the input
|
|
5480
|
+
* asset a user pays with has no offer behind it.
|
|
5461
5481
|
*
|
|
5462
5482
|
* An asset sourced from the offer rather than from a token has its own
|
|
5463
5483
|
* companion, {@link fromOffer}. One companion per source, not one per call
|
|
@@ -5474,7 +5494,7 @@ var CheckoutAssetUi = {
|
|
|
5474
5494
|
}),
|
|
5475
5495
|
/**
|
|
5476
5496
|
* The view of the asset an offer sells: the offer supplies its name and the
|
|
5477
|
-
*
|
|
5497
|
+
* fallback artwork, the caller supplies the symbol and the chain.
|
|
5478
5498
|
*
|
|
5479
5499
|
* `symbol` is a parameter rather than `offer.asset.code` because the symbol a
|
|
5480
5500
|
* provider trades under is the provider's, not the catalogue's - Ondo's
|
|
@@ -5482,14 +5502,26 @@ var CheckoutAssetUi = {
|
|
|
5482
5502
|
* asset stands in. Keeping it out here is what lets one companion serve every
|
|
5483
5503
|
* provider instead of forking per provider.
|
|
5484
5504
|
*
|
|
5505
|
+
* The icon is resolved from the public token registry when `tokenMetadata`
|
|
5506
|
+
* carries a listed token — `useCheckoutOfferTokenMetadata` fetches it,
|
|
5507
|
+
* keyed by the token `OfferDetail.tokens` lists for this chain — and falls
|
|
5508
|
+
* back to the offer's own logo otherwise. `null` covers every way the
|
|
5509
|
+
* registry answer can be absent (unlisted, not settled, lookup failed);
|
|
5510
|
+
* which one it is stays the concern of the hook's state machine, not of
|
|
5511
|
+
* this model, because the icon is the same either way.
|
|
5512
|
+
*
|
|
5485
5513
|
* Deliberately no decimals. An offer names an asset; it does not answer for
|
|
5486
5514
|
* the scale of any particular quantity, and every amount a checkout renders
|
|
5487
5515
|
* arrives as a `BlockchainAmount` carrying its own.
|
|
5488
5516
|
*/
|
|
5489
|
-
fromOffer: (offer, {
|
|
5517
|
+
fromOffer: (offer, {
|
|
5518
|
+
symbol,
|
|
5519
|
+
networkName,
|
|
5520
|
+
tokenMetadata
|
|
5521
|
+
}) => ({
|
|
5490
5522
|
name: offer.name,
|
|
5491
5523
|
symbol,
|
|
5492
|
-
iconUrl:
|
|
5524
|
+
iconUrl: offerAssetIconUrl(offer, tokenMetadata),
|
|
5493
5525
|
network: { name: networkName, iconUrl: null }
|
|
5494
5526
|
})
|
|
5495
5527
|
};
|
|
@@ -6010,6 +6042,7 @@ function useOndoBuyReviewViewModel({
|
|
|
6010
6042
|
ondoSymbol,
|
|
6011
6043
|
chain,
|
|
6012
6044
|
offer,
|
|
6045
|
+
outputTokenMetadata,
|
|
6013
6046
|
enabled = true,
|
|
6014
6047
|
onComplete
|
|
6015
6048
|
}) {
|
|
@@ -6062,7 +6095,8 @@ function useOndoBuyReviewViewModel({
|
|
|
6062
6095
|
type: "active",
|
|
6063
6096
|
outputAsset: CheckoutAssetUi.fromOffer(offer, {
|
|
6064
6097
|
symbol: ondoSymbol,
|
|
6065
|
-
networkName: getNetworkName(chain)
|
|
6098
|
+
networkName: getNetworkName(chain),
|
|
6099
|
+
tokenMetadata: outputTokenMetadata
|
|
6066
6100
|
}),
|
|
6067
6101
|
outputAmount: assetAmount(
|
|
6068
6102
|
formatAmount(built.receiveOutputAmount, locale),
|
|
@@ -6393,6 +6427,7 @@ function useOndoSidebarViewModel({
|
|
|
6393
6427
|
offer,
|
|
6394
6428
|
ondoSymbol,
|
|
6395
6429
|
chain,
|
|
6430
|
+
tokenMetadata,
|
|
6396
6431
|
priceState,
|
|
6397
6432
|
tradingStatusState
|
|
6398
6433
|
}) {
|
|
@@ -6400,7 +6435,8 @@ function useOndoSidebarViewModel({
|
|
|
6400
6435
|
const state = {
|
|
6401
6436
|
asset: CheckoutAssetUi.fromOffer(offer, {
|
|
6402
6437
|
symbol: ondoSymbol,
|
|
6403
|
-
networkName: getNetworkName(chain)
|
|
6438
|
+
networkName: getNetworkName(chain),
|
|
6439
|
+
tokenMetadata
|
|
6404
6440
|
}),
|
|
6405
6441
|
// No frontline endpoint carries any of these today, and the detail list
|
|
6406
6442
|
// drops a null row rather than dashing it.
|
|
@@ -6590,6 +6626,99 @@ function toConfirmedWalletUi(wallets, wallet) {
|
|
|
6590
6626
|
};
|
|
6591
6627
|
}
|
|
6592
6628
|
|
|
6629
|
+
// src/client/hooks/shared/useTokenMetadata.ts
|
|
6630
|
+
import { useCallback as useCallback3, useEffect as useEffect10, useState as useState10 } from "react";
|
|
6631
|
+
var DISABLED_STATE = { type: "DISABLED" };
|
|
6632
|
+
var LOADING_STATE = { type: "LOADING" };
|
|
6633
|
+
function useTokenMetadata(options) {
|
|
6634
|
+
const { chain, address, data, enabled = true } = options;
|
|
6635
|
+
const { coinlist, isReady } = useCoinList();
|
|
6636
|
+
const log = useLogger("useTokenMetadata");
|
|
6637
|
+
const [state, setState] = useState10(
|
|
6638
|
+
() => data !== void 0 ? { type: "CONTENT", tokenMetadata: data } : LOADING_STATE
|
|
6639
|
+
);
|
|
6640
|
+
const [refetchCount, setRefetchCount] = useState10(0);
|
|
6641
|
+
const refetch = useCallback3(() => {
|
|
6642
|
+
setRefetchCount((count) => count + 1);
|
|
6643
|
+
}, []);
|
|
6644
|
+
useEffect10(() => {
|
|
6645
|
+
let isCancelled = false;
|
|
6646
|
+
const seedActive = data !== void 0 && refetchCount === 0;
|
|
6647
|
+
if (!isReady || !enabled || seedActive) {
|
|
6648
|
+
return () => {
|
|
6649
|
+
isCancelled = true;
|
|
6650
|
+
};
|
|
6651
|
+
}
|
|
6652
|
+
setState(LOADING_STATE);
|
|
6653
|
+
coinlist.tokens.get({ chain, address }).then((tokenMetadata) => {
|
|
6654
|
+
if (!isCancelled) {
|
|
6655
|
+
log.debug(() => ({
|
|
6656
|
+
msg: "settled",
|
|
6657
|
+
fields: {
|
|
6658
|
+
state: "CONTENT",
|
|
6659
|
+
listed: tokenMetadata !== null,
|
|
6660
|
+
symbol: tokenMetadata?.symbol ?? null
|
|
6661
|
+
}
|
|
6662
|
+
}));
|
|
6663
|
+
setState({ type: "CONTENT", tokenMetadata });
|
|
6664
|
+
}
|
|
6665
|
+
}).catch((error) => {
|
|
6666
|
+
if (!isCancelled) {
|
|
6667
|
+
log.failure(
|
|
6668
|
+
() => ({
|
|
6669
|
+
msg: "settled",
|
|
6670
|
+
fields: { state: "ERROR", reason: "generic-error" }
|
|
6671
|
+
}),
|
|
6672
|
+
error
|
|
6673
|
+
);
|
|
6674
|
+
setState({ type: "ERROR", reason: "generic-error" });
|
|
6675
|
+
}
|
|
6676
|
+
});
|
|
6677
|
+
return () => {
|
|
6678
|
+
isCancelled = true;
|
|
6679
|
+
};
|
|
6680
|
+
}, [coinlist, isReady, enabled, chain, address, data, refetchCount, log]);
|
|
6681
|
+
return {
|
|
6682
|
+
// LOADING would be a lie while disabled: nothing is in flight and nothing
|
|
6683
|
+
// will replace it. Settled states (a seed, a previous answer) survive.
|
|
6684
|
+
state: !enabled && state.type === "LOADING" ? DISABLED_STATE : state,
|
|
6685
|
+
refetch
|
|
6686
|
+
};
|
|
6687
|
+
}
|
|
6688
|
+
|
|
6689
|
+
// src/client/hooks/checkout/shared/data/useCheckoutOfferTokenMetadata.ts
|
|
6690
|
+
var NO_TOKEN_ADDRESS = EvmContractAddress(
|
|
6691
|
+
"0x0000000000000000000000000000000000000000"
|
|
6692
|
+
);
|
|
6693
|
+
function offerTokenIdentifier(offer, chain) {
|
|
6694
|
+
const byChain = offer.tokens.filter((token) => token.chain === chain);
|
|
6695
|
+
const asset = byChain.find((token) => token.role === "swap") ?? byChain.find((token) => token.role === "distribution");
|
|
6696
|
+
return asset === void 0 ? null : { chain, address: asset.address };
|
|
6697
|
+
}
|
|
6698
|
+
function tokenMetadataOf(state) {
|
|
6699
|
+
return state.type === "CONTENT" ? state.tokenMetadata : null;
|
|
6700
|
+
}
|
|
6701
|
+
function useCheckoutOfferTokenMetadata({
|
|
6702
|
+
offer,
|
|
6703
|
+
chain,
|
|
6704
|
+
data,
|
|
6705
|
+
enabled = true
|
|
6706
|
+
}) {
|
|
6707
|
+
const identifier = offerTokenIdentifier(offer, chain);
|
|
6708
|
+
const { state } = useTokenMetadata({
|
|
6709
|
+
// Primitive keys, not the identifier object: the underlying hook re-fetches
|
|
6710
|
+
// only when `(chain, address)` changes, so a host that rebuilds the offer
|
|
6711
|
+
// object per render does not refetch the registry per render.
|
|
6712
|
+
chain: identifier?.chain ?? chain,
|
|
6713
|
+
address: identifier?.address ?? NO_TOKEN_ADDRESS,
|
|
6714
|
+
// Nothing to look up when the offer lists no token here: seed "not
|
|
6715
|
+
// listed" and never fire a request against the placeholder address.
|
|
6716
|
+
enabled: enabled && identifier !== null,
|
|
6717
|
+
data: data !== void 0 ? data : identifier === null ? null : void 0
|
|
6718
|
+
});
|
|
6719
|
+
return { state };
|
|
6720
|
+
}
|
|
6721
|
+
|
|
6593
6722
|
// src/client/hooks/checkout/ondo/buy/useOndoBuyCheckoutViewModel.ts
|
|
6594
6723
|
function useOndoBuyCheckoutViewModel({
|
|
6595
6724
|
offer,
|
|
@@ -6600,8 +6729,8 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6600
6729
|
onOrderConfirmed
|
|
6601
6730
|
}) {
|
|
6602
6731
|
const locale = useLocale();
|
|
6603
|
-
const [step, setStep] =
|
|
6604
|
-
const [orderConfirmed, setOrderConfirmed] =
|
|
6732
|
+
const [step, setStep] = useState11({ type: "wallet" });
|
|
6733
|
+
const [orderConfirmed, setOrderConfirmed] = useState11(null);
|
|
6605
6734
|
const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
|
|
6606
6735
|
const live = enabled && swappableHere;
|
|
6607
6736
|
const { state: priceState } = useOndoPrice({
|
|
@@ -6617,6 +6746,20 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6617
6746
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
6618
6747
|
enabled: live
|
|
6619
6748
|
});
|
|
6749
|
+
const { state: outputTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
6750
|
+
offer,
|
|
6751
|
+
chain,
|
|
6752
|
+
enabled: live
|
|
6753
|
+
});
|
|
6754
|
+
const outputTokenMetadata = tokenMetadataOf(outputTokenMetadataState);
|
|
6755
|
+
const orderConfirmedUi = (order) => order === null ? { type: "hidden" } : toOrderConfirmedUi({
|
|
6756
|
+
order,
|
|
6757
|
+
chain,
|
|
6758
|
+
locale,
|
|
6759
|
+
offer,
|
|
6760
|
+
ondoSymbol,
|
|
6761
|
+
outputTokenMetadata
|
|
6762
|
+
});
|
|
6620
6763
|
const { state: walletState, onEvent: onWalletEvent } = useOndoWalletSelectViewModel({
|
|
6621
6764
|
stepInput: walletStepInput(step),
|
|
6622
6765
|
wallets,
|
|
@@ -6663,11 +6806,10 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6663
6806
|
ondoSymbol,
|
|
6664
6807
|
chain,
|
|
6665
6808
|
offer,
|
|
6809
|
+
outputTokenMetadata,
|
|
6666
6810
|
enabled: live,
|
|
6667
6811
|
onComplete: (order) => {
|
|
6668
|
-
setOrderConfirmed(
|
|
6669
|
-
toOrderConfirmedUi({ order, chain, locale, offer, ondoSymbol })
|
|
6670
|
-
);
|
|
6812
|
+
setOrderConfirmed(order);
|
|
6671
6813
|
setStep({ type: "wallet" });
|
|
6672
6814
|
onOrderConfirmed?.(order);
|
|
6673
6815
|
}
|
|
@@ -6676,6 +6818,7 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6676
6818
|
offer,
|
|
6677
6819
|
ondoSymbol,
|
|
6678
6820
|
chain,
|
|
6821
|
+
tokenMetadata: outputTokenMetadata,
|
|
6679
6822
|
priceState,
|
|
6680
6823
|
tradingStatusState
|
|
6681
6824
|
});
|
|
@@ -6685,7 +6828,7 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6685
6828
|
amount: amountState,
|
|
6686
6829
|
review: reviewState,
|
|
6687
6830
|
sidebar: sidebarState,
|
|
6688
|
-
orderConfirmed
|
|
6831
|
+
orderConfirmed: orderConfirmedUi(orderConfirmed)
|
|
6689
6832
|
};
|
|
6690
6833
|
const onEvent = (event) => {
|
|
6691
6834
|
switch (event.type) {
|
|
@@ -6709,7 +6852,7 @@ function useOndoBuyCheckoutViewModel({
|
|
|
6709
6852
|
onReviewEvent(event);
|
|
6710
6853
|
return;
|
|
6711
6854
|
case "ON_CLOSE_ORDER_CONFIRMED":
|
|
6712
|
-
setOrderConfirmed(
|
|
6855
|
+
setOrderConfirmed(null);
|
|
6713
6856
|
return;
|
|
6714
6857
|
default: {
|
|
6715
6858
|
const exhaustive = event;
|
|
@@ -6763,14 +6906,16 @@ function toOrderConfirmedUi({
|
|
|
6763
6906
|
chain,
|
|
6764
6907
|
locale,
|
|
6765
6908
|
offer,
|
|
6766
|
-
ondoSymbol
|
|
6909
|
+
ondoSymbol,
|
|
6910
|
+
outputTokenMetadata
|
|
6767
6911
|
}) {
|
|
6768
6912
|
const inputSymbol = TOKEN_REGISTRY.erc20(order.inputAsset).symbol;
|
|
6769
6913
|
return {
|
|
6770
6914
|
type: "visible",
|
|
6771
6915
|
outputAsset: CheckoutAssetUi.fromOffer(offer, {
|
|
6772
6916
|
symbol: ondoSymbol,
|
|
6773
|
-
networkName: getNetworkName(chain)
|
|
6917
|
+
networkName: getNetworkName(chain),
|
|
6918
|
+
tokenMetadata: outputTokenMetadata
|
|
6774
6919
|
}),
|
|
6775
6920
|
outputAmount: assetAmount(
|
|
6776
6921
|
formatAmount(order.transaction.receiveOutputAmount, locale),
|
|
@@ -6790,13 +6935,13 @@ function toOrderConfirmedUi({
|
|
|
6790
6935
|
}
|
|
6791
6936
|
|
|
6792
6937
|
// src/client/hooks/checkout/ondo/sell/useOndoSellCheckoutViewModel.ts
|
|
6793
|
-
import { useState as
|
|
6938
|
+
import { useState as useState16 } from "react";
|
|
6794
6939
|
|
|
6795
6940
|
// src/client/hooks/checkout/ondo/sell/amount/useOndoSellAmountViewModel.ts
|
|
6796
|
-
import { useEffect as
|
|
6941
|
+
import { useEffect as useEffect12, useRef as useRef9, useState as useState13 } from "react";
|
|
6797
6942
|
|
|
6798
6943
|
// src/client/hooks/shared/erc20/useErc20Balance.ts
|
|
6799
|
-
import { useEffect as
|
|
6944
|
+
import { useEffect as useEffect11, useRef as useRef8, useState as useState12 } from "react";
|
|
6800
6945
|
function useErc20Balance(options) {
|
|
6801
6946
|
const {
|
|
6802
6947
|
tokenAddress,
|
|
@@ -6807,12 +6952,12 @@ function useErc20Balance(options) {
|
|
|
6807
6952
|
} = options;
|
|
6808
6953
|
const { coinlist, isReady } = useCoinList();
|
|
6809
6954
|
const log = useLogger("useErc20Balance");
|
|
6810
|
-
const [balance, setBalance] =
|
|
6811
|
-
const [isLoading, setIsLoading] =
|
|
6955
|
+
const [balance, setBalance] = useState12(null);
|
|
6956
|
+
const [isLoading, setIsLoading] = useState12(true);
|
|
6812
6957
|
const fetchIdRef = useRef8(0);
|
|
6813
6958
|
const isFetchingRef = useRef8(false);
|
|
6814
6959
|
const hasReadRef = useRef8(false);
|
|
6815
|
-
|
|
6960
|
+
useEffect11(() => {
|
|
6816
6961
|
if (!isReady) return;
|
|
6817
6962
|
setBalance(null);
|
|
6818
6963
|
hasReadRef.current = false;
|
|
@@ -6889,15 +7034,16 @@ function useOndoSellAmountViewModel({
|
|
|
6889
7034
|
ondoSymbol,
|
|
6890
7035
|
chain,
|
|
6891
7036
|
offer,
|
|
7037
|
+
inputTokenMetadata,
|
|
6892
7038
|
enabled = true,
|
|
6893
7039
|
onComplete,
|
|
6894
7040
|
onEdit
|
|
6895
7041
|
}) {
|
|
6896
7042
|
const { coinlist } = useCoinList();
|
|
6897
7043
|
const locale = useLocale();
|
|
6898
|
-
const [amountInput, setAmountInput] =
|
|
6899
|
-
const [error, setError] =
|
|
6900
|
-
const [phase, setPhase] =
|
|
7044
|
+
const [amountInput, setAmountInput] = useState13("");
|
|
7045
|
+
const [error, setError] = useState13(null);
|
|
7046
|
+
const [phase, setPhase] = useState13(null);
|
|
6901
7047
|
const preparationIdRef = useRef9(0);
|
|
6902
7048
|
const isActive = stepInput.type === "active";
|
|
6903
7049
|
const networkName = getNetworkName(chain);
|
|
@@ -6909,7 +7055,7 @@ function useOndoSellAmountViewModel({
|
|
|
6909
7055
|
chain,
|
|
6910
7056
|
enabled: enabled && isActive && sellAsset2 !== null
|
|
6911
7057
|
});
|
|
6912
|
-
|
|
7058
|
+
useEffect12(() => {
|
|
6913
7059
|
if (stepInput.type === "incomplete") {
|
|
6914
7060
|
++preparationIdRef.current;
|
|
6915
7061
|
setAmountInput("");
|
|
@@ -6935,7 +7081,8 @@ function useOndoSellAmountViewModel({
|
|
|
6935
7081
|
type: "complete",
|
|
6936
7082
|
asset: CheckoutAssetUi.fromOffer(offer, {
|
|
6937
7083
|
symbol: stepInput.inputAsset,
|
|
6938
|
-
networkName
|
|
7084
|
+
networkName,
|
|
7085
|
+
tokenMetadata: inputTokenMetadata
|
|
6939
7086
|
}),
|
|
6940
7087
|
amountFormatted: assetAmount(
|
|
6941
7088
|
formatAmount(stepInput.amount, locale),
|
|
@@ -6957,7 +7104,8 @@ function useOndoSellAmountViewModel({
|
|
|
6957
7104
|
return {
|
|
6958
7105
|
asset: CheckoutAssetUi.fromOffer(offer, {
|
|
6959
7106
|
symbol: ondoSymbol,
|
|
6960
|
-
networkName
|
|
7107
|
+
networkName,
|
|
7108
|
+
tokenMetadata: inputTokenMetadata
|
|
6961
7109
|
}),
|
|
6962
7110
|
balance: assetAmount(formatAmount(amount, locale), ondoSymbol),
|
|
6963
7111
|
rawBalance: balance
|
|
@@ -7144,15 +7292,15 @@ function preparationErrorMessage2(error) {
|
|
|
7144
7292
|
}
|
|
7145
7293
|
|
|
7146
7294
|
// src/client/hooks/checkout/ondo/sell/review/useOndoSellReviewViewModel.ts
|
|
7147
|
-
import { useEffect as
|
|
7295
|
+
import { useEffect as useEffect14, useRef as useRef11, useState as useState15 } from "react";
|
|
7148
7296
|
|
|
7149
7297
|
// src/client/hooks/checkout/ondo/sell/data/useOndoSellTransaction.ts
|
|
7150
|
-
import { useCallback as
|
|
7298
|
+
import { useCallback as useCallback4, useEffect as useEffect13, useRef as useRef10, useState as useState14 } from "react";
|
|
7151
7299
|
function useOndoSellTransaction(options) {
|
|
7152
7300
|
const { request, data, enabled } = options;
|
|
7153
7301
|
const { coinlist, isReady } = useCoinList();
|
|
7154
7302
|
const log = useLogger("useOndoSellTransaction");
|
|
7155
|
-
const [state, setState] =
|
|
7303
|
+
const [state, setState] = useState14(
|
|
7156
7304
|
() => data === void 0 ? { type: "LOADING" } : {
|
|
7157
7305
|
type: "CONTENT",
|
|
7158
7306
|
transaction: data,
|
|
@@ -7165,7 +7313,7 @@ function useOndoSellTransaction(options) {
|
|
|
7165
7313
|
const requestKey = request === null ? null : stableKey2(request);
|
|
7166
7314
|
const requestRef = useRef10(request);
|
|
7167
7315
|
requestRef.current = request;
|
|
7168
|
-
const build =
|
|
7316
|
+
const build = useCallback4(async () => {
|
|
7169
7317
|
const params = requestRef.current;
|
|
7170
7318
|
if (!isReady || !enabled || params === null) return;
|
|
7171
7319
|
if (isFetchingRef.current) return;
|
|
@@ -7201,7 +7349,7 @@ function useOndoSellTransaction(options) {
|
|
|
7201
7349
|
isFetchingRef.current = false;
|
|
7202
7350
|
}
|
|
7203
7351
|
}, [coinlist, isReady, enabled, log]);
|
|
7204
|
-
|
|
7352
|
+
useEffect13(() => {
|
|
7205
7353
|
if (data === void 0) return;
|
|
7206
7354
|
++fetchIdRef.current;
|
|
7207
7355
|
setState({
|
|
@@ -7212,14 +7360,14 @@ function useOndoSellTransaction(options) {
|
|
|
7212
7360
|
});
|
|
7213
7361
|
}, [data]);
|
|
7214
7362
|
const hasSeed = data !== void 0;
|
|
7215
|
-
|
|
7363
|
+
useEffect13(() => {
|
|
7216
7364
|
if (hasSeed || requestKey === null) return;
|
|
7217
7365
|
build();
|
|
7218
7366
|
return () => {
|
|
7219
7367
|
++fetchIdRef.current;
|
|
7220
7368
|
};
|
|
7221
7369
|
}, [build, requestKey, hasSeed]);
|
|
7222
|
-
const refetch =
|
|
7370
|
+
const refetch = useCallback4(() => {
|
|
7223
7371
|
build();
|
|
7224
7372
|
}, [build]);
|
|
7225
7373
|
return { state, refetch };
|
|
@@ -7244,8 +7392,8 @@ function useOndoSellReviewViewModel({
|
|
|
7244
7392
|
}) {
|
|
7245
7393
|
const { coinlist } = useCoinList();
|
|
7246
7394
|
const locale = useLocale();
|
|
7247
|
-
const [phase, setPhase] =
|
|
7248
|
-
const [error, setError] =
|
|
7395
|
+
const [phase, setPhase] = useState15(null);
|
|
7396
|
+
const [error, setError] = useState15(null);
|
|
7249
7397
|
const isActive = stepInput.type === "active";
|
|
7250
7398
|
const { state: transactionState, refetch } = useOndoSellTransaction({
|
|
7251
7399
|
request: isActive ? {
|
|
@@ -7258,7 +7406,7 @@ function useOndoSellReviewViewModel({
|
|
|
7258
7406
|
enabled: enabled && isActive
|
|
7259
7407
|
});
|
|
7260
7408
|
const executionIdRef = useRef11(0);
|
|
7261
|
-
|
|
7409
|
+
useEffect14(() => {
|
|
7262
7410
|
if (stepInput.type === "incomplete") {
|
|
7263
7411
|
++executionIdRef.current;
|
|
7264
7412
|
setError(null);
|
|
@@ -7468,12 +7616,12 @@ function useOndoSellCheckoutViewModel({
|
|
|
7468
7616
|
onOrderConfirmed
|
|
7469
7617
|
}) {
|
|
7470
7618
|
const locale = useLocale();
|
|
7471
|
-
const [initialStep] =
|
|
7619
|
+
const [initialStep] = useState16(
|
|
7472
7620
|
() => wallets.preselected === null ? { type: "wallet" } : { type: "amount", wallet: wallets.preselected }
|
|
7473
7621
|
);
|
|
7474
|
-
const [step, setStep] =
|
|
7622
|
+
const [step, setStep] = useState16(initialStep);
|
|
7475
7623
|
const hasWalletStep = initialStep.type === "wallet";
|
|
7476
|
-
const [orderConfirmed, setOrderConfirmed] =
|
|
7624
|
+
const [orderConfirmed, setOrderConfirmed] = useState16(null);
|
|
7477
7625
|
const swappableHere = swapSpender(offer.swapContracts, chain) !== null;
|
|
7478
7626
|
const live = enabled && swappableHere;
|
|
7479
7627
|
const { state: priceState } = useOndoPrice({
|
|
@@ -7489,6 +7637,20 @@ function useOndoSellCheckoutViewModel({
|
|
|
7489
7637
|
pollIntervalMs: ONDO_POLL_INTERVAL_MS,
|
|
7490
7638
|
enabled: live
|
|
7491
7639
|
});
|
|
7640
|
+
const { state: inputTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
7641
|
+
offer,
|
|
7642
|
+
chain,
|
|
7643
|
+
enabled: live
|
|
7644
|
+
});
|
|
7645
|
+
const inputTokenMetadata = tokenMetadataOf(inputTokenMetadataState);
|
|
7646
|
+
const orderConfirmedUi = (order) => order === null ? { type: "hidden" } : toOrderConfirmedUi2({
|
|
7647
|
+
order,
|
|
7648
|
+
chain,
|
|
7649
|
+
locale,
|
|
7650
|
+
offer,
|
|
7651
|
+
ondoSymbol,
|
|
7652
|
+
inputTokenMetadata
|
|
7653
|
+
});
|
|
7492
7654
|
const { state: walletState, onEvent: onWalletEvent } = useOndoWalletSelectViewModel({
|
|
7493
7655
|
stepInput: walletStepInput2(step),
|
|
7494
7656
|
wallets,
|
|
@@ -7505,6 +7667,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7505
7667
|
ondoSymbol,
|
|
7506
7668
|
chain,
|
|
7507
7669
|
offer,
|
|
7670
|
+
inputTokenMetadata,
|
|
7508
7671
|
enabled: live,
|
|
7509
7672
|
// Both transitions read the step through the updater rather than the one
|
|
7510
7673
|
// this render closed over. Preparing an amount takes an approval to mine,
|
|
@@ -7537,9 +7700,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7537
7700
|
chain,
|
|
7538
7701
|
enabled: live,
|
|
7539
7702
|
onComplete: (order) => {
|
|
7540
|
-
setOrderConfirmed(
|
|
7541
|
-
toOrderConfirmedUi2({ order, chain, locale, offer, ondoSymbol })
|
|
7542
|
-
);
|
|
7703
|
+
setOrderConfirmed(order);
|
|
7543
7704
|
setStep(initialStep);
|
|
7544
7705
|
onOrderConfirmed?.(order);
|
|
7545
7706
|
}
|
|
@@ -7548,6 +7709,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7548
7709
|
offer,
|
|
7549
7710
|
ondoSymbol,
|
|
7550
7711
|
chain,
|
|
7712
|
+
tokenMetadata: inputTokenMetadata,
|
|
7551
7713
|
priceState,
|
|
7552
7714
|
tradingStatusState
|
|
7553
7715
|
});
|
|
@@ -7557,7 +7719,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7557
7719
|
amount: amountState,
|
|
7558
7720
|
review: reviewState,
|
|
7559
7721
|
sidebar: sidebarState,
|
|
7560
|
-
orderConfirmed
|
|
7722
|
+
orderConfirmed: orderConfirmedUi(orderConfirmed)
|
|
7561
7723
|
};
|
|
7562
7724
|
const onEvent = (event) => {
|
|
7563
7725
|
switch (event.type) {
|
|
@@ -7581,7 +7743,7 @@ function useOndoSellCheckoutViewModel({
|
|
|
7581
7743
|
onReviewEvent(event);
|
|
7582
7744
|
return;
|
|
7583
7745
|
case "ON_CLOSE_SELL_ORDER_CONFIRMED":
|
|
7584
|
-
setOrderConfirmed(
|
|
7746
|
+
setOrderConfirmed(null);
|
|
7585
7747
|
return;
|
|
7586
7748
|
default: {
|
|
7587
7749
|
const exhaustive = event;
|
|
@@ -7649,14 +7811,16 @@ function toOrderConfirmedUi2({
|
|
|
7649
7811
|
chain,
|
|
7650
7812
|
locale,
|
|
7651
7813
|
offer,
|
|
7652
|
-
ondoSymbol
|
|
7814
|
+
ondoSymbol,
|
|
7815
|
+
inputTokenMetadata
|
|
7653
7816
|
}) {
|
|
7654
7817
|
const settlementSymbol = TOKEN_REGISTRY.erc20(ONDO_SETTLEMENT_ASSET).symbol;
|
|
7655
7818
|
return {
|
|
7656
7819
|
type: "visible",
|
|
7657
7820
|
soldAsset: CheckoutAssetUi.fromOffer(offer, {
|
|
7658
7821
|
symbol: ondoSymbol,
|
|
7659
|
-
networkName: getNetworkName(chain)
|
|
7822
|
+
networkName: getNetworkName(chain),
|
|
7823
|
+
tokenMetadata: inputTokenMetadata
|
|
7660
7824
|
}),
|
|
7661
7825
|
soldAmount: assetAmount(
|
|
7662
7826
|
formatAmount(order.transaction.spendInputAmount, locale),
|
|
@@ -7680,10 +7844,10 @@ function toOrderConfirmedUi2({
|
|
|
7680
7844
|
}
|
|
7681
7845
|
|
|
7682
7846
|
// src/client/hooks/checkout/superstate/swap/useSuperstateSwapCheckoutViewModel.ts
|
|
7683
|
-
import { useState as
|
|
7847
|
+
import { useState as useState22 } from "react";
|
|
7684
7848
|
|
|
7685
7849
|
// src/client/hooks/checkout/superstate/swap/amount/useSuperstateAmountViewModel.ts
|
|
7686
|
-
import { useEffect as
|
|
7850
|
+
import { useEffect as useEffect15, useState as useState17 } from "react";
|
|
7687
7851
|
var NO_WALLET3 = EvmWalletAddress(
|
|
7688
7852
|
"0x0000000000000000000000000000000000000000"
|
|
7689
7853
|
);
|
|
@@ -7697,11 +7861,11 @@ function useSuperstateAmountViewModel({
|
|
|
7697
7861
|
enabled = true
|
|
7698
7862
|
}) {
|
|
7699
7863
|
const locale = useLocale();
|
|
7700
|
-
const [amountInput, setAmountInput] =
|
|
7701
|
-
const [selectedAsset, setSelectedAsset] =
|
|
7864
|
+
const [amountInput, setAmountInput] = useState17("");
|
|
7865
|
+
const [selectedAsset, setSelectedAsset] = useState17(
|
|
7702
7866
|
SUPERSTATE_SUPPORTED_INPUT_ASSETS[0]
|
|
7703
7867
|
);
|
|
7704
|
-
const [error, setError] =
|
|
7868
|
+
const [error, setError] = useState17(null);
|
|
7705
7869
|
const isActive = stepInput.type === "active";
|
|
7706
7870
|
const networkName = getNetworkName(chain);
|
|
7707
7871
|
const { balances, isLoading: balancesLoading } = useErc20TokenBalances({
|
|
@@ -7714,7 +7878,7 @@ function useSuperstateAmountViewModel({
|
|
|
7714
7878
|
// on this step satisfies the first and not the second.
|
|
7715
7879
|
enabled: enabled && isActive
|
|
7716
7880
|
});
|
|
7717
|
-
|
|
7881
|
+
useEffect15(() => {
|
|
7718
7882
|
if (stepInput.type === "incomplete") {
|
|
7719
7883
|
setAmountInput("");
|
|
7720
7884
|
setSelectedAsset(SUPERSTATE_SUPPORTED_INPUT_ASSETS[0]);
|
|
@@ -7885,20 +8049,20 @@ function toInputAssetUi2({
|
|
|
7885
8049
|
}
|
|
7886
8050
|
|
|
7887
8051
|
// src/client/hooks/checkout/superstate/swap/data/useSwapOutputToken.ts
|
|
7888
|
-
import { useCallback as
|
|
7889
|
-
var
|
|
8052
|
+
import { useCallback as useCallback5, useEffect as useEffect16, useRef as useRef12, useState as useState18 } from "react";
|
|
8053
|
+
var LOADING_STATE2 = { type: "LOADING" };
|
|
7890
8054
|
function useSwapOutputToken(options) {
|
|
7891
8055
|
const { contractAddress, chain, enabled } = options;
|
|
7892
8056
|
const { coinlist, isReady } = useCoinList();
|
|
7893
8057
|
const log = useLogger("useSwapOutputToken");
|
|
7894
|
-
const [outputTokenState, setOutputTokenState] =
|
|
7895
|
-
const [retryCount, setRetryCount] =
|
|
8058
|
+
const [outputTokenState, setOutputTokenState] = useState18(LOADING_STATE2);
|
|
8059
|
+
const [retryCount, setRetryCount] = useState18(0);
|
|
7896
8060
|
const fetchIdRef = useRef12(0);
|
|
7897
|
-
const refetch =
|
|
7898
|
-
setOutputTokenState(
|
|
8061
|
+
const refetch = useCallback5(() => {
|
|
8062
|
+
setOutputTokenState(LOADING_STATE2);
|
|
7899
8063
|
setRetryCount((count) => count + 1);
|
|
7900
8064
|
}, []);
|
|
7901
|
-
|
|
8065
|
+
useEffect16(() => {
|
|
7902
8066
|
if (!enabled || !isReady) return;
|
|
7903
8067
|
const currentFetchId = ++fetchIdRef.current;
|
|
7904
8068
|
const load = async () => {
|
|
@@ -7931,7 +8095,7 @@ function useSwapOutputToken(options) {
|
|
|
7931
8095
|
}
|
|
7932
8096
|
|
|
7933
8097
|
// src/client/hooks/checkout/superstate/swap/data/useSwapQuote.ts
|
|
7934
|
-
import { useEffect as
|
|
8098
|
+
import { useEffect as useEffect17, useRef as useRef13, useState as useState19 } from "react";
|
|
7935
8099
|
function useSwapQuote(options) {
|
|
7936
8100
|
const {
|
|
7937
8101
|
contractAddress,
|
|
@@ -7944,13 +8108,13 @@ function useSwapQuote(options) {
|
|
|
7944
8108
|
} = options;
|
|
7945
8109
|
const { coinlist, isReady } = useCoinList();
|
|
7946
8110
|
const log = useLogger("useSwapQuote");
|
|
7947
|
-
const [quote, setQuote] =
|
|
7948
|
-
const [isLoading, setIsLoading] =
|
|
7949
|
-
const [isRefreshing, setIsRefreshing] =
|
|
8111
|
+
const [quote, setQuote] = useState19(null);
|
|
8112
|
+
const [isLoading, setIsLoading] = useState19(true);
|
|
8113
|
+
const [isRefreshing, setIsRefreshing] = useState19(false);
|
|
7950
8114
|
const isFetchingRef = useRef13(false);
|
|
7951
8115
|
const hasQuoteRef = useRef13(false);
|
|
7952
8116
|
const fetchIdRef = useRef13(0);
|
|
7953
|
-
|
|
8117
|
+
useEffect17(() => {
|
|
7954
8118
|
if (!isReady) return;
|
|
7955
8119
|
if (!enabled) {
|
|
7956
8120
|
setIsLoading(false);
|
|
@@ -8020,7 +8184,7 @@ function useSwapQuote(options) {
|
|
|
8020
8184
|
}
|
|
8021
8185
|
|
|
8022
8186
|
// src/client/hooks/checkout/superstate/swap/review/useSuperstateReviewViewModel.ts
|
|
8023
|
-
import { useEffect as
|
|
8187
|
+
import { useEffect as useEffect18, useState as useState20 } from "react";
|
|
8024
8188
|
function useSuperstateReviewViewModel({
|
|
8025
8189
|
stepInput,
|
|
8026
8190
|
contractAddress,
|
|
@@ -8030,11 +8194,11 @@ function useSuperstateReviewViewModel({
|
|
|
8030
8194
|
}) {
|
|
8031
8195
|
const { coinlist, isReady } = useCoinList();
|
|
8032
8196
|
const locale = useLocale();
|
|
8033
|
-
const [slippageBps, setSlippageBps] =
|
|
8034
|
-
const [slippageExpanded, setSlippageExpanded] =
|
|
8035
|
-
const [phase, setPhase] =
|
|
8036
|
-
const [error, setError] =
|
|
8037
|
-
|
|
8197
|
+
const [slippageBps, setSlippageBps] = useState20(DEFAULT_SLIPPAGE_BPS);
|
|
8198
|
+
const [slippageExpanded, setSlippageExpanded] = useState20(false);
|
|
8199
|
+
const [phase, setPhase] = useState20(null);
|
|
8200
|
+
const [error, setError] = useState20(null);
|
|
8201
|
+
useEffect18(() => {
|
|
8038
8202
|
if (stepInput.type === "incomplete") {
|
|
8039
8203
|
setSlippageBps(DEFAULT_SLIPPAGE_BPS);
|
|
8040
8204
|
setSlippageExpanded(false);
|
|
@@ -8363,7 +8527,7 @@ function priceUi(quote, outputToken, locale) {
|
|
|
8363
8527
|
}
|
|
8364
8528
|
|
|
8365
8529
|
// src/client/hooks/checkout/superstate/swap/wallet/useSuperstateWalletViewModel.ts
|
|
8366
|
-
import { useEffect as
|
|
8530
|
+
import { useEffect as useEffect19, useState as useState21 } from "react";
|
|
8367
8531
|
var CONNECT_FAILED2 = "Could not connect that wallet. Please try again.";
|
|
8368
8532
|
function useSuperstateWalletViewModel({
|
|
8369
8533
|
stepInput,
|
|
@@ -8376,12 +8540,12 @@ function useSuperstateWalletViewModel({
|
|
|
8376
8540
|
}) {
|
|
8377
8541
|
const { coinlist, isReady } = useCoinList();
|
|
8378
8542
|
const log = useLogger("useSuperstateWalletViewModel");
|
|
8379
|
-
const [selected, setSelected] =
|
|
8380
|
-
const [phase, setPhase] =
|
|
8381
|
-
const [error, setError] =
|
|
8543
|
+
const [selected, setSelected] = useState21(null);
|
|
8544
|
+
const [phase, setPhase] = useState21(null);
|
|
8545
|
+
const [error, setError] = useState21(null);
|
|
8382
8546
|
const networkName = getNetworkName(chain);
|
|
8383
8547
|
const selectedWallet = resolveWallet2(wallets, selected);
|
|
8384
|
-
|
|
8548
|
+
useEffect19(() => {
|
|
8385
8549
|
if (stepInput.type === "completed") {
|
|
8386
8550
|
setPhase(null);
|
|
8387
8551
|
setError(null);
|
|
@@ -8600,12 +8764,20 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8600
8764
|
}) {
|
|
8601
8765
|
const locale = useLocale();
|
|
8602
8766
|
const contractAddress = superstateSwapContractAddress(chain);
|
|
8603
|
-
const
|
|
8604
|
-
const [
|
|
8605
|
-
const [orderConfirmed, setOrderConfirmed] = useState21({ type: "hidden" });
|
|
8767
|
+
const [step, setStep] = useState22({ type: "wallet" });
|
|
8768
|
+
const [orderConfirmed, setOrderConfirmed] = useState22(null);
|
|
8606
8769
|
const { inputAmount, inputTokenAddress } = quoteInput(step, chain);
|
|
8607
8770
|
const live = enabled && contractAddress !== null;
|
|
8608
8771
|
const contract = contractAddress ?? NO_CONTRACT;
|
|
8772
|
+
const { state: offerTokenMetadataState } = useCheckoutOfferTokenMetadata({
|
|
8773
|
+
offer,
|
|
8774
|
+
chain,
|
|
8775
|
+
enabled: live
|
|
8776
|
+
});
|
|
8777
|
+
const assetIconUrl = offerAssetIconUrl(
|
|
8778
|
+
offer,
|
|
8779
|
+
tokenMetadataOf(offerTokenMetadataState)
|
|
8780
|
+
);
|
|
8609
8781
|
const { outputTokenState, refetch: refetchOutputToken } = useSwapOutputToken({
|
|
8610
8782
|
contractAddress: contract,
|
|
8611
8783
|
chain,
|
|
@@ -8662,9 +8834,7 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8662
8834
|
chain,
|
|
8663
8835
|
assetIconUrl,
|
|
8664
8836
|
onComplete: (order) => {
|
|
8665
|
-
setOrderConfirmed(
|
|
8666
|
-
toOrderConfirmedUi3({ order, chain, locale, assetIconUrl })
|
|
8667
|
-
);
|
|
8837
|
+
setOrderConfirmed(order);
|
|
8668
8838
|
setStep({ type: "wallet" });
|
|
8669
8839
|
onOrderConfirmed?.(order);
|
|
8670
8840
|
}
|
|
@@ -8690,7 +8860,15 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8690
8860
|
amount: amountState,
|
|
8691
8861
|
review: reviewState,
|
|
8692
8862
|
sidebar: sidebarState,
|
|
8693
|
-
|
|
8863
|
+
// Derived here rather than in the review completion callback, so a
|
|
8864
|
+
// registry lookup that settles while the order is being placed still
|
|
8865
|
+
// reaches the dialog instead of the fallback icon that closure captured.
|
|
8866
|
+
orderConfirmed: orderConfirmed === null ? { type: "hidden" } : toOrderConfirmedUi3({
|
|
8867
|
+
order: orderConfirmed,
|
|
8868
|
+
chain,
|
|
8869
|
+
locale,
|
|
8870
|
+
assetIconUrl
|
|
8871
|
+
})
|
|
8694
8872
|
};
|
|
8695
8873
|
};
|
|
8696
8874
|
const onEvent = (event) => {
|
|
@@ -8715,7 +8893,7 @@ function useSuperstateSwapCheckoutViewModel({
|
|
|
8715
8893
|
onReviewEvent(event);
|
|
8716
8894
|
return;
|
|
8717
8895
|
case "ON_CLOSE_ORDER_CONFIRMED":
|
|
8718
|
-
setOrderConfirmed(
|
|
8896
|
+
setOrderConfirmed(null);
|
|
8719
8897
|
return;
|
|
8720
8898
|
case "ON_RETRY_LOAD":
|
|
8721
8899
|
refetchOutputToken();
|
|
@@ -8830,7 +9008,7 @@ function CheckoutContainer({
|
|
|
8830
9008
|
enabled = true,
|
|
8831
9009
|
className
|
|
8832
9010
|
}) {
|
|
8833
|
-
const [side] =
|
|
9011
|
+
const [side] = useState23(() => config["ondo::swap"].side());
|
|
8834
9012
|
const isOndo = offer.type === "ondo::swap";
|
|
8835
9013
|
const ondoSymbol = config["ondo::swap"].symbol(offer);
|
|
8836
9014
|
const ondoBuy = useOndoBuyCheckoutViewModel({
|
|
@@ -9403,23 +9581,23 @@ function EmptyState() {
|
|
|
9403
9581
|
}
|
|
9404
9582
|
|
|
9405
9583
|
// src/client/hooks/offers/grid/useOffersGridViewModel.ts
|
|
9406
|
-
import { useCallback as
|
|
9584
|
+
import { useCallback as useCallback6, useMemo as useMemo4 } from "react";
|
|
9407
9585
|
|
|
9408
9586
|
// src/client/hooks/offers/data/useOffers.ts
|
|
9409
|
-
import { useEffect as
|
|
9410
|
-
var
|
|
9587
|
+
import { useEffect as useEffect20, useState as useState24 } from "react";
|
|
9588
|
+
var LOADING_STATE3 = { type: "LOADING" };
|
|
9411
9589
|
function useOffers(options = {}) {
|
|
9412
9590
|
const { coinlist, isReady } = useCoinList();
|
|
9413
9591
|
const log = useLogger("useOffers");
|
|
9414
9592
|
const { data: serverOffers } = options;
|
|
9415
|
-
const [offersState, setOffersState] =
|
|
9416
|
-
serverOffers !== void 0 ? { type: "CONTENT", offers: serverOffers } :
|
|
9593
|
+
const [offersState, setOffersState] = useState24(
|
|
9594
|
+
serverOffers !== void 0 ? { type: "CONTENT", offers: serverOffers } : LOADING_STATE3
|
|
9417
9595
|
);
|
|
9418
|
-
|
|
9596
|
+
useEffect20(() => {
|
|
9419
9597
|
let isCancelled = false;
|
|
9420
9598
|
if (!isReady) {
|
|
9421
9599
|
if (serverOffers === void 0) {
|
|
9422
|
-
setOffersState(
|
|
9600
|
+
setOffersState(LOADING_STATE3);
|
|
9423
9601
|
}
|
|
9424
9602
|
return () => {
|
|
9425
9603
|
isCancelled = true;
|
|
@@ -9430,7 +9608,7 @@ function useOffers(options = {}) {
|
|
|
9430
9608
|
isCancelled = true;
|
|
9431
9609
|
};
|
|
9432
9610
|
}
|
|
9433
|
-
setOffersState(
|
|
9611
|
+
setOffersState(LOADING_STATE3);
|
|
9434
9612
|
coinlist.offers.list().then((offers) => {
|
|
9435
9613
|
if (!isCancelled) {
|
|
9436
9614
|
log.debug(() => ({
|
|
@@ -9485,7 +9663,7 @@ function useOffersGridViewModel(options = {}) {
|
|
|
9485
9663
|
() => toUiState(offersState, onOfferClick !== void 0),
|
|
9486
9664
|
[offersState, onOfferClick]
|
|
9487
9665
|
);
|
|
9488
|
-
const onEvent =
|
|
9666
|
+
const onEvent = useCallback6(
|
|
9489
9667
|
(event) => {
|
|
9490
9668
|
switch (event.type) {
|
|
9491
9669
|
case "ON_OFFER_CLICK": {
|
|
@@ -9546,13 +9724,13 @@ function OffersGridContainer({
|
|
|
9546
9724
|
}
|
|
9547
9725
|
|
|
9548
9726
|
// src/client/components/requirements/checklist/ConnectedWalletList.tsx
|
|
9549
|
-
import { useState as
|
|
9727
|
+
import { useState as useState25 } from "react";
|
|
9550
9728
|
import { jsx as jsx56, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
9551
9729
|
function ConnectedWalletRow({
|
|
9552
9730
|
wallet,
|
|
9553
9731
|
onRemove
|
|
9554
9732
|
}) {
|
|
9555
|
-
const [state, setState] =
|
|
9733
|
+
const [state, setState] = useState25("idle");
|
|
9556
9734
|
const remove = async () => {
|
|
9557
9735
|
if (!onRemove) return;
|
|
9558
9736
|
setState("removing");
|
|
@@ -10122,25 +10300,25 @@ function toError(error) {
|
|
|
10122
10300
|
}
|
|
10123
10301
|
|
|
10124
10302
|
// src/client/hooks/requirements/identity-verification/useIdentityVerificationViewModel.ts
|
|
10125
|
-
import { useCallback as
|
|
10303
|
+
import { useCallback as useCallback8, useEffect as useEffect22, useMemo as useMemo5, useRef as useRef15 } from "react";
|
|
10126
10304
|
|
|
10127
10305
|
// src/client/hooks/requirements/data/useKycToken.ts
|
|
10128
|
-
import { useCallback as
|
|
10306
|
+
import { useCallback as useCallback7, useEffect as useEffect21, useRef as useRef14, useState as useState26 } from "react";
|
|
10129
10307
|
var IDLE_STATE = { type: "IDLE" };
|
|
10130
|
-
var
|
|
10308
|
+
var LOADING_STATE4 = { type: "LOADING" };
|
|
10131
10309
|
function useKycToken(levelName, reset) {
|
|
10132
10310
|
const { coinlist } = useCoinList();
|
|
10133
10311
|
const log = useLogger("useKycToken");
|
|
10134
|
-
const [kycTokenState, setKycTokenState] =
|
|
10312
|
+
const [kycTokenState, setKycTokenState] = useState26(IDLE_STATE);
|
|
10135
10313
|
const resetPendingRef = useRef14(reset === true);
|
|
10136
10314
|
const tokenIssuedRef = useRef14(false);
|
|
10137
|
-
|
|
10315
|
+
useEffect21(() => {
|
|
10138
10316
|
if (!tokenIssuedRef.current) {
|
|
10139
10317
|
resetPendingRef.current = reset === true;
|
|
10140
10318
|
}
|
|
10141
10319
|
}, [reset]);
|
|
10142
|
-
const fetchToken =
|
|
10143
|
-
setKycTokenState(
|
|
10320
|
+
const fetchToken = useCallback7(async () => {
|
|
10321
|
+
setKycTokenState(LOADING_STATE4);
|
|
10144
10322
|
try {
|
|
10145
10323
|
const kycToken = await coinlist.requirements.createKycToken({
|
|
10146
10324
|
levelName,
|
|
@@ -10174,7 +10352,7 @@ function useIdentityVerificationViewModel(options = {}) {
|
|
|
10174
10352
|
const { levelName, reset, locale, onSubmitted, onError } = options;
|
|
10175
10353
|
const { kycTokenState, fetchToken } = useKycToken(levelName, reset);
|
|
10176
10354
|
const fetchedRef = useRef15(false);
|
|
10177
|
-
|
|
10355
|
+
useEffect22(() => {
|
|
10178
10356
|
if (fetchedRef.current) {
|
|
10179
10357
|
return;
|
|
10180
10358
|
}
|
|
@@ -10208,7 +10386,7 @@ function useIdentityVerificationViewModel(options = {}) {
|
|
|
10208
10386
|
}
|
|
10209
10387
|
}
|
|
10210
10388
|
}, [kycTokenState, locale, fetchToken]);
|
|
10211
|
-
const onEvent =
|
|
10389
|
+
const onEvent = useCallback8(
|
|
10212
10390
|
(event) => {
|
|
10213
10391
|
switch (event.type) {
|
|
10214
10392
|
case "ON_RETRY":
|
|
@@ -10470,12 +10648,12 @@ function SignOnlyScreen({
|
|
|
10470
10648
|
}
|
|
10471
10649
|
|
|
10472
10650
|
// src/client/hooks/requirements/tax-document/useTaxDocumentModalViewModel.ts
|
|
10473
|
-
import { useCallback as
|
|
10651
|
+
import { useCallback as useCallback10, useEffect as useEffect24, useMemo as useMemo6 } from "react";
|
|
10474
10652
|
|
|
10475
10653
|
// src/client/hooks/requirements/data/useTaxDocument.ts
|
|
10476
|
-
import { useCallback as
|
|
10654
|
+
import { useCallback as useCallback9, useEffect as useEffect23, useState as useState27 } from "react";
|
|
10477
10655
|
var IDLE_SIGN = { type: "idle", error: null };
|
|
10478
|
-
var
|
|
10656
|
+
var LOADING_STATE5 = { type: "LOADING" };
|
|
10479
10657
|
var SIGN_FAILED_MESSAGE = "Unable to sign document. Please try again.";
|
|
10480
10658
|
var DOB_INVALID_MESSAGE = "Enter your date of birth as MM/DD/YYYY.";
|
|
10481
10659
|
var FIELD_KEYS = {
|
|
@@ -10548,8 +10726,8 @@ function useTaxDocument({
|
|
|
10548
10726
|
}) {
|
|
10549
10727
|
const { coinlist, isReady } = useCoinList();
|
|
10550
10728
|
const log = useLogger("useTaxDocument");
|
|
10551
|
-
const [state, setState] =
|
|
10552
|
-
|
|
10729
|
+
const [state, setState] = useState27(LOADING_STATE5);
|
|
10730
|
+
useEffect23(() => {
|
|
10553
10731
|
let isCancelled = false;
|
|
10554
10732
|
if (!isOpen) {
|
|
10555
10733
|
return () => {
|
|
@@ -10557,12 +10735,12 @@ function useTaxDocument({
|
|
|
10557
10735
|
};
|
|
10558
10736
|
}
|
|
10559
10737
|
if (!isReady) {
|
|
10560
|
-
setState(
|
|
10738
|
+
setState(LOADING_STATE5);
|
|
10561
10739
|
return () => {
|
|
10562
10740
|
isCancelled = true;
|
|
10563
10741
|
};
|
|
10564
10742
|
}
|
|
10565
|
-
setState(
|
|
10743
|
+
setState(LOADING_STATE5);
|
|
10566
10744
|
coinlist.requirements.getPii().then((pii) => {
|
|
10567
10745
|
if (isCancelled) return;
|
|
10568
10746
|
if (pii.kind === "company") {
|
|
@@ -10590,7 +10768,7 @@ function useTaxDocument({
|
|
|
10590
10768
|
isCancelled = true;
|
|
10591
10769
|
};
|
|
10592
10770
|
}, [coinlist, isReady, isOpen, log]);
|
|
10593
|
-
const onEditField =
|
|
10771
|
+
const onEditField = useCallback9(
|
|
10594
10772
|
(field, value) => {
|
|
10595
10773
|
setState(
|
|
10596
10774
|
(prev) => prev.type === "EDITING" ? { ...prev, fields: { ...prev.fields, [field]: value } } : prev
|
|
@@ -10598,7 +10776,7 @@ function useTaxDocument({
|
|
|
10598
10776
|
},
|
|
10599
10777
|
[]
|
|
10600
10778
|
);
|
|
10601
|
-
const onStartEdit =
|
|
10779
|
+
const onStartEdit = useCallback9(() => {
|
|
10602
10780
|
setState(
|
|
10603
10781
|
(prev) => prev.type === "REVIEW" ? {
|
|
10604
10782
|
type: "EDITING",
|
|
@@ -10609,7 +10787,7 @@ function useTaxDocument({
|
|
|
10609
10787
|
} : prev
|
|
10610
10788
|
);
|
|
10611
10789
|
}, []);
|
|
10612
|
-
const onSaveEdit =
|
|
10790
|
+
const onSaveEdit = useCallback9(() => {
|
|
10613
10791
|
setState(
|
|
10614
10792
|
(prev) => prev.type === "EDITING" ? {
|
|
10615
10793
|
type: "REVIEW",
|
|
@@ -10620,7 +10798,7 @@ function useTaxDocument({
|
|
|
10620
10798
|
} : prev
|
|
10621
10799
|
);
|
|
10622
10800
|
}, []);
|
|
10623
|
-
const onCancelEdit =
|
|
10801
|
+
const onCancelEdit = useCallback9(() => {
|
|
10624
10802
|
setState(
|
|
10625
10803
|
(prev) => prev.type === "EDITING" ? {
|
|
10626
10804
|
type: "REVIEW",
|
|
@@ -10631,7 +10809,7 @@ function useTaxDocument({
|
|
|
10631
10809
|
} : prev
|
|
10632
10810
|
);
|
|
10633
10811
|
}, []);
|
|
10634
|
-
const onSign =
|
|
10812
|
+
const onSign = useCallback9(() => {
|
|
10635
10813
|
if (state.type !== "REVIEW" && state.type !== "SIGN_ONLY") return;
|
|
10636
10814
|
if (state.type === "REVIEW" && state.fields.dob.trim() !== "" && !isValidUsDate(state.fields.dob)) {
|
|
10637
10815
|
setState({
|
|
@@ -10673,7 +10851,7 @@ function useTaxDocumentModalViewModel({
|
|
|
10673
10851
|
onSubmitted
|
|
10674
10852
|
}) {
|
|
10675
10853
|
const { state, onEditField, onStartEdit, onSaveEdit, onCancelEdit, onSign } = useTaxDocument({ isOpen });
|
|
10676
|
-
|
|
10854
|
+
useEffect24(() => {
|
|
10677
10855
|
if (state.type === "SUBMITTED") {
|
|
10678
10856
|
onSubmitted?.(state.submission);
|
|
10679
10857
|
onClose();
|
|
@@ -10685,7 +10863,7 @@ function useTaxDocumentModalViewModel({
|
|
|
10685
10863
|
}
|
|
10686
10864
|
return { type: "content", title: toTitle(state), screen: toScreen(state) };
|
|
10687
10865
|
}, [isOpen, state]);
|
|
10688
|
-
const onEvent =
|
|
10866
|
+
const onEvent = useCallback10(
|
|
10689
10867
|
(event) => {
|
|
10690
10868
|
switch (event.type) {
|
|
10691
10869
|
case "ON_CLOSE":
|
|
@@ -10901,10 +11079,10 @@ function Screen2({
|
|
|
10901
11079
|
}
|
|
10902
11080
|
|
|
10903
11081
|
// src/client/hooks/requirements/wallet/useConnectWalletModalViewModel.ts
|
|
10904
|
-
import { useCallback as
|
|
11082
|
+
import { useCallback as useCallback12, useEffect as useEffect26, useMemo as useMemo7 } from "react";
|
|
10905
11083
|
|
|
10906
11084
|
// src/client/hooks/requirements/data/useConnectWallet.ts
|
|
10907
|
-
import { useCallback as
|
|
11085
|
+
import { useCallback as useCallback11, useEffect as useEffect25, useRef as useRef16, useState as useState28 } from "react";
|
|
10908
11086
|
|
|
10909
11087
|
// src/client/core/wallets/connect-external-wallet.ts
|
|
10910
11088
|
var DEFAULT_STATEMENT = "Sign this message to prove you own this wallet. This does not cost gas or move funds.";
|
|
@@ -11035,24 +11213,24 @@ function useConnectWallet({
|
|
|
11035
11213
|
statement
|
|
11036
11214
|
}) {
|
|
11037
11215
|
const { coinlist } = useCoinList();
|
|
11038
|
-
const [state, setState] =
|
|
11216
|
+
const [state, setState] = useState28(
|
|
11039
11217
|
() => wallet ? { type: "READY", address: wallet.address, sign: IDLE_SIGN2 } : { type: "NEEDS_WALLET" }
|
|
11040
11218
|
);
|
|
11041
11219
|
const attempt = useRef16(0);
|
|
11042
|
-
|
|
11220
|
+
useEffect25(() => {
|
|
11043
11221
|
attempt.current += 1;
|
|
11044
11222
|
if (!isOpen) return;
|
|
11045
11223
|
setState(
|
|
11046
11224
|
wallet ? { type: "READY", address: wallet.address, sign: IDLE_SIGN2 } : { type: "NEEDS_WALLET" }
|
|
11047
11225
|
);
|
|
11048
11226
|
}, [isOpen, wallet?.address]);
|
|
11049
|
-
|
|
11227
|
+
useEffect25(
|
|
11050
11228
|
() => () => {
|
|
11051
11229
|
attempt.current += 1;
|
|
11052
11230
|
},
|
|
11053
11231
|
[]
|
|
11054
11232
|
);
|
|
11055
|
-
const onSign =
|
|
11233
|
+
const onSign = useCallback11(() => {
|
|
11056
11234
|
if (!wallet || state.type !== "READY") return;
|
|
11057
11235
|
attempt.current += 1;
|
|
11058
11236
|
const gen = attempt.current;
|
|
@@ -11114,7 +11292,7 @@ function useConnectWalletModalViewModel({
|
|
|
11114
11292
|
challengeType,
|
|
11115
11293
|
statement
|
|
11116
11294
|
});
|
|
11117
|
-
|
|
11295
|
+
useEffect26(() => {
|
|
11118
11296
|
if (state.type === "CONNECTED") {
|
|
11119
11297
|
onConnected?.(state.binding);
|
|
11120
11298
|
onClose();
|
|
@@ -11145,7 +11323,7 @@ function useConnectWalletModalViewModel({
|
|
|
11145
11323
|
canRequestConnect
|
|
11146
11324
|
};
|
|
11147
11325
|
}, [isOpen, state, onRequestConnect]);
|
|
11148
|
-
const onEvent =
|
|
11326
|
+
const onEvent = useCallback12(
|
|
11149
11327
|
(event) => {
|
|
11150
11328
|
switch (event.type) {
|
|
11151
11329
|
case "ON_CLOSE":
|
|
@@ -11186,7 +11364,7 @@ function ConnectWalletModalContainer({
|
|
|
11186
11364
|
}
|
|
11187
11365
|
|
|
11188
11366
|
// src/client/hooks/requirements/checklist/useRequirementsChecklistViewModel.ts
|
|
11189
|
-
import { useCallback as
|
|
11367
|
+
import { useCallback as useCallback15, useEffect as useEffect29, useMemo as useMemo8, useRef as useRef17, useState as useState31 } from "react";
|
|
11190
11368
|
|
|
11191
11369
|
// src/client/hooks/requirements/checklist/useRequirementsChecklistViewModel.types.ts
|
|
11192
11370
|
var RequirementItemUi = {
|
|
@@ -11240,8 +11418,8 @@ var ChecklistStatus = {
|
|
|
11240
11418
|
};
|
|
11241
11419
|
|
|
11242
11420
|
// src/client/hooks/requirements/data/useOptionAddresses.ts
|
|
11243
|
-
import { useCallback as
|
|
11244
|
-
var
|
|
11421
|
+
import { useCallback as useCallback13, useEffect as useEffect27, useState as useState29 } from "react";
|
|
11422
|
+
var LOADING_STATE6 = { type: "LOADING" };
|
|
11245
11423
|
var EMPTY_STATE = {
|
|
11246
11424
|
type: "CONTENT",
|
|
11247
11425
|
addresses: []
|
|
@@ -11250,19 +11428,19 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11250
11428
|
const { coinlist, isReady } = useCoinList();
|
|
11251
11429
|
const log = useLogger("useOptionAddresses");
|
|
11252
11430
|
const { data, enabled = true } = options;
|
|
11253
|
-
const [addressesState, setAddressesState] =
|
|
11254
|
-
data !== void 0 ? { type: "CONTENT", addresses: data } :
|
|
11431
|
+
const [addressesState, setAddressesState] = useState29(
|
|
11432
|
+
data !== void 0 ? { type: "CONTENT", addresses: data } : LOADING_STATE6
|
|
11255
11433
|
);
|
|
11256
|
-
const [fetchKey, setFetchKey] =
|
|
11257
|
-
const refetch =
|
|
11258
|
-
const disconnect =
|
|
11434
|
+
const [fetchKey, setFetchKey] = useState29(0);
|
|
11435
|
+
const refetch = useCallback13(() => setFetchKey((k) => k + 1), []);
|
|
11436
|
+
const disconnect = useCallback13(
|
|
11259
11437
|
async (addressId) => {
|
|
11260
11438
|
await coinlist.wallets.remove({ offerId, addressId });
|
|
11261
11439
|
refetch();
|
|
11262
11440
|
},
|
|
11263
11441
|
[coinlist, offerId, refetch]
|
|
11264
11442
|
);
|
|
11265
|
-
|
|
11443
|
+
useEffect27(() => {
|
|
11266
11444
|
let isCancelled = false;
|
|
11267
11445
|
if (!enabled) {
|
|
11268
11446
|
setAddressesState(
|
|
@@ -11274,7 +11452,7 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11274
11452
|
}
|
|
11275
11453
|
if (!isReady) {
|
|
11276
11454
|
if (data === void 0) {
|
|
11277
|
-
setAddressesState(
|
|
11455
|
+
setAddressesState(LOADING_STATE6);
|
|
11278
11456
|
}
|
|
11279
11457
|
return () => {
|
|
11280
11458
|
isCancelled = true;
|
|
@@ -11291,7 +11469,7 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11291
11469
|
isCancelled = true;
|
|
11292
11470
|
};
|
|
11293
11471
|
}
|
|
11294
|
-
setAddressesState(
|
|
11472
|
+
setAddressesState(LOADING_STATE6);
|
|
11295
11473
|
coinlist.wallets.list({ offerId, offerOptionId }).then((addresses) => {
|
|
11296
11474
|
if (!isCancelled) {
|
|
11297
11475
|
log.debug(() => ({
|
|
@@ -11318,22 +11496,22 @@ function useOptionAddresses(offerId, offerOptionId, options = {}) {
|
|
|
11318
11496
|
}
|
|
11319
11497
|
|
|
11320
11498
|
// src/client/hooks/requirements/data/useRequirements.ts
|
|
11321
|
-
import { useCallback as
|
|
11322
|
-
var
|
|
11499
|
+
import { useCallback as useCallback14, useEffect as useEffect28, useState as useState30 } from "react";
|
|
11500
|
+
var LOADING_STATE7 = { type: "LOADING" };
|
|
11323
11501
|
function useRequirements(offerId, options = {}) {
|
|
11324
11502
|
const { coinlist, isReady } = useCoinList();
|
|
11325
11503
|
const log = useLogger("useRequirements");
|
|
11326
11504
|
const { data } = options;
|
|
11327
|
-
const [requirementsState, setRequirementsState] =
|
|
11328
|
-
data !== void 0 ? { type: "CONTENT", ...data } :
|
|
11505
|
+
const [requirementsState, setRequirementsState] = useState30(
|
|
11506
|
+
data !== void 0 ? { type: "CONTENT", ...data } : LOADING_STATE7
|
|
11329
11507
|
);
|
|
11330
|
-
const [fetchKey, setFetchKey] =
|
|
11331
|
-
const refetch =
|
|
11332
|
-
|
|
11508
|
+
const [fetchKey, setFetchKey] = useState30(0);
|
|
11509
|
+
const refetch = useCallback14(() => setFetchKey((k) => k + 1), []);
|
|
11510
|
+
useEffect28(() => {
|
|
11333
11511
|
let isCancelled = false;
|
|
11334
11512
|
if (!isReady) {
|
|
11335
11513
|
if (data === void 0) {
|
|
11336
|
-
setRequirementsState(
|
|
11514
|
+
setRequirementsState(LOADING_STATE7);
|
|
11337
11515
|
}
|
|
11338
11516
|
return () => {
|
|
11339
11517
|
isCancelled = true;
|
|
@@ -11350,7 +11528,7 @@ function useRequirements(offerId, options = {}) {
|
|
|
11350
11528
|
isCancelled = true;
|
|
11351
11529
|
};
|
|
11352
11530
|
}
|
|
11353
|
-
setRequirementsState(
|
|
11531
|
+
setRequirementsState(LOADING_STATE7);
|
|
11354
11532
|
Promise.all([
|
|
11355
11533
|
coinlist.requirements.forOffer(offerId),
|
|
11356
11534
|
coinlist.requirements.statuses(offerId)
|
|
@@ -11429,19 +11607,19 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11429
11607
|
const log = useLogger("useRequirementsChecklistViewModel");
|
|
11430
11608
|
const { coinlist } = useCoinList();
|
|
11431
11609
|
const { requirementsState, refetch } = useRequirements(offerId, { data });
|
|
11432
|
-
const [expandedId, setExpandedId] =
|
|
11433
|
-
const [taxDocumentOpen, setTaxDocumentOpen] =
|
|
11434
|
-
const [connectWalletOpen, setConnectWalletOpen] =
|
|
11435
|
-
const [verifyingRequirementId, setVerifyingRequirementId] =
|
|
11610
|
+
const [expandedId, setExpandedId] = useState31(null);
|
|
11611
|
+
const [taxDocumentOpen, setTaxDocumentOpen] = useState31(false);
|
|
11612
|
+
const [connectWalletOpen, setConnectWalletOpen] = useState31(false);
|
|
11613
|
+
const [verifyingRequirementId, setVerifyingRequirementId] = useState31(null);
|
|
11436
11614
|
const isMountedRef = useRef17(true);
|
|
11437
|
-
|
|
11615
|
+
useEffect29(() => {
|
|
11438
11616
|
isMountedRef.current = true;
|
|
11439
11617
|
return () => {
|
|
11440
11618
|
isMountedRef.current = false;
|
|
11441
11619
|
};
|
|
11442
11620
|
}, []);
|
|
11443
|
-
const [hasWalletRequirement, setHasWalletRequirement] =
|
|
11444
|
-
|
|
11621
|
+
const [hasWalletRequirement, setHasWalletRequirement] = useState31(false);
|
|
11622
|
+
useEffect29(() => {
|
|
11445
11623
|
if (requirementsState.type === "CONTENT") {
|
|
11446
11624
|
setHasWalletRequirement(
|
|
11447
11625
|
(requirementsState.requirements[optionId] ?? []).some(
|
|
@@ -11457,14 +11635,14 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11457
11635
|
} = useOptionAddresses(offerId, optionId, {
|
|
11458
11636
|
enabled: hasWalletRequirement
|
|
11459
11637
|
});
|
|
11460
|
-
const removeWallet =
|
|
11638
|
+
const removeWallet = useCallback15(
|
|
11461
11639
|
async (addressId) => {
|
|
11462
11640
|
await disconnect(OfferOptionAddressId(addressId));
|
|
11463
11641
|
refetch();
|
|
11464
11642
|
},
|
|
11465
11643
|
[disconnect, refetch]
|
|
11466
11644
|
);
|
|
11467
|
-
const awaitVerificationResult =
|
|
11645
|
+
const awaitVerificationResult = useCallback15(
|
|
11468
11646
|
(requirementId, statusBeforeSubmit) => {
|
|
11469
11647
|
void (async () => {
|
|
11470
11648
|
const deadline = Date.now() + VERIFICATION_POLL_TIMEOUT_MS;
|
|
@@ -11573,7 +11751,7 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11573
11751
|
identityVerificationOptions,
|
|
11574
11752
|
removeWallet
|
|
11575
11753
|
]);
|
|
11576
|
-
const handleRequirementAction =
|
|
11754
|
+
const handleRequirementAction = useCallback15(
|
|
11577
11755
|
(requirement) => {
|
|
11578
11756
|
const inlineVerification = statusById.get(requirement.id)?.kycLevel !== void 0 && onRequirementActionOverride === void 0;
|
|
11579
11757
|
if (inlineVerification) {
|
|
@@ -11605,7 +11783,7 @@ function useRequirementsChecklistViewModel(options) {
|
|
|
11605
11783
|
coinlist
|
|
11606
11784
|
]
|
|
11607
11785
|
);
|
|
11608
|
-
const onEvent =
|
|
11786
|
+
const onEvent = useCallback15(
|
|
11609
11787
|
(event) => {
|
|
11610
11788
|
switch (event.type) {
|
|
11611
11789
|
case "ON_TOGGLE_ITEM":
|
|
@@ -11785,7 +11963,7 @@ function pinoClientLogger(options) {
|
|
|
11785
11963
|
}
|
|
11786
11964
|
|
|
11787
11965
|
// src/client/hooks/auth/useCompleteOAuth.ts
|
|
11788
|
-
import { useEffect as
|
|
11966
|
+
import { useEffect as useEffect30, useRef as useRef18 } from "react";
|
|
11789
11967
|
function useCompleteOAuth(options) {
|
|
11790
11968
|
const { coinlist } = useCoinList();
|
|
11791
11969
|
const log = useLogger("useCompleteOAuth");
|
|
@@ -11796,7 +11974,7 @@ function useCompleteOAuth(options) {
|
|
|
11796
11974
|
onFailureRef.current = options.onFailure;
|
|
11797
11975
|
onSuccessRef.current = options.onSuccess;
|
|
11798
11976
|
const hasStartedExchangeRef = useRef18(false);
|
|
11799
|
-
|
|
11977
|
+
useEffect30(() => {
|
|
11800
11978
|
if (typeof window === "undefined") return;
|
|
11801
11979
|
const params = new URLSearchParams(window.location.search);
|
|
11802
11980
|
if (!params.has("code") && !params.has("error")) return;
|
|
@@ -11860,20 +12038,20 @@ function useCompleteOAuth(options) {
|
|
|
11860
12038
|
}
|
|
11861
12039
|
|
|
11862
12040
|
// src/client/hooks/checkout/coin-list/token-sale/data/useParticipations.ts
|
|
11863
|
-
import { useEffect as
|
|
11864
|
-
var
|
|
12041
|
+
import { useEffect as useEffect31, useState as useState32 } from "react";
|
|
12042
|
+
var LOADING_STATE8 = { type: "LOADING" };
|
|
11865
12043
|
function useParticipations(offerId, options = {}) {
|
|
11866
12044
|
const { coinlist, isReady } = useCoinList();
|
|
11867
12045
|
const log = useLogger("useParticipations");
|
|
11868
12046
|
const { data } = options;
|
|
11869
|
-
const [participationsState, setParticipationsState] =
|
|
11870
|
-
data !== void 0 ? { type: "CONTENT", participations: data } :
|
|
12047
|
+
const [participationsState, setParticipationsState] = useState32(
|
|
12048
|
+
data !== void 0 ? { type: "CONTENT", participations: data } : LOADING_STATE8
|
|
11871
12049
|
);
|
|
11872
|
-
|
|
12050
|
+
useEffect31(() => {
|
|
11873
12051
|
let isCancelled = false;
|
|
11874
12052
|
if (!isReady) {
|
|
11875
12053
|
if (data === void 0) {
|
|
11876
|
-
setParticipationsState(
|
|
12054
|
+
setParticipationsState(LOADING_STATE8);
|
|
11877
12055
|
}
|
|
11878
12056
|
return () => {
|
|
11879
12057
|
isCancelled = true;
|
|
@@ -11884,7 +12062,7 @@ function useParticipations(offerId, options = {}) {
|
|
|
11884
12062
|
isCancelled = true;
|
|
11885
12063
|
};
|
|
11886
12064
|
}
|
|
11887
|
-
setParticipationsState(
|
|
12065
|
+
setParticipationsState(LOADING_STATE8);
|
|
11888
12066
|
coinlist.tokenSale.list(offerId).then((participations) => {
|
|
11889
12067
|
if (!isCancelled) {
|
|
11890
12068
|
log.debug(() => ({
|
|
@@ -11911,20 +12089,20 @@ function useParticipations(offerId, options = {}) {
|
|
|
11911
12089
|
}
|
|
11912
12090
|
|
|
11913
12091
|
// src/client/hooks/offers/data/useOfferDetails.ts
|
|
11914
|
-
import { useEffect as
|
|
11915
|
-
var
|
|
12092
|
+
import { useEffect as useEffect32, useState as useState33 } from "react";
|
|
12093
|
+
var LOADING_STATE9 = { type: "LOADING" };
|
|
11916
12094
|
function useOfferDetails(offerId, options = {}) {
|
|
11917
12095
|
const { coinlist, isReady } = useCoinList();
|
|
11918
12096
|
const log = useLogger("useOfferDetails");
|
|
11919
12097
|
const { data } = options;
|
|
11920
|
-
const [offerDetailsState, setOfferDetailsState] =
|
|
11921
|
-
data !== void 0 ? { type: "CONTENT", offerDetail: data } :
|
|
12098
|
+
const [offerDetailsState, setOfferDetailsState] = useState33(
|
|
12099
|
+
data !== void 0 ? { type: "CONTENT", offerDetail: data } : LOADING_STATE9
|
|
11922
12100
|
);
|
|
11923
|
-
|
|
12101
|
+
useEffect32(() => {
|
|
11924
12102
|
let isCancelled = false;
|
|
11925
12103
|
if (!isReady) {
|
|
11926
12104
|
if (data === void 0) {
|
|
11927
|
-
setOfferDetailsState(
|
|
12105
|
+
setOfferDetailsState(LOADING_STATE9);
|
|
11928
12106
|
}
|
|
11929
12107
|
return () => {
|
|
11930
12108
|
isCancelled = true;
|
|
@@ -11935,7 +12113,7 @@ function useOfferDetails(offerId, options = {}) {
|
|
|
11935
12113
|
isCancelled = true;
|
|
11936
12114
|
};
|
|
11937
12115
|
}
|
|
11938
|
-
setOfferDetailsState(
|
|
12116
|
+
setOfferDetailsState(LOADING_STATE9);
|
|
11939
12117
|
coinlist.offers.get(offerId).then((offerDetail) => {
|
|
11940
12118
|
if (!isCancelled) {
|
|
11941
12119
|
log.debug(() => ({
|
|
@@ -11975,66 +12153,6 @@ var OfferAssetCardUi = {
|
|
|
11975
12153
|
})
|
|
11976
12154
|
};
|
|
11977
12155
|
|
|
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
12156
|
// src/client/ui/format/date.ts
|
|
12039
12157
|
function formatMonthYear(date, locale) {
|
|
12040
12158
|
return new Intl.DateTimeFormat(locale, {
|
|
@@ -12123,7 +12241,9 @@ export {
|
|
|
12123
12241
|
formatCountdown,
|
|
12124
12242
|
formatMonthYear,
|
|
12125
12243
|
formatSaleCardCountdown,
|
|
12244
|
+
offerAssetIconUrl,
|
|
12126
12245
|
offerIconUrl,
|
|
12246
|
+
offerTokenIdentifier,
|
|
12127
12247
|
ondoLoadErrorReason,
|
|
12128
12248
|
pinoClientLogger,
|
|
12129
12249
|
prepareOndoBuy,
|
|
@@ -12132,6 +12252,9 @@ export {
|
|
|
12132
12252
|
quoteOverAsks,
|
|
12133
12253
|
stablecoinIconUrl,
|
|
12134
12254
|
submitErc20Approval,
|
|
12255
|
+
tokenLogoUrl,
|
|
12256
|
+
tokenMetadataOf,
|
|
12257
|
+
useCheckoutOfferTokenMetadata,
|
|
12135
12258
|
useCoinList,
|
|
12136
12259
|
useCoinListSignInCardViewModel,
|
|
12137
12260
|
useCompleteOAuth,
|