@coinlist-co/react 0.12.2-rc.0ff2d03 → 0.12.2-rc.3de3751
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-SVPFFLIT.js → chunk-HMLWCXAP.js} +195 -183
- package/dist/chunk-HMLWCXAP.js.map +1 -0
- package/dist/{chunk-QTBEDN7C.js → chunk-L7SVKXXW.js} +2 -2
- package/dist/{chunk-PWGUKS4Q.js → chunk-RLOYYAMO.js} +6 -25
- package/dist/chunk-RLOYYAMO.js.map +1 -0
- package/dist/client/index.d.ts +705 -663
- package/dist/client/index.js +5852 -6840
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -2
- package/dist/{time-BDzqB806.d.ts → time-DkU7jivQ.d.ts} +15 -17
- package/dist/{token-registry-snapshot-cvLsnMo_.d.ts → token-registry-snapshot-D0OWXMe4.d.ts} +19 -21
- package/dist/universal/index.d.ts +10 -9
- package/dist/universal/index.js +8 -6
- package/package.json +1 -1
- package/dist/chunk-PWGUKS4Q.js.map +0 -1
- package/dist/chunk-SVPFFLIT.js.map +0 -1
- /package/dist/{chunk-QTBEDN7C.js.map → chunk-L7SVKXXW.js.map} +0 -0
package/dist/client/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, MouseEventHandler } from 'react';
|
|
3
|
-
import { A as AuthorizationCode, C as CodeVerifier, W as WalletError,
|
|
3
|
+
import { A as AuthorizationCode, C as CodeVerifier, W as WalletError, E as EthereumChain, a as AssetSymbol, O as OfferVaultContract, b as EvmContractAddress, B as BlockchainAmount, c as CentrifugeVaultBuyTransaction, d as CentrifugeClaimDirection, e as CentrifugeNamespace, f as OfferId, g as OfferOptionId, h as AssetId, P as Participation, i as CoinListTokenSaleNamespace, j as OfferSwapContract, k as OndoBuyTransaction, l as OndoSellTransaction, m as OndoNamespace, n as OndoSwapTransactionCore, o as OrderBookSide, S as SwapQuote, p as Bps, q as EvmWalletAddress, r as SuperstateSwapNamespace, R as RequirementsNamespace, s as Requirement, t as WalletChallengeType, u as OfferOptionAddress, v as WalletsNamespace, w as Config, x as OAuthAccessToken, y as OffersNamespace, z as Erc20Namespace, T as TokensNamespace, D as Offer, F as TokenMetadata, G as OfferDetail, H as StablecoinSymbol, I as Erc20Asset, J as CoinListTokenSaleOfferDetail, K as CentrifugeVaultLegId, L as CentrifugeVaultOfferDetail, M as Seconds, N as AsyncOfferDetail, Q as RequirementStatusInfo, U as KycLevelName, V as RequirementType, X as RequirementStatusValue, Y as RequirementId, Z as PinoLoggerOptions, _ as Logger, $ as CentrifugeVaultStatus, a0 as CentrifugeVaultRef, a1 as BuildOndoBuyParams, a2 as OndoSwapOfferDetail, a3 as BuildOndoSellParams, a4 as OndoQuote, a5 as OndoQuoteSize, a6 as OndoTradingStatus, a7 as AssetDecimals, a8 as SuperstateSwapOfferDetail, a9 as CentrifugeVaultLeg, aa as CentrifugeVault, ab as OfferOptionAddressId, ac as DocumentSubmission, ad as TokenIdentifier } from '../time-DkU7jivQ.js';
|
|
4
4
|
import { Hash } from 'viem';
|
|
5
|
-
import { E as EvmWallet, C as ConnectWallet, F as FormattedAmountAssetUi, T as TxExplorerUrl, A as AssetIconUrl,
|
|
5
|
+
import { E as EvmWallet, C as ConnectWallet, W as WalletSelection, F as FormattedAmountAssetUi, T as TxExplorerUrl, A as AssetIconUrl, a as WalletLabelResolver, S as ShortenedWalletAddress, b as FormattedPercentUi, N as NonEmptyArray, c as TokenRegistrySnapshot } from '../token-registry-snapshot-D0OWXMe4.js';
|
|
6
6
|
|
|
7
7
|
type AuthState = 'unknown' | 'logged-in' | 'logged-out';
|
|
8
8
|
/** Discriminated error reasons from {@link CoinListClient.completeOAuth}. */
|
|
@@ -73,7 +73,7 @@ interface ClientAuthNamespace {
|
|
|
73
73
|
logout(): void;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
type Erc20AllowancePhase = 'checking-allowance' |
|
|
76
|
+
type Erc20AllowancePhase = 'checking-allowance' | ResetThenApprovePhase;
|
|
77
77
|
type Erc20AllowanceError = {
|
|
78
78
|
step: 'allowance-check';
|
|
79
79
|
} | Erc20ApprovalError;
|
|
@@ -84,24 +84,32 @@ type Erc20ApprovalError = {
|
|
|
84
84
|
} | {
|
|
85
85
|
step: 'approval-reverted';
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* The phases {@link resetThenApprove} reports, in order. The two reset phases
|
|
89
|
+
* occur only when there is a non-zero allowance to reset.
|
|
90
|
+
*/
|
|
91
|
+
type ResetThenApprovePhase = 'resetting-allowance' | 'confirming-allowance-reset' | 'approving' | 'confirming-approval';
|
|
87
92
|
|
|
88
93
|
/**
|
|
89
|
-
* Progress phases emitted while a
|
|
90
|
-
* allowance that already covers the
|
|
91
|
-
*
|
|
92
|
-
* @alpha
|
|
94
|
+
* Progress phases emitted while a backend-built order is being prepared, in
|
|
95
|
+
* the order they occur. An allowance that already covers the order skips the
|
|
96
|
+
* approval phases.
|
|
93
97
|
*/
|
|
94
|
-
type
|
|
98
|
+
type ApproveThenBuildPhase = Erc20AllowancePhase | 'building-transaction';
|
|
95
99
|
/**
|
|
96
100
|
* A step-tagged reason a preparation failed.
|
|
97
101
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
102
|
+
* Every arm names a *remedy* rather than a provider or a trade: an unsupported
|
|
103
|
+
* chain, a refused approval and a build that would not complete are fixed the
|
|
104
|
+
* same way whichever token was being approved, and whoever built it.
|
|
101
105
|
*
|
|
102
|
-
*
|
|
106
|
+
* `insufficient-allowance` is separated from the generic build failure because
|
|
107
|
+
* it is the one with a remedy: the backend reads the allowance itself before
|
|
108
|
+
* building, so reaching it means the approval this flow just mined is not the
|
|
109
|
+
* one the backend sees. That is usually its RPC node lagging a block behind,
|
|
110
|
+
* which retrying fixes - so it is a retry, not a re-approval.
|
|
103
111
|
*/
|
|
104
|
-
type
|
|
112
|
+
type ApproveThenBuildError = {
|
|
105
113
|
step: 'unsupported-chain';
|
|
106
114
|
chain: EthereumChain;
|
|
107
115
|
} | Erc20AllowanceError | {
|
|
@@ -109,14 +117,34 @@ type CentrifugeBuyPreparationError = {
|
|
|
109
117
|
} | {
|
|
110
118
|
step: 'build-transaction';
|
|
111
119
|
};
|
|
112
|
-
/**
|
|
113
|
-
|
|
120
|
+
/**
|
|
121
|
+
* A prepared order of whichever kind was asked for, or the step that stopped
|
|
122
|
+
* it. Generic in the transaction, so a caller gets back the type its `build`
|
|
123
|
+
* returned.
|
|
124
|
+
*/
|
|
125
|
+
type ApproveThenBuildResult<T> = {
|
|
114
126
|
type: 'success';
|
|
115
|
-
transaction:
|
|
127
|
+
transaction: T;
|
|
116
128
|
} | {
|
|
117
129
|
type: 'error';
|
|
118
|
-
error:
|
|
130
|
+
error: ApproveThenBuildError;
|
|
119
131
|
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Progress phases emitted while a request is being prepared, in order. An
|
|
135
|
+
* allowance that already covers the deposit skips the approval phases.
|
|
136
|
+
*
|
|
137
|
+
* @alpha
|
|
138
|
+
*/
|
|
139
|
+
type CentrifugeBuyPreparationPhase = ApproveThenBuildPhase;
|
|
140
|
+
/**
|
|
141
|
+
* A step-tagged reason a preparation failed - see {@link ApproveThenBuildError}.
|
|
142
|
+
*
|
|
143
|
+
* @alpha
|
|
144
|
+
*/
|
|
145
|
+
type CentrifugeBuyPreparationError = ApproveThenBuildError;
|
|
146
|
+
/** @alpha */
|
|
147
|
+
type CentrifugeBuyPreparationResult = ApproveThenBuildResult<CentrifugeVaultBuyTransaction>;
|
|
120
148
|
/** @alpha */
|
|
121
149
|
type PrepareCentrifugeBuyParams = {
|
|
122
150
|
wallet: EvmWallet;
|
|
@@ -388,28 +416,13 @@ interface ClientCoinListTokenSaleNamespace extends CoinListTokenSaleNamespace {
|
|
|
388
416
|
* Progress phases emitted while an order is being prepared, in the order they
|
|
389
417
|
* occur. An allowance that already covers the order skips the approval phases.
|
|
390
418
|
*/
|
|
391
|
-
type OndoSwapPreparationPhase =
|
|
419
|
+
type OndoSwapPreparationPhase = ApproveThenBuildPhase;
|
|
392
420
|
/**
|
|
393
|
-
* A step-tagged reason a preparation failed.
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* trade: an unsupported chain, a refused approval and a build that would not
|
|
397
|
-
* complete are fixed the same way whichever token was being approved.
|
|
398
|
-
*
|
|
399
|
-
* `insufficient-allowance` is separated from the generic build failure because
|
|
400
|
-
* it is the one with a remedy: frontline reads the allowance before asking
|
|
401
|
-
* Ninshubur for anything, so reaching it means the approval this flow just
|
|
402
|
-
* mined is not the one frontline sees. That is usually its RPC node lagging a
|
|
403
|
-
* block behind, which retrying fixes - so it is a retry, not a re-approval.
|
|
421
|
+
* A step-tagged reason a preparation failed. Shared by both directions, and
|
|
422
|
+
* with every other backend-built checkout, because every arm names a remedy
|
|
423
|
+
* rather than a trade - see {@link ApproveThenBuildError}.
|
|
404
424
|
*/
|
|
405
|
-
type OndoSwapPreparationError =
|
|
406
|
-
step: 'unsupported-chain';
|
|
407
|
-
chain: EthereumChain;
|
|
408
|
-
} | Erc20AllowanceError | {
|
|
409
|
-
step: 'insufficient-allowance';
|
|
410
|
-
} | {
|
|
411
|
-
step: 'build-transaction';
|
|
412
|
-
};
|
|
425
|
+
type OndoSwapPreparationError = ApproveThenBuildError;
|
|
413
426
|
/**
|
|
414
427
|
* A prepared order of whichever kind was asked for, or the step that stopped
|
|
415
428
|
* it.
|
|
@@ -417,13 +430,7 @@ type OndoSwapPreparationError = {
|
|
|
417
430
|
* Generic in the transaction rather than a union over the two, so a caller
|
|
418
431
|
* that asked for a sale cannot be handed a purchase to narrow.
|
|
419
432
|
*/
|
|
420
|
-
type OndoSwapPreparationResult<T> =
|
|
421
|
-
type: 'success';
|
|
422
|
-
transaction: T;
|
|
423
|
-
} | {
|
|
424
|
-
type: 'error';
|
|
425
|
-
error: OndoSwapPreparationError;
|
|
426
|
-
};
|
|
433
|
+
type OndoSwapPreparationResult<T> = ApproveThenBuildResult<T>;
|
|
427
434
|
type OndoBuyPreparationResult = OndoSwapPreparationResult<OndoBuyTransaction>;
|
|
428
435
|
type OndoSellPreparationResult = OndoSwapPreparationResult<OndoSellTransaction>;
|
|
429
436
|
/** What both preparations take, before the two fields whose meaning forks. */
|
|
@@ -477,12 +484,21 @@ type OndoSwapExecutionPhase = 'broadcasting-swap' | 'confirming-swap';
|
|
|
477
484
|
* `quote-expired` is a refusal to broadcast rather than a failure of a
|
|
478
485
|
* broadcast: it would revert on chain and cost the user gas, and it is fixed
|
|
479
486
|
* by building a fresh transaction.
|
|
487
|
+
*
|
|
488
|
+
* `swap` means the wallet never sent it, so placing again is safe.
|
|
489
|
+
* `swap-unconfirmed` means it was sent and the receipt wait failed: the swap
|
|
490
|
+
* may still mine, and placing again can fill the order twice. `txHash` is
|
|
491
|
+
* the transaction to look up before doing anything else.
|
|
480
492
|
*/
|
|
481
493
|
type OndoSwapExecutionError = {
|
|
482
494
|
step: 'quote-expired';
|
|
483
495
|
} | {
|
|
484
496
|
step: 'swap';
|
|
485
497
|
cause: WalletError;
|
|
498
|
+
} | {
|
|
499
|
+
step: 'swap-unconfirmed';
|
|
500
|
+
txHash: Hash;
|
|
501
|
+
cause: WalletError;
|
|
486
502
|
} | {
|
|
487
503
|
step: 'swap-reverted';
|
|
488
504
|
};
|
|
@@ -585,9 +601,21 @@ type SwapExecutionError = {
|
|
|
585
601
|
step: 'swap-paused';
|
|
586
602
|
} | {
|
|
587
603
|
step: 'swap-stopped';
|
|
588
|
-
} | Erc20AllowanceError
|
|
604
|
+
} | Erc20AllowanceError
|
|
605
|
+
/** The wallet never sent the swap, so swapping again is safe. */
|
|
606
|
+
| {
|
|
589
607
|
step: 'swap';
|
|
590
608
|
cause: WalletError;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The swap was sent and the receipt wait failed. It may still mine, so
|
|
612
|
+
* swapping again can fill the order twice: `txHash` is the transaction to
|
|
613
|
+
* look up before doing anything else.
|
|
614
|
+
*/
|
|
615
|
+
| {
|
|
616
|
+
step: 'swap-unconfirmed';
|
|
617
|
+
txHash: Hash;
|
|
618
|
+
cause: WalletError;
|
|
591
619
|
} | {
|
|
592
620
|
step: 'swap-reverted';
|
|
593
621
|
};
|
|
@@ -642,9 +670,21 @@ type WalletAuthorizationError = {
|
|
|
642
670
|
cause: WalletError;
|
|
643
671
|
} | {
|
|
644
672
|
step: 'allow-wallet';
|
|
645
|
-
}
|
|
673
|
+
}
|
|
674
|
+
/** The wallet never sent the allow-list transaction. */
|
|
675
|
+
| {
|
|
646
676
|
step: 'broadcast';
|
|
647
677
|
cause: WalletError;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* The allow-list transaction was sent and the receipt wait failed. It may
|
|
681
|
+
* still mine, so authorizing again would send a second one: `txHash` is the
|
|
682
|
+
* transaction to look up first.
|
|
683
|
+
*/
|
|
684
|
+
| {
|
|
685
|
+
step: 'broadcast-unconfirmed';
|
|
686
|
+
txHash: Hash;
|
|
687
|
+
cause: WalletError;
|
|
648
688
|
} | {
|
|
649
689
|
step: 'not-authorized';
|
|
650
690
|
};
|
|
@@ -1307,61 +1347,45 @@ type OndoSellOrderTerms = {
|
|
|
1307
1347
|
};
|
|
1308
1348
|
|
|
1309
1349
|
/**
|
|
1310
|
-
* The wallets a checkout can spend from, supplied by the host
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
* anything else - a partner may be a wallet provider themselves - so wallet
|
|
1314
|
-
* discovery and connection are inverted onto the host. It hands over ready
|
|
1315
|
-
* {@link EvmWallet}s and two lambdas; the SDK decides nothing about how they
|
|
1316
|
-
* came to exist.
|
|
1350
|
+
* The wallets a checkout can spend from, supplied by the host: the shared
|
|
1351
|
+
* {@link WalletSelection} every screen reads its wallets from, plus the one
|
|
1352
|
+
* thing only a checkout asks for.
|
|
1317
1353
|
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1320
|
-
* wallet type to keep in sync with the first.
|
|
1354
|
+
* A `null` `externalAdapter` hides the external-wallet row entirely, for a
|
|
1355
|
+
* host that only offers embedded wallets.
|
|
1321
1356
|
*
|
|
1322
|
-
* Everything
|
|
1323
|
-
* from the checkout's execution chain rather than from the wallet,
|
|
1324
|
-
* that is the chain the transaction goes to whatever the wallet is
|
|
1325
|
-
* pointed at.
|
|
1357
|
+
* Everything a wallet row displays beyond the address - the network name -
|
|
1358
|
+
* comes from the checkout's execution chain rather than from the wallet,
|
|
1359
|
+
* because that is the chain the transaction goes to whatever the wallet is
|
|
1360
|
+
* currently pointed at.
|
|
1326
1361
|
*/
|
|
1327
|
-
type CheckoutWalletSelection = {
|
|
1328
|
-
/**
|
|
1329
|
-
* The user's embedded (custodial) wallets, in display order. Empty when they
|
|
1330
|
-
* have none, which is a normal state, not an error.
|
|
1331
|
-
*/
|
|
1332
|
-
embedded: EvmWallet[];
|
|
1333
|
-
/** The connected external wallet, or `null` while none is connected. */
|
|
1334
|
-
external: EvmWallet | null;
|
|
1362
|
+
type CheckoutWalletSelection = WalletSelection & {
|
|
1335
1363
|
/**
|
|
1336
1364
|
* A wallet the host has already settled on, or `null` to let the user pick.
|
|
1337
1365
|
*
|
|
1338
|
-
*
|
|
1339
|
-
*
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1366
|
+
* That is for the host that already knows the answer - a sell page reached
|
|
1367
|
+
* from a position knows which wallet holds it, and a host with a single
|
|
1368
|
+
* embedded wallet has only one answer on a buy too - so asking again would
|
|
1369
|
+
* be a question with one possible answer. Every checkout honours it, in one
|
|
1370
|
+
* of two ways:
|
|
1343
1371
|
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
* a
|
|
1372
|
+
* - **Ondo buy, Ondo sell and Centrifuge buy skip their wallet step** and
|
|
1373
|
+
* open on the amount, renumbering the steps that remain. The wallet does
|
|
1374
|
+
* not have to appear in `embedded` or `external`: the host supplies a
|
|
1375
|
+
* ready {@link EvmWallet}, and these flows never resolve it back to a row.
|
|
1376
|
+
* - **Superstate never skips its wallet step**, because that step
|
|
1377
|
+
* allow-lists the wallet on-chain and no preselection can stand in for it.
|
|
1378
|
+
* The step opens with the preselected wallet's row already selected, so
|
|
1379
|
+
* the user confirms it rather than finding it. That needs a row: a wallet
|
|
1380
|
+
* matching neither an `embedded` one nor the connected `external` one by
|
|
1381
|
+
* address selects nothing, and the user picks as if none was preselected.
|
|
1347
1382
|
*
|
|
1348
|
-
* **
|
|
1349
|
-
*
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1352
|
-
* assume a skip from the field being set.
|
|
1383
|
+
* Read **once**, when the checkout mounts. The approval a checkout asks for
|
|
1384
|
+
* is granted by one specific wallet, so a change mid-flow is ignored; remount
|
|
1385
|
+
* the checkout (a `key`) to apply a new one. After an order the flow resets
|
|
1386
|
+
* to the step it opened on, so a skipped wallet step stays skipped.
|
|
1353
1387
|
*/
|
|
1354
1388
|
preselected: EvmWallet | null;
|
|
1355
|
-
/**
|
|
1356
|
-
* Opens the host's wallet connector. Resolves once the attempt finishes; the
|
|
1357
|
-
* SDK reads the outcome from `external` on the next render rather than from
|
|
1358
|
-
* a return value, so a host that connects through a redirect still works.
|
|
1359
|
-
*
|
|
1360
|
-
* Rejecting is how a declined or failed connection is reported.
|
|
1361
|
-
*/
|
|
1362
|
-
connectExternal: () => Promise<void>;
|
|
1363
|
-
/** Disconnects the external wallet. Resolves when it is gone. */
|
|
1364
|
-
disconnectExternal: () => Promise<void>;
|
|
1365
1389
|
};
|
|
1366
1390
|
|
|
1367
1391
|
/** What the swap actually filled at, once it has mined. */
|
|
@@ -1488,9 +1512,29 @@ interface CheckoutContainerProps {
|
|
|
1488
1512
|
*/
|
|
1489
1513
|
side?: OrderBookSide;
|
|
1490
1514
|
/**
|
|
1491
|
-
* The wallets the buyer can spend from, and the
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1515
|
+
* The wallets the buyer can spend from, and the host's connector for an
|
|
1516
|
+
* external one. The SDK ships no wallet stack, so this is how a host plugs
|
|
1517
|
+
* in Privy, AppKit, or its own.
|
|
1518
|
+
*
|
|
1519
|
+
* ```tsx
|
|
1520
|
+
* const wallets: CheckoutWalletSelection = {
|
|
1521
|
+
* embedded: myEmbeddedWallets,
|
|
1522
|
+
* external: myConnectedWallet, // or null
|
|
1523
|
+
* // `null` hides the external-wallet row, for a host with embedded
|
|
1524
|
+
* // wallets only.
|
|
1525
|
+
* externalAdapter: {
|
|
1526
|
+
* connect: () => myConnector.open(),
|
|
1527
|
+
* disconnect: () => myConnector.disconnect(),
|
|
1528
|
+
* },
|
|
1529
|
+
* preselected: null, // or the wallet the host already settled on
|
|
1530
|
+
* };
|
|
1531
|
+
* ```
|
|
1532
|
+
*
|
|
1533
|
+
* Every provider honours `wallets.preselected`. Ondo (buy and sell) and
|
|
1534
|
+
* Centrifuge skip their wallet step and open on the amount, renumbering the
|
|
1535
|
+
* cards that remain. Superstate never skips it, because that step
|
|
1536
|
+
* allow-lists the wallet on-chain: it opens the step with the preselected
|
|
1537
|
+
* wallet's row already selected instead. Read once, at mount - see below.
|
|
1494
1538
|
*/
|
|
1495
1539
|
wallets: CheckoutWalletSelection;
|
|
1496
1540
|
/**
|
|
@@ -1518,22 +1562,29 @@ interface CheckoutContainerProps {
|
|
|
1518
1562
|
* assigns to `const exhaustive: never`, so a new offer type is a compile error
|
|
1519
1563
|
* here as well as in {@link CheckoutConfig}.
|
|
1520
1564
|
*
|
|
1521
|
-
* ## One mount, one offer, one chain, one side
|
|
1522
|
-
*
|
|
1523
|
-
* `offer`, `chain
|
|
1524
|
-
* the mount. Each provider's viewmodel owns a step machine
|
|
1525
|
-
* authorized, how much is being spent
|
|
1526
|
-
* it was made against: a Superstate wallet authorization
|
|
1527
|
-
* offer, and an ERC-20 approval is granted per chain, for
|
|
1528
|
-
* Changing any of
|
|
1529
|
-
* it was never made for
|
|
1530
|
-
* approval covers the coin the *old* direction spent. So the
|
|
1531
|
-
* try to: `side` is read once into state and later values
|
|
1532
|
-
* swap could also land mid-execution, between an approval and the broadcast it
|
|
1565
|
+
* ## One mount, one offer, one chain, one side, one preselected wallet
|
|
1566
|
+
*
|
|
1567
|
+
* `offer`, `chain`, the `side` and `wallets.preselected` are read as fixed for
|
|
1568
|
+
* the lifetime of the mount. Each provider's viewmodel owns a step machine -
|
|
1569
|
+
* which wallet was authorized, how much is being spent - and that progress is
|
|
1570
|
+
* bound to the order it was made against: a Superstate wallet authorization
|
|
1571
|
+
* is allow-listed per offer, and an ERC-20 approval is granted per chain, for
|
|
1572
|
+
* one specific token. Changing any of them in place would carry a completed
|
|
1573
|
+
* step onto an order it was never made for - a flipped side most sharply of
|
|
1574
|
+
* all, since the approval covers the coin the *old* direction spent. So the
|
|
1575
|
+
* container does not try to: `side` is read once into state and later values
|
|
1576
|
+
* are ignored. A swap could also land mid-execution, between an approval and the broadcast it
|
|
1533
1577
|
* was granted for, which is worse than not switching at all.
|
|
1534
1578
|
*
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1579
|
+
* The preselected wallet is the same kind of progress: whether the flow has a
|
|
1580
|
+
* wallet step at all is decided from it at mount, and the approval that
|
|
1581
|
+
* follows is granted by that wallet. The rest of `wallets` stays live - a
|
|
1582
|
+
* newly connected external wallet appears as a row without a remount.
|
|
1583
|
+
*
|
|
1584
|
+
* **To render a different offer, chain, side or preselected wallet, remount
|
|
1585
|
+
* rather than reassign** - give the container a `key` that changes with them
|
|
1586
|
+
* (add `wallets.preselected?.address` to it if the host's preselection can
|
|
1587
|
+
* change on one page):
|
|
1537
1588
|
*
|
|
1538
1589
|
* ```tsx
|
|
1539
1590
|
* <CheckoutContainer
|
|
@@ -1567,7 +1618,8 @@ interface CheckoutContainerProps {
|
|
|
1567
1618
|
*
|
|
1568
1619
|
* A sell page reached from a position also knows which wallet holds it, so it
|
|
1569
1620
|
* usually sets {@link CheckoutWalletSelection.preselected} and opens on the
|
|
1570
|
-
* amount.
|
|
1621
|
+
* amount. A buy page can do the same whenever the host has one answer - a
|
|
1622
|
+
* single embedded wallet, say.
|
|
1571
1623
|
*
|
|
1572
1624
|
* ### A buy/sell toggle on one page
|
|
1573
1625
|
*
|
|
@@ -2406,16 +2458,24 @@ interface UseOffersResult {
|
|
|
2406
2458
|
declare function useOffers(options?: UseOffersOptions): UseOffersResult;
|
|
2407
2459
|
|
|
2408
2460
|
/**
|
|
2409
|
-
* Why a
|
|
2410
|
-
* differently.
|
|
2461
|
+
* Why a read failed, in the only two flavours every UI acts on differently.
|
|
2411
2462
|
*
|
|
2412
2463
|
* `not-authenticated` is split out because no retry helps until the user
|
|
2413
|
-
* signs in
|
|
2414
|
-
* retry.
|
|
2464
|
+
* signs in, and because the remedy is one the UI can name. Everything else
|
|
2465
|
+
* collapses into `generic-error` and is offered a retry. A provider that has a
|
|
2466
|
+
* third remedy of its own - Ondo's closed market - widens this union rather
|
|
2467
|
+
* than restating it.
|
|
2468
|
+
*/
|
|
2469
|
+
type LoadErrorReason = 'not-authenticated' | 'generic-error';
|
|
2470
|
+
|
|
2471
|
+
/**
|
|
2472
|
+
* Why a Centrifuge read failed. Centrifuge has no remedy of its own to add,
|
|
2473
|
+
* so this is {@link LoadErrorReason} under the name its states already
|
|
2474
|
+
* publish, classified by `loadErrorReason`.
|
|
2415
2475
|
*
|
|
2416
2476
|
* @alpha
|
|
2417
2477
|
*/
|
|
2418
|
-
type CentrifugeLoadErrorReason =
|
|
2478
|
+
type CentrifugeLoadErrorReason = LoadErrorReason;
|
|
2419
2479
|
|
|
2420
2480
|
/**
|
|
2421
2481
|
* The state of one vault's status poll.
|
|
@@ -2432,6 +2492,8 @@ type CentrifugeLoadErrorReason = 'not-authenticated' | 'generic-error';
|
|
|
2432
2492
|
* @alpha
|
|
2433
2493
|
*/
|
|
2434
2494
|
type LoadCentrifugeVaultStatusState = {
|
|
2495
|
+
type: 'DISABLED';
|
|
2496
|
+
} | {
|
|
2435
2497
|
type: 'LOADING';
|
|
2436
2498
|
} | {
|
|
2437
2499
|
type: 'ERROR';
|
|
@@ -2481,11 +2543,11 @@ interface UseCentrifugeVaultStatusesResult {
|
|
|
2481
2543
|
* otherwise left to the poll: the first tick fires as it always does, and
|
|
2482
2544
|
* only replaces the seed once it has a status of its own.
|
|
2483
2545
|
*
|
|
2484
|
-
* Disabled it neither fetches nor holds a timer
|
|
2485
|
-
*
|
|
2486
|
-
*
|
|
2487
|
-
*
|
|
2488
|
-
*
|
|
2546
|
+
* Disabled it neither fetches nor holds a timer. A vault with no status in
|
|
2547
|
+
* hand reports `DISABLED`, not an empty `CONTENT`: there is no empty vault
|
|
2548
|
+
* status, and an invented one would be worse than none, since `CONTENT` here
|
|
2549
|
+
* is what a caller is allowed to block on. A status already in hand survives
|
|
2550
|
+
* being switched off.
|
|
2489
2551
|
*
|
|
2490
2552
|
* @alpha
|
|
2491
2553
|
*/
|
|
@@ -2536,12 +2598,16 @@ declare function useCentrifugeVaultStatus(options: UseCentrifugeVaultStatusOptio
|
|
|
2536
2598
|
* that provider's `use{X}ViewModel.types`; these live here because Ondo and
|
|
2537
2599
|
* Superstate both render them.
|
|
2538
2600
|
*
|
|
2539
|
-
* Models only. A screen's `{X}UiState` and `{X}UiEvent` stay in that
|
|
2540
|
-
* `use{X}ViewModel.types` even when two providers' happen to agree
|
|
2541
|
-
* state machine is where providers diverge, and sharing one would
|
|
2542
|
-
* divergence a breaking change rather than a local edit.
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2601
|
+
* Models only. A provider screen's `{X}UiState` and `{X}UiEvent` stay in that
|
|
2602
|
+
* screen's `use{X}ViewModel.types` even when two providers' happen to agree
|
|
2603
|
+
* today: a state machine is where providers diverge, and sharing one would
|
|
2604
|
+
* make the divergence a breaking change rather than a local edit. A step with
|
|
2605
|
+
* zero provider input is the exception and is shared whole, in its own
|
|
2606
|
+
* `shared/` screen directory - the wallet step Ondo and Centrifuge render as
|
|
2607
|
+
* it stands, while Superstate's allow-lists on-chain from the same rows and
|
|
2608
|
+
* the same models; and the validate-only amount step Centrifuge and
|
|
2609
|
+
* Superstate render as it stands, while Ondo's approves on confirm and builds
|
|
2610
|
+
* its own from the same rules and leaves.
|
|
2545
2611
|
*
|
|
2546
2612
|
* No React and no hooks: this is the module Views and leaf components import.
|
|
2547
2613
|
*/
|
|
@@ -2561,6 +2627,17 @@ type CheckoutCtaUi = {
|
|
|
2561
2627
|
type: 'loading';
|
|
2562
2628
|
message: string;
|
|
2563
2629
|
};
|
|
2630
|
+
/**
|
|
2631
|
+
* What an amount field's number is denominated in, drawn beside it.
|
|
2632
|
+
*
|
|
2633
|
+
* A token symbol follows the number as its unit (`1,000 USDC`); a currency
|
|
2634
|
+
* sign leads it (`$1,000`). One closed variant rather than a `prefix` and a
|
|
2635
|
+
* `suffix` that could both be set, because a figure has one unit.
|
|
2636
|
+
*/
|
|
2637
|
+
type CheckoutAmountAdornmentUi = {
|
|
2638
|
+
type: 'prefix' | 'suffix';
|
|
2639
|
+
text: string;
|
|
2640
|
+
};
|
|
2564
2641
|
/**
|
|
2565
2642
|
* A status and the copy that names it: an Ondo market that is open, a sale
|
|
2566
2643
|
* still running, a window that has closed.
|
|
@@ -2667,6 +2744,42 @@ type CheckoutWalletUi = {
|
|
|
2667
2744
|
type CheckoutEmbeddedWalletUi = CheckoutWalletUi & {
|
|
2668
2745
|
walletAddress: EvmWalletAddress;
|
|
2669
2746
|
};
|
|
2747
|
+
/**
|
|
2748
|
+
* The external-wallet row of a checkout's wallet step.
|
|
2749
|
+
*
|
|
2750
|
+
* - `hidden`: the host offers no connector and none is connected, so there is
|
|
2751
|
+
* no row at all - a host that only supports embedded wallets.
|
|
2752
|
+
* - `disconnected`: the host offers a connector and nothing is connected yet.
|
|
2753
|
+
* The row is the invitation to connect one.
|
|
2754
|
+
* - `connected`: a wallet like any other. `canDisconnect` is `false` when the
|
|
2755
|
+
* host offers no connector (it handed over a wallet the user cannot change
|
|
2756
|
+
* from here) or while the step is using that wallet.
|
|
2757
|
+
*
|
|
2758
|
+
* A SUM rather than a nullable wallet beside a flag, so a View cannot offer to
|
|
2759
|
+
* connect a wallet the host has no way of connecting.
|
|
2760
|
+
*/
|
|
2761
|
+
type CheckoutExternalWalletUi = {
|
|
2762
|
+
type: 'hidden';
|
|
2763
|
+
} | {
|
|
2764
|
+
type: 'disconnected';
|
|
2765
|
+
} | {
|
|
2766
|
+
type: 'connected';
|
|
2767
|
+
wallet: CheckoutWalletUi;
|
|
2768
|
+
canDisconnect: boolean;
|
|
2769
|
+
};
|
|
2770
|
+
declare const CheckoutExternalWalletUi: {
|
|
2771
|
+
/**
|
|
2772
|
+
* The external-wallet row for the host's wallets.
|
|
2773
|
+
*
|
|
2774
|
+
* `locked` is for a step that is using the external wallet right now - mid
|
|
2775
|
+
* signature, say - and must not let it be disconnected underneath itself.
|
|
2776
|
+
*/
|
|
2777
|
+
fromDomain: (wallets: WalletSelection, { network, selected, locked, }: {
|
|
2778
|
+
network: string;
|
|
2779
|
+
selected: boolean;
|
|
2780
|
+
locked: boolean;
|
|
2781
|
+
}) => CheckoutExternalWalletUi;
|
|
2782
|
+
};
|
|
2670
2783
|
/**
|
|
2671
2784
|
* The wallet the user settled on.
|
|
2672
2785
|
*
|
|
@@ -2719,95 +2832,23 @@ type CheckoutSelectableInputAssetUi = {
|
|
|
2719
2832
|
rawBalance: bigint;
|
|
2720
2833
|
selected: boolean;
|
|
2721
2834
|
};
|
|
2722
|
-
|
|
2723
|
-
/**
|
|
2724
|
-
* Step 2 of the Centrifuge checkout: how much of the funding token to deposit.
|
|
2725
|
-
*
|
|
2726
|
-
* Nothing here touches the chain. Confirming checks the amount in memory and
|
|
2727
|
-
* hands it up. The review step approves and places the request together.
|
|
2728
|
-
*
|
|
2729
|
-
* @alpha
|
|
2730
|
-
*/
|
|
2731
|
-
type CentrifugeBuyAmountUiState = {
|
|
2732
|
-
type: 'incomplete';
|
|
2733
|
-
} | {
|
|
2734
|
-
type: 'active';
|
|
2735
|
-
/** Exactly what the user has typed. `'1.'` is a legal thing to hold. */
|
|
2736
|
-
amountInput: string;
|
|
2737
|
-
walletAddress: ShortenedWalletAddress;
|
|
2738
|
-
inputAssets: CheckoutSelectableInputAssetUi[];
|
|
2739
|
-
confirmCta: CheckoutCtaUi;
|
|
2740
|
-
error: string | null;
|
|
2741
|
-
} | {
|
|
2742
|
-
type: 'complete';
|
|
2743
|
-
inputAsset: CheckoutAssetUi;
|
|
2744
|
-
amountFormatted: FormattedAmountAssetUi;
|
|
2745
|
-
};
|
|
2746
|
-
/** @alpha */
|
|
2747
|
-
type CentrifugeBuyAmountUiEvent = {
|
|
2748
|
-
type: 'ON_AMOUNT_CHANGE';
|
|
2749
|
-
value: string;
|
|
2750
|
-
} | {
|
|
2751
|
-
type: 'ON_MAX_AMOUNT_CLICK';
|
|
2752
|
-
} | {
|
|
2753
|
-
type: 'ON_SELECT_PAY_WITH';
|
|
2754
|
-
value: AssetSymbol;
|
|
2755
|
-
} | {
|
|
2756
|
-
type: 'ON_CONFIRM_AMOUNT';
|
|
2757
|
-
} | {
|
|
2758
|
-
type: 'ON_EDIT_AMOUNT';
|
|
2759
|
-
};
|
|
2760
|
-
|
|
2761
2835
|
/**
|
|
2762
|
-
*
|
|
2763
|
-
*
|
|
2764
|
-
* `isRefreshing` rides on `CONTENT` so a rebuild never blanks the numbers on
|
|
2765
|
-
* screen. A failed rebuild keeps them and says why.
|
|
2836
|
+
* Where a placed order can be checked: the wallet it settles to, and the
|
|
2837
|
+
* transaction on a block explorer.
|
|
2766
2838
|
*
|
|
2767
|
-
*
|
|
2839
|
+
* Every provider's order dialog carries the pair, and builds it the same way
|
|
2840
|
+
* from the same three facts, so it is one model rather than two fields each
|
|
2841
|
+
* dialog re-derives.
|
|
2768
2842
|
*/
|
|
2769
|
-
type
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
type: 'ERROR';
|
|
2773
|
-
reason: CentrifugeLoadErrorReason;
|
|
2774
|
-
} | {
|
|
2775
|
-
type: 'CONTENT';
|
|
2776
|
-
transaction: CentrifugeVaultBuyTransaction;
|
|
2777
|
-
isRefreshing: boolean;
|
|
2778
|
-
refreshError: CentrifugeLoadErrorReason | null;
|
|
2779
|
-
};
|
|
2780
|
-
/** @alpha */
|
|
2781
|
-
interface UseCentrifugeBuyTransactionOptions {
|
|
2782
|
-
/**
|
|
2783
|
-
* The request to build, or `null` before an amount is confirmed. A `null`
|
|
2784
|
-
* request fetches nothing.
|
|
2785
|
-
*/
|
|
2786
|
-
request: BuildCentrifugeVaultBuyParams | null;
|
|
2843
|
+
type CheckoutReceiptUi = {
|
|
2844
|
+
/** The wallet the order settles to. */
|
|
2845
|
+
recipientAddress: ShortenedWalletAddress;
|
|
2787
2846
|
/**
|
|
2788
|
-
*
|
|
2789
|
-
*
|
|
2790
|
-
* `refetch` still builds.
|
|
2847
|
+
* The order's transaction on a block explorer. Always present: a dialog
|
|
2848
|
+
* only exists once there is a transaction to point at.
|
|
2791
2849
|
*/
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
enabled: boolean;
|
|
2795
|
-
}
|
|
2796
|
-
/** @alpha */
|
|
2797
|
-
interface UseCentrifugeBuyTransactionResult {
|
|
2798
|
-
state: LoadCentrifugeBuyTransactionState;
|
|
2799
|
-
/** Builds a fresh request for the same deposit. */
|
|
2800
|
-
refetch: () => void;
|
|
2801
|
-
}
|
|
2802
|
-
/**
|
|
2803
|
-
* Holds the deposit request the review step places, and rebuilds it when
|
|
2804
|
-
* asked.
|
|
2805
|
-
*
|
|
2806
|
-
* **Never polls.** A request is built once, when the user confirms an amount.
|
|
2807
|
-
*
|
|
2808
|
-
* @alpha
|
|
2809
|
-
*/
|
|
2810
|
-
declare function useCentrifugeBuyTransaction(options: UseCentrifugeBuyTransactionOptions): UseCentrifugeBuyTransactionResult;
|
|
2850
|
+
txExplorerUrl: TxExplorerUrl;
|
|
2851
|
+
};
|
|
2811
2852
|
|
|
2812
2853
|
/**
|
|
2813
2854
|
* Step 3 of the Centrifuge checkout: confirming the deposit and placing it.
|
|
@@ -2842,38 +2883,37 @@ type CentrifugeBuyReviewUiEvent = {
|
|
|
2842
2883
|
};
|
|
2843
2884
|
|
|
2844
2885
|
/**
|
|
2845
|
-
* Why a
|
|
2846
|
-
* failing.
|
|
2886
|
+
* Why a checkout cannot run right now, as opposed to a step of it failing.
|
|
2847
2887
|
*
|
|
2848
|
-
*
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
*
|
|
2853
|
-
*
|
|
2888
|
+
* Every provider has the same two kinds of answer, and only the second is
|
|
2889
|
+
* named per provider:
|
|
2890
|
+
*
|
|
2891
|
+
* - `unsupported-chain`: the offer names no contract on the chain the host
|
|
2892
|
+
* asked for, so there is no spender to approve and nothing to broadcast to.
|
|
2893
|
+
* Settled at mount, since the offer and the chain are both fixed for its
|
|
2894
|
+
* lifetime, so nothing can clear it.
|
|
2895
|
+
* - `TBlocked`: the provider is known not to take an order right now - a
|
|
2896
|
+
* closed market, a paused vault. Known from a poll, never assumed from one
|
|
2897
|
+
* that is still loading or failed, and it clears on its own once the poll
|
|
2898
|
+
* says so.
|
|
2899
|
+
*
|
|
2900
|
+
* A union rather than a bare flag because the View switches on it for copy.
|
|
2854
2901
|
*/
|
|
2855
|
-
'unsupported-chain'
|
|
2902
|
+
type CheckoutBlockedReason<TBlocked extends string> = 'unsupported-chain' | TBlocked;
|
|
2903
|
+
|
|
2856
2904
|
/**
|
|
2857
|
-
*
|
|
2858
|
-
*
|
|
2859
|
-
*
|
|
2905
|
+
* Why a Centrifuge checkout cannot run right now, as opposed to a step of it
|
|
2906
|
+
* failing. See {@link CheckoutBlockedReason} for `unsupported-chain`, which
|
|
2907
|
+
* here means the offer names no vault proxy on the chain.
|
|
2908
|
+
*
|
|
2909
|
+
* `not-orderable` is Centrifuge's block: the vault is known to be unable to
|
|
2910
|
+
* take a request - halted, unlinked, or not permissioned. Known from a status
|
|
2911
|
+
* whose orderability is blocked; loading and failed statuses are unknown, and
|
|
2912
|
+
* unknown does not block.
|
|
2860
2913
|
*
|
|
2861
|
-
*
|
|
2862
|
-
* dialog is up. Past that, a pause belongs to the step it interrupts.
|
|
2914
|
+
* @alpha
|
|
2863
2915
|
*/
|
|
2864
|
-
|
|
2865
|
-
/** @alpha */
|
|
2866
|
-
declare const CentrifugeCheckoutErrorReason: {
|
|
2867
|
-
/**
|
|
2868
|
-
* Which reason, if any, replaces the whole checkout. `null` means the steps
|
|
2869
|
-
* render.
|
|
2870
|
-
*/
|
|
2871
|
-
of: ({ depositableHere, notOrderable, atEntry, }: {
|
|
2872
|
-
depositableHere: boolean;
|
|
2873
|
-
notOrderable: boolean;
|
|
2874
|
-
atEntry: boolean;
|
|
2875
|
-
}) => CentrifugeCheckoutErrorReason | null;
|
|
2876
|
-
};
|
|
2916
|
+
type CentrifugeCheckoutErrorReason = CheckoutBlockedReason<'not-orderable'>;
|
|
2877
2917
|
|
|
2878
2918
|
/**
|
|
2879
2919
|
* The asset panel beside the Centrifuge checkout.
|
|
@@ -2928,24 +2968,113 @@ type CentrifugeSidebarMinimumUi = {
|
|
|
2928
2968
|
};
|
|
2929
2969
|
|
|
2930
2970
|
/**
|
|
2931
|
-
*
|
|
2971
|
+
* The amount step of a checkout whose amount step takes no provider input:
|
|
2972
|
+
* how much to spend, and which stablecoin to spend it in. Centrifuge and
|
|
2973
|
+
* Superstate render it as it stands.
|
|
2974
|
+
*
|
|
2975
|
+
* Shared whole, state machine included, because it is not a provider state
|
|
2976
|
+
* machine: nothing here touches the chain, so confirming checks the amount in
|
|
2977
|
+
* memory and hands it up, and there is nothing for a provider to diverge on.
|
|
2978
|
+
* It forks the moment one provider needs different behaviour - Ondo's already
|
|
2979
|
+
* has, since its confirm approves and builds an order, so it keeps its own
|
|
2980
|
+
* state over the same rules and leaves.
|
|
2981
|
+
*
|
|
2982
|
+
* The CTA is a `CheckoutCtaUi` all the same, rather than a `confirmEnabled`
|
|
2983
|
+
* flag, so the View renders it through the one CTA every amount step uses. It
|
|
2984
|
+
* is never `loading` here.
|
|
2985
|
+
*/
|
|
2986
|
+
type CheckoutAmountUiState = {
|
|
2987
|
+
type: 'incomplete';
|
|
2988
|
+
} | {
|
|
2989
|
+
type: 'active';
|
|
2990
|
+
/**
|
|
2991
|
+
* Exactly what the user has typed, not a parsed number: the field is
|
|
2992
|
+
* mid-edit, and `'1.'` is a legal thing to be holding.
|
|
2993
|
+
*/
|
|
2994
|
+
amountInput: string;
|
|
2995
|
+
/**
|
|
2996
|
+
* What the field is denominated in: the selected coin's symbol after the
|
|
2997
|
+
* number, or a `$` before it for a dollar-denominated field.
|
|
2998
|
+
*/
|
|
2999
|
+
adornment: CheckoutAmountAdornmentUi;
|
|
3000
|
+
/** The wallet the funds come from, per the wallet step. */
|
|
3001
|
+
walletAddress: ShortenedWalletAddress;
|
|
3002
|
+
/**
|
|
3003
|
+
* Every fundable asset, in display order, whether or not the user holds
|
|
3004
|
+
* any. One entry renders as a plain card, two or more as a picker.
|
|
3005
|
+
*/
|
|
3006
|
+
inputAssets: CheckoutSelectableInputAssetUi[];
|
|
3007
|
+
confirmCta: CheckoutCtaUi;
|
|
3008
|
+
/**
|
|
3009
|
+
* Validation copy, e.g. `Insufficient USDC.`, or why no amount can be
|
|
3010
|
+
* confirmed right now, which takes its place.
|
|
3011
|
+
*/
|
|
3012
|
+
error: string | null;
|
|
3013
|
+
} | {
|
|
3014
|
+
type: 'complete';
|
|
3015
|
+
inputAsset: CheckoutAssetUi;
|
|
3016
|
+
/**
|
|
3017
|
+
* The confirmed amount as the field asked for it: `1,000.00 USDC`, or
|
|
3018
|
+
* `$1,000.00` for a dollar-denominated field.
|
|
3019
|
+
*/
|
|
3020
|
+
amountFormatted: FormattedAmountAssetUi;
|
|
3021
|
+
/**
|
|
3022
|
+
* The same figure in the asset actually being paid, e.g. `1,000.00
|
|
3023
|
+
* USDC`, when the headline names dollars rather than the asset. `null`
|
|
3024
|
+
* when the headline already is in the asset.
|
|
3025
|
+
*
|
|
3026
|
+
* Both are shown for a dollar field because the two are only equal while
|
|
3027
|
+
* the funding asset is a dollar stablecoin - the day a non-dollar one is
|
|
3028
|
+
* fundable, the summary would otherwise silently claim it was.
|
|
3029
|
+
*/
|
|
3030
|
+
inputAmountFormatted: FormattedAmountAssetUi | null;
|
|
3031
|
+
};
|
|
3032
|
+
/**
|
|
3033
|
+
* Everything the amount step raises. `ON_CONFIRM_AMOUNT` only moves the flow
|
|
3034
|
+
* to the review step: nothing is placed or paid for here.
|
|
3035
|
+
*/
|
|
3036
|
+
type CheckoutAmountUiEvent = {
|
|
3037
|
+
type: 'ON_AMOUNT_CHANGE';
|
|
3038
|
+
value: string;
|
|
3039
|
+
} | {
|
|
3040
|
+
type: 'ON_MAX_AMOUNT_CLICK';
|
|
3041
|
+
} | {
|
|
3042
|
+
type: 'ON_SELECT_PAY_WITH';
|
|
3043
|
+
value: AssetSymbol;
|
|
3044
|
+
} | {
|
|
3045
|
+
type: 'ON_CONFIRM_AMOUNT';
|
|
3046
|
+
} | {
|
|
3047
|
+
type: 'ON_EDIT_AMOUNT';
|
|
3048
|
+
};
|
|
3049
|
+
|
|
3050
|
+
/**
|
|
3051
|
+
* Step 1 of a checkout whose wallet step takes no provider input: which wallet
|
|
3052
|
+
* funds the order and receives the asset. Ondo (buy and sell) and Centrifuge
|
|
3053
|
+
* render it as it stands.
|
|
2932
3054
|
*
|
|
2933
|
-
*
|
|
2934
|
-
*
|
|
3055
|
+
* Shared whole, state machine included, because it is not a provider state
|
|
3056
|
+
* machine: no provider answers anything here, so there is nothing for one to
|
|
3057
|
+
* diverge on. It forks the moment one provider needs different behaviour -
|
|
3058
|
+
* Superstate already has, since its confirm allow-lists the wallet on-chain,
|
|
3059
|
+
* so it keeps its own state over the same rows.
|
|
2935
3060
|
*
|
|
2936
|
-
*
|
|
2937
|
-
* is
|
|
3061
|
+
* There is no `inactive` arm. This step is the first one, so it is either
|
|
3062
|
+
* being filled in or already answered - it is never waiting on a step above
|
|
3063
|
+
* it.
|
|
2938
3064
|
*
|
|
2939
|
-
*
|
|
3065
|
+
* Nothing is allow-listed: the user picks a wallet and confirms, and
|
|
3066
|
+
* confirming is synchronous. Hence a plain `confirmEnabled` rather than a
|
|
3067
|
+
* `CheckoutCtaUi` with loading copy.
|
|
2940
3068
|
*/
|
|
2941
|
-
type
|
|
3069
|
+
type CheckoutWalletSelectUiState = {
|
|
2942
3070
|
type: 'active';
|
|
2943
3071
|
/** The user's CoinList wallets. Empty when they have none. */
|
|
2944
3072
|
embeddedWallets: CheckoutEmbeddedWalletUi[];
|
|
2945
|
-
/**
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3073
|
+
/**
|
|
3074
|
+
* The external-wallet row: absent when the host offers no connector,
|
|
3075
|
+
* an invitation to connect one, or the connected wallet.
|
|
3076
|
+
*/
|
|
3077
|
+
externalWallet: CheckoutExternalWalletUi;
|
|
2949
3078
|
confirmEnabled: boolean;
|
|
2950
3079
|
/** Copy for a failed connect, e.g. the user rejected the wallet prompt. */
|
|
2951
3080
|
error: string | null;
|
|
@@ -2953,8 +3082,7 @@ type CentrifugeWalletSelectUiState = {
|
|
|
2953
3082
|
type: 'completed';
|
|
2954
3083
|
wallet: CheckoutConfirmedWalletUi;
|
|
2955
3084
|
};
|
|
2956
|
-
|
|
2957
|
-
type CentrifugeWalletSelectUiEvent = {
|
|
3085
|
+
type CheckoutWalletSelectUiEvent = {
|
|
2958
3086
|
type: 'ON_SELECT_WALLET';
|
|
2959
3087
|
value: CheckoutWalletTypeUi;
|
|
2960
3088
|
}
|
|
@@ -2981,8 +3109,13 @@ type CentrifugeWalletSelectUiEvent = {
|
|
|
2981
3109
|
*/
|
|
2982
3110
|
type CentrifugeBuyCheckoutUiState = {
|
|
2983
3111
|
type: 'content';
|
|
2984
|
-
|
|
2985
|
-
|
|
3112
|
+
/**
|
|
3113
|
+
* The wallet step, or `null` when the host preselected a wallet and the
|
|
3114
|
+
* flow skipped it. The later steps are numbered from it. Never `null`
|
|
3115
|
+
* today: this flow does not honour a preselection yet.
|
|
3116
|
+
*/
|
|
3117
|
+
wallet: CheckoutWalletSelectUiState | null;
|
|
3118
|
+
amount: CheckoutAmountUiState;
|
|
2986
3119
|
review: CentrifugeBuyReviewUiState;
|
|
2987
3120
|
sidebar: CentrifugeSidebarUiState;
|
|
2988
3121
|
orderPlaced: CentrifugeOrderPlacedUiState;
|
|
@@ -2991,7 +3124,7 @@ type CentrifugeBuyCheckoutUiState = {
|
|
|
2991
3124
|
reason: CentrifugeCheckoutErrorReason;
|
|
2992
3125
|
};
|
|
2993
3126
|
/** @alpha */
|
|
2994
|
-
type CentrifugeBuyCheckoutUiEvent =
|
|
3127
|
+
type CentrifugeBuyCheckoutUiEvent = CheckoutWalletSelectUiEvent | CheckoutAmountUiEvent | CentrifugeBuyReviewUiEvent | CentrifugeOrderPlacedUiEvent;
|
|
2995
3128
|
/**
|
|
2996
3129
|
* The dialog that closes the checkout once the request has mined.
|
|
2997
3130
|
*
|
|
@@ -3001,13 +3134,11 @@ type CentrifugeBuyCheckoutUiEvent = CentrifugeWalletSelectUiEvent | CentrifugeBu
|
|
|
3001
3134
|
*/
|
|
3002
3135
|
type CentrifugeOrderPlacedUiState = {
|
|
3003
3136
|
type: 'hidden';
|
|
3004
|
-
} | {
|
|
3137
|
+
} | ({
|
|
3005
3138
|
type: 'visible';
|
|
3006
3139
|
outputAsset: CheckoutAssetUi;
|
|
3007
3140
|
totalCost: FormattedAmountAssetUi;
|
|
3008
|
-
|
|
3009
|
-
txExplorerUrl: TxExplorerUrl;
|
|
3010
|
-
};
|
|
3141
|
+
} & CheckoutReceiptUi);
|
|
3011
3142
|
/** @alpha */
|
|
3012
3143
|
type CentrifugeOrderPlacedUiEvent = {
|
|
3013
3144
|
type: 'ON_CLOSE_ORDER_PLACED';
|
|
@@ -3017,6 +3148,15 @@ type CentrifugeOrderPlacedUiEvent = {
|
|
|
3017
3148
|
interface UseCentrifugeBuyCheckoutViewModelOptions {
|
|
3018
3149
|
offer: CentrifugeVaultOfferDetail;
|
|
3019
3150
|
chain: EthereumChain;
|
|
3151
|
+
/**
|
|
3152
|
+
* The host's wallets, its connector for an external one if any, and
|
|
3153
|
+
* optionally the wallet it has already settled on.
|
|
3154
|
+
*
|
|
3155
|
+
* `wallets.preselected` is read **once**, to seed the step machine: set, the
|
|
3156
|
+
* flow has no wallet step and opens on the amount. A host that changes it
|
|
3157
|
+
* mid-flow is ignored, because the approval the review grants is granted by
|
|
3158
|
+
* one specific wallet.
|
|
3159
|
+
*/
|
|
3020
3160
|
wallets: CheckoutWalletSelection;
|
|
3021
3161
|
enabled?: boolean;
|
|
3022
3162
|
/** Fired once the request has mined. The dialog shows either way. */
|
|
@@ -3034,15 +3174,22 @@ interface UseCentrifugeBuyCheckoutViewModelResult {
|
|
|
3034
3174
|
* review, and sidebar steps. The status poll lives here. The amount step
|
|
3035
3175
|
* only validates.
|
|
3036
3176
|
*
|
|
3037
|
-
* A vault that is known to be blocked replaces the checkout only at the
|
|
3038
|
-
*
|
|
3177
|
+
* A vault that is known to be blocked replaces the checkout only at the step
|
|
3178
|
+
* the flow opened on: the wallet step, or the amount for a wallet the host
|
|
3179
|
+
* preselected. A status that is still loading, or that failed, does not.
|
|
3039
3180
|
*
|
|
3040
3181
|
* @alpha
|
|
3041
3182
|
*/
|
|
3042
3183
|
declare function useCentrifugeBuyCheckoutViewModel({ offer, chain, wallets, enabled, onOrderPlaced, }: UseCentrifugeBuyCheckoutViewModelOptions): UseCentrifugeBuyCheckoutViewModelResult;
|
|
3043
3184
|
|
|
3044
|
-
type LoadParticipationsReason =
|
|
3185
|
+
type LoadParticipationsReason = LoadErrorReason;
|
|
3186
|
+
/**
|
|
3187
|
+
* The state of the participations read. `DISABLED` means the hook was
|
|
3188
|
+
* switched off before an answer arrived, so nothing is in flight.
|
|
3189
|
+
*/
|
|
3045
3190
|
type LoadParticipationsState = {
|
|
3191
|
+
type: 'DISABLED';
|
|
3192
|
+
} | {
|
|
3046
3193
|
type: 'LOADING';
|
|
3047
3194
|
} | {
|
|
3048
3195
|
type: 'ERROR';
|
|
@@ -3054,30 +3201,38 @@ type LoadParticipationsState = {
|
|
|
3054
3201
|
interface UseParticipationsOptions {
|
|
3055
3202
|
/**
|
|
3056
3203
|
* Participations pre-fetched on the server (e.g. via `CoinListServer#tokenSale.list()`).
|
|
3057
|
-
* When provided, the hook uses this data as-is and skips the
|
|
3204
|
+
* When provided, the hook uses this data as-is and skips the initial
|
|
3205
|
+
* client-side fetch; {@link UseParticipationsResult.refetch} still fetches.
|
|
3058
3206
|
*/
|
|
3059
3207
|
data?: Participation[];
|
|
3060
3208
|
/**
|
|
3061
3209
|
* When `false`, the hook sends no request. A seeded or already-fetched
|
|
3062
|
-
* `CONTENT` survives; otherwise the hook
|
|
3210
|
+
* `CONTENT` survives; otherwise the hook reports `DISABLED`. Defaults to
|
|
3211
|
+
* `true`.
|
|
3063
3212
|
*/
|
|
3064
3213
|
enabled?: boolean;
|
|
3065
3214
|
}
|
|
3066
3215
|
interface UseParticipationsResult {
|
|
3067
3216
|
participationsState: LoadParticipationsState;
|
|
3217
|
+
/**
|
|
3218
|
+
* Fetches again: the recovery path after an `ERROR`, and the way past a
|
|
3219
|
+
* server seed (`data`), which only the first fetch honours. No-op while
|
|
3220
|
+
* disabled.
|
|
3221
|
+
*/
|
|
3222
|
+
refetch: () => void;
|
|
3068
3223
|
}
|
|
3069
3224
|
/**
|
|
3070
3225
|
* Loads all CoinList participations for the current user and exposes a UI-friendly state.
|
|
3071
3226
|
* Optionally filters by offer when `offerId` is provided.
|
|
3072
3227
|
*
|
|
3073
|
-
* Pass `data` (pre-fetched server-side) to
|
|
3074
|
-
*
|
|
3075
|
-
*
|
|
3228
|
+
* Pass `data` (pre-fetched server-side) to open on it and skip the initial
|
|
3229
|
+
* client-side fetch. Pass `enabled: false` to skip the fetch when the hook
|
|
3230
|
+
* must be called but the data is not needed yet.
|
|
3076
3231
|
*
|
|
3077
3232
|
* Returns `LOADING` while CoinList is initializing or while participations are being fetched.
|
|
3078
|
-
* Returns `CONTENT` with all participations when
|
|
3233
|
+
* Returns `CONTENT` with all participations when the read succeeds.
|
|
3079
3234
|
* Returns `ERROR` with:
|
|
3080
|
-
* - `not-authenticated` when
|
|
3235
|
+
* - `not-authenticated` when the user has to sign in first
|
|
3081
3236
|
* - `generic-error` for any other failure
|
|
3082
3237
|
*/
|
|
3083
3238
|
declare function useParticipations(offerId?: OfferId, options?: UseParticipationsOptions): UseParticipationsResult;
|
|
@@ -3146,29 +3301,44 @@ type OndoBuyAmountUiEvent = {
|
|
|
3146
3301
|
* branch in every consumer to distinguish. Split it out if that stops being
|
|
3147
3302
|
* true.
|
|
3148
3303
|
*/
|
|
3149
|
-
type OndoLoadErrorReason =
|
|
3304
|
+
type OndoLoadErrorReason = LoadErrorReason | 'not-tradable';
|
|
3150
3305
|
|
|
3151
3306
|
/**
|
|
3152
|
-
* The state of
|
|
3307
|
+
* The state of a firm, expiring transaction a review step acts on.
|
|
3308
|
+
*
|
|
3309
|
+
* `DISABLED` means the caller switched the hook off before a transaction was
|
|
3310
|
+
* in hand, so nothing is being built. A transaction already in hand - a seed,
|
|
3311
|
+
* or an earlier build - survives being switched off.
|
|
3153
3312
|
*
|
|
3154
|
-
* `isRefreshing` rides on `CONTENT` rather than replacing it, so a
|
|
3155
|
-
* flight never blanks the numbers the user is reading. A
|
|
3156
|
-
* keeps them too, and reports why alongside - the previous
|
|
3157
|
-
* be good, and a failed
|
|
3313
|
+
* `isRefreshing` rides on `CONTENT` rather than replacing it, so a rebuild in
|
|
3314
|
+
* flight never blanks the numbers the user is reading. A rebuild that fails
|
|
3315
|
+
* keeps them too, and reports why alongside - the previous transaction may
|
|
3316
|
+
* still be good, and a failed rebuild is fixed by rebuilding again.
|
|
3158
3317
|
*/
|
|
3159
|
-
type
|
|
3318
|
+
type LoadFirmTransactionState<T, R> = {
|
|
3319
|
+
type: 'DISABLED';
|
|
3320
|
+
} | {
|
|
3160
3321
|
type: 'LOADING';
|
|
3161
3322
|
} | {
|
|
3162
3323
|
type: 'ERROR';
|
|
3163
|
-
reason:
|
|
3324
|
+
reason: R;
|
|
3164
3325
|
} | {
|
|
3165
3326
|
type: 'CONTENT';
|
|
3166
|
-
transaction:
|
|
3327
|
+
transaction: T;
|
|
3167
3328
|
isRefreshing: boolean;
|
|
3168
|
-
/** Why the last
|
|
3169
|
-
refreshError:
|
|
3329
|
+
/** Why the last rebuild failed; `null` when the transaction is fresh. */
|
|
3330
|
+
refreshError: R | null;
|
|
3170
3331
|
};
|
|
3171
|
-
|
|
3332
|
+
|
|
3333
|
+
/**
|
|
3334
|
+
* The state of the built purchase a review step acts on.
|
|
3335
|
+
*
|
|
3336
|
+
* `DISABLED` while switched off with no purchase in hand. `isRefreshing` rides
|
|
3337
|
+
* on `CONTENT`, so a refresh in flight never blanks the numbers the user is
|
|
3338
|
+
* reading, and a refresh that fails keeps them and says why.
|
|
3339
|
+
*/
|
|
3340
|
+
type LoadOndoBuyTransactionState = LoadFirmTransactionState<OndoBuyTransaction, OndoLoadErrorReason>;
|
|
3341
|
+
interface UseOndoBuyTransactionOptions {
|
|
3172
3342
|
/**
|
|
3173
3343
|
* The order to build, or `null` while there is not one yet - before the
|
|
3174
3344
|
* amount step is confirmed. A `null` request fetches nothing.
|
|
@@ -3191,29 +3361,50 @@ interface UseOndoBuyTransactionResult {
|
|
|
3191
3361
|
}
|
|
3192
3362
|
/**
|
|
3193
3363
|
* Holds the firm, expiring purchase the buy review step places an order
|
|
3194
|
-
* against, and rebuilds it on demand.
|
|
3195
|
-
*
|
|
3196
|
-
* **Never polls.** Building spends an attestation, so a new one is only ever
|
|
3197
|
-
* obtained when the caller asks - on `refetch`, or on the first render if no
|
|
3198
|
-
* `data` was supplied. That is also why an expired purchase is left expired
|
|
3199
|
-
* here: whether to replace it is the user's call, not a timer's.
|
|
3200
|
-
*
|
|
3201
|
-
* Disabled it fetches nothing and stays on whatever state it opened with. That
|
|
3202
|
-
* is `LOADING` and not an empty `CONTENT` because there is no empty
|
|
3203
|
-
* purchase: firm calldata for an order that does not exist is not
|
|
3204
|
-
* representable. A caller that switches this hook off should switch its own
|
|
3205
|
-
* rendering off with it - which is what the review step does, since a step
|
|
3206
|
-
* that is not active is `incomplete` and never reads this state at all.
|
|
3364
|
+
* against, and rebuilds it on demand. **Never polls**: each build spends an
|
|
3365
|
+
* attestation.
|
|
3207
3366
|
*
|
|
3208
3367
|
* One of a pair with `useOndoSellTransaction`, and deliberately not one hook
|
|
3209
|
-
* over both. The two endpoints answer different shapes - a purchase
|
|
3210
|
-
* an exact quantity, a sale to a range - so a shared hook
|
|
3211
|
-
* review step a union to narrow after its own directory had
|
|
3212
|
-
* which trade it was. The machinery
|
|
3213
|
-
*
|
|
3368
|
+
* over both (ADR-10). The two endpoints answer different shapes - a purchase
|
|
3369
|
+
* commits to an exact quantity, a sale to a range - so a shared public hook
|
|
3370
|
+
* would hand every review step a union to narrow after its own directory had
|
|
3371
|
+
* already settled which trade it was. The machinery is shared instead, in
|
|
3372
|
+
* `useFirmTransaction`.
|
|
3214
3373
|
*/
|
|
3215
3374
|
declare function useOndoBuyTransaction(options: UseOndoBuyTransactionOptions): UseOndoBuyTransactionResult;
|
|
3216
3375
|
|
|
3376
|
+
/**
|
|
3377
|
+
* Whether the numbers on an Ondo review step can still be traded on.
|
|
3378
|
+
*
|
|
3379
|
+
* A quote is only good for a few seconds, so this drives the line above the CTA
|
|
3380
|
+
* and whether the CTA can be pressed at all. `refresh-failed` is its own arm
|
|
3381
|
+
* rather than folding into the step's `error`, because the remedy differs: a
|
|
3382
|
+
* failed refresh is fixed by refreshing again, a failed order is not.
|
|
3383
|
+
*
|
|
3384
|
+
* One type for both products, because a buy and a sell quote expire, refresh
|
|
3385
|
+
* and fail to refresh in exactly the same way: `useOndoReviewExecution` derives
|
|
3386
|
+
* it for both from the same firm transaction state.
|
|
3387
|
+
*/
|
|
3388
|
+
type OndoQuoteStatusUi =
|
|
3389
|
+
/** Still good. `expiresInLabel` is the countdown copy, already formatted. */
|
|
3390
|
+
{
|
|
3391
|
+
type: 'valid';
|
|
3392
|
+
expiresInLabel: string;
|
|
3393
|
+
}
|
|
3394
|
+
/** A refresh is in flight; the previous numbers are still on screen. */
|
|
3395
|
+
| {
|
|
3396
|
+
type: 'refreshing';
|
|
3397
|
+
}
|
|
3398
|
+
/** Too old to trade on. The user must refresh before placing the order. */
|
|
3399
|
+
| {
|
|
3400
|
+
type: 'expired';
|
|
3401
|
+
}
|
|
3402
|
+
/** The refresh failed. `message` says why. */
|
|
3403
|
+
| {
|
|
3404
|
+
type: 'refresh-failed';
|
|
3405
|
+
message: string;
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3217
3408
|
/**
|
|
3218
3409
|
* Step 3 of the Ondo checkout: what the order comes to, and placing it.
|
|
3219
3410
|
*
|
|
@@ -3251,38 +3442,11 @@ type OndoBuyReviewUiState = {
|
|
|
3251
3442
|
coinlistFee: FormattedAmountAssetUi | null;
|
|
3252
3443
|
/** What the user pays in the input asset, e.g. `1,000.00 USDC`. */
|
|
3253
3444
|
total: FormattedAmountAssetUi;
|
|
3254
|
-
quote:
|
|
3445
|
+
quote: OndoQuoteStatusUi;
|
|
3255
3446
|
placeOrderCta: CheckoutCtaUi;
|
|
3256
3447
|
/** A failure from placing the order, distinct from a quote problem. */
|
|
3257
3448
|
error: string | null;
|
|
3258
3449
|
};
|
|
3259
|
-
/**
|
|
3260
|
-
* Whether the shown numbers can still be traded on.
|
|
3261
|
-
*
|
|
3262
|
-
* A quote is only good for a few seconds, so this drives the line above the CTA
|
|
3263
|
-
* and whether the CTA can be pressed at all. `refresh-failed` is its own arm
|
|
3264
|
-
* rather than folding into the step's `error`, because the remedy differs: a
|
|
3265
|
-
* failed refresh is fixed by refreshing again, a failed order is not.
|
|
3266
|
-
*/
|
|
3267
|
-
type OndoBuyQuoteStatusUi =
|
|
3268
|
-
/** Still good. `expiresInLabel` is the countdown copy, already formatted. */
|
|
3269
|
-
{
|
|
3270
|
-
type: 'valid';
|
|
3271
|
-
expiresInLabel: string;
|
|
3272
|
-
}
|
|
3273
|
-
/** A refresh is in flight; the previous numbers are still on screen. */
|
|
3274
|
-
| {
|
|
3275
|
-
type: 'refreshing';
|
|
3276
|
-
}
|
|
3277
|
-
/** Too old to trade on. The user must refresh before placing the order. */
|
|
3278
|
-
| {
|
|
3279
|
-
type: 'expired';
|
|
3280
|
-
}
|
|
3281
|
-
/** The refresh failed. `message` says why. */
|
|
3282
|
-
| {
|
|
3283
|
-
type: 'refresh-failed';
|
|
3284
|
-
message: string;
|
|
3285
|
-
};
|
|
3286
3450
|
type OndoBuyReviewUiEvent = {
|
|
3287
3451
|
type: 'ON_REFRESH_QUOTE';
|
|
3288
3452
|
}
|
|
@@ -3295,9 +3459,14 @@ type OndoBuyReviewUiEvent = {
|
|
|
3295
3459
|
|
|
3296
3460
|
/**
|
|
3297
3461
|
* Why an Ondo checkout cannot run right now, as opposed to a step of it
|
|
3298
|
-
* failing.
|
|
3462
|
+
* failing. See {@link CheckoutBlockedReason} for `unsupported-chain`, which
|
|
3463
|
+
* here means the offer names no CoinList swap contract on the chain (see
|
|
3464
|
+
* `swapSpender`).
|
|
3299
3465
|
*
|
|
3300
|
-
*
|
|
3466
|
+
* `not-tradable` is Ondo's block: it is not filling orders for this asset on
|
|
3467
|
+
* this side right now, because the market is closed or paused, or the asset is
|
|
3468
|
+
* paused or closed for the session. The trading-status poll keeps running
|
|
3469
|
+
* underneath it, and the checkout comes back once the asset is tradable again.
|
|
3301
3470
|
*
|
|
3302
3471
|
* Shared by both products because each reason is a property of the integration
|
|
3303
3472
|
* or of the market rather than of a direction: buying and selling go through
|
|
@@ -3306,47 +3475,7 @@ type OndoBuyReviewUiEvent = {
|
|
|
3306
3475
|
* exception the provider-level `shared/` exists for, and it is narrow - the
|
|
3307
3476
|
* step states stay per-product, since that is where the two genuinely diverge.
|
|
3308
3477
|
*/
|
|
3309
|
-
type OndoCheckoutErrorReason =
|
|
3310
|
-
/**
|
|
3311
|
-
* The offer names no CoinList swap contract on the chain the host asked for,
|
|
3312
|
-
* so there is no spender to approve and nothing to broadcast to.
|
|
3313
|
-
*
|
|
3314
|
-
* Not retryable, and not the host's mistake to correct at runtime: both the
|
|
3315
|
-
* offer and the chain are fixed for the lifetime of the mount. See
|
|
3316
|
-
* `swapSpender`.
|
|
3317
|
-
*/
|
|
3318
|
-
'unsupported-chain'
|
|
3319
|
-
/**
|
|
3320
|
-
* Ondo is not filling orders for this asset on this side right now: the
|
|
3321
|
-
* market is closed or paused, or the asset is paused or closed for the
|
|
3322
|
-
* session. Known from the trading-status poll, never assumed from a status
|
|
3323
|
-
* that is still loading or failed to load.
|
|
3324
|
-
*
|
|
3325
|
-
* Unlike `unsupported-chain` this one clears on its own. The trading-status
|
|
3326
|
-
* poll keeps running underneath it, and the checkout comes back once the
|
|
3327
|
-
* asset is tradable again. Only shown while the user is on the step the flow
|
|
3328
|
-
* opened on: once they are past it, a pause is a step's to report, so it
|
|
3329
|
-
* cannot pull an order out from under the user mid-flow.
|
|
3330
|
-
*/
|
|
3331
|
-
| 'not-tradable';
|
|
3332
|
-
declare const OndoCheckoutErrorReason: {
|
|
3333
|
-
/**
|
|
3334
|
-
* Which reason, if any, replaces the whole checkout. `null` means the steps
|
|
3335
|
-
* render.
|
|
3336
|
-
*
|
|
3337
|
-
* `unsupported-chain` wins because it is settled at mount: no market state
|
|
3338
|
-
* can make a chain with no contract tradable. `not-tradable` needs both a
|
|
3339
|
-
* market *known* to be closed and a user still at the start of the flow,
|
|
3340
|
-
* with no order confirmation on screen. Past the first step a pause belongs
|
|
3341
|
-
* to the step it interrupts, and a just-placed order's dialog must not be
|
|
3342
|
-
* hidden by a market that closed after it filled.
|
|
3343
|
-
*/
|
|
3344
|
-
of: ({ swappableHere, notTradable, atEntry, }: {
|
|
3345
|
-
swappableHere: boolean;
|
|
3346
|
-
notTradable: boolean;
|
|
3347
|
-
atEntry: boolean;
|
|
3348
|
-
}) => OndoCheckoutErrorReason | null;
|
|
3349
|
-
};
|
|
3478
|
+
type OndoCheckoutErrorReason = CheckoutBlockedReason<'not-tradable'>;
|
|
3350
3479
|
|
|
3351
3480
|
/**
|
|
3352
3481
|
* The reference panel beside the Ondo checkout: which asset is being bought,
|
|
@@ -3417,54 +3546,6 @@ type OndoSidebarPriceUi =
|
|
|
3417
3546
|
type: 'unavailable';
|
|
3418
3547
|
};
|
|
3419
3548
|
|
|
3420
|
-
/**
|
|
3421
|
-
* Step 1 of the Ondo checkout: which wallet funds the purchase and receives the
|
|
3422
|
-
* asset.
|
|
3423
|
-
*
|
|
3424
|
-
* There is no `inactive` arm. This step is the first one, so it is either being
|
|
3425
|
-
* filled in or already answered — it is never waiting on a step above it.
|
|
3426
|
-
*
|
|
3427
|
-
* Unlike Superstate's equivalent, nothing is allow-listed here: the user picks
|
|
3428
|
-
* a wallet and confirms, and confirming is synchronous. Hence a plain
|
|
3429
|
-
* `confirmEnabled` rather than the `CheckoutCtaUi` Superstate's step carries.
|
|
3430
|
-
* The rows themselves are the shared `Checkout*WalletUi` models — the two
|
|
3431
|
-
* providers render the same wallets and disagree only about what confirming
|
|
3432
|
-
* does.
|
|
3433
|
-
*/
|
|
3434
|
-
type OndoWalletSelectUiState = {
|
|
3435
|
-
type: 'active';
|
|
3436
|
-
/** The user's CoinList wallets. Empty when they have none. */
|
|
3437
|
-
embeddedWallets: CheckoutEmbeddedWalletUi[];
|
|
3438
|
-
/** `null` until an external wallet is connected. The row still renders. */
|
|
3439
|
-
externalWallet: CheckoutWalletUi | null;
|
|
3440
|
-
/** Whether the connected external wallet may be disconnected here. */
|
|
3441
|
-
canDisconnect: boolean;
|
|
3442
|
-
confirmEnabled: boolean;
|
|
3443
|
-
/** Copy for a failed connect, e.g. the user rejected the wallet prompt. */
|
|
3444
|
-
error: string | null;
|
|
3445
|
-
} | {
|
|
3446
|
-
type: 'completed';
|
|
3447
|
-
wallet: CheckoutConfirmedWalletUi;
|
|
3448
|
-
};
|
|
3449
|
-
type OndoWalletSelectUiEvent = {
|
|
3450
|
-
type: 'ON_SELECT_WALLET';
|
|
3451
|
-
value: CheckoutWalletTypeUi;
|
|
3452
|
-
}
|
|
3453
|
-
/**
|
|
3454
|
-
* Tapping the external row while nothing is connected. Split from
|
|
3455
|
-
* `ON_SELECT_WALLET` because it opens the host's wallet connector rather than
|
|
3456
|
-
* changing the selection.
|
|
3457
|
-
*/
|
|
3458
|
-
| {
|
|
3459
|
-
type: 'ON_CONNECT_WALLET';
|
|
3460
|
-
} | {
|
|
3461
|
-
type: 'ON_DISCONNECT_WALLET';
|
|
3462
|
-
} | {
|
|
3463
|
-
type: 'ON_CONFIRM_WALLET';
|
|
3464
|
-
} | {
|
|
3465
|
-
type: 'ON_EDIT_WALLET';
|
|
3466
|
-
};
|
|
3467
|
-
|
|
3468
3549
|
/**
|
|
3469
3550
|
* The whole Ondo buy checkout: three step cards, the reference panel beside
|
|
3470
3551
|
* them, and the dialog that closes the flow.
|
|
@@ -3484,7 +3565,12 @@ type OndoWalletSelectUiEvent = {
|
|
|
3484
3565
|
*/
|
|
3485
3566
|
type OndoBuyCheckoutUiState = {
|
|
3486
3567
|
type: 'content';
|
|
3487
|
-
|
|
3568
|
+
/**
|
|
3569
|
+
* The wallet step, or `null` when the host preselected a wallet and the
|
|
3570
|
+
* flow skipped it. The later steps are numbered from it. Never `null`
|
|
3571
|
+
* today: the buy flow does not honour a preselection yet.
|
|
3572
|
+
*/
|
|
3573
|
+
wallet: CheckoutWalletSelectUiState | null;
|
|
3488
3574
|
amount: OndoBuyAmountUiState;
|
|
3489
3575
|
review: OndoBuyReviewUiState;
|
|
3490
3576
|
/** The asset panel. Read-only, so it raises no events. */
|
|
@@ -3510,7 +3596,7 @@ type OndoBuyCheckoutUiState = {
|
|
|
3510
3596
|
* tags must stay globally unique, which is why the edit events are
|
|
3511
3597
|
* `ON_EDIT_WALLET` and `ON_EDIT_AMOUNT` rather than a shared `ON_EDIT`.
|
|
3512
3598
|
*/
|
|
3513
|
-
type OndoBuyCheckoutUiEvent =
|
|
3599
|
+
type OndoBuyCheckoutUiEvent = CheckoutWalletSelectUiEvent | OndoBuyAmountUiEvent | OndoBuyReviewUiEvent | OndoOrderConfirmedUiEvent;
|
|
3514
3600
|
/**
|
|
3515
3601
|
* The dialog that closes the Ondo checkout, once the swap is mined.
|
|
3516
3602
|
*
|
|
@@ -3520,7 +3606,7 @@ type OndoBuyCheckoutUiEvent = OndoWalletSelectUiEvent | OndoBuyAmountUiEvent | O
|
|
|
3520
3606
|
*/
|
|
3521
3607
|
type OndoOrderConfirmedUiState = {
|
|
3522
3608
|
type: 'hidden';
|
|
3523
|
-
} | {
|
|
3609
|
+
} | ({
|
|
3524
3610
|
type: 'visible';
|
|
3525
3611
|
/**
|
|
3526
3612
|
* What was bought.
|
|
@@ -3536,14 +3622,7 @@ type OndoOrderConfirmedUiState = {
|
|
|
3536
3622
|
totalCost: FormattedAmountAssetUi;
|
|
3537
3623
|
/** Price of one whole token at the time of the fill, e.g. `$378.99`. */
|
|
3538
3624
|
pricePerShare: FormattedAmountAssetUi;
|
|
3539
|
-
|
|
3540
|
-
recipientAddress: ShortenedWalletAddress;
|
|
3541
|
-
/**
|
|
3542
|
-
* The settled swap on a block explorer. Always present: the dialog only
|
|
3543
|
-
* exists once there is a mined transaction to point at.
|
|
3544
|
-
*/
|
|
3545
|
-
txExplorerUrl: TxExplorerUrl;
|
|
3546
|
-
};
|
|
3625
|
+
} & CheckoutReceiptUi);
|
|
3547
3626
|
/**
|
|
3548
3627
|
* Closing is the only thing the dialog raises.
|
|
3549
3628
|
*
|
|
@@ -3572,7 +3651,17 @@ interface UseOndoBuyCheckoutViewModelOptions {
|
|
|
3572
3651
|
* Fixed for the lifetime of the hook, as `offer` is.
|
|
3573
3652
|
*/
|
|
3574
3653
|
chain: EthereumChain;
|
|
3575
|
-
/**
|
|
3654
|
+
/**
|
|
3655
|
+
* The host's wallets, its connector for an external one if any, and
|
|
3656
|
+
* optionally the wallet it has already settled on.
|
|
3657
|
+
*
|
|
3658
|
+
* `wallets.preselected` is read **once**, to seed the step machine: set, the
|
|
3659
|
+
* flow has no wallet step and opens on the amount. A host that changes it
|
|
3660
|
+
* mid-flow is ignored, because the approval that follows the amount step is
|
|
3661
|
+
* granted by one specific wallet, and moving the flow onto another one under
|
|
3662
|
+
* it would strand that approval and build calldata the new wallet cannot
|
|
3663
|
+
* broadcast.
|
|
3664
|
+
*/
|
|
3576
3665
|
wallets: CheckoutWalletSelection;
|
|
3577
3666
|
/**
|
|
3578
3667
|
* Default `true`. When `false` nothing is fetched and no timer runs, for a
|
|
@@ -3611,12 +3700,12 @@ interface UseOndoBuyCheckoutViewModelResult {
|
|
|
3611
3700
|
* wallet is the same kind of answer for as long as it lasts. See
|
|
3612
3701
|
* {@link OndoCheckoutErrorReason}.
|
|
3613
3702
|
*
|
|
3614
|
-
* `offer` and `chain` are read as fixed for the lifetime of the hook
|
|
3615
|
-
*
|
|
3616
|
-
*
|
|
3617
|
-
*
|
|
3618
|
-
*
|
|
3619
|
-
* documents. That discards the flow with its component instance, which is the
|
|
3703
|
+
* `offer` and `chain` are read as fixed for the lifetime of the hook, and so is
|
|
3704
|
+
* the wallet the flow opened on. The step machine holds a committed quote and
|
|
3705
|
+
* an approval granted on one chain by one wallet for one order, so changing any
|
|
3706
|
+
* of them in place would carry them onto an order they were never priced for.
|
|
3707
|
+
* Remount instead: give the component holding this hook a `key` that changes
|
|
3708
|
+
* with the offer and the chain, as {@link CheckoutContainer} documents. That discards the flow with its component instance, which is the
|
|
3620
3709
|
* only reset that cannot land between an approval and the broadcast it was
|
|
3621
3710
|
* granted for.
|
|
3622
3711
|
*/
|
|
@@ -3700,23 +3789,11 @@ type OndoSellAmountUiEvent = {
|
|
|
3700
3789
|
/**
|
|
3701
3790
|
* The state of the built sale a review step acts on.
|
|
3702
3791
|
*
|
|
3703
|
-
* `
|
|
3704
|
-
* flight never blanks the numbers the user is
|
|
3705
|
-
*
|
|
3706
|
-
* be good, and a failed refresh is fixed by refreshing again.
|
|
3792
|
+
* `DISABLED` while switched off with no sale in hand. `isRefreshing` rides on
|
|
3793
|
+
* `CONTENT`, so a refresh in flight never blanks the numbers the user is
|
|
3794
|
+
* reading, and a refresh that fails keeps them and says why.
|
|
3707
3795
|
*/
|
|
3708
|
-
type LoadOndoSellTransactionState =
|
|
3709
|
-
type: 'LOADING';
|
|
3710
|
-
} | {
|
|
3711
|
-
type: 'ERROR';
|
|
3712
|
-
reason: OndoLoadErrorReason;
|
|
3713
|
-
} | {
|
|
3714
|
-
type: 'CONTENT';
|
|
3715
|
-
transaction: OndoSellTransaction;
|
|
3716
|
-
isRefreshing: boolean;
|
|
3717
|
-
/** Why the last refresh failed; `null` when the sale is fresh. */
|
|
3718
|
-
refreshError: OndoLoadErrorReason | null;
|
|
3719
|
-
};
|
|
3796
|
+
type LoadOndoSellTransactionState = LoadFirmTransactionState<OndoSellTransaction, OndoLoadErrorReason>;
|
|
3720
3797
|
interface UseOndoSellTransactionOptions {
|
|
3721
3798
|
/**
|
|
3722
3799
|
* The order to build, or `null` while there is not one yet - before the
|
|
@@ -3739,26 +3816,15 @@ interface UseOndoSellTransactionResult {
|
|
|
3739
3816
|
refetch: () => void;
|
|
3740
3817
|
}
|
|
3741
3818
|
/**
|
|
3742
|
-
* Holds the firm, expiring sale the sell review step places an order
|
|
3743
|
-
*
|
|
3744
|
-
*
|
|
3745
|
-
* **Never polls.** Building spends an attestation, so a new one is only ever
|
|
3746
|
-
* obtained when the caller asks - on `refetch`, or on the first render if no
|
|
3747
|
-
* `data` was supplied. That is also why an expired sale is left expired
|
|
3748
|
-
* here: whether to replace it is the user's call, not a timer's.
|
|
3749
|
-
*
|
|
3750
|
-
* Disabled it fetches nothing and stays on whatever state it opened with. That
|
|
3751
|
-
* is `LOADING` and not an empty `CONTENT` because there is no empty
|
|
3752
|
-
* sale: firm calldata for an order that does not exist is not
|
|
3753
|
-
* representable. A caller that switches this hook off should switch its own
|
|
3754
|
-
* rendering off with it - which is what the review step does, since a step
|
|
3755
|
-
* that is not active is `incomplete` and never reads this state at all.
|
|
3819
|
+
* Holds the firm, expiring sale the sell review step places an order against,
|
|
3820
|
+
* and rebuilds it on demand. **Never polls**: each build spends an
|
|
3821
|
+
* attestation.
|
|
3756
3822
|
*
|
|
3757
3823
|
* The sell half of the pair `useOndoBuyTransaction` opens - see there for why
|
|
3758
|
-
* the two are not one hook. What differs is entirely in what `CONTENT`
|
|
3759
|
-
* an {@link OndoSellTransaction} publishes an expected outcome and a
|
|
3760
|
-
* beneath it rather than one attested quantity, and the review step
|
|
3761
|
-
* both.
|
|
3824
|
+
* the two are not one hook. What differs is entirely in what `CONTENT`
|
|
3825
|
+
* carries: an {@link OndoSellTransaction} publishes an expected outcome and a
|
|
3826
|
+
* floor beneath it rather than one attested quantity, and the review step
|
|
3827
|
+
* renders both.
|
|
3762
3828
|
*/
|
|
3763
3829
|
declare function useOndoSellTransaction(options: UseOndoSellTransactionOptions): UseOndoSellTransactionResult;
|
|
3764
3830
|
|
|
@@ -3818,7 +3884,7 @@ type OndoSellReviewUiState = {
|
|
|
3818
3884
|
* is what the order is expected to fill at.
|
|
3819
3885
|
*/
|
|
3820
3886
|
pricePerShare: FormattedAmountAssetUi;
|
|
3821
|
-
quote:
|
|
3887
|
+
quote: OndoQuoteStatusUi;
|
|
3822
3888
|
placeOrderCta: CheckoutCtaUi;
|
|
3823
3889
|
/** A failure from placing the order, distinct from a quote problem. */
|
|
3824
3890
|
error: string | null;
|
|
@@ -3851,33 +3917,6 @@ type OndoSellOutcomeUi = {
|
|
|
3851
3917
|
*/
|
|
3852
3918
|
fee: FormattedAmountAssetUi | null;
|
|
3853
3919
|
};
|
|
3854
|
-
/**
|
|
3855
|
-
* Whether the shown numbers can still be traded on.
|
|
3856
|
-
*
|
|
3857
|
-
* A quote is only good for a few seconds, so this drives the line above the CTA
|
|
3858
|
-
* and whether the CTA can be pressed at all. `refresh-failed` is its own arm
|
|
3859
|
-
* rather than folding into the step's `error`, because the remedy differs: a
|
|
3860
|
-
* failed refresh is fixed by refreshing again, a failed order is not.
|
|
3861
|
-
*/
|
|
3862
|
-
type OndoSellQuoteStatusUi =
|
|
3863
|
-
/** Still good. `expiresInLabel` is the countdown copy, already formatted. */
|
|
3864
|
-
{
|
|
3865
|
-
type: 'valid';
|
|
3866
|
-
expiresInLabel: string;
|
|
3867
|
-
}
|
|
3868
|
-
/** A refresh is in flight; the previous numbers are still on screen. */
|
|
3869
|
-
| {
|
|
3870
|
-
type: 'refreshing';
|
|
3871
|
-
}
|
|
3872
|
-
/** Too old to trade on. The user must refresh before placing the order. */
|
|
3873
|
-
| {
|
|
3874
|
-
type: 'expired';
|
|
3875
|
-
}
|
|
3876
|
-
/** The refresh failed. `message` says why. */
|
|
3877
|
-
| {
|
|
3878
|
-
type: 'refresh-failed';
|
|
3879
|
-
message: string;
|
|
3880
|
-
};
|
|
3881
3920
|
type OndoSellReviewUiEvent = {
|
|
3882
3921
|
type: 'ON_REFRESH_SELL_QUOTE';
|
|
3883
3922
|
}
|
|
@@ -3913,7 +3952,7 @@ type OndoSellCheckoutUiState = {
|
|
|
3913
3952
|
* two-step flow numbered `1, 2` and a three-step flow numbered `1, 2, 3`
|
|
3914
3953
|
* cannot disagree. A boolean beside a non-null state would have let them.
|
|
3915
3954
|
*/
|
|
3916
|
-
wallet:
|
|
3955
|
+
wallet: CheckoutWalletSelectUiState | null;
|
|
3917
3956
|
amount: OndoSellAmountUiState;
|
|
3918
3957
|
review: OndoSellReviewUiState;
|
|
3919
3958
|
/** The asset panel. Read-only, so it raises no events. */
|
|
@@ -3941,7 +3980,7 @@ type OndoSellCheckoutUiState = {
|
|
|
3941
3980
|
* separate, and a shared tag would make one product's event dispatch into the
|
|
3942
3981
|
* other's handler in any host that composed both.
|
|
3943
3982
|
*/
|
|
3944
|
-
type OndoSellCheckoutUiEvent =
|
|
3983
|
+
type OndoSellCheckoutUiEvent = CheckoutWalletSelectUiEvent | OndoSellAmountUiEvent | OndoSellReviewUiEvent | OndoSellOrderConfirmedUiEvent;
|
|
3945
3984
|
/**
|
|
3946
3985
|
* The dialog that closes the Ondo sell checkout, once the swap is mined.
|
|
3947
3986
|
*
|
|
@@ -3951,7 +3990,7 @@ type OndoSellCheckoutUiEvent = OndoWalletSelectUiEvent | OndoSellAmountUiEvent |
|
|
|
3951
3990
|
*/
|
|
3952
3991
|
type OndoSellOrderConfirmedUiState = {
|
|
3953
3992
|
type: 'hidden';
|
|
3954
|
-
} | {
|
|
3993
|
+
} | ({
|
|
3955
3994
|
type: 'visible';
|
|
3956
3995
|
/**
|
|
3957
3996
|
* What was sold.
|
|
@@ -3976,14 +4015,7 @@ type OndoSellOrderConfirmedUiState = {
|
|
|
3976
4015
|
proceedsSymbol: AssetSymbol;
|
|
3977
4016
|
/** Price of one whole token at the time of the fill, e.g. `$378.99`. */
|
|
3978
4017
|
pricePerShare: FormattedAmountAssetUi;
|
|
3979
|
-
|
|
3980
|
-
recipientAddress: ShortenedWalletAddress;
|
|
3981
|
-
/**
|
|
3982
|
-
* The settled swap on a block explorer. Always present: the dialog only
|
|
3983
|
-
* exists once there is a mined transaction to point at.
|
|
3984
|
-
*/
|
|
3985
|
-
txExplorerUrl: TxExplorerUrl;
|
|
3986
|
-
};
|
|
4018
|
+
} & CheckoutReceiptUi);
|
|
3987
4019
|
/**
|
|
3988
4020
|
* Closing is the only thing the dialog raises.
|
|
3989
4021
|
*
|
|
@@ -4013,7 +4045,7 @@ interface UseOndoSellCheckoutViewModelOptions {
|
|
|
4013
4045
|
*/
|
|
4014
4046
|
chain: EthereumChain;
|
|
4015
4047
|
/**
|
|
4016
|
-
* The host's wallets,
|
|
4048
|
+
* The host's wallets, its connector for an external one if any, and
|
|
4017
4049
|
* optionally the wallet it has already settled on.
|
|
4018
4050
|
*
|
|
4019
4051
|
* `wallets.preselected` is read **once**, to seed the step machine. A host
|
|
@@ -4078,6 +4110,7 @@ declare function useOndoSellCheckoutViewModel({ offer, chain, wallets, enabled,
|
|
|
4078
4110
|
/**
|
|
4079
4111
|
* The state of the indicative-price poll.
|
|
4080
4112
|
*
|
|
4113
|
+
* - `DISABLED`: switched off with no price in hand, so none is coming.
|
|
4081
4114
|
* - `LOADING`: no price yet (initial, or the provider is still initializing).
|
|
4082
4115
|
* - `ERROR`: no price could be fetched at all.
|
|
4083
4116
|
* - `CONTENT`: a price is in hand; `isRefreshing` says whether a newer one is
|
|
@@ -4089,6 +4122,8 @@ declare function useOndoSellCheckoutViewModel({ offer, chain, wallets, enabled,
|
|
|
4089
4122
|
* when the UI has nothing to show.
|
|
4090
4123
|
*/
|
|
4091
4124
|
type LoadOndoPriceState = {
|
|
4125
|
+
type: 'DISABLED';
|
|
4126
|
+
} | {
|
|
4092
4127
|
type: 'LOADING';
|
|
4093
4128
|
} | {
|
|
4094
4129
|
type: 'ERROR';
|
|
@@ -4135,15 +4170,12 @@ interface UseOndoPriceResult {
|
|
|
4135
4170
|
* - committing a fillable quote is `coinlist.ondo.prepareBuy` or
|
|
4136
4171
|
* `coinlist.ondo.prepareSell`, whichever way the trade runs.
|
|
4137
4172
|
*
|
|
4138
|
-
* Disabled
|
|
4139
|
-
*
|
|
4140
|
-
*
|
|
4141
|
-
*
|
|
4142
|
-
*
|
|
4143
|
-
*
|
|
4144
|
-
* `useOptionAddresses` does, and one whose content is a number cannot. A caller
|
|
4145
|
-
* that switches this hook off should switch its own rendering off with it,
|
|
4146
|
-
* rather than read `LOADING` as "a price is coming".
|
|
4173
|
+
* Disabled it neither fetches nor holds a timer. With no price in hand it
|
|
4174
|
+
* reports `DISABLED` - not `LOADING`, since nothing is coming, and not an
|
|
4175
|
+
* empty `CONTENT`, since there is no empty price. A price already in hand (the
|
|
4176
|
+
* `data` seed, or an earlier tick) survives being switched off. Before the
|
|
4177
|
+
* provider is ready it is `LOADING`: the read is coming, it just cannot leave
|
|
4178
|
+
* yet.
|
|
4147
4179
|
*
|
|
4148
4180
|
* A `data` price opens the state instead of `LOADING` and is otherwise left to
|
|
4149
4181
|
* the poll: the first tick fires as it always does, and only replaces the seed
|
|
@@ -4163,6 +4195,8 @@ declare function useOndoPrice(options: UseOndoPriceOptions): UseOndoPriceResult;
|
|
|
4163
4195
|
* unknown may not.
|
|
4164
4196
|
*/
|
|
4165
4197
|
type LoadOndoTradingStatusState = {
|
|
4198
|
+
type: 'DISABLED';
|
|
4199
|
+
} | {
|
|
4166
4200
|
type: 'LOADING';
|
|
4167
4201
|
} | {
|
|
4168
4202
|
type: 'ERROR';
|
|
@@ -4173,8 +4207,8 @@ type LoadOndoTradingStatusState = {
|
|
|
4173
4207
|
};
|
|
4174
4208
|
/**
|
|
4175
4209
|
* Whether the market is *known* to be closed for this side: the one reading of
|
|
4176
|
-
* the poll a caller may block an order on. `LOADING` and `ERROR`
|
|
4177
|
-
* and unknown never blocks.
|
|
4210
|
+
* the poll a caller may block an order on. `DISABLED`, `LOADING` and `ERROR`
|
|
4211
|
+
* are unknown, and unknown never blocks.
|
|
4178
4212
|
*/
|
|
4179
4213
|
declare function isNotTradable(state: LoadOndoTradingStatusState): boolean;
|
|
4180
4214
|
interface UseOndoTradingStatusOptions {
|
|
@@ -4217,94 +4251,30 @@ interface UseOndoTradingStatusResult {
|
|
|
4217
4251
|
* the poll: the first tick fires as it always does, and only replaces the seed
|
|
4218
4252
|
* once it has a status of its own.
|
|
4219
4253
|
*
|
|
4220
|
-
* Disabled it neither fetches nor holds a timer
|
|
4221
|
-
*
|
|
4222
|
-
*
|
|
4223
|
-
*
|
|
4224
|
-
*
|
|
4254
|
+
* Disabled it neither fetches nor holds a timer. With no status in hand it
|
|
4255
|
+
* reports `DISABLED`, not an empty `CONTENT`: there is no empty market status,
|
|
4256
|
+
* and an invented one would be worse than none, since `CONTENT` here is what a
|
|
4257
|
+
* caller is allowed to block an order on. A status already in hand survives
|
|
4258
|
+
* being switched off.
|
|
4225
4259
|
*/
|
|
4226
4260
|
declare function useOndoTradingStatus(options: UseOndoTradingStatusOptions): UseOndoTradingStatusResult;
|
|
4227
4261
|
|
|
4228
4262
|
/**
|
|
4229
|
-
*
|
|
4230
|
-
* spend.
|
|
4263
|
+
* The state of the swap's output-token read.
|
|
4231
4264
|
*
|
|
4232
|
-
*
|
|
4233
|
-
*
|
|
4234
|
-
*
|
|
4235
|
-
*
|
|
4236
|
-
*
|
|
4237
|
-
*/
|
|
4238
|
-
type SuperstateAmountUiState = {
|
|
4239
|
-
type: 'incomplete';
|
|
4240
|
-
} | {
|
|
4241
|
-
type: 'active';
|
|
4242
|
-
/**
|
|
4243
|
-
* Exactly what the user has typed, not a parsed number: the field is
|
|
4244
|
-
* mid-edit, and `'1.'` is a legal thing to be holding.
|
|
4245
|
-
*/
|
|
4246
|
-
amountInput: string;
|
|
4247
|
-
/** The wallet the funds come from, per step 1. */
|
|
4248
|
-
walletAddress: ShortenedWalletAddress;
|
|
4249
|
-
/**
|
|
4250
|
-
* Every supported input asset, in display order, whether or not the user
|
|
4251
|
-
* holds any. One entry renders as a plain card, two or more as a picker.
|
|
4252
|
-
*/
|
|
4253
|
-
inputAssets: CheckoutSelectableInputAssetUi[];
|
|
4254
|
-
confirmEnabled: boolean;
|
|
4255
|
-
/** Validation copy, e.g. `Amount must be greater than 0.` */
|
|
4256
|
-
error: string | null;
|
|
4257
|
-
} | {
|
|
4258
|
-
type: 'complete';
|
|
4259
|
-
inputAsset: CheckoutAssetUi;
|
|
4260
|
-
/**
|
|
4261
|
-
* What the user is spending, as the field asked for it: dollars, e.g.
|
|
4262
|
-
* `$1,000.00`. The Superstate field is dollar-denominated, which is why
|
|
4263
|
-
* this is prefixed rather than suffixed with a symbol.
|
|
4264
|
-
*/
|
|
4265
|
-
amountFormatted: FormattedAmountAssetUi;
|
|
4266
|
-
/**
|
|
4267
|
-
* The same figure in the asset actually being paid, e.g. `1,000.00 USDC`.
|
|
4268
|
-
*
|
|
4269
|
-
* Both are shown because the two are only equal while the funding asset
|
|
4270
|
-
* is a dollar stablecoin — the day a non-dollar one is fundable, the
|
|
4271
|
-
* summary would otherwise silently claim it was.
|
|
4272
|
-
*/
|
|
4273
|
-
inputAmountFormatted: FormattedAmountAssetUi;
|
|
4274
|
-
};
|
|
4275
|
-
type SuperstateAmountUiEvent = {
|
|
4276
|
-
type: 'ON_AMOUNT_CHANGE';
|
|
4277
|
-
value: string;
|
|
4278
|
-
} | {
|
|
4279
|
-
type: 'ON_MAX_AMOUNT_CLICK';
|
|
4280
|
-
} | {
|
|
4281
|
-
type: 'ON_SELECT_PAY_WITH';
|
|
4282
|
-
value: AssetSymbol;
|
|
4283
|
-
}
|
|
4284
|
-
/**
|
|
4285
|
-
* Named for what it does rather than for the step: confirming here previews
|
|
4286
|
-
* the order on step 3, it does not place or pay for anything.
|
|
4265
|
+
* - `DISABLED`: switched off before an answer arrived.
|
|
4266
|
+
* - `LOADING`: no answer yet (initial, a re-read after the contract or chain
|
|
4267
|
+
* changed, or the provider still initializing).
|
|
4268
|
+
* - `ERROR`: the read failed.
|
|
4269
|
+
* - `CONTENT`: the output token was read.
|
|
4287
4270
|
*/
|
|
4288
|
-
|
|
4289
|
-
type: '
|
|
4271
|
+
type LoadSwapOutputTokenState = {
|
|
4272
|
+
type: 'DISABLED';
|
|
4290
4273
|
} | {
|
|
4291
|
-
type: 'ON_EDIT_AMOUNT';
|
|
4292
|
-
};
|
|
4293
|
-
|
|
4294
|
-
/**
|
|
4295
|
-
* The state of the swap's output-token fetch.
|
|
4296
|
-
*
|
|
4297
|
-
* - `LOADING`: no result yet (initial, or provider still initializing).
|
|
4298
|
-
* - `ERROR`: the fetch failed.
|
|
4299
|
-
* - `CONTENT`: the output token was fetched successfully.
|
|
4300
|
-
*
|
|
4301
|
-
* A stale `CONTENT`/`ERROR` is preserved while a re-fetch (e.g. after a chain
|
|
4302
|
-
* change) is in flight, rather than flipping back to `LOADING`.
|
|
4303
|
-
*/
|
|
4304
|
-
type SwapOutputTokenState = {
|
|
4305
4274
|
type: 'LOADING';
|
|
4306
4275
|
} | {
|
|
4307
4276
|
type: 'ERROR';
|
|
4277
|
+
reason: LoadErrorReason;
|
|
4308
4278
|
} | {
|
|
4309
4279
|
type: 'CONTENT';
|
|
4310
4280
|
outputToken: Erc20Asset;
|
|
@@ -4317,12 +4287,12 @@ interface UseSwapOutputTokenOptions {
|
|
|
4317
4287
|
enabled: boolean;
|
|
4318
4288
|
}
|
|
4319
4289
|
interface UseSwapOutputTokenResult {
|
|
4320
|
-
|
|
4290
|
+
state: LoadSwapOutputTokenState;
|
|
4321
4291
|
/**
|
|
4322
|
-
* Runs the
|
|
4292
|
+
* Runs the read again after a failure.
|
|
4323
4293
|
*
|
|
4324
4294
|
* The output token is read once and never polled, so `ERROR` is otherwise
|
|
4325
|
-
* terminal until a dependency changes
|
|
4295
|
+
* terminal until a dependency changes - and without it there is no quote,
|
|
4326
4296
|
* no price and no minimum received, which is why the Superstate checkout
|
|
4327
4297
|
* surfaces it as a whole-flow failure with a retry rather than as one
|
|
4328
4298
|
* unavailable corner.
|
|
@@ -4330,11 +4300,11 @@ interface UseSwapOutputTokenResult {
|
|
|
4330
4300
|
refetch: () => void;
|
|
4331
4301
|
}
|
|
4332
4302
|
/**
|
|
4333
|
-
*
|
|
4303
|
+
* Reads the ERC-20 output token a swap contract pays out. Reads again when the
|
|
4334
4304
|
* contract or chain changes, and once when `enabled` flips to true.
|
|
4335
4305
|
*
|
|
4336
|
-
* The
|
|
4337
|
-
* retried until a dependency changes.
|
|
4306
|
+
* The read runs once (no polling); a failure resolves to `ERROR` and is not
|
|
4307
|
+
* retried until a dependency changes or `refetch` is called.
|
|
4338
4308
|
*/
|
|
4339
4309
|
declare function useSwapOutputToken(options: UseSwapOutputTokenOptions): UseSwapOutputTokenResult;
|
|
4340
4310
|
|
|
@@ -4355,21 +4325,45 @@ interface UseSwapQuoteOptions {
|
|
|
4355
4325
|
/** When false, the hook neither fetches nor polls. */
|
|
4356
4326
|
enabled: boolean;
|
|
4357
4327
|
}
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4328
|
+
/**
|
|
4329
|
+
* The state of the quote poll.
|
|
4330
|
+
*
|
|
4331
|
+
* - `DISABLED`: switched off with no quote in hand, so none is coming.
|
|
4332
|
+
* - `LOADING`: no quote yet - the first read is in flight, the provider is
|
|
4333
|
+
* still initializing, or the output token's decimals are not known yet.
|
|
4334
|
+
* - `ERROR`: no quote could be read at all.
|
|
4335
|
+
* - `CONTENT`: a quote is in hand; `isRefreshing` says whether a newer one is
|
|
4336
|
+
* on the way.
|
|
4337
|
+
*
|
|
4338
|
+
* A tick that fails with a quote already in hand stays `CONTENT`, so `ERROR`
|
|
4339
|
+
* means "never got one". A quote also survives a change of amount until the
|
|
4340
|
+
* new one lands, with `isRefreshing` set: the review step compares the quote
|
|
4341
|
+
* against the amount, and that flag is what tells it the mismatch is a reprice
|
|
4342
|
+
* in flight rather than a quote for the wrong order.
|
|
4343
|
+
*/
|
|
4344
|
+
type LoadSwapQuoteState = {
|
|
4345
|
+
type: 'DISABLED';
|
|
4346
|
+
} | {
|
|
4347
|
+
type: 'LOADING';
|
|
4348
|
+
} | {
|
|
4349
|
+
type: 'ERROR';
|
|
4350
|
+
reason: LoadErrorReason;
|
|
4351
|
+
} | {
|
|
4352
|
+
type: 'CONTENT';
|
|
4353
|
+
quote: SwapQuote;
|
|
4364
4354
|
isRefreshing: boolean;
|
|
4355
|
+
};
|
|
4356
|
+
interface UseSwapQuoteResult {
|
|
4357
|
+
state: LoadSwapQuoteState;
|
|
4365
4358
|
}
|
|
4366
4359
|
/**
|
|
4367
4360
|
* Polls a read-only swap quote for `inputAmount` of `inputTokenAddress` against
|
|
4368
4361
|
* the given swap contract, refreshing every `pollIntervalMs`.
|
|
4369
4362
|
*
|
|
4370
|
-
* A failed
|
|
4371
|
-
*
|
|
4372
|
-
*
|
|
4363
|
+
* A failed tick with a quote in hand keeps it and the next tick retries.
|
|
4364
|
+
* Quoting waits while `outputTokenDecimals` is `null` and until the CoinList
|
|
4365
|
+
* provider finishes initializing. Disabled it neither fetches nor holds a
|
|
4366
|
+
* timer; a quote already in hand survives being switched off.
|
|
4373
4367
|
*/
|
|
4374
4368
|
declare function useSwapQuote(options: UseSwapQuoteOptions): UseSwapQuoteResult;
|
|
4375
4369
|
|
|
@@ -4532,10 +4526,11 @@ type SuperstateWalletUiState = {
|
|
|
4532
4526
|
type: 'active';
|
|
4533
4527
|
/** The user's CoinList wallets. Empty when they have none. */
|
|
4534
4528
|
embeddedWallets: CheckoutEmbeddedWalletUi[];
|
|
4535
|
-
/**
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4529
|
+
/**
|
|
4530
|
+
* The external-wallet row: absent when the host offers no connector,
|
|
4531
|
+
* an invitation to connect one, or the connected wallet.
|
|
4532
|
+
*/
|
|
4533
|
+
externalWallet: CheckoutExternalWalletUi;
|
|
4539
4534
|
/**
|
|
4540
4535
|
* Confirming runs the authorization, so this reports its phase as
|
|
4541
4536
|
* loading copy — `Sign the message in your wallet…` and the rest.
|
|
@@ -4579,7 +4574,7 @@ type SuperstateWalletUiEvent = {
|
|
|
4579
4574
|
type SuperstateSwapCheckoutUiState = {
|
|
4580
4575
|
type: 'content';
|
|
4581
4576
|
wallet: SuperstateWalletUiState;
|
|
4582
|
-
amount:
|
|
4577
|
+
amount: CheckoutAmountUiState;
|
|
4583
4578
|
review: SuperstateReviewUiState;
|
|
4584
4579
|
/** The sale panel. Read-only, so it raises no events. */
|
|
4585
4580
|
sidebar: SuperstateSidebarUiState;
|
|
@@ -4614,7 +4609,7 @@ type SuperstateSwapLoadErrorReason =
|
|
|
4614
4609
|
* edit events are `ON_EDIT_WALLET` and `ON_EDIT_AMOUNT` rather than a shared
|
|
4615
4610
|
* `ON_EDIT`.
|
|
4616
4611
|
*/
|
|
4617
|
-
type SuperstateSwapCheckoutUiEvent = SuperstateWalletUiEvent |
|
|
4612
|
+
type SuperstateSwapCheckoutUiEvent = SuperstateWalletUiEvent | CheckoutAmountUiEvent | SuperstateReviewUiEvent | SuperstateOrderConfirmedUiEvent | SuperstateSwapCheckoutRetryUiEvent;
|
|
4618
4613
|
/**
|
|
4619
4614
|
* Retrying the load behind the flow-level `error` arm.
|
|
4620
4615
|
*
|
|
@@ -4634,7 +4629,7 @@ type SuperstateSwapCheckoutRetryUiEvent = {
|
|
|
4634
4629
|
*/
|
|
4635
4630
|
type SuperstateOrderConfirmedUiState = {
|
|
4636
4631
|
type: 'hidden';
|
|
4637
|
-
} | {
|
|
4632
|
+
} | ({
|
|
4638
4633
|
type: 'visible';
|
|
4639
4634
|
/** What was bought. */
|
|
4640
4635
|
asset: CheckoutAssetUi;
|
|
@@ -4658,14 +4653,7 @@ type SuperstateOrderConfirmedUiState = {
|
|
|
4658
4653
|
* `outputAmount`, so `outputAmountConfirmed` covers it too.
|
|
4659
4654
|
*/
|
|
4660
4655
|
pricePerShare: FormattedAmountAssetUi;
|
|
4661
|
-
|
|
4662
|
-
recipientAddress: ShortenedWalletAddress;
|
|
4663
|
-
/**
|
|
4664
|
-
* The settled swap on a block explorer. Always present: the dialog only
|
|
4665
|
-
* exists once there is a mined transaction to point at.
|
|
4666
|
-
*/
|
|
4667
|
-
txExplorerUrl: TxExplorerUrl;
|
|
4668
|
-
};
|
|
4656
|
+
} & CheckoutReceiptUi);
|
|
4669
4657
|
/**
|
|
4670
4658
|
* Closing is the only thing the dialog raises.
|
|
4671
4659
|
*
|
|
@@ -4693,7 +4681,17 @@ interface UseSuperstateSwapCheckoutViewModelOptions {
|
|
|
4693
4681
|
* Fixed for the lifetime of the hook, as `offer` is.
|
|
4694
4682
|
*/
|
|
4695
4683
|
chain: EthereumChain;
|
|
4696
|
-
/**
|
|
4684
|
+
/**
|
|
4685
|
+
* The host's wallets, its connector for an external one if any, and
|
|
4686
|
+
* optionally the wallet it has already settled on.
|
|
4687
|
+
*
|
|
4688
|
+
* `wallets.preselected` never skips the wallet step here: that step
|
|
4689
|
+
* allow-lists the wallet on-chain, which no preselection can stand in for.
|
|
4690
|
+
* It pre-selects the wallet's row instead, so the user confirms and
|
|
4691
|
+
* allow-lists it rather than picking it again. A preselected wallet that
|
|
4692
|
+
* is neither one of `embedded` nor the connected `external` has no row to
|
|
4693
|
+
* select, and the step opens with nothing picked.
|
|
4694
|
+
*/
|
|
4697
4695
|
wallets: CheckoutWalletSelection;
|
|
4698
4696
|
/**
|
|
4699
4697
|
* Default `true`. When `false` nothing is fetched and no timer runs, for a
|
|
@@ -4792,11 +4790,14 @@ declare function useCentrifugeClaim(): UseCentrifugeClaimResult;
|
|
|
4792
4790
|
* failures: a flaky tick must not make a claimable position vanish under the
|
|
4793
4791
|
* user. A read that has never answered is absent, not zero. `ERROR` is
|
|
4794
4792
|
* reserved for the case where nothing answered at all, so a screen has
|
|
4795
|
-
* nothing to show but a retry.
|
|
4793
|
+
* nothing to show but a retry. `DISABLED` means the hook is switched off and
|
|
4794
|
+
* holds nothing.
|
|
4796
4795
|
*
|
|
4797
4796
|
* @alpha
|
|
4798
4797
|
*/
|
|
4799
4798
|
type LoadCentrifugeClaimPositionsState = {
|
|
4799
|
+
type: 'DISABLED';
|
|
4800
|
+
} | {
|
|
4800
4801
|
type: 'LOADING';
|
|
4801
4802
|
} | {
|
|
4802
4803
|
type: 'ERROR';
|
|
@@ -4823,8 +4824,7 @@ interface UseCentrifugeClaimPositionsOptions {
|
|
|
4823
4824
|
*/
|
|
4824
4825
|
data?: CentrifugeVaultLeg[];
|
|
4825
4826
|
/**
|
|
4826
|
-
* Default `true`. When `false`: no requests, no timers, and
|
|
4827
|
-
* `CONTENT`.
|
|
4827
|
+
* Default `true`. When `false`: no requests, no timers, and `DISABLED`.
|
|
4828
4828
|
*/
|
|
4829
4829
|
enabled?: boolean;
|
|
4830
4830
|
}
|
|
@@ -5156,26 +5156,47 @@ interface UseErc20BalanceOptions {
|
|
|
5156
5156
|
* has one.
|
|
5157
5157
|
*/
|
|
5158
5158
|
tokenAddress: EvmContractAddress | null;
|
|
5159
|
-
|
|
5159
|
+
/**
|
|
5160
|
+
* The wallet whose balance is read. `null` when there is no wallet yet,
|
|
5161
|
+
* which reads nothing and holds `DISABLED`, exactly as `enabled: false`
|
|
5162
|
+
* does: there is no holding to wait for.
|
|
5163
|
+
*/
|
|
5164
|
+
owner: EvmWalletAddress | null;
|
|
5160
5165
|
chain: EthereumChain;
|
|
5161
5166
|
/** How often to refresh. Defaults to {@link ERC20_BALANCE_POLL_INTERVAL_MS}. */
|
|
5162
5167
|
pollIntervalMs?: number;
|
|
5163
5168
|
/** When false, the hook neither fetches nor polls. */
|
|
5164
5169
|
enabled: boolean;
|
|
5165
5170
|
}
|
|
5171
|
+
/**
|
|
5172
|
+
* The state of one balance read.
|
|
5173
|
+
*
|
|
5174
|
+
* Every arm answers for the token, owner and chain currently named by the
|
|
5175
|
+
* options, and nothing else: from the moment any of them changes the state is
|
|
5176
|
+
* `LOADING` until the read for the new one lands. A balance carried across
|
|
5177
|
+
* that change would be a number read for something else, indistinguishable
|
|
5178
|
+
* from a fresh one.
|
|
5179
|
+
*
|
|
5180
|
+
* - `DISABLED`: switched off. No balance is held, for the same reason.
|
|
5181
|
+
* - `LOADING`: no read has settled for this request yet, or `tokenAddress` is
|
|
5182
|
+
* not known yet.
|
|
5183
|
+
* - `ERROR`: the last read failed. A failed read is not a zero balance, and an
|
|
5184
|
+
* order must not be sized against the one before it, so it is dropped.
|
|
5185
|
+
* - `CONTENT`: raw base units of the token.
|
|
5186
|
+
*/
|
|
5187
|
+
type LoadErc20BalanceState = {
|
|
5188
|
+
type: 'DISABLED';
|
|
5189
|
+
} | {
|
|
5190
|
+
type: 'LOADING';
|
|
5191
|
+
} | {
|
|
5192
|
+
type: 'ERROR';
|
|
5193
|
+
reason: LoadErrorReason;
|
|
5194
|
+
} | {
|
|
5195
|
+
type: 'CONTENT';
|
|
5196
|
+
balance: bigint;
|
|
5197
|
+
};
|
|
5166
5198
|
interface UseErc20BalanceResult {
|
|
5167
|
-
|
|
5168
|
-
* Raw base units of the token currently named by the options, or `null`.
|
|
5169
|
-
*
|
|
5170
|
-
* `null` covers every state that is not a settled read of *this* request:
|
|
5171
|
-
* before the first one settles, after one fails, while disabled, and from
|
|
5172
|
-
* the moment the token, owner or chain changes until the read for the new
|
|
5173
|
-
* one lands. A caller cannot tell those apart on purpose - none of them is a
|
|
5174
|
-
* number to size an order against - and `isLoading` is what says whether to
|
|
5175
|
-
* wait.
|
|
5176
|
-
*/
|
|
5177
|
-
balance: bigint | null;
|
|
5178
|
-
isLoading: boolean;
|
|
5199
|
+
state: LoadErc20BalanceState;
|
|
5179
5200
|
}
|
|
5180
5201
|
/**
|
|
5181
5202
|
* Polls one wallet's balance of one ERC-20, named by contract address.
|
|
@@ -5189,15 +5210,18 @@ interface UseErc20BalanceResult {
|
|
|
5189
5210
|
* each independently, which is a different job from following a single token
|
|
5190
5211
|
* whose address may not be known yet.
|
|
5191
5212
|
*
|
|
5192
|
-
*
|
|
5193
|
-
*
|
|
5194
|
-
* until the first read settles; background polls do not toggle it. Disabled, or
|
|
5195
|
-
* with no `tokenAddress`, it neither fetches nor holds a timer.
|
|
5213
|
+
* Disabled, with no `owner`, or with no `tokenAddress`, it neither fetches
|
|
5214
|
+
* nor holds a timer.
|
|
5196
5215
|
*/
|
|
5197
5216
|
declare function useErc20Balance(options: UseErc20BalanceOptions): UseErc20BalanceResult;
|
|
5198
5217
|
|
|
5199
5218
|
interface UseErc20TokenBalancesOptions {
|
|
5200
|
-
|
|
5219
|
+
/**
|
|
5220
|
+
* The wallet whose balances are read. `null` when there is no wallet yet -
|
|
5221
|
+
* a checkout step waiting on the wallet step - which reads nothing and holds
|
|
5222
|
+
* `DISABLED`, exactly as `enabled: false` does.
|
|
5223
|
+
*/
|
|
5224
|
+
address: EvmWalletAddress | null;
|
|
5201
5225
|
chain: EthereumChain;
|
|
5202
5226
|
/** The assets to read balances for. */
|
|
5203
5227
|
assets: NonEmptyArray<StablecoinSymbol>;
|
|
@@ -5209,29 +5233,47 @@ interface UseErc20TokenBalancesOptions {
|
|
|
5209
5233
|
/** When false, the hook neither fetches nor polls. */
|
|
5210
5234
|
enabled: boolean;
|
|
5211
5235
|
}
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5236
|
+
/**
|
|
5237
|
+
* The state of the balance reads.
|
|
5238
|
+
*
|
|
5239
|
+
* Every arm answers for the address, chain and assets currently named by the
|
|
5240
|
+
* options: from the moment any of them changes the state is `LOADING` until
|
|
5241
|
+
* the reads for the new ones land, so one wallet's balances never stand in
|
|
5242
|
+
* for another's.
|
|
5243
|
+
*
|
|
5244
|
+
* - `DISABLED`: switched off. No balances are held.
|
|
5245
|
+
* - `LOADING`: no poll has settled for this request yet.
|
|
5246
|
+
* - `ERROR`: every read the last poll made failed, so there is no balance at
|
|
5247
|
+
* all to show.
|
|
5248
|
+
* - `CONTENT`: raw on-chain balances keyed by the requested assets. Each
|
|
5249
|
+
* requested asset with a deployment on the chain has an entry (`bigint` on
|
|
5250
|
+
* success, `null` on a failed read). Assets the chain has no deployment for
|
|
5251
|
+
* (e.g. USDT on Base Sepolia) are omitted entirely, so absence and failure
|
|
5252
|
+
* stay tellable apart.
|
|
5253
|
+
*/
|
|
5254
|
+
type LoadErc20TokenBalancesState = {
|
|
5255
|
+
type: 'DISABLED';
|
|
5256
|
+
} | {
|
|
5257
|
+
type: 'LOADING';
|
|
5258
|
+
} | {
|
|
5259
|
+
type: 'ERROR';
|
|
5260
|
+
reason: LoadErrorReason;
|
|
5261
|
+
} | {
|
|
5262
|
+
type: 'CONTENT';
|
|
5220
5263
|
balances: Map<StablecoinSymbol, bigint | null>;
|
|
5221
|
-
|
|
5264
|
+
};
|
|
5265
|
+
interface UseErc20TokenBalancesResult {
|
|
5266
|
+
state: LoadErc20TokenBalancesState;
|
|
5222
5267
|
}
|
|
5223
5268
|
/**
|
|
5224
5269
|
* Polls the raw ERC-20 balances of `assets` for `address`, refreshing every
|
|
5225
5270
|
* `pollIntervalMs`. Each asset settles independently: a failed read maps to
|
|
5226
5271
|
* `null` while the others still resolve, and an asset the chain has no
|
|
5227
5272
|
* deployment for is omitted from the result rather than read at a fake
|
|
5228
|
-
* address.
|
|
5229
|
-
* flight. `assets` is compared by contents, so passing an inline array does
|
|
5273
|
+
* address. `assets` is compared by contents, so passing an inline array does
|
|
5230
5274
|
* not restart the poll.
|
|
5231
5275
|
*
|
|
5232
|
-
*
|
|
5233
|
-
* not toggle it. Disabled (or before the provider is ready) the hook does not
|
|
5234
|
-
* fetch.
|
|
5276
|
+
* Disabled, or with no `address`, it neither fetches nor holds a timer.
|
|
5235
5277
|
*/
|
|
5236
5278
|
declare function useErc20TokenBalances(options: UseErc20TokenBalancesOptions): UseErc20TokenBalancesResult;
|
|
5237
5279
|
|
|
@@ -5367,4 +5409,4 @@ declare class CoinListClientInitializationError extends Error {
|
|
|
5367
5409
|
constructor(message?: string);
|
|
5368
5410
|
}
|
|
5369
5411
|
|
|
5370
|
-
export { type
|
|
5412
|
+
export { type ApproveThenBuildError, type ApproveThenBuildPhase, type ApproveThenBuildResult, type AuthState, type AuthorizeWalletParams, type BuyCentrifugeParams, type CentrifugeBuyCheckoutUiEvent, type CentrifugeBuyCheckoutUiState, type CentrifugeBuyError, type CentrifugeBuyPhase, type CentrifugeBuyPlacementError, type CentrifugeBuyPlacementPhase, type CentrifugeBuyPlacementResult, type CentrifugeBuyPreparationError, type CentrifugeBuyPreparationPhase, type CentrifugeBuyPreparationResult, type CentrifugeBuyResult, type CentrifugeBuyReviewUiEvent, type CentrifugeBuyReviewUiState, type CentrifugeCheckoutErrorReason, type CentrifugeClaimActionUi, type CentrifugeClaimBlockedReasonUi, type CentrifugeClaimDialogUi, type CentrifugeClaimError, type CentrifugeClaimFailureUi, type CentrifugeClaimParams, type CentrifugeClaimPhase, type CentrifugeClaimProgressUi, type CentrifugeClaimResult, type CentrifugeClaimRowUi, type CentrifugeClaimState, type CentrifugeClaimStepUi, type CentrifugeLoadErrorReason, type CentrifugeOrderPlaced, type CentrifugeOrderPlacedUiEvent, type CentrifugeOrderPlacedUiState, type CentrifugeSidebarMinimumUi, type CentrifugeSidebarUiState, type CentrifugeVaultCheckoutConfig, type CentrifugeVaultClaimConfig, type CentrifugeVaultClaimUiEvent, type CentrifugeVaultClaimUiState, type CentrifugeVaultClaimed, ChecklistStatus, type CheckoutAmountAdornmentUi, type CheckoutAmountUiEvent, type CheckoutAmountUiState, CheckoutAssetUi, type CheckoutBlockedReason, type CheckoutConfig, type CheckoutConfirmedWalletUi, CheckoutContainer, type CheckoutContainerProps, type CheckoutCtaUi, type CheckoutEmbeddedWalletUi, CheckoutExternalWalletUi, type CheckoutNetworkUi, type CheckoutReceiptUi, type CheckoutSelectableInputAssetUi, type CheckoutStatusUi, type CheckoutWalletSelectUiEvent, type CheckoutWalletSelectUiState, type CheckoutWalletSelection, type CheckoutWalletTypeUi, type CheckoutWalletUi, type ClaimCentrifugeVaultParams, type ClaimConfig, ClaimContainer, type ClaimContainerProps, type ClaimExternalWalletUi, type ClientAuthNamespace, type ClientCentrifugeNamespace, type ClientCoinListTokenSaleNamespace, type ClientConfig, type ClientOndoNamespace, type ClientRequirementsNamespace, type ClientSuperstateSwapNamespace, type ClientSupportNamespace, type ClientWalletsNamespace, type CoinListClient, CoinListClientInitializationError, CoinListProvider, type CoinListProviderProps, CoinListSignInButton, type CoinListSignInButtonProps, CoinListSignInCardContainer, type CoinListSignInCardContainerProps, type CoinListSignInCardUiEvent, type CoinListSignInCardUiState, CoinListStyleScope, type CoinListStyleScopeProps, type CoinListTokenSaleCheckoutConfig, type CompleteOAuthFailureReason, type ConnectWalletError, type ConnectWalletErrorCode, type ConnectWalletFlowError, type ConnectWalletFlowResult, type ConnectWalletParams, type ConnectWalletPhase, type ConnectWalletSignState, type ConnectWalletState, type ConnectedWalletUi, type Erc20AllowanceError, type Erc20AllowancePhase, type Erc20ApprovalError, type ExecuteOndoSwapParams, type ExecuteSwapParams, type ExecuteTokenSaleParams, type ExternalWalletRequestUi, type KycTokenErrorReason, type KycTokenState, type LoadCentrifugeClaimPositionsState, type LoadCentrifugeVaultStatusState, type LoadErc20BalanceState, type LoadErc20TokenBalancesState, type LoadErrorReason, type LoadFirmTransactionState, type LoadOfferDetailsReason, type LoadOfferDetailsState, type LoadOffersReason, type LoadOffersState, type LoadOndoBuyTransactionState, type LoadOndoPriceState, type LoadOndoSellTransactionState, type LoadOndoTradingStatusState, type LoadOptionAddressesReason, type LoadOptionAddressesState, type LoadParticipationsReason, type LoadParticipationsState, type LoadRequirementsReason, type LoadRequirementsState, type LoadSwapOutputTokenState, type LoadSwapQuoteState, type LoadTokenMetadataState, type LoadTokenRegistryState, type LogoImageUi, type OAuthClientErrorReason, type OAuthClientResult, OfferAssetCard, type OfferAssetCardProps, OfferAssetCardUi, OfferLogoUi, OfferSaleCard, type OfferSaleCardProps, OfferSaleCardUi, OffersGridContainer, type OffersGridContainerProps, type OffersGridData, type OndoBuyAmountUiEvent, type OndoBuyAmountUiState, type OndoBuyCheckoutUiEvent, type OndoBuyCheckoutUiState, type OndoBuyOrderPlaced, type OndoBuyOrderTerms, type OndoBuyPreparationResult, type OndoBuyReviewUiEvent, type OndoBuyReviewUiState, type OndoCheckoutConfig, type OndoCheckoutErrorReason, type OndoLoadErrorReason, type OndoOrderConfirmedUiEvent, type OndoOrderConfirmedUiState, type OndoOrderPlaced, type OndoOrderPlacedCore, type OndoQuoteStatusUi, type OndoSellAmountUiEvent, type OndoSellAmountUiState, type OndoSellBalanceUi, type OndoSellCheckoutUiEvent, type OndoSellCheckoutUiState, type OndoSellOrderConfirmedUiEvent, type OndoSellOrderConfirmedUiState, type OndoSellOrderPlaced, type OndoSellOrderTerms, type OndoSellOutcomeUi, type OndoSellPreparationResult, type OndoSellReviewUiEvent, type OndoSellReviewUiState, type OndoSellSourceWalletUi, type OndoSidebarPriceUi, type OndoSidebarUiState, type OndoSwapExecutionError, type OndoSwapExecutionPhase, type OndoSwapExecutionResult, type OndoSwapPreparationError, type OndoSwapPreparationPhase, type OndoSwapPreparationResult, type PlaceCentrifugeRequestParams, type PrepareCentrifugeBuyParams, type PrepareOndoBuyParams, type PrepareOndoSellParams, type PrepareOndoSwapParamsCore, RequirementItemUi, RequirementStatus, RequirementVariant, RequirementsChecklistContainer, type RequirementsChecklistContainerProps, type RequirementsChecklistItemUi, type RequirementsChecklistUiEvent, type RequirementsChecklistUiState, RequirementsChecklistView, type RequirementsChecklistViewProps, type RequirementsData, type RequirementsVerificationUi, type ResetThenApprovePhase, type SignState, type SuperstateCheckoutConfig, type SuperstateOrderConfirmedUiEvent, type SuperstateOrderConfirmedUiState, type SuperstateOrderPlaced, type SuperstateReviewUiEvent, type SuperstateReviewUiState, type SuperstateSidebarPriceUi, type SuperstateSidebarUiState, type SuperstateSlippageOptionUi, type SuperstateSlippageUi, type SuperstateSwapCheckoutRetryUiEvent, type SuperstateSwapCheckoutUiEvent, type SuperstateSwapCheckoutUiState, type SuperstateSwapLoadErrorReason, type SuperstateWalletUiEvent, type SuperstateWalletUiState, type SwapExecutionError, type SwapExecutionPhase, type SwapExecutionResult, type TaxDocumentAddressParts, type TaxDocumentFields, type TaxDocumentState, type TokenSaleExecutionError, type TokenSaleExecutionPhase, type TokenSaleExecutionResult, type UseCentrifugeBuyCheckoutViewModelOptions, type UseCentrifugeBuyCheckoutViewModelResult, type UseCentrifugeClaimPositionsOptions, type UseCentrifugeClaimPositionsResult, type UseCentrifugeClaimResult, type UseCentrifugeVaultClaimViewModelOptions, type UseCentrifugeVaultClaimViewModelResult, type UseCentrifugeVaultStatusOptions, type UseCentrifugeVaultStatusResult, type UseCentrifugeVaultStatusesOptions, type UseCentrifugeVaultStatusesResult, type UseCoinListResult, type UseCoinListSignInCardViewModelOptions, type UseCoinListSignInCardViewModelResult, type UseCompleteOAuthOptions, type UseConnectWalletOptions, type UseConnectWalletResult, type UseErc20BalanceOptions, type UseErc20BalanceResult, type UseErc20TokenBalancesOptions, type UseErc20TokenBalancesResult, type UseKycTokenResult, type UseOfferDetailsOptions, type UseOfferDetailsResult, type UseOffersOptions, type UseOffersResult, type UseOndoBuyCheckoutViewModelOptions, type UseOndoBuyCheckoutViewModelResult, type UseOndoBuyTransactionOptions, type UseOndoBuyTransactionResult, type UseOndoPriceOptions, type UseOndoPriceResult, type UseOndoSellCheckoutViewModelOptions, type UseOndoSellCheckoutViewModelResult, type UseOndoSellTransactionOptions, type UseOndoSellTransactionResult, type UseOndoTradingStatusOptions, type UseOndoTradingStatusResult, type UseOptionAddressesOptions, type UseOptionAddressesResult, type UseParticipationsOptions, type UseParticipationsResult, type UseRequirementsChecklistViewModelOptions, type UseRequirementsChecklistViewModelResult, type UseRequirementsOptions, type UseRequirementsResult, type UseSuperstateSwapCheckoutViewModelOptions, type UseSuperstateSwapCheckoutViewModelResult, type UseSwapOutputTokenOptions, type UseSwapOutputTokenResult, type UseSwapQuoteOptions, type UseSwapQuoteResult, type UseTaxDocumentOptions, type UseTaxDocumentResult, type UseTokenMetadataOptions, type UseTokenMetadataResult, type UseTokenRegistryOptions, type UseTokenRegistryResult, type WalletAuthorizationError, type WalletAuthorizationPhase, type WalletAuthorizationResult, type WalletsStatus, createCoinListClient, isNotTradable, pinoClientLogger, useCentrifugeBuyCheckoutViewModel, useCentrifugeClaim, useCentrifugeClaimPositions, useCentrifugeVaultClaimViewModel, useCentrifugeVaultStatus, useCentrifugeVaultStatuses, useCoinList, useCoinListSignInCardViewModel, useCompleteOAuth, useConnectWallet, useErc20Balance, useErc20TokenBalances, useKycToken, useOfferDetails, useOffers, useOndoBuyCheckoutViewModel, useOndoBuyTransaction, useOndoPrice, useOndoSellCheckoutViewModel, useOndoSellTransaction, useOndoTradingStatus, useOptionAddresses, useParticipations, useRequirements, useRequirementsChecklistViewModel, useSuperstateSwapCheckoutViewModel, useSwapOutputToken, useSwapQuote, useTaxDocument, useTokenMetadata, useTokenRegistry };
|