@coinlist-co/react 0.12.2-rc.abd9d38 → 0.12.2-rc.bc20f5b

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 (33) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-45LAPB7U.js → chunk-3WW5FLT7.js} +2 -2
  3. package/dist/{chunk-HDJEDOS4.js → chunk-C6GF7MDF.js} +759 -412
  4. package/dist/chunk-C6GF7MDF.js.map +1 -0
  5. package/dist/{chunk-M7WDZZPX.js → chunk-IZJ4JSSC.js} +69 -4
  6. package/dist/chunk-IZJ4JSSC.js.map +1 -0
  7. package/dist/client/index.cjs +11305 -7943
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +1545 -10
  10. package/dist/client/index.d.ts +1545 -10
  11. package/dist/client/index.js +7725 -4781
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/server/index.cjs +347 -62
  14. package/dist/server/index.cjs.map +1 -1
  15. package/dist/server/index.d.cts +6 -2
  16. package/dist/server/index.d.ts +6 -2
  17. package/dist/server/index.js +4 -2
  18. package/dist/server/index.js.map +1 -1
  19. package/dist/{tokens-namespace-DrwRi0AQ.d.cts → time-CVZpAkGY.d.cts} +815 -192
  20. package/dist/{tokens-namespace-DrwRi0AQ.d.ts → time-CVZpAkGY.d.ts} +815 -192
  21. package/dist/{token-registry-snapshot-C-Qs3Lgs.d.ts → token-registry-snapshot-BkwA8KmD.d.ts} +74 -8
  22. package/dist/{token-registry-snapshot-CpzLmsc2.d.cts → token-registry-snapshot-bR14QehS.d.cts} +74 -8
  23. package/dist/universal/index.cjs +812 -385
  24. package/dist/universal/index.cjs.map +1 -1
  25. package/dist/universal/index.d.cts +54 -6
  26. package/dist/universal/index.d.ts +54 -6
  27. package/dist/universal/index.js +30 -2
  28. package/package.json +1 -1
  29. package/dist/chunk-HDJEDOS4.js.map +0 -1
  30. package/dist/chunk-M7WDZZPX.js.map +0 -1
  31. package/dist/time-BOCS1TbH.d.cts +0 -50
  32. package/dist/time-C7mhO5_a.d.ts +0 -50
  33. /package/dist/{chunk-45LAPB7U.js.map → chunk-3WW5FLT7.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,282 @@ 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 CentrifugeVaultStatus = {
2122
+ fromDto: (dto) => ({
2123
+ chain: EthereumChain(dto.chain),
2124
+ symbol: AssetSymbol(dto.symbol),
2125
+ vaultAddress: EvmContractAddress(dto.vault_address),
2126
+ linked: dto.linked,
2127
+ permissioned: dto.permissioned,
2128
+ membershipValidUntil: dateOrNull(
2129
+ dto.membership_valid_until,
2130
+ "CentrifugeVaultStatus.membership_valid_until"
2131
+ ),
2132
+ halted: dto.halted,
2133
+ priceUpdatedAt: dateOrNull(
2134
+ dto.price_updated_at,
2135
+ "CentrifugeVaultStatus.price_updated_at"
2136
+ ),
2137
+ orderability: parseOrderability(
2138
+ dto.can_order,
2139
+ dto.reasons,
2140
+ "CentrifugeVaultStatus"
2141
+ ),
2142
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
2143
+ })
2144
+ };
2145
+ var CentrifugeVaultBuyTransaction = {
2146
+ fromDto: (dto) => {
2147
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
2148
+ label: "spend_input_amount",
2149
+ raw: dto.spend_input_amount,
2150
+ decimals: AssetDecimals(dto.spend_input_decimals)
2151
+ });
2152
+ if (spendInputAmount.raw <= 0n) {
2153
+ throw new ValidationError(
2154
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
2155
+ );
2156
+ }
2157
+ return {
2158
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
2159
+ spendInputAmount
2160
+ };
2161
+ }
2162
+ };
2163
+ var CentrifugeVaultClaimTransaction = {
2164
+ fromDto: (dto) => ({
2165
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
2166
+ claimableShares: blockchainAmountFromRawOrThrow({
2167
+ label: "claimable_shares",
2168
+ raw: dto.claimable_shares,
2169
+ decimals: AssetDecimals(dto.share_decimals)
2170
+ })
2171
+ })
2172
+ };
2173
+ var CentrifugeVaultPosition = {
2174
+ fromDto: (dto) => {
2175
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
2176
+ const shareDecimals = AssetDecimals(dto.share_decimals);
2177
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
2178
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
2179
+ return {
2180
+ chain: EthereumChain(dto.chain),
2181
+ symbol: AssetSymbol(dto.symbol),
2182
+ walletAddress: EvmWalletAddress(dto.wallet_address),
2183
+ status: dto.status,
2184
+ requested: asset("requested", dto.requested),
2185
+ pending: asset("pending", dto.pending),
2186
+ filledAssets: asset("filled_assets", dto.filled_assets),
2187
+ earnedShares: shares("earned_shares", dto.earned_shares),
2188
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
2189
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
2190
+ shareBalance: shares("share_balance", dto.share_balance),
2191
+ averagePrice: decimalOrNull(dto.average_price),
2192
+ frozen: dto.frozen,
2193
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
2194
+ };
2195
+ }
2196
+ };
2197
+ var CentrifugeVaultRedeemPosition = {
2198
+ fromDto: (dto) => ({
2199
+ chain: EthereumChain(dto.chain),
2200
+ symbol: AssetSymbol(dto.symbol),
2201
+ walletAddress: EvmWalletAddress(dto.wallet_address),
2202
+ status: dto.status,
2203
+ pending: blockchainAmountFromRawOrThrow({
2204
+ label: "pending",
2205
+ raw: dto.pending,
2206
+ decimals: AssetDecimals(dto.share_decimals)
2207
+ }),
2208
+ claimableAssets: blockchainAmountFromRawOrThrow({
2209
+ label: "claimable_assets",
2210
+ raw: dto.claimable_assets,
2211
+ decimals: AssetDecimals(dto.asset_decimals)
2212
+ }),
2213
+ frozen: dto.frozen,
2214
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
2215
+ })
2216
+ };
2217
+ var CentrifugeVaultClaimProceedsTransaction = {
2218
+ fromDto: (dto) => ({
2219
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
2220
+ claimableAssets: blockchainAmountFromRawOrThrow({
2221
+ label: "claimable_assets",
2222
+ raw: dto.claimable_assets,
2223
+ decimals: AssetDecimals(dto.asset_decimals)
2224
+ })
2225
+ })
2226
+ };
2227
+ function parseOrderability(canOrder, reasons, model) {
2228
+ const [first, ...rest] = reasons;
2229
+ if (canOrder) {
2230
+ if (first !== void 0) {
2231
+ throw new ValidationError(
2232
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
2233
+ );
2234
+ }
2235
+ return { type: "orderable" };
2236
+ }
2237
+ if (first === void 0) {
2238
+ throw new ValidationError(
2239
+ `${model}.reasons: expected at least one when can_order is false`
2240
+ );
2241
+ }
2242
+ return { type: "blocked", reasons: [first, ...rest] };
2243
+ }
2244
+ function parseTransactionCore(dto, model) {
2245
+ return {
2246
+ tx: {
2247
+ to: EvmContractAddress(dto.to),
2248
+ data: HexEncodedTransactionData(dto.data)
2249
+ },
2250
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
2251
+ };
2252
+ }
2253
+
2254
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
2255
+ async function getCentrifugeVaultStatus(api, params) {
2256
+ const dto = await api.send({
2257
+ method: "GET",
2258
+ url: "/v1/centrifuge/vault/status",
2259
+ queryParams: {
2260
+ symbol: params.symbol,
2261
+ chain: params.chain
2262
+ },
2263
+ attributes: Attributes.protected()
2264
+ });
2265
+ return CentrifugeVaultStatus.fromDto(dto);
2266
+ }
2267
+ async function buildCentrifugeVaultBuy(api, params) {
2268
+ const dto = await api.send({
2269
+ method: "POST",
2270
+ url: "/v1/centrifuge/vault/invest",
2271
+ body: {
2272
+ ...walletFields(params),
2273
+ amount: params.amount.raw.toString()
2274
+ },
2275
+ attributes: Attributes.protected()
2276
+ });
2277
+ if (dto.spend_input_decimals !== params.amount.decimals) {
2278
+ throw new ValidationError(
2279
+ `spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
2280
+ );
2281
+ }
2282
+ return CentrifugeVaultBuyTransaction.fromDto(dto);
2283
+ }
2284
+ async function getCentrifugeVaultPosition(api, params) {
2285
+ const dto = await api.send({
2286
+ method: "GET",
2287
+ url: "/v1/centrifuge/vault/position",
2288
+ queryParams: walletFields(params),
2289
+ attributes: Attributes.protected()
2290
+ });
2291
+ return CentrifugeVaultPosition.fromDto(dto);
2292
+ }
2293
+ async function getCentrifugeVaultRedeemPosition(api, params) {
2294
+ const dto = await api.send({
2295
+ method: "GET",
2296
+ url: "/v1/centrifuge/vault/redeem-position",
2297
+ queryParams: walletFields(params),
2298
+ attributes: Attributes.protected()
2299
+ });
2300
+ return CentrifugeVaultRedeemPosition.fromDto(dto);
2301
+ }
2302
+ async function createCentrifugeVaultClaim(api, params) {
2303
+ const dto = await api.send({
2304
+ method: "POST",
2305
+ url: "/v1/centrifuge/vault/claim",
2306
+ body: walletFields(params),
2307
+ attributes: Attributes.protected()
2308
+ });
2309
+ return CentrifugeVaultClaimTransaction.fromDto(dto);
2310
+ }
2311
+ async function createCentrifugeVaultClaimProceeds(api, params) {
2312
+ const dto = await api.send({
2313
+ method: "POST",
2314
+ url: "/v1/centrifuge/vault/claim-proceeds",
2315
+ body: walletFields(params),
2316
+ attributes: Attributes.protected()
2317
+ });
2318
+ return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
2319
+ }
2320
+ function walletFields(params) {
2321
+ return {
2322
+ symbol: params.symbol,
2323
+ chain: params.chain,
2324
+ wallet_address: params.walletAddress
2325
+ };
2326
+ }
2327
+
2328
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
2329
+ var CentrifugeNamespaceImpl = class {
2330
+ constructor(ctx) {
2331
+ this.ctx = ctx;
2332
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
2333
+ }
2334
+ async getVaultStatus(params) {
2335
+ return this.log.wrap("getVaultStatus", params, async () => {
2336
+ await this.ctx.ensureUserAuthenticated();
2337
+ return getCentrifugeVaultStatus(this.ctx.api, params);
2338
+ });
2339
+ }
2340
+ async getPosition(params) {
2341
+ return this.log.wrap("getPosition", params, async () => {
2342
+ await this.ctx.ensureUserAuthenticated();
2343
+ return getCentrifugeVaultPosition(this.ctx.api, params);
2344
+ });
2345
+ }
2346
+ async getRedeemPosition(params) {
2347
+ return this.log.wrap("getRedeemPosition", params, async () => {
2348
+ await this.ctx.ensureUserAuthenticated();
2349
+ return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
2350
+ });
2351
+ }
2352
+ async createClaim(params) {
2353
+ return this.log.wrap("createClaim", params, async () => {
2354
+ await this.ctx.ensureUserAuthenticated();
2355
+ return createCentrifugeVaultClaim(this.ctx.api, params);
2356
+ });
2357
+ }
2358
+ async createClaimProceeds(params) {
2359
+ return this.log.wrap("createClaimProceeds", params, async () => {
2360
+ await this.ctx.ensureUserAuthenticated();
2361
+ return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
2362
+ });
2363
+ }
2364
+ async buildBuyTransaction(params) {
2365
+ return this.log.wrap("buildBuyTransaction", params, async () => {
2366
+ await this.ctx.ensureUserAuthenticated();
2367
+ return buildCentrifugeVaultBuy(this.ctx.api, params);
2368
+ });
2369
+ }
2370
+ };
2371
+
2063
2372
  // src/universal/types/providers/coin-list/token-sale.ts
2064
2373
  var ParticipationId = (value) => value;
2065
2374
  var Blockchain = (value) => value;
@@ -2174,39 +2483,15 @@ var CoinListTokenSaleNamespaceImpl = class {
2174
2483
  };
2175
2484
 
2176
2485
  // src/universal/core/shared/blockchain/formatters.ts
2177
- var import_viem4 = require("viem");
2486
+ var import_viem5 = require("viem");
2178
2487
  function formatRawAmount(amount) {
2179
- return (0, import_viem4.formatUnits)(amount.raw, amount.decimals);
2488
+ return (0, import_viem5.formatUnits)(amount.raw, amount.decimals);
2180
2489
  }
2181
2490
  var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
2182
2491
  var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
2183
2492
  var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
2184
2493
  var USD_FRACTION_DIGITS = AssetDecimals(2);
2185
2494
 
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
2495
  // src/universal/types/providers/ondo/ondo.ts
2211
2496
  var OndoTradingStatus = {
2212
2497
  fromDto: (dto) => {
@@ -2222,7 +2507,6 @@ var OndoTradingStatus = {
2222
2507
  };
2223
2508
  }
2224
2509
  };
2225
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
2226
2510
  var OndoQuote = {
2227
2511
  fromDto: (dto) => {
2228
2512
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -4060,6 +4344,7 @@ var CoinListServerImpl = class {
4060
4344
  this.tokenSale = new CoinListTokenSaleNamespaceImpl(ctx);
4061
4345
  this.superstate = new SuperstateSwapNamespaceImpl(ctx);
4062
4346
  this.ondo = new OndoNamespaceImpl(ctx);
4347
+ this.centrifuge = new CentrifugeNamespaceImpl(ctx);
4063
4348
  this.tokens = new TokensNamespaceImpl(
4064
4349
  _config.tokensBaseUrl ?? NABU_BASE_URL,
4065
4350
  logger