@coinlist-co/react 0.12.2-rc.0fda52c → 0.12.2-rc.5f2ca48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-STAHYDLY.js → chunk-6NCNF5GF.js} +2 -2
  2. package/dist/{chunk-KRA6EM2L.js → chunk-VUIDJYHY.js} +18 -3
  3. package/dist/chunk-VUIDJYHY.js.map +1 -0
  4. package/dist/{chunk-BNMF2HMW.js → chunk-XCRU3YE2.js} +628 -402
  5. package/dist/chunk-XCRU3YE2.js.map +1 -0
  6. package/dist/client/index.cjs +605 -160
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +271 -29
  9. package/dist/client/index.d.ts +271 -29
  10. package/dist/client/index.js +294 -21
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +216 -62
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +10 -2
  15. package/dist/server/index.d.ts +10 -2
  16. package/dist/server/index.js +4 -2
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/{time-B5YOQxuh.d.ts → time-CTuVDTx6.d.ts} +1 -1
  19. package/dist/{time-BY3apBpc.d.cts → time-Dv1dejVB.d.cts} +1 -1
  20. package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +9 -7
  21. package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +9 -7
  22. package/dist/{tokens-namespace-BJfFeowE.d.cts → tokens-namespace-CcvHrw-k.d.cts} +462 -20
  23. package/dist/{tokens-namespace-BJfFeowE.d.ts → tokens-namespace-CcvHrw-k.d.ts} +462 -20
  24. package/dist/universal/index.cjs +568 -316
  25. package/dist/universal/index.cjs.map +1 -1
  26. package/dist/universal/index.d.cts +38 -6
  27. package/dist/universal/index.d.ts +38 -6
  28. package/dist/universal/index.js +22 -2
  29. package/package.json +1 -1
  30. package/dist/chunk-BNMF2HMW.js.map +0 -1
  31. package/dist/chunk-KRA6EM2L.js.map +0 -1
  32. /package/dist/{chunk-STAHYDLY.js.map → chunk-6NCNF5GF.js.map} +0 -0
@@ -1293,40 +1293,6 @@ async function fetchAllPages(fetchPage, baseParams) {
1293
1293
  return items;
1294
1294
  }
1295
1295
 
1296
- // src/universal/core/shared/utils/wire.ts
1297
- function unknownTypeError(dto, model) {
1298
- const type = dto.type;
1299
- throw new ValidationError(
1300
- `${model}.type: unknown type ${JSON.stringify(type)}`
1301
- );
1302
- }
1303
- function requiredString(value, field) {
1304
- const text = notBlankStringOrNull(value);
1305
- if (text === null) {
1306
- throw new ValidationError(
1307
- `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
1308
- );
1309
- }
1310
- return text;
1311
- }
1312
- function requiredDate(value, field) {
1313
- const date = typeof value === "string" ? new Date(value) : null;
1314
- if (date === null || Number.isNaN(date.getTime())) {
1315
- throw new ValidationError(
1316
- `${field}: expected a date, got ${JSON.stringify(value)}`
1317
- );
1318
- }
1319
- return date;
1320
- }
1321
- function requiredArray(value, field) {
1322
- if (!Array.isArray(value)) {
1323
- throw new ValidationError(
1324
- `${field}: expected an array, got ${typeof value}`
1325
- );
1326
- }
1327
- return value;
1328
- }
1329
-
1330
1296
  // src/universal/types/blockchain/core.ts
1331
1297
  var ETHEREUM_CHAINS = {
1332
1298
  ethereum_mainnet: true,
@@ -1415,13 +1381,54 @@ function combineAmounts(a, b, op) {
1415
1381
  }
1416
1382
  var AssetSymbol = (value) => value;
1417
1383
 
1384
+ // src/universal/core/shared/utils/wire.ts
1385
+ function unknownTypeError(dto, model) {
1386
+ const type = dto.type;
1387
+ throw new ValidationError(
1388
+ `${model}.type: unknown type ${JSON.stringify(type)}`
1389
+ );
1390
+ }
1391
+ function requiredString(value, field) {
1392
+ const text = notBlankStringOrNull(value);
1393
+ if (text === null) {
1394
+ throw new ValidationError(
1395
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
1396
+ );
1397
+ }
1398
+ return text;
1399
+ }
1400
+ function requiredDate(value, field) {
1401
+ const date = typeof value === "string" ? new Date(value) : null;
1402
+ if (date === null || Number.isNaN(date.getTime())) {
1403
+ throw new ValidationError(
1404
+ `${field}: expected a date, got ${JSON.stringify(value)}`
1405
+ );
1406
+ }
1407
+ return date;
1408
+ }
1409
+ function dateOrNull(value, field) {
1410
+ return value === null ? null : requiredDate(value, field);
1411
+ }
1412
+ function decimalOrNull(value) {
1413
+ return value === null ? null : DecimalString(value);
1414
+ }
1415
+ function requiredArray(value, field) {
1416
+ if (!Array.isArray(value)) {
1417
+ throw new ValidationError(
1418
+ `${field}: expected an array, got ${typeof value}`
1419
+ );
1420
+ }
1421
+ return value;
1422
+ }
1423
+
1418
1424
  // src/universal/types/offer.ts
1419
1425
  var OfferId = (value) => value;
1420
1426
  var OfferSlug = (value) => value;
1421
1427
  var OFFER_TYPES = {
1422
1428
  "coinlist::token_sale": true,
1423
1429
  "superstate::swap": true,
1424
- "ondo::swap": true
1430
+ "ondo::swap": true,
1431
+ "centrifuge::vault": true
1425
1432
  };
1426
1433
  var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
1427
1434
  var OfferEditorial = {
@@ -1463,6 +1470,7 @@ var Offer = {
1463
1470
  // on the wire: copying them would hand every consumer a `startsAt` that
1464
1471
  // is 1970 for one variant and a date for the others.
1465
1472
  case "ondo::swap":
1473
+ case "centrifuge::vault":
1466
1474
  return {
1467
1475
  ...base2,
1468
1476
  type: dto.type,
@@ -1527,6 +1535,19 @@ var OfferSwapContract = {
1527
1535
  address: EvmContractAddress(dto.address)
1528
1536
  })
1529
1537
  };
1538
+ var OfferVaultContract = {
1539
+ fromDto: (dto) => ({
1540
+ chain: Chain(dto.chain),
1541
+ address: EvmContractAddress(dto.address)
1542
+ }),
1543
+ /**
1544
+ * Drops every proxy on a chain this SDK does not name, as
1545
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1546
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1547
+ * should not throw away the proxies the SDK can use.
1548
+ */
1549
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1550
+ };
1530
1551
  var OfferDetail = {
1531
1552
  fromDto: (dto) => {
1532
1553
  const fundingAssets = requiredArray(
@@ -1589,6 +1610,18 @@ var OfferDetail = {
1589
1610
  "OfferDetail.swap_contracts"
1590
1611
  ).map(OfferSwapContract.fromDto)
1591
1612
  };
1613
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1614
+ // the same reason as `swap_contracts`: this is the spender a user
1615
+ // approves.
1616
+ case "centrifuge::vault":
1617
+ return {
1618
+ ...base2,
1619
+ type: dto.type,
1620
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1621
+ vaultContracts: OfferVaultContract.listFromDto(
1622
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1623
+ )
1624
+ };
1592
1625
  default:
1593
1626
  return unknownTypeError(dto, "OfferDetail");
1594
1627
  }
@@ -2060,6 +2093,151 @@ function transportFor(api, override, chain, logger) {
2060
2093
  return typeof override === "string" ? (0, import_viem3.http)(override) : override;
2061
2094
  }
2062
2095
 
2096
+ // src/universal/core/shared/blockchain/math.ts
2097
+ var import_viem4 = require("viem");
2098
+ function blockchainAmountFromRawOrThrow({
2099
+ label,
2100
+ raw,
2101
+ decimals
2102
+ }) {
2103
+ const trimmed = raw.trim();
2104
+ if (trimmed === "") {
2105
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
2106
+ }
2107
+ let value;
2108
+ try {
2109
+ value = BigInt(trimmed);
2110
+ } catch {
2111
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
2112
+ }
2113
+ try {
2114
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
2115
+ } catch {
2116
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
2117
+ }
2118
+ }
2119
+
2120
+ // src/universal/types/providers/centrifuge/centrifuge.ts
2121
+ var CentrifugeVaultQuote = {
2122
+ fromDto: (dto) => {
2123
+ const spendDecimals = AssetDecimals(dto.spend_input_decimals);
2124
+ const shareDecimals = AssetDecimals(dto.share_decimals);
2125
+ return {
2126
+ chain: EthereumChain(dto.chain),
2127
+ symbol: AssetSymbol(dto.symbol),
2128
+ spendInputAmount: blockchainAmountFromRawOrThrow({
2129
+ label: "spend_input_amount",
2130
+ raw: dto.spend_input_amount,
2131
+ decimals: spendDecimals
2132
+ }),
2133
+ estimatedShares: blockchainAmountFromRawOrThrow({
2134
+ label: "estimated_shares",
2135
+ raw: dto.estimated_shares,
2136
+ decimals: shareDecimals
2137
+ }),
2138
+ indicativePrice: decimalOrNull(dto.indicative_price),
2139
+ minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
2140
+ label: "minimum_input_amount",
2141
+ raw: dto.minimum_input_amount,
2142
+ decimals: spendDecimals
2143
+ }),
2144
+ orderability: parseOrderability(
2145
+ dto.can_order,
2146
+ dto.reasons,
2147
+ "CentrifugeVaultQuote"
2148
+ )
2149
+ };
2150
+ }
2151
+ };
2152
+ var CentrifugeVaultStatus = {
2153
+ fromDto: (dto) => ({
2154
+ chain: EthereumChain(dto.chain),
2155
+ symbol: AssetSymbol(dto.symbol),
2156
+ vaultAddress: EvmContractAddress(dto.vault_address),
2157
+ linked: dto.linked,
2158
+ permissioned: dto.permissioned,
2159
+ membershipValidUntil: dateOrNull(
2160
+ dto.membership_valid_until,
2161
+ "CentrifugeVaultStatus.membership_valid_until"
2162
+ ),
2163
+ halted: dto.halted,
2164
+ priceUpdatedAt: dateOrNull(
2165
+ dto.price_updated_at,
2166
+ "CentrifugeVaultStatus.price_updated_at"
2167
+ ),
2168
+ orderability: parseOrderability(
2169
+ dto.can_order,
2170
+ dto.reasons,
2171
+ "CentrifugeVaultStatus"
2172
+ ),
2173
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
2174
+ })
2175
+ };
2176
+ function parseOrderability(canOrder, reasons, model) {
2177
+ const [first, ...rest] = reasons;
2178
+ if (canOrder) {
2179
+ if (first !== void 0) {
2180
+ throw new ValidationError(
2181
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
2182
+ );
2183
+ }
2184
+ return { type: "orderable" };
2185
+ }
2186
+ if (first === void 0) {
2187
+ throw new ValidationError(
2188
+ `${model}.reasons: expected at least one when can_order is false`
2189
+ );
2190
+ }
2191
+ return { type: "blocked", reasons: [first, ...rest] };
2192
+ }
2193
+
2194
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
2195
+ async function getCentrifugeVaultQuote(api, params) {
2196
+ const dto = await api.send({
2197
+ method: "GET",
2198
+ url: "/v1/centrifuge/vault/quote",
2199
+ queryParams: {
2200
+ symbol: params.symbol,
2201
+ chain: params.chain,
2202
+ amount: params.amount.raw.toString()
2203
+ },
2204
+ attributes: Attributes.protected()
2205
+ });
2206
+ return CentrifugeVaultQuote.fromDto(dto);
2207
+ }
2208
+ async function getCentrifugeVaultStatus(api, params) {
2209
+ const dto = await api.send({
2210
+ method: "GET",
2211
+ url: "/v1/centrifuge/vault/status",
2212
+ queryParams: {
2213
+ symbol: params.symbol,
2214
+ chain: params.chain
2215
+ },
2216
+ attributes: Attributes.protected()
2217
+ });
2218
+ return CentrifugeVaultStatus.fromDto(dto);
2219
+ }
2220
+
2221
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
2222
+ var CentrifugeNamespaceImpl = class {
2223
+ constructor(ctx) {
2224
+ this.ctx = ctx;
2225
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
2226
+ }
2227
+ async getQuote(params) {
2228
+ return this.log.wrap("getQuote", params, async () => {
2229
+ await this.ctx.ensureUserAuthenticated();
2230
+ return getCentrifugeVaultQuote(this.ctx.api, params);
2231
+ });
2232
+ }
2233
+ async getVaultStatus(params) {
2234
+ return this.log.wrap("getVaultStatus", params, async () => {
2235
+ await this.ctx.ensureUserAuthenticated();
2236
+ return getCentrifugeVaultStatus(this.ctx.api, params);
2237
+ });
2238
+ }
2239
+ };
2240
+
2063
2241
  // src/universal/types/providers/coin-list/token-sale.ts
2064
2242
  var ParticipationId = (value) => value;
2065
2243
  var Blockchain = (value) => value;
@@ -2174,39 +2352,15 @@ var CoinListTokenSaleNamespaceImpl = class {
2174
2352
  };
2175
2353
 
2176
2354
  // src/universal/core/shared/blockchain/formatters.ts
2177
- var import_viem4 = require("viem");
2355
+ var import_viem5 = require("viem");
2178
2356
  function formatRawAmount(amount) {
2179
- return (0, import_viem4.formatUnits)(amount.raw, amount.decimals);
2357
+ return (0, import_viem5.formatUnits)(amount.raw, amount.decimals);
2180
2358
  }
2181
2359
  var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
2182
2360
  var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
2183
2361
  var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
2184
2362
  var USD_FRACTION_DIGITS = AssetDecimals(2);
2185
2363
 
2186
- // src/universal/core/shared/blockchain/math.ts
2187
- var import_viem5 = require("viem");
2188
- function blockchainAmountFromRawOrThrow({
2189
- label,
2190
- raw,
2191
- decimals
2192
- }) {
2193
- const trimmed = raw.trim();
2194
- if (trimmed === "") {
2195
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
2196
- }
2197
- let value;
2198
- try {
2199
- value = BigInt(trimmed);
2200
- } catch {
2201
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
2202
- }
2203
- try {
2204
- return BlockchainAmount({ raw: assertUint256(value), decimals });
2205
- } catch {
2206
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
2207
- }
2208
- }
2209
-
2210
2364
  // src/universal/types/providers/ondo/ondo.ts
2211
2365
  var OndoTradingStatus = {
2212
2366
  fromDto: (dto) => {
@@ -2222,7 +2376,6 @@ var OndoTradingStatus = {
2222
2376
  };
2223
2377
  }
2224
2378
  };
2225
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
2226
2379
  var OndoQuote = {
2227
2380
  fromDto: (dto) => {
2228
2381
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -4060,6 +4213,7 @@ var CoinListServerImpl = class {
4060
4213
  this.tokenSale = new CoinListTokenSaleNamespaceImpl(ctx);
4061
4214
  this.superstate = new SuperstateSwapNamespaceImpl(ctx);
4062
4215
  this.ondo = new OndoNamespaceImpl(ctx);
4216
+ this.centrifuge = new CentrifugeNamespaceImpl(ctx);
4063
4217
  this.tokens = new TokensNamespaceImpl(
4064
4218
  _config.tokensBaseUrl ?? NABU_BASE_URL,
4065
4219
  logger