@coinlist-co/react 0.12.2-rc.31c2f50 → 0.12.2-rc.5f2ca48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4IZ2F732.js → chunk-6NCNF5GF.js} +2 -2
- package/dist/{chunk-UJYSXXJF.js → chunk-VUIDJYHY.js} +6 -156
- package/dist/chunk-VUIDJYHY.js.map +1 -0
- package/dist/{chunk-NBO5E2RO.js → chunk-XCRU3YE2.js} +599 -409
- package/dist/chunk-XCRU3YE2.js.map +1 -0
- package/dist/client/index.cjs +458 -111
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +184 -5
- package/dist/client/index.d.ts +184 -5
- package/dist/client/index.js +222 -9
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +151 -26
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +10 -2
- package/dist/server/index.d.ts +10 -2
- package/dist/server/index.js +4 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{time-DvgN98Q9.d.ts → time-CTuVDTx6.d.ts} +1 -1
- package/dist/{time-CFocgYyl.d.cts → time-Dv1dejVB.d.cts} +1 -1
- package/dist/{token-registry-snapshot-Cc_eA5zM.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +1 -1
- package/dist/{token-registry-snapshot-BsAfBL_b.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +1 -1
- package/dist/{tokens-namespace-D_XSpiS-.d.cts → tokens-namespace-CcvHrw-k.d.cts} +361 -2
- package/dist/{tokens-namespace-D_XSpiS-.d.ts → tokens-namespace-CcvHrw-k.d.ts} +361 -2
- package/dist/universal/index.cjs +528 -472
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +18 -321
- package/dist/universal/index.d.ts +18 -321
- package/dist/universal/index.js +11 -7
- package/package.json +1 -1
- package/dist/chunk-NBO5E2RO.js.map +0 -1
- package/dist/chunk-UJYSXXJF.js.map +0 -1
- /package/dist/{chunk-4IZ2F732.js.map → chunk-6NCNF5GF.js.map} +0 -0
package/dist/client/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/client/index.ts
|
|
31
31
|
var client_exports = {};
|
|
32
32
|
__export(client_exports, {
|
|
33
|
+
CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES: () => CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES,
|
|
33
34
|
ChecklistStatus: () => ChecklistStatus,
|
|
34
35
|
CheckoutAssetUi: () => CheckoutAssetUi,
|
|
35
36
|
CheckoutContainer: () => CheckoutContainer,
|
|
@@ -100,6 +101,9 @@ __export(client_exports, {
|
|
|
100
101
|
USDT_ICON_URL: () => USDT_ICON_URL,
|
|
101
102
|
VerificationOverlay: () => VerificationOverlay,
|
|
102
103
|
authorizeWallet: () => authorizeWallet,
|
|
104
|
+
centrifugeLoadErrorReason: () => centrifugeLoadErrorReason,
|
|
105
|
+
centrifugeVaultOrderReasonMessage: () => centrifugeVaultOrderReasonMessage,
|
|
106
|
+
centrifugeVaultOrderingMessage: () => centrifugeVaultOrderingMessage,
|
|
103
107
|
classifyWalletError: () => classifyWalletError,
|
|
104
108
|
connectExternalWalletFlow: () => connectExternalWalletFlow,
|
|
105
109
|
createCoinListClient: () => createCoinListClient,
|
|
@@ -119,6 +123,7 @@ __export(client_exports, {
|
|
|
119
123
|
pinoClientLogger: () => pinoClientLogger,
|
|
120
124
|
prepareOndoBuy: () => prepareOndoBuy,
|
|
121
125
|
prepareOndoSell: () => prepareOndoSell,
|
|
126
|
+
primaryCentrifugeVaultOrderReason: () => primaryCentrifugeVaultOrderReason,
|
|
122
127
|
quoteIsStale: () => quoteIsStale,
|
|
123
128
|
quoteOverAsks: () => quoteOverAsks,
|
|
124
129
|
stablecoinIconUrl: () => stablecoinIconUrl,
|
|
@@ -126,6 +131,8 @@ __export(client_exports, {
|
|
|
126
131
|
tokenLogoSrcSet: () => tokenLogoSrcSet,
|
|
127
132
|
tokenLogoUrl: () => tokenLogoUrl,
|
|
128
133
|
tokenMetadataOf: () => tokenMetadataOf,
|
|
134
|
+
useCentrifugeQuote: () => useCentrifugeQuote,
|
|
135
|
+
useCentrifugeVaultStatus: () => useCentrifugeVaultStatus,
|
|
129
136
|
useCheckoutOfferTokenMetadata: () => useCheckoutOfferTokenMetadata,
|
|
130
137
|
useCoinList: () => useCoinList,
|
|
131
138
|
useCoinListSignInCardViewModel: () => useCoinListSignInCardViewModel,
|
|
@@ -1562,49 +1569,8 @@ async function fetchAllPages(fetchPage, baseParams) {
|
|
|
1562
1569
|
return items;
|
|
1563
1570
|
}
|
|
1564
1571
|
|
|
1565
|
-
// src/universal/
|
|
1566
|
-
var
|
|
1567
|
-
var PaginatedResponse = {
|
|
1568
|
-
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1569
|
-
/**
|
|
1570
|
-
* For a mapper that decides the page as a whole - one that drops items it
|
|
1571
|
-
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1572
|
-
* cursors are the wire's either way: dropping an item changes what the
|
|
1573
|
-
* page holds, not where the next page starts.
|
|
1574
|
-
*/
|
|
1575
|
-
fromDtoPage: (dto, pageMapper) => ({
|
|
1576
|
-
data: pageMapper(dto.data),
|
|
1577
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1578
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1579
|
-
})
|
|
1580
|
-
};
|
|
1581
|
-
var PaginationParams = {
|
|
1582
|
-
toQueryParams: (params) => {
|
|
1583
|
-
const queryParams = {};
|
|
1584
|
-
if (params.after) {
|
|
1585
|
-
queryParams.starting_after = params.after;
|
|
1586
|
-
}
|
|
1587
|
-
if (params.before) {
|
|
1588
|
-
queryParams.starting_before = params.before;
|
|
1589
|
-
}
|
|
1590
|
-
if (params.limit) {
|
|
1591
|
-
queryParams.limit = params.limit;
|
|
1592
|
-
}
|
|
1593
|
-
return queryParams;
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
|
|
1597
|
-
// src/universal/types/asset.ts
|
|
1598
|
-
var AssetId = (value) => value;
|
|
1599
|
-
var AssetCode = (value) => value;
|
|
1600
|
-
var Asset = {
|
|
1601
|
-
fromDto: (dto) => ({
|
|
1602
|
-
id: AssetId(dto.id),
|
|
1603
|
-
code: AssetCode(dto.code),
|
|
1604
|
-
name: dto.name,
|
|
1605
|
-
fractionalDigits: dto.fractional_digits
|
|
1606
|
-
})
|
|
1607
|
-
};
|
|
1572
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
1573
|
+
var import_viem3 = require("viem");
|
|
1608
1574
|
|
|
1609
1575
|
// src/universal/types/blockchain/core.ts
|
|
1610
1576
|
var ETHEREUM_CHAINS = {
|
|
@@ -1696,6 +1662,65 @@ var AssetSymbol = (value) => value;
|
|
|
1696
1662
|
var StablecoinSymbol = (value) => value;
|
|
1697
1663
|
var Bps = (value) => value;
|
|
1698
1664
|
|
|
1665
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
1666
|
+
function blockchainAmountFromRawOrThrow({
|
|
1667
|
+
label,
|
|
1668
|
+
raw,
|
|
1669
|
+
decimals
|
|
1670
|
+
}) {
|
|
1671
|
+
const trimmed = raw.trim();
|
|
1672
|
+
if (trimmed === "") {
|
|
1673
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1674
|
+
}
|
|
1675
|
+
let value;
|
|
1676
|
+
try {
|
|
1677
|
+
value = BigInt(trimmed);
|
|
1678
|
+
} catch {
|
|
1679
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1680
|
+
}
|
|
1681
|
+
try {
|
|
1682
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
1683
|
+
} catch {
|
|
1684
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
function parseBlockchainAmount(amount, decimals) {
|
|
1688
|
+
const trimmed = amount.trim();
|
|
1689
|
+
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
1690
|
+
if (trimmed.startsWith("-")) {
|
|
1691
|
+
return { valid: false, reason: { type: "negative" } };
|
|
1692
|
+
}
|
|
1693
|
+
if (/[eE]/.test(trimmed)) {
|
|
1694
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1695
|
+
}
|
|
1696
|
+
if (trimmed === ".") {
|
|
1697
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1698
|
+
}
|
|
1699
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1700
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1701
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1702
|
+
}
|
|
1703
|
+
const [, fraction = ""] = normalised.split(".");
|
|
1704
|
+
if (fraction.length > decimals) {
|
|
1705
|
+
return {
|
|
1706
|
+
valid: false,
|
|
1707
|
+
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
try {
|
|
1711
|
+
const raw = (0, import_viem3.parseUnits)(normalised, decimals);
|
|
1712
|
+
if (raw > MAX_UINT_256) {
|
|
1713
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
1714
|
+
}
|
|
1715
|
+
return {
|
|
1716
|
+
valid: true,
|
|
1717
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
1718
|
+
};
|
|
1719
|
+
} catch {
|
|
1720
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1699
1724
|
// src/universal/core/shared/utils/wire.ts
|
|
1700
1725
|
function unknownTypeError(dto, model) {
|
|
1701
1726
|
const type = dto.type;
|
|
@@ -1721,6 +1746,9 @@ function requiredDate(value, field) {
|
|
|
1721
1746
|
}
|
|
1722
1747
|
return date;
|
|
1723
1748
|
}
|
|
1749
|
+
function dateOrNull(value, field) {
|
|
1750
|
+
return value === null ? null : requiredDate(value, field);
|
|
1751
|
+
}
|
|
1724
1752
|
function decimalOrNull(value) {
|
|
1725
1753
|
return value === null ? null : DecimalString(value);
|
|
1726
1754
|
}
|
|
@@ -1733,6 +1761,174 @@ function requiredArray(value, field) {
|
|
|
1733
1761
|
return value;
|
|
1734
1762
|
}
|
|
1735
1763
|
|
|
1764
|
+
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
1765
|
+
var CentrifugeVaultQuote = {
|
|
1766
|
+
fromDto: (dto) => {
|
|
1767
|
+
const spendDecimals = AssetDecimals(dto.spend_input_decimals);
|
|
1768
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
1769
|
+
return {
|
|
1770
|
+
chain: EthereumChain(dto.chain),
|
|
1771
|
+
symbol: AssetSymbol(dto.symbol),
|
|
1772
|
+
spendInputAmount: blockchainAmountFromRawOrThrow({
|
|
1773
|
+
label: "spend_input_amount",
|
|
1774
|
+
raw: dto.spend_input_amount,
|
|
1775
|
+
decimals: spendDecimals
|
|
1776
|
+
}),
|
|
1777
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
1778
|
+
label: "estimated_shares",
|
|
1779
|
+
raw: dto.estimated_shares,
|
|
1780
|
+
decimals: shareDecimals
|
|
1781
|
+
}),
|
|
1782
|
+
indicativePrice: decimalOrNull(dto.indicative_price),
|
|
1783
|
+
minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
|
|
1784
|
+
label: "minimum_input_amount",
|
|
1785
|
+
raw: dto.minimum_input_amount,
|
|
1786
|
+
decimals: spendDecimals
|
|
1787
|
+
}),
|
|
1788
|
+
orderability: parseOrderability(
|
|
1789
|
+
dto.can_order,
|
|
1790
|
+
dto.reasons,
|
|
1791
|
+
"CentrifugeVaultQuote"
|
|
1792
|
+
)
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
var CentrifugeVaultStatus = {
|
|
1797
|
+
fromDto: (dto) => ({
|
|
1798
|
+
chain: EthereumChain(dto.chain),
|
|
1799
|
+
symbol: AssetSymbol(dto.symbol),
|
|
1800
|
+
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
1801
|
+
linked: dto.linked,
|
|
1802
|
+
permissioned: dto.permissioned,
|
|
1803
|
+
membershipValidUntil: dateOrNull(
|
|
1804
|
+
dto.membership_valid_until,
|
|
1805
|
+
"CentrifugeVaultStatus.membership_valid_until"
|
|
1806
|
+
),
|
|
1807
|
+
halted: dto.halted,
|
|
1808
|
+
priceUpdatedAt: dateOrNull(
|
|
1809
|
+
dto.price_updated_at,
|
|
1810
|
+
"CentrifugeVaultStatus.price_updated_at"
|
|
1811
|
+
),
|
|
1812
|
+
orderability: parseOrderability(
|
|
1813
|
+
dto.can_order,
|
|
1814
|
+
dto.reasons,
|
|
1815
|
+
"CentrifugeVaultStatus"
|
|
1816
|
+
),
|
|
1817
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
1818
|
+
})
|
|
1819
|
+
};
|
|
1820
|
+
function parseOrderability(canOrder, reasons, model) {
|
|
1821
|
+
const [first, ...rest] = reasons;
|
|
1822
|
+
if (canOrder) {
|
|
1823
|
+
if (first !== void 0) {
|
|
1824
|
+
throw new ValidationError(
|
|
1825
|
+
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
return { type: "orderable" };
|
|
1829
|
+
}
|
|
1830
|
+
if (first === void 0) {
|
|
1831
|
+
throw new ValidationError(
|
|
1832
|
+
`${model}.reasons: expected at least one when can_order is false`
|
|
1833
|
+
);
|
|
1834
|
+
}
|
|
1835
|
+
return { type: "blocked", reasons: [first, ...rest] };
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
1839
|
+
async function getCentrifugeVaultQuote(api, params) {
|
|
1840
|
+
const dto = await api.send({
|
|
1841
|
+
method: "GET",
|
|
1842
|
+
url: "/v1/centrifuge/vault/quote",
|
|
1843
|
+
queryParams: {
|
|
1844
|
+
symbol: params.symbol,
|
|
1845
|
+
chain: params.chain,
|
|
1846
|
+
amount: params.amount.raw.toString()
|
|
1847
|
+
},
|
|
1848
|
+
attributes: Attributes.protected()
|
|
1849
|
+
});
|
|
1850
|
+
return CentrifugeVaultQuote.fromDto(dto);
|
|
1851
|
+
}
|
|
1852
|
+
async function getCentrifugeVaultStatus(api, params) {
|
|
1853
|
+
const dto = await api.send({
|
|
1854
|
+
method: "GET",
|
|
1855
|
+
url: "/v1/centrifuge/vault/status",
|
|
1856
|
+
queryParams: {
|
|
1857
|
+
symbol: params.symbol,
|
|
1858
|
+
chain: params.chain
|
|
1859
|
+
},
|
|
1860
|
+
attributes: Attributes.protected()
|
|
1861
|
+
});
|
|
1862
|
+
return CentrifugeVaultStatus.fromDto(dto);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
// src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
|
|
1866
|
+
var CentrifugeNamespaceImpl = class {
|
|
1867
|
+
constructor(ctx) {
|
|
1868
|
+
this.ctx = ctx;
|
|
1869
|
+
this.log = internalLogger(ctx.logger, "CENTRIFUGE");
|
|
1870
|
+
}
|
|
1871
|
+
async getQuote(params) {
|
|
1872
|
+
return this.log.wrap("getQuote", params, async () => {
|
|
1873
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1874
|
+
return getCentrifugeVaultQuote(this.ctx.api, params);
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
async getVaultStatus(params) {
|
|
1878
|
+
return this.log.wrap("getVaultStatus", params, async () => {
|
|
1879
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1880
|
+
return getCentrifugeVaultStatus(this.ctx.api, params);
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
|
|
1885
|
+
// src/universal/core/checkout/centrifuge/constants.ts
|
|
1886
|
+
var CENTRIFUGE_POLL_INTERVAL_MS = 15e3;
|
|
1887
|
+
|
|
1888
|
+
// src/universal/types/pagination.ts
|
|
1889
|
+
var Cursor = (value) => value;
|
|
1890
|
+
var PaginatedResponse = {
|
|
1891
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1892
|
+
/**
|
|
1893
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1894
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1895
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1896
|
+
* page holds, not where the next page starts.
|
|
1897
|
+
*/
|
|
1898
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1899
|
+
data: pageMapper(dto.data),
|
|
1900
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1901
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1902
|
+
})
|
|
1903
|
+
};
|
|
1904
|
+
var PaginationParams = {
|
|
1905
|
+
toQueryParams: (params) => {
|
|
1906
|
+
const queryParams = {};
|
|
1907
|
+
if (params.after) {
|
|
1908
|
+
queryParams.starting_after = params.after;
|
|
1909
|
+
}
|
|
1910
|
+
if (params.before) {
|
|
1911
|
+
queryParams.starting_before = params.before;
|
|
1912
|
+
}
|
|
1913
|
+
if (params.limit) {
|
|
1914
|
+
queryParams.limit = params.limit;
|
|
1915
|
+
}
|
|
1916
|
+
return queryParams;
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// src/universal/types/asset.ts
|
|
1921
|
+
var AssetId = (value) => value;
|
|
1922
|
+
var AssetCode = (value) => value;
|
|
1923
|
+
var Asset = {
|
|
1924
|
+
fromDto: (dto) => ({
|
|
1925
|
+
id: AssetId(dto.id),
|
|
1926
|
+
code: AssetCode(dto.code),
|
|
1927
|
+
name: dto.name,
|
|
1928
|
+
fractionalDigits: dto.fractional_digits
|
|
1929
|
+
})
|
|
1930
|
+
};
|
|
1931
|
+
|
|
1736
1932
|
// src/universal/types/offer.ts
|
|
1737
1933
|
var OfferId = (value) => value;
|
|
1738
1934
|
var OfferSlug = (value) => value;
|
|
@@ -2201,7 +2397,7 @@ function isOndoNotTradableError(error) {
|
|
|
2201
2397
|
}
|
|
2202
2398
|
|
|
2203
2399
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
2204
|
-
var
|
|
2400
|
+
var import_viem4 = require("viem");
|
|
2205
2401
|
|
|
2206
2402
|
// src/universal/types/blockchain/ui.ts
|
|
2207
2403
|
var FormattedAmountUi = (value) => value;
|
|
@@ -2272,7 +2468,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
|
2272
2468
|
};
|
|
2273
2469
|
}
|
|
2274
2470
|
function formatRawAmount(amount) {
|
|
2275
|
-
return (0,
|
|
2471
|
+
return (0, import_viem4.formatUnits)(amount.raw, amount.decimals);
|
|
2276
2472
|
}
|
|
2277
2473
|
function formatBpsAsPercent(bps, locale) {
|
|
2278
2474
|
const whole = bps / 100n;
|
|
@@ -2365,66 +2561,6 @@ function explorerBaseUrl(chain) {
|
|
|
2365
2561
|
}
|
|
2366
2562
|
}
|
|
2367
2563
|
|
|
2368
|
-
// src/universal/core/shared/blockchain/math.ts
|
|
2369
|
-
var import_viem4 = require("viem");
|
|
2370
|
-
function blockchainAmountFromRawOrThrow({
|
|
2371
|
-
label,
|
|
2372
|
-
raw,
|
|
2373
|
-
decimals
|
|
2374
|
-
}) {
|
|
2375
|
-
const trimmed = raw.trim();
|
|
2376
|
-
if (trimmed === "") {
|
|
2377
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
2378
|
-
}
|
|
2379
|
-
let value;
|
|
2380
|
-
try {
|
|
2381
|
-
value = BigInt(trimmed);
|
|
2382
|
-
} catch {
|
|
2383
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
2384
|
-
}
|
|
2385
|
-
try {
|
|
2386
|
-
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
2387
|
-
} catch {
|
|
2388
|
-
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
2389
|
-
}
|
|
2390
|
-
}
|
|
2391
|
-
function parseBlockchainAmount(amount, decimals) {
|
|
2392
|
-
const trimmed = amount.trim();
|
|
2393
|
-
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
2394
|
-
if (trimmed.startsWith("-")) {
|
|
2395
|
-
return { valid: false, reason: { type: "negative" } };
|
|
2396
|
-
}
|
|
2397
|
-
if (/[eE]/.test(trimmed)) {
|
|
2398
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
2399
|
-
}
|
|
2400
|
-
if (trimmed === ".") {
|
|
2401
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
2402
|
-
}
|
|
2403
|
-
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
2404
|
-
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
2405
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
2406
|
-
}
|
|
2407
|
-
const [, fraction = ""] = normalised.split(".");
|
|
2408
|
-
if (fraction.length > decimals) {
|
|
2409
|
-
return {
|
|
2410
|
-
valid: false,
|
|
2411
|
-
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
2412
|
-
};
|
|
2413
|
-
}
|
|
2414
|
-
try {
|
|
2415
|
-
const raw = (0, import_viem4.parseUnits)(normalised, decimals);
|
|
2416
|
-
if (raw > MAX_UINT_256) {
|
|
2417
|
-
return { valid: false, reason: { type: "overflow" } };
|
|
2418
|
-
}
|
|
2419
|
-
return {
|
|
2420
|
-
valid: true,
|
|
2421
|
-
amount: BlockchainAmount({ raw, decimals })
|
|
2422
|
-
};
|
|
2423
|
-
} catch {
|
|
2424
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
2425
|
-
}
|
|
2426
|
-
}
|
|
2427
|
-
|
|
2428
2564
|
// src/universal/types/providers/ondo/ondo.ts
|
|
2429
2565
|
var OndoTradingStatus = {
|
|
2430
2566
|
fromDto: (dto) => {
|
|
@@ -5296,6 +5432,7 @@ var CoinListClientImpl = class {
|
|
|
5296
5432
|
this.wallets
|
|
5297
5433
|
);
|
|
5298
5434
|
this.ondo = new ClientOndoNamespaceImpl(ctx, this.erc20);
|
|
5435
|
+
this.centrifuge = new CentrifugeNamespaceImpl(ctx);
|
|
5299
5436
|
this.tokens = new TokensNamespaceImpl(
|
|
5300
5437
|
config.tokensBaseUrl ?? NABU_BASE_URL,
|
|
5301
5438
|
logger
|
|
@@ -16845,17 +16982,220 @@ function useCompleteOAuth(options) {
|
|
|
16845
16982
|
}, [coinlist, log]);
|
|
16846
16983
|
}
|
|
16847
16984
|
|
|
16848
|
-
// src/client/hooks/checkout/
|
|
16985
|
+
// src/client/hooks/checkout/centrifuge/shared/centrifuge-order-reason.ts
|
|
16986
|
+
var CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES = {
|
|
16987
|
+
vault_unlinked: "This vault is no longer available on this network.",
|
|
16988
|
+
vault_halted: "Investing in this vault is paused.",
|
|
16989
|
+
proxy_not_permissioned: "This vault cannot accept investments right now.",
|
|
16990
|
+
price_unavailable: "A price is not available for this vault right now.",
|
|
16991
|
+
below_minimum: "Enter at least the minimum amount to invest."
|
|
16992
|
+
};
|
|
16993
|
+
var ORDER_REASON_SEVERITY = {
|
|
16994
|
+
vault_unlinked: 0,
|
|
16995
|
+
vault_halted: 1,
|
|
16996
|
+
proxy_not_permissioned: 2,
|
|
16997
|
+
price_unavailable: 3,
|
|
16998
|
+
below_minimum: 4
|
|
16999
|
+
};
|
|
17000
|
+
function centrifugeVaultOrderReasonMessage(reason) {
|
|
17001
|
+
return CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES[reason];
|
|
17002
|
+
}
|
|
17003
|
+
function primaryCentrifugeVaultOrderReason(reasons) {
|
|
17004
|
+
if (reasons.length === 0) return null;
|
|
17005
|
+
return reasons.reduce(
|
|
17006
|
+
(best, reason) => ORDER_REASON_SEVERITY[reason] < ORDER_REASON_SEVERITY[best] ? reason : best
|
|
17007
|
+
);
|
|
17008
|
+
}
|
|
17009
|
+
function centrifugeVaultOrderingMessage(orderability) {
|
|
17010
|
+
if (orderability.type === "orderable") return null;
|
|
17011
|
+
const reason = primaryCentrifugeVaultOrderReason(orderability.reasons);
|
|
17012
|
+
return reason === null ? null : centrifugeVaultOrderReasonMessage(reason);
|
|
17013
|
+
}
|
|
17014
|
+
|
|
17015
|
+
// src/client/hooks/checkout/centrifuge/shared/data/centrifuge-load-error.ts
|
|
17016
|
+
function centrifugeLoadErrorReason(error) {
|
|
17017
|
+
return error instanceof NotAuthenticatedError ? "not-authenticated" : "generic-error";
|
|
17018
|
+
}
|
|
17019
|
+
|
|
17020
|
+
// src/client/hooks/checkout/centrifuge/shared/data/useCentrifugeQuote.ts
|
|
16849
17021
|
var import_react51 = require("react");
|
|
17022
|
+
var LOADING3 = { type: "LOADING" };
|
|
17023
|
+
function useCentrifugeQuote(options) {
|
|
17024
|
+
const {
|
|
17025
|
+
symbol,
|
|
17026
|
+
chain,
|
|
17027
|
+
amount,
|
|
17028
|
+
pollIntervalMs = CENTRIFUGE_POLL_INTERVAL_MS,
|
|
17029
|
+
data,
|
|
17030
|
+
enabled
|
|
17031
|
+
} = options;
|
|
17032
|
+
const { coinlist, isReady } = useCoinList();
|
|
17033
|
+
const log = useLogger("useCentrifugeQuote");
|
|
17034
|
+
const [state, setState] = (0, import_react51.useState)(
|
|
17035
|
+
() => data === void 0 ? LOADING3 : { type: "CONTENT", quote: data, isRefreshing: false }
|
|
17036
|
+
);
|
|
17037
|
+
const fetchIdRef = (0, import_react51.useRef)(0);
|
|
17038
|
+
const isFetchingRef = (0, import_react51.useRef)(false);
|
|
17039
|
+
const hasQuoteRef = (0, import_react51.useRef)(data !== void 0);
|
|
17040
|
+
(0, import_react51.useEffect)(() => {
|
|
17041
|
+
if (!isReady || !enabled) return;
|
|
17042
|
+
const currentFetchId = ++fetchIdRef.current;
|
|
17043
|
+
isFetchingRef.current = false;
|
|
17044
|
+
const load = async () => {
|
|
17045
|
+
if (isFetchingRef.current) return;
|
|
17046
|
+
isFetchingRef.current = true;
|
|
17047
|
+
setState(
|
|
17048
|
+
(previous) => previous.type === "CONTENT" ? { ...previous, isRefreshing: true } : previous
|
|
17049
|
+
);
|
|
17050
|
+
try {
|
|
17051
|
+
const quote = await coinlist.centrifuge.getQuote({
|
|
17052
|
+
symbol,
|
|
17053
|
+
chain,
|
|
17054
|
+
// Rebuilt from primitives the effect depends on, so an inline
|
|
17055
|
+
// `amount` from the checkout viewmodel does not restart the poll.
|
|
17056
|
+
amount: BlockchainAmount({
|
|
17057
|
+
raw: amount.raw,
|
|
17058
|
+
decimals: amount.decimals
|
|
17059
|
+
})
|
|
17060
|
+
});
|
|
17061
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
17062
|
+
log.debug(() => ({
|
|
17063
|
+
msg: "settled",
|
|
17064
|
+
fields: { state: "CONTENT" }
|
|
17065
|
+
}));
|
|
17066
|
+
hasQuoteRef.current = true;
|
|
17067
|
+
setState({ type: "CONTENT", quote, isRefreshing: false });
|
|
17068
|
+
} catch (error) {
|
|
17069
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
17070
|
+
const reason = centrifugeLoadErrorReason(error);
|
|
17071
|
+
if (hasQuoteRef.current) {
|
|
17072
|
+
log.warning(
|
|
17073
|
+
() => ({
|
|
17074
|
+
msg: "poll failed; keeping the last quote",
|
|
17075
|
+
fields: { reason }
|
|
17076
|
+
}),
|
|
17077
|
+
error
|
|
17078
|
+
);
|
|
17079
|
+
} else {
|
|
17080
|
+
log.failure(
|
|
17081
|
+
() => ({ msg: "settled", fields: { state: "ERROR", reason } }),
|
|
17082
|
+
error
|
|
17083
|
+
);
|
|
17084
|
+
}
|
|
17085
|
+
setState(
|
|
17086
|
+
(previous) => previous.type === "CONTENT" ? { ...previous, isRefreshing: false } : { type: "ERROR", reason }
|
|
17087
|
+
);
|
|
17088
|
+
} finally {
|
|
17089
|
+
if (currentFetchId === fetchIdRef.current) {
|
|
17090
|
+
isFetchingRef.current = false;
|
|
17091
|
+
}
|
|
17092
|
+
}
|
|
17093
|
+
};
|
|
17094
|
+
load();
|
|
17095
|
+
const interval = setInterval(load, pollIntervalMs);
|
|
17096
|
+
return () => {
|
|
17097
|
+
clearInterval(interval);
|
|
17098
|
+
++fetchIdRef.current;
|
|
17099
|
+
};
|
|
17100
|
+
}, [
|
|
17101
|
+
coinlist,
|
|
17102
|
+
isReady,
|
|
17103
|
+
enabled,
|
|
17104
|
+
symbol,
|
|
17105
|
+
chain,
|
|
17106
|
+
amount.raw,
|
|
17107
|
+
amount.decimals,
|
|
17108
|
+
pollIntervalMs,
|
|
17109
|
+
log
|
|
17110
|
+
]);
|
|
17111
|
+
return { state };
|
|
17112
|
+
}
|
|
17113
|
+
|
|
17114
|
+
// src/client/hooks/checkout/centrifuge/shared/data/useCentrifugeVaultStatus.ts
|
|
17115
|
+
var import_react52 = require("react");
|
|
17116
|
+
var LOADING4 = { type: "LOADING" };
|
|
17117
|
+
function useCentrifugeVaultStatus(options) {
|
|
17118
|
+
const {
|
|
17119
|
+
symbol,
|
|
17120
|
+
chain,
|
|
17121
|
+
pollIntervalMs = CENTRIFUGE_POLL_INTERVAL_MS,
|
|
17122
|
+
data,
|
|
17123
|
+
enabled
|
|
17124
|
+
} = options;
|
|
17125
|
+
const { coinlist, isReady } = useCoinList();
|
|
17126
|
+
const log = useLogger("useCentrifugeVaultStatus");
|
|
17127
|
+
const [state, setState] = (0, import_react52.useState)(
|
|
17128
|
+
() => data === void 0 ? LOADING4 : { type: "CONTENT", status: data }
|
|
17129
|
+
);
|
|
17130
|
+
const fetchIdRef = (0, import_react52.useRef)(0);
|
|
17131
|
+
const isFetchingRef = (0, import_react52.useRef)(false);
|
|
17132
|
+
const hasStatusRef = (0, import_react52.useRef)(data !== void 0);
|
|
17133
|
+
(0, import_react52.useEffect)(() => {
|
|
17134
|
+
if (!isReady || !enabled) return;
|
|
17135
|
+
const currentFetchId = ++fetchIdRef.current;
|
|
17136
|
+
isFetchingRef.current = false;
|
|
17137
|
+
const load = async () => {
|
|
17138
|
+
if (isFetchingRef.current) return;
|
|
17139
|
+
isFetchingRef.current = true;
|
|
17140
|
+
try {
|
|
17141
|
+
const status = await coinlist.centrifuge.getVaultStatus({
|
|
17142
|
+
symbol,
|
|
17143
|
+
chain
|
|
17144
|
+
});
|
|
17145
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
17146
|
+
log.debug(() => ({
|
|
17147
|
+
msg: "settled",
|
|
17148
|
+
fields: { state: "CONTENT", orderability: status.orderability.type }
|
|
17149
|
+
}));
|
|
17150
|
+
hasStatusRef.current = true;
|
|
17151
|
+
setState({ type: "CONTENT", status });
|
|
17152
|
+
} catch (error) {
|
|
17153
|
+
if (currentFetchId !== fetchIdRef.current) return;
|
|
17154
|
+
const reason = centrifugeLoadErrorReason(error);
|
|
17155
|
+
if (hasStatusRef.current) {
|
|
17156
|
+
log.warning(
|
|
17157
|
+
() => ({
|
|
17158
|
+
msg: "poll failed; keeping the last status",
|
|
17159
|
+
fields: { reason }
|
|
17160
|
+
}),
|
|
17161
|
+
error
|
|
17162
|
+
);
|
|
17163
|
+
} else {
|
|
17164
|
+
log.failure(
|
|
17165
|
+
() => ({ msg: "settled", fields: { state: "ERROR", reason } }),
|
|
17166
|
+
error
|
|
17167
|
+
);
|
|
17168
|
+
}
|
|
17169
|
+
setState(
|
|
17170
|
+
(previous) => previous.type === "CONTENT" ? previous : { type: "ERROR", reason }
|
|
17171
|
+
);
|
|
17172
|
+
} finally {
|
|
17173
|
+
if (currentFetchId === fetchIdRef.current) {
|
|
17174
|
+
isFetchingRef.current = false;
|
|
17175
|
+
}
|
|
17176
|
+
}
|
|
17177
|
+
};
|
|
17178
|
+
load();
|
|
17179
|
+
const interval = setInterval(load, pollIntervalMs);
|
|
17180
|
+
return () => {
|
|
17181
|
+
clearInterval(interval);
|
|
17182
|
+
++fetchIdRef.current;
|
|
17183
|
+
};
|
|
17184
|
+
}, [coinlist, isReady, enabled, symbol, chain, pollIntervalMs, log]);
|
|
17185
|
+
return { state };
|
|
17186
|
+
}
|
|
17187
|
+
|
|
17188
|
+
// src/client/hooks/checkout/coin-list/token-sale/data/useParticipations.ts
|
|
17189
|
+
var import_react53 = require("react");
|
|
16850
17190
|
var LOADING_STATE9 = { type: "LOADING" };
|
|
16851
17191
|
function useParticipations(offerId, options = {}) {
|
|
16852
17192
|
const { coinlist, isReady } = useCoinList();
|
|
16853
17193
|
const log = useLogger("useParticipations");
|
|
16854
17194
|
const { data, enabled = true } = options;
|
|
16855
|
-
const [participationsState, setParticipationsState] = (0,
|
|
17195
|
+
const [participationsState, setParticipationsState] = (0, import_react53.useState)(
|
|
16856
17196
|
data !== void 0 ? { type: "CONTENT", participations: data } : LOADING_STATE9
|
|
16857
17197
|
);
|
|
16858
|
-
(0,
|
|
17198
|
+
(0, import_react53.useEffect)(() => {
|
|
16859
17199
|
let isCancelled = false;
|
|
16860
17200
|
if (!enabled) {
|
|
16861
17201
|
return () => {
|
|
@@ -16902,16 +17242,16 @@ function useParticipations(offerId, options = {}) {
|
|
|
16902
17242
|
}
|
|
16903
17243
|
|
|
16904
17244
|
// src/client/hooks/offers/data/useOfferDetails.ts
|
|
16905
|
-
var
|
|
17245
|
+
var import_react54 = require("react");
|
|
16906
17246
|
var LOADING_STATE10 = { type: "LOADING" };
|
|
16907
17247
|
function useOfferDetails(offerId, options = {}) {
|
|
16908
17248
|
const { coinlist, isReady } = useCoinList();
|
|
16909
17249
|
const log = useLogger("useOfferDetails");
|
|
16910
17250
|
const { data, enabled = true } = options;
|
|
16911
|
-
const [offerDetailsState, setOfferDetailsState] = (0,
|
|
17251
|
+
const [offerDetailsState, setOfferDetailsState] = (0, import_react54.useState)(
|
|
16912
17252
|
data !== void 0 ? { type: "CONTENT", offerDetail: data } : LOADING_STATE10
|
|
16913
17253
|
);
|
|
16914
|
-
(0,
|
|
17254
|
+
(0, import_react54.useEffect)(() => {
|
|
16915
17255
|
let isCancelled = false;
|
|
16916
17256
|
if (!enabled) {
|
|
16917
17257
|
return () => {
|
|
@@ -16989,6 +17329,7 @@ function formatMonthYear(date, locale) {
|
|
|
16989
17329
|
}
|
|
16990
17330
|
// Annotate the CommonJS export names for ESM import in node:
|
|
16991
17331
|
0 && (module.exports = {
|
|
17332
|
+
CENTRIFUGE_VAULT_ORDER_REASON_MESSAGES,
|
|
16992
17333
|
ChecklistStatus,
|
|
16993
17334
|
CheckoutAssetUi,
|
|
16994
17335
|
CheckoutContainer,
|
|
@@ -17059,6 +17400,9 @@ function formatMonthYear(date, locale) {
|
|
|
17059
17400
|
USDT_ICON_URL,
|
|
17060
17401
|
VerificationOverlay,
|
|
17061
17402
|
authorizeWallet,
|
|
17403
|
+
centrifugeLoadErrorReason,
|
|
17404
|
+
centrifugeVaultOrderReasonMessage,
|
|
17405
|
+
centrifugeVaultOrderingMessage,
|
|
17062
17406
|
classifyWalletError,
|
|
17063
17407
|
connectExternalWalletFlow,
|
|
17064
17408
|
createCoinListClient,
|
|
@@ -17078,6 +17422,7 @@ function formatMonthYear(date, locale) {
|
|
|
17078
17422
|
pinoClientLogger,
|
|
17079
17423
|
prepareOndoBuy,
|
|
17080
17424
|
prepareOndoSell,
|
|
17425
|
+
primaryCentrifugeVaultOrderReason,
|
|
17081
17426
|
quoteIsStale,
|
|
17082
17427
|
quoteOverAsks,
|
|
17083
17428
|
stablecoinIconUrl,
|
|
@@ -17085,6 +17430,8 @@ function formatMonthYear(date, locale) {
|
|
|
17085
17430
|
tokenLogoSrcSet,
|
|
17086
17431
|
tokenLogoUrl,
|
|
17087
17432
|
tokenMetadataOf,
|
|
17433
|
+
useCentrifugeQuote,
|
|
17434
|
+
useCentrifugeVaultStatus,
|
|
17088
17435
|
useCheckoutOfferTokenMetadata,
|
|
17089
17436
|
useCoinList,
|
|
17090
17437
|
useCoinListSignInCardViewModel,
|