@coinlist-co/react 0.12.2-rc.0fda52c → 0.12.2-rc.4851c6a

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 (36) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-STAHYDLY.js → chunk-AYBP3HRJ.js} +10 -10
  3. package/dist/chunk-AYBP3HRJ.js.map +1 -0
  4. package/dist/{chunk-BNMF2HMW.js → chunk-GOUUYOPZ.js} +1168 -796
  5. package/dist/chunk-GOUUYOPZ.js.map +1 -0
  6. package/dist/{chunk-KRA6EM2L.js → chunk-LBIFCRFP.js} +162 -186
  7. package/dist/chunk-LBIFCRFP.js.map +1 -0
  8. package/dist/chunk-MJ6YXZWH.js +22 -0
  9. package/dist/chunk-MJ6YXZWH.js.map +1 -0
  10. package/dist/client/index.d.ts +3042 -4221
  11. package/dist/client/index.js +8471 -5549
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/server/index.d.ts +7 -33
  14. package/dist/server/index.js +8 -4
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/{tokens-namespace-BJfFeowE.d.cts → time-Bzgi6FbG.d.ts} +2150 -2847
  17. package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-BmjXOvvg.d.ts} +74 -42
  18. package/dist/universal/index.d.ts +64 -983
  19. package/dist/universal/index.js +36 -36
  20. package/package.json +18 -14
  21. package/dist/chunk-BNMF2HMW.js.map +0 -1
  22. package/dist/chunk-KRA6EM2L.js.map +0 -1
  23. package/dist/chunk-STAHYDLY.js.map +0 -1
  24. package/dist/client/index.cjs +0 -17035
  25. package/dist/client/index.cjs.map +0 -1
  26. package/dist/client/index.d.cts +0 -6608
  27. package/dist/server/index.cjs +0 -4240
  28. package/dist/server/index.cjs.map +0 -1
  29. package/dist/server/index.d.cts +0 -378
  30. package/dist/time-B5YOQxuh.d.ts +0 -50
  31. package/dist/time-BY3apBpc.d.cts +0 -50
  32. package/dist/token-registry-snapshot-DyjrA32p.d.cts +0 -179
  33. package/dist/tokens-namespace-BJfFeowE.d.ts +0 -3353
  34. package/dist/universal/index.cjs +0 -4125
  35. package/dist/universal/index.cjs.map +0 -1
  36. package/dist/universal/index.d.cts +0 -1294
@@ -291,166 +291,6 @@ function isExpired({
291
291
  return now >= expiresAt - buffer;
292
292
  }
293
293
 
294
- // src/universal/core/shared/blockchain/erc20/abi.ts
295
- var ERC20_ABI = [
296
- {
297
- type: "function",
298
- name: "allowance",
299
- inputs: [
300
- { name: "owner", type: "address" },
301
- { name: "spender", type: "address" }
302
- ],
303
- outputs: [{ name: "", type: "uint256" }],
304
- stateMutability: "view"
305
- },
306
- {
307
- type: "function",
308
- name: "approve",
309
- inputs: [
310
- { name: "spender", type: "address" },
311
- { name: "amount", type: "uint256" }
312
- ],
313
- outputs: [{ name: "", type: "bool" }],
314
- stateMutability: "nonpayable"
315
- },
316
- {
317
- type: "function",
318
- name: "balanceOf",
319
- inputs: [{ name: "account", type: "address" }],
320
- outputs: [{ name: "", type: "uint256" }],
321
- stateMutability: "view"
322
- },
323
- {
324
- type: "function",
325
- name: "decimals",
326
- inputs: [],
327
- outputs: [{ name: "", type: "uint8" }],
328
- stateMutability: "view"
329
- },
330
- {
331
- type: "function",
332
- name: "name",
333
- inputs: [],
334
- outputs: [{ name: "", type: "string" }],
335
- stateMutability: "view"
336
- },
337
- {
338
- type: "function",
339
- name: "symbol",
340
- inputs: [],
341
- outputs: [{ name: "", type: "string" }],
342
- stateMutability: "view"
343
- },
344
- {
345
- type: "function",
346
- name: "totalSupply",
347
- inputs: [],
348
- outputs: [{ name: "", type: "uint256" }],
349
- stateMutability: "view"
350
- },
351
- {
352
- type: "function",
353
- name: "transfer",
354
- inputs: [
355
- { name: "recipient", type: "address" },
356
- { name: "amount", type: "uint256" }
357
- ],
358
- outputs: [{ name: "", type: "bool" }],
359
- stateMutability: "nonpayable"
360
- },
361
- {
362
- type: "function",
363
- name: "transferFrom",
364
- inputs: [
365
- { name: "sender", type: "address" },
366
- { name: "recipient", type: "address" },
367
- { name: "amount", type: "uint256" }
368
- ],
369
- outputs: [{ name: "", type: "bool" }],
370
- stateMutability: "nonpayable"
371
- },
372
- {
373
- type: "event",
374
- name: "Approval",
375
- inputs: [
376
- { name: "owner", type: "address", indexed: true },
377
- { name: "spender", type: "address", indexed: true },
378
- { name: "value", type: "uint256", indexed: false }
379
- ],
380
- anonymous: false
381
- },
382
- {
383
- type: "event",
384
- name: "Transfer",
385
- inputs: [
386
- { name: "from", type: "address", indexed: true },
387
- { name: "to", type: "address", indexed: true },
388
- { name: "value", type: "uint256", indexed: false }
389
- ],
390
- anonymous: false
391
- }
392
- ];
393
-
394
- // src/universal/api/pagination.ts
395
- async function fetchAllPages(fetchPage, baseParams) {
396
- const items = [];
397
- let cursor = null;
398
- do {
399
- const params = {
400
- ...baseParams ?? {},
401
- after: cursor ?? void 0
402
- };
403
- const page = await fetchPage(params);
404
- items.push(...page.data);
405
- cursor = page.startingAfter;
406
- } while (cursor);
407
- return items;
408
- }
409
-
410
- // src/universal/types/pagination.ts
411
- var Cursor = (value) => value;
412
- var PaginatedResponse = {
413
- fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
414
- /**
415
- * For a mapper that decides the page as a whole - one that drops items it
416
- * cannot map, such as `Offer.listFromDto` - rather than item by item. The
417
- * cursors are the wire's either way: dropping an item changes what the
418
- * page holds, not where the next page starts.
419
- */
420
- fromDtoPage: (dto, pageMapper) => ({
421
- data: pageMapper(dto.data),
422
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
423
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
424
- })
425
- };
426
- var PaginationParams = {
427
- toQueryParams: (params) => {
428
- const queryParams = {};
429
- if (params.after) {
430
- queryParams.starting_after = params.after;
431
- }
432
- if (params.before) {
433
- queryParams.starting_before = params.before;
434
- }
435
- if (params.limit) {
436
- queryParams.limit = params.limit;
437
- }
438
- return queryParams;
439
- }
440
- };
441
-
442
- // src/universal/types/asset.ts
443
- var AssetId = (value) => value;
444
- var AssetCode = (value) => value;
445
- var Asset = {
446
- fromDto: (dto) => ({
447
- id: AssetId(dto.id),
448
- code: AssetCode(dto.code),
449
- name: dto.name,
450
- fractionalDigits: dto.fractional_digits
451
- })
452
- };
453
-
454
294
  // src/universal/types/blockchain/core.ts
455
295
  var ETHEREUM_CHAINS = {
456
296
  ethereum_mainnet: true,
@@ -513,8 +353,18 @@ var BlockchainAmount = Object.assign(
513
353
  {
514
354
  add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
515
355
  sub: (a, b) => combineAmounts(a, b, (x, y) => x - y),
516
- mul: multiplyAmounts,
517
- div: divideAmounts
356
+ /**
357
+ * `a * b`, in `a`'s decimals - a price times a quantity. Multiplies before
358
+ * it rescales, then truncates towards zero. The exact inverse of `div`.
359
+ */
360
+ mul: (a, b) => multiplyAmounts(a, b),
361
+ /**
362
+ * `a / b`, in `a`'s decimals - a price, a ratio. Rescales before it
363
+ * divides, then truncates towards zero.
364
+ *
365
+ * @throws MathError when `b` is zero.
366
+ */
367
+ div: (a, b) => divideAmounts(a, b)
518
368
  }
519
369
  );
520
370
  function multiplyAmounts(a, b) {
@@ -548,6 +398,66 @@ var StablecoinSymbol = (value) => value;
548
398
  var KnownAssetSymbol = StablecoinSymbol;
549
399
  var Bps = (value) => value;
550
400
 
401
+ // src/universal/core/shared/blockchain/math.ts
402
+ import { parseUnits } from "viem";
403
+ function blockchainAmountFromRawOrThrow({
404
+ label,
405
+ raw,
406
+ decimals
407
+ }) {
408
+ const trimmed = raw.trim();
409
+ if (trimmed === "") {
410
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
411
+ }
412
+ let value;
413
+ try {
414
+ value = BigInt(trimmed);
415
+ } catch {
416
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
417
+ }
418
+ try {
419
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
420
+ } catch {
421
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
422
+ }
423
+ }
424
+ function parseBlockchainAmount(amount, decimals) {
425
+ const trimmed = amount.trim();
426
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
427
+ if (trimmed.startsWith("-")) {
428
+ return { valid: false, reason: { type: "negative" } };
429
+ }
430
+ if (/[eE]/.test(trimmed)) {
431
+ return { valid: false, reason: { type: "invalid-format" } };
432
+ }
433
+ if (trimmed === ".") {
434
+ return { valid: false, reason: { type: "invalid-format" } };
435
+ }
436
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
437
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
438
+ return { valid: false, reason: { type: "invalid-format" } };
439
+ }
440
+ const [, fraction = ""] = normalised.split(".");
441
+ if (fraction.length > decimals) {
442
+ return {
443
+ valid: false,
444
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
445
+ };
446
+ }
447
+ try {
448
+ const raw = parseUnits(normalised, decimals);
449
+ if (raw > MAX_UINT_256) {
450
+ return { valid: false, reason: { type: "overflow" } };
451
+ }
452
+ return {
453
+ valid: true,
454
+ amount: BlockchainAmount({ raw, decimals })
455
+ };
456
+ } catch {
457
+ return { valid: false, reason: { type: "invalid-format" } };
458
+ }
459
+ }
460
+
551
461
  // src/universal/core/shared/utils/crypto.ts
552
462
  async function sha256(data) {
553
463
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
@@ -623,6 +533,12 @@ function requiredDate(value, field) {
623
533
  }
624
534
  return date;
625
535
  }
536
+ function dateOrNull(value, field) {
537
+ return value === null ? null : requiredDate(value, field);
538
+ }
539
+ function decimalOrNull(value) {
540
+ return value === null ? null : DecimalString(value);
541
+ }
626
542
  function requiredArray(value, field) {
627
543
  if (!Array.isArray(value)) {
628
544
  throw new ValidationError(
@@ -632,290 +548,240 @@ function requiredArray(value, field) {
632
548
  return value;
633
549
  }
634
550
 
635
- // src/universal/types/offer.ts
636
- var OfferId = (value) => value;
637
- var OfferSlug = (value) => value;
638
- var OFFER_TYPES = {
639
- "coinlist::token_sale": true,
640
- "superstate::swap": true,
641
- "ondo::swap": true
642
- };
643
- var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
644
- var OfferEditorial = {
645
- /**
646
- * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
647
- * the same three checks name the payload that failed them.
648
- */
649
- fromDto: (dto, model) => ({
650
- tagline: requiredString(dto.tagline, `${model}.tagline`),
651
- bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
652
- startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
551
+ // src/universal/types/providers/centrifuge/centrifuge.ts
552
+ var CentrifugeVaultStatus = {
553
+ fromDto: (dto) => ({
554
+ chain: EthereumChain(dto.chain),
555
+ symbol: AssetSymbol(dto.symbol),
556
+ vaultAddress: EvmContractAddress(dto.vault_address),
557
+ linked: dto.linked,
558
+ permissioned: dto.permissioned,
559
+ membershipValidUntil: dateOrNull(
560
+ dto.membership_valid_until,
561
+ "CentrifugeVaultStatus.membership_valid_until"
562
+ ),
563
+ halted: dto.halted,
564
+ priceUpdatedAt: dateOrNull(
565
+ dto.price_updated_at,
566
+ "CentrifugeVaultStatus.price_updated_at"
567
+ ),
568
+ orderability: parseOrderability(
569
+ dto.can_order,
570
+ dto.reasons,
571
+ "CentrifugeVaultStatus"
572
+ ),
573
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
653
574
  })
654
575
  };
655
- var Offer = {
576
+ var CentrifugeVaultBuyTransaction = {
656
577
  fromDto: (dto) => {
657
- const tokens = requiredArray(dto.tokens, "Offer.tokens");
658
- const base2 = {
659
- id: OfferId(dto.id),
660
- slug: OfferSlug(dto.slug),
661
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
662
- tokens: OfferToken.listFromDto(tokens)
578
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
579
+ label: "spend_input_amount",
580
+ raw: dto.spend_input_amount,
581
+ decimals: AssetDecimals(dto.spend_input_decimals)
582
+ });
583
+ if (spendInputAmount.raw <= 0n) {
584
+ throw new ValidationError(
585
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
586
+ );
587
+ }
588
+ return {
589
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
590
+ spendInputAmount
663
591
  };
664
- switch (dto.type) {
665
- case "coinlist::token_sale":
666
- return {
667
- ...base2,
668
- ...OfferEditorial.fromDto(dto, "Offer"),
669
- type: dto.type,
670
- logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
671
- };
672
- case "superstate::swap":
673
- return {
674
- ...base2,
675
- ...OfferEditorial.fromDto(dto, "Offer"),
676
- type: dto.type,
677
- logoUrl: notBlankStringOrNull(dto.logo_url)
678
- };
679
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
680
- // on the wire: copying them would hand every consumer a `startsAt` that
681
- // is 1970 for one variant and a date for the others.
682
- case "ondo::swap":
683
- return {
684
- ...base2,
685
- type: dto.type,
686
- logoUrl: notBlankStringOrNull(dto.logo_url)
687
- };
688
- default:
689
- return unknownTypeError(dto, "Offer");
690
- }
691
- },
692
- /**
693
- * Maps a page of offers, dropping every offer whose `type` this SDK does not
694
- * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
695
- * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
696
- * reject the whole page, so one offer of an unknown type would blank the
697
- * grid for every offer beside it. A single offer fetched by id still
698
- * throws, because there is nothing beside it to keep.
699
- */
700
- listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
701
- };
702
- var OfferToken = {
703
- fromDto: (dto) => ({
704
- role: dto.role,
705
- chain: Chain(dto.chain),
706
- address: EvmContractAddress(dto.address)
707
- }),
708
- /**
709
- * Maps an offer's token list, dropping every token on a chain this SDK does
710
- * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
711
- * plain `.map` would throw out of `Offer.fromDto` and, through
712
- * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
713
- * one Base token blanked production's offers list. Dropping costs that
714
- * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
715
- * so nobody could have looked it up anyway.
716
- *
717
- * Same shape as `TokenMetadata.fromRegistryDto`.
718
- */
719
- listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
592
+ }
720
593
  };
721
-
722
- // src/universal/types/trading.ts
723
- var Ticker = (value) => value;
724
- var Isin = (value) => value;
725
-
726
- // src/universal/types/offer-detail.ts
727
- var OfferOptionId = (value) => value;
728
- var OfferOptionSlug = (value) => value;
729
- var OfferSwapContract = {
594
+ var CentrifugeVaultClaimTransaction = {
730
595
  fromDto: (dto) => ({
731
- chain: Chain(dto.chain),
732
- address: EvmContractAddress(dto.address)
596
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
597
+ claimableShares: blockchainAmountFromRawOrThrow({
598
+ label: "claimable_shares",
599
+ raw: dto.claimable_shares,
600
+ decimals: AssetDecimals(dto.share_decimals)
601
+ })
733
602
  })
734
603
  };
735
- var OfferDetail = {
604
+ var CentrifugeVaultPosition = {
736
605
  fromDto: (dto) => {
737
- const fundingAssets = requiredArray(
738
- dto.funding_assets,
739
- "OfferDetail.funding_assets"
740
- );
741
- const options = requiredArray(dto.options, "OfferDetail.options");
742
- const terms = requiredArray(dto.terms, "OfferDetail.terms");
743
- const links = requiredArray(dto.links, "OfferDetail.links");
744
- const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
745
- const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
746
- const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
747
- const isin = notBlankStringOrNull(dto.isin);
748
- const ticker = notBlankStringOrNull(dto.ticker);
749
- const base2 = {
750
- id: OfferId(dto.id),
751
- slug: OfferSlug(dto.slug),
752
- name: dto.name,
753
- asset: Asset.fromDto(dto.asset),
754
- fundingAssets: fundingAssets.map(Asset.fromDto),
755
- tokens: OfferToken.listFromDto(tokens),
756
- about: notBlankStringOrNull(dto.about),
757
- category: dto.category,
758
- issuer: notBlankStringOrNull(dto.issuer),
759
- isin: isin === null ? null : Isin(isin),
760
- ticker: ticker === null ? null : Ticker(ticker),
761
- instrumentType: notBlankStringOrNull(dto.instrument_type),
762
- listingVenue: notBlankStringOrNull(dto.listing_venue),
763
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
764
- faqs: faqs.map(FaqItem.fromDto),
765
- links: links.map(Link.fromDto),
766
- milestones: milestones.map(Milestone.fromDto),
767
- options: options.map(OfferOption.fromDto),
768
- terms: terms.map(TermItem.fromDto)
606
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
607
+ const shareDecimals = AssetDecimals(dto.share_decimals);
608
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
609
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
610
+ return {
611
+ chain: EthereumChain(dto.chain),
612
+ symbol: AssetSymbol(dto.symbol),
613
+ walletAddress: EvmWalletAddress(dto.wallet_address),
614
+ status: dto.status,
615
+ requested: asset("requested", dto.requested),
616
+ pending: asset("pending", dto.pending),
617
+ filledAssets: asset("filled_assets", dto.filled_assets),
618
+ earnedShares: shares("earned_shares", dto.earned_shares),
619
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
620
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
621
+ shareBalance: shares("share_balance", dto.share_balance),
622
+ averagePrice: decimalOrNull(dto.average_price),
623
+ frozen: dto.frozen,
624
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
769
625
  };
770
- switch (dto.type) {
771
- case "coinlist::token_sale":
772
- return {
773
- ...base2,
774
- ...OfferEditorial.fromDto(dto, "OfferDetail"),
775
- type: dto.type,
776
- logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
777
- };
778
- case "superstate::swap":
779
- return {
780
- ...base2,
781
- ...OfferEditorial.fromDto(dto, "OfferDetail"),
782
- type: dto.type,
783
- logoUrl: notBlankStringOrNull(dto.logo_url)
784
- };
785
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
786
- // on the wire, as in `Offer.fromDto`.
787
- case "ondo::swap":
788
- return {
789
- ...base2,
790
- type: dto.type,
791
- logoUrl: notBlankStringOrNull(dto.logo_url),
792
- swapContracts: requiredArray(
793
- dto.swap_contracts,
794
- "OfferDetail.swap_contracts"
795
- ).map(OfferSwapContract.fromDto)
796
- };
797
- default:
798
- return unknownTypeError(dto, "OfferDetail");
799
- }
800
626
  }
801
627
  };
802
- var OfferOption = {
803
- fromDto: (dto) => ({
804
- id: OfferOptionId(dto.id),
805
- slug: OfferOptionSlug(dto.slug),
806
- bidIncrement: dto.bid_increment,
807
- floorPriceUsd: dto.floor_price_usd,
808
- minimumPurchaseUsd: dto.minimum_purchase_usd,
809
- priceUsd: dto.price_usd,
810
- saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
811
- totalTokenSupply: dto.total_token_supply
812
- })
813
- };
814
- var FaqItem = {
628
+ var CentrifugeVaultRedeemPosition = {
815
629
  fromDto: (dto) => ({
816
- question: notBlankStringOrNull(dto.question),
817
- answer: notBlankStringOrNull(dto.answer)
630
+ chain: EthereumChain(dto.chain),
631
+ symbol: AssetSymbol(dto.symbol),
632
+ walletAddress: EvmWalletAddress(dto.wallet_address),
633
+ status: dto.status,
634
+ pending: blockchainAmountFromRawOrThrow({
635
+ label: "pending",
636
+ raw: dto.pending,
637
+ decimals: AssetDecimals(dto.share_decimals)
638
+ }),
639
+ claimableAssets: blockchainAmountFromRawOrThrow({
640
+ label: "claimable_assets",
641
+ raw: dto.claimable_assets,
642
+ decimals: AssetDecimals(dto.asset_decimals)
643
+ }),
644
+ frozen: dto.frozen,
645
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
818
646
  })
819
647
  };
820
- var Link = {
821
- fromDto: (dto) => ({
822
- label: notBlankStringOrNull(dto.label),
823
- url: notBlankStringOrNull(dto.url)
824
- })
648
+ var CentrifugeVaultLeg = {
649
+ /**
650
+ * What a claim on the leg would collect: shares for `invest`, the funding
651
+ * token for `redeem`.
652
+ */
653
+ claimable: (leg) => {
654
+ switch (leg.direction) {
655
+ case "invest":
656
+ return leg.position.claimableShares;
657
+ case "redeem":
658
+ return leg.position.claimableAssets;
659
+ default: {
660
+ const exhaustive = leg;
661
+ return exhaustive;
662
+ }
663
+ }
664
+ },
665
+ /** Whether the leg has anything queued or anything ready to claim. */
666
+ isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
825
667
  };
826
- var TermItem = {
827
- fromDto: (dto) => ({
828
- key: notBlankStringOrNull(dto.key),
829
- value: notBlankStringOrNull(dto.value)
830
- })
668
+ var CentrifugeVaultLegId = {
669
+ /** Addresses compare case-insensitively: frontline echoes them lower case. */
670
+ of: (leg) => [
671
+ leg.direction,
672
+ leg.position.chain,
673
+ leg.position.walletAddress.toLowerCase()
674
+ ].join(":")
831
675
  };
832
- var Milestone = {
676
+ var CentrifugeVaultClaimProceedsTransaction = {
833
677
  fromDto: (dto) => ({
834
- name: notBlankStringOrNull(dto.name),
835
- schedule: notBlankStringOrNull(dto.schedule),
836
- status: dto.status
678
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
679
+ claimableAssets: blockchainAmountFromRawOrThrow({
680
+ label: "claimable_assets",
681
+ raw: dto.claimable_assets,
682
+ decimals: AssetDecimals(dto.asset_decimals)
683
+ })
837
684
  })
838
685
  };
839
-
840
- // src/universal/types/providers/coin-list/token-sale.ts
841
- var ParticipationId = (value) => value;
842
- var Blockchain = (value) => value;
843
- var WalletAddress = (value) => value;
844
- var ParticipationsPaginationParams = {
845
- toQueryParams: (params) => {
846
- const queryParams = PaginationParams.toQueryParams(params);
847
- if (params.offerId) {
848
- queryParams["filters[0][field]"] = "offer_id";
849
- queryParams["filters[0][op]"] = "==";
850
- queryParams["filters[0][value]"] = params.offerId;
686
+ function parseOrderability(canOrder, reasons, model) {
687
+ const [first, ...rest] = reasons;
688
+ if (canOrder) {
689
+ if (first !== void 0) {
690
+ throw new ValidationError(
691
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
692
+ );
851
693
  }
852
- return queryParams;
694
+ return { type: "orderable" };
853
695
  }
854
- };
855
- var Participation = {
856
- /** Maps API DTO shape into the SDK participation domain model. */
857
- fromDto: (dto) => {
858
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
859
- return {
860
- id: ParticipationId(dto.id),
861
- offerId: OfferId(dto.offer_id),
862
- offerOptionId: OfferOptionId(dto.offer_option_id),
863
- status: dto.status,
864
- amount: dto.amount,
865
- displayAmount: dto.amount_string,
866
- asset: Asset.fromDto(dto.asset),
867
- chain: Blockchain(dto.chain),
868
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
869
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
870
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
871
- };
696
+ if (first === void 0) {
697
+ throw new ValidationError(
698
+ `${model}.reasons: expected at least one when can_order is false`
699
+ );
872
700
  }
873
- };
874
- var CreateParticipationParams = {
875
- /** Maps participation creation params into API DTO payload. */
876
- toDto: (params) => ({
877
- offer_id: params.offerId,
878
- offer_option_id: params.offerOptionId,
879
- chain: params.chain,
880
- wallet_address: params.walletAddress,
881
- amount: params.amount,
882
- asset_id: params.assetId,
883
- approval_transaction_hash: params.approvalTransactionHash
884
- })
885
- };
886
-
887
- // src/universal/api/frontline/providers/coin-list/token-sale.ts
888
- async function fetchParticipations(api, offerId) {
889
- return fetchAllPages(
890
- (params) => fetchParticipationsPage(api, params),
891
- { offerId }
892
- );
701
+ return { type: "blocked", reasons: [first, ...rest] };
893
702
  }
894
- async function fetchParticipationsPage(api, params) {
895
- const pageDto = await api.send({
896
- method: "GET",
897
- url: "/v1/participations",
898
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
899
- attributes: Attributes.protected()
900
- });
901
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
703
+ function parseTransactionCore(dto, model) {
704
+ return {
705
+ tx: {
706
+ to: EvmContractAddress(dto.to),
707
+ data: HexEncodedTransactionData(dto.data)
708
+ },
709
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
710
+ };
902
711
  }
903
- async function fetchParticipation(api, id) {
712
+
713
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
714
+ async function getCentrifugeVaultStatus(api, params) {
904
715
  const dto = await api.send({
905
716
  method: "GET",
906
- url: `/v1/participations/${id}`,
717
+ url: "/v1/centrifuge/vault/status",
718
+ queryParams: {
719
+ symbol: params.symbol,
720
+ chain: params.chain
721
+ },
907
722
  attributes: Attributes.protected()
908
723
  });
909
- return Participation.fromDto(dto);
724
+ return CentrifugeVaultStatus.fromDto(dto);
910
725
  }
911
- async function createParticipation(api, params) {
726
+ async function buildCentrifugeVaultBuy(api, params) {
912
727
  const dto = await api.send({
913
728
  method: "POST",
914
- url: "/v1/participations",
915
- body: CreateParticipationParams.toDto(params),
729
+ url: "/v1/centrifuge/vault/invest",
730
+ body: {
731
+ ...walletFields(params),
732
+ amount: params.amount.raw.toString()
733
+ },
916
734
  attributes: Attributes.protected()
917
735
  });
918
- return Participation.fromDto(dto);
736
+ if (dto.spend_input_decimals !== params.amount.decimals) {
737
+ throw new ValidationError(
738
+ `spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
739
+ );
740
+ }
741
+ return CentrifugeVaultBuyTransaction.fromDto(dto);
742
+ }
743
+ async function getCentrifugeVaultPosition(api, params) {
744
+ const dto = await api.send({
745
+ method: "GET",
746
+ url: "/v1/centrifuge/vault/position",
747
+ queryParams: walletFields(params),
748
+ attributes: Attributes.protected()
749
+ });
750
+ return CentrifugeVaultPosition.fromDto(dto);
751
+ }
752
+ async function getCentrifugeVaultRedeemPosition(api, params) {
753
+ const dto = await api.send({
754
+ method: "GET",
755
+ url: "/v1/centrifuge/vault/redeem-position",
756
+ queryParams: walletFields(params),
757
+ attributes: Attributes.protected()
758
+ });
759
+ return CentrifugeVaultRedeemPosition.fromDto(dto);
760
+ }
761
+ async function createCentrifugeVaultClaim(api, params) {
762
+ const dto = await api.send({
763
+ method: "POST",
764
+ url: "/v1/centrifuge/vault/claim",
765
+ body: walletFields(params),
766
+ attributes: Attributes.protected()
767
+ });
768
+ return CentrifugeVaultClaimTransaction.fromDto(dto);
769
+ }
770
+ async function createCentrifugeVaultClaimProceeds(api, params) {
771
+ const dto = await api.send({
772
+ method: "POST",
773
+ url: "/v1/centrifuge/vault/claim-proceeds",
774
+ body: walletFields(params),
775
+ attributes: Attributes.protected()
776
+ });
777
+ return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
778
+ }
779
+ function walletFields(params) {
780
+ return {
781
+ symbol: params.symbol,
782
+ chain: params.chain,
783
+ wallet_address: params.walletAddress
784
+ };
919
785
  }
920
786
 
921
787
  // src/universal/core/shared/observability/log-cause.ts
@@ -1101,34 +967,46 @@ var noopInternalLogger = {
1101
967
  wrap: (_op, _params, run) => run()
1102
968
  };
1103
969
 
1104
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1105
- var CoinListTokenSaleNamespaceImpl = class {
970
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
971
+ var CentrifugeNamespaceImpl = class {
1106
972
  constructor(ctx) {
1107
973
  this.ctx = ctx;
1108
- this.log = internalLogger(ctx.logger, "TOKEN_SALE");
974
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
1109
975
  }
1110
- async list(offerId) {
1111
- return this.log.wrap("list", offerId, async () => {
976
+ async getVaultStatus(params) {
977
+ return this.log.wrap("getVaultStatus", params, async () => {
1112
978
  await this.ctx.ensureUserAuthenticated();
1113
- return fetchParticipations(this.ctx.api, offerId);
979
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1114
980
  });
1115
981
  }
1116
- async listPage(params) {
1117
- return this.log.wrap("listPage", params, async () => {
982
+ async getPosition(params) {
983
+ return this.log.wrap("getPosition", params, async () => {
1118
984
  await this.ctx.ensureUserAuthenticated();
1119
- return fetchParticipationsPage(this.ctx.api, params);
985
+ return getCentrifugeVaultPosition(this.ctx.api, params);
1120
986
  });
1121
987
  }
1122
- async get(id) {
1123
- return this.log.wrap("get", id, async () => {
988
+ async getRedeemPosition(params) {
989
+ return this.log.wrap("getRedeemPosition", params, async () => {
1124
990
  await this.ctx.ensureUserAuthenticated();
1125
- return fetchParticipation(this.ctx.api, id);
991
+ return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
1126
992
  });
1127
993
  }
1128
- async createParticipation(params) {
1129
- return this.log.wrap("createParticipation", params, async () => {
994
+ async createClaim(params) {
995
+ return this.log.wrap("createClaim", params, async () => {
1130
996
  await this.ctx.ensureUserAuthenticated();
1131
- return createParticipation(this.ctx.api, params);
997
+ return createCentrifugeVaultClaim(this.ctx.api, params);
998
+ });
999
+ }
1000
+ async createClaimProceeds(params) {
1001
+ return this.log.wrap("createClaimProceeds", params, async () => {
1002
+ await this.ctx.ensureUserAuthenticated();
1003
+ return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
1004
+ });
1005
+ }
1006
+ async buildBuyTransaction(params) {
1007
+ return this.log.wrap("buildBuyTransaction", params, async () => {
1008
+ await this.ctx.ensureUserAuthenticated();
1009
+ return buildCentrifugeVaultBuy(this.ctx.api, params);
1132
1010
  });
1133
1011
  }
1134
1012
  };
@@ -1249,6 +1127,435 @@ function formattedUsdPrice(amount, locale) {
1249
1127
  );
1250
1128
  }
1251
1129
 
1130
+ // src/universal/types/asset.ts
1131
+ var AssetId = (value) => value;
1132
+ var AssetCode = (value) => value;
1133
+ var Asset = {
1134
+ fromDto: (dto) => ({
1135
+ id: AssetId(dto.id),
1136
+ code: AssetCode(dto.code),
1137
+ name: dto.name,
1138
+ fractionalDigits: dto.fractional_digits
1139
+ })
1140
+ };
1141
+
1142
+ // src/universal/types/offer.ts
1143
+ var OfferId = (value) => value;
1144
+ var OfferSlug = (value) => value;
1145
+ var OFFER_TYPES = {
1146
+ "coinlist::token_sale": true,
1147
+ "superstate::swap": true,
1148
+ "ondo::swap": true,
1149
+ "centrifuge::vault": true
1150
+ };
1151
+ var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
1152
+ var OfferEditorial = {
1153
+ /**
1154
+ * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
1155
+ * the same three checks name the payload that failed them.
1156
+ */
1157
+ fromDto: (dto, model) => ({
1158
+ tagline: requiredString(dto.tagline, `${model}.tagline`),
1159
+ bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
1160
+ startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
1161
+ })
1162
+ };
1163
+ var Offer = {
1164
+ fromDto: (dto) => {
1165
+ const tokens = requiredArray(dto.tokens, "Offer.tokens");
1166
+ const base2 = {
1167
+ id: OfferId(dto.id),
1168
+ slug: OfferSlug(dto.slug),
1169
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1170
+ tokens: OfferToken.listFromDto(tokens)
1171
+ };
1172
+ switch (dto.type) {
1173
+ case "coinlist::token_sale":
1174
+ return {
1175
+ ...base2,
1176
+ ...OfferEditorial.fromDto(dto, "Offer"),
1177
+ type: dto.type,
1178
+ logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
1179
+ };
1180
+ case "superstate::swap":
1181
+ return {
1182
+ ...base2,
1183
+ ...OfferEditorial.fromDto(dto, "Offer"),
1184
+ type: dto.type,
1185
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1186
+ };
1187
+ // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
1188
+ // on the wire: copying them would hand every consumer a `startsAt` that
1189
+ // is 1970 for one variant and a date for the others.
1190
+ case "ondo::swap":
1191
+ case "centrifuge::vault":
1192
+ return {
1193
+ ...base2,
1194
+ type: dto.type,
1195
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1196
+ };
1197
+ default:
1198
+ return unknownTypeError(dto, "Offer");
1199
+ }
1200
+ },
1201
+ /**
1202
+ * Maps a page of offers, dropping every offer whose `type` this SDK does not
1203
+ * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
1204
+ * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
1205
+ * reject the whole page, so one offer of an unknown type would blank the
1206
+ * grid for every offer beside it. A single offer fetched by id still
1207
+ * throws, because there is nothing beside it to keep.
1208
+ */
1209
+ listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
1210
+ };
1211
+ var OfferToken = {
1212
+ fromDto: (dto) => ({
1213
+ role: dto.role,
1214
+ chain: Chain(dto.chain),
1215
+ address: EvmContractAddress(dto.address)
1216
+ }),
1217
+ /**
1218
+ * Maps an offer's token list, dropping every token on a chain this SDK does
1219
+ * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
1220
+ * plain `.map` would throw out of `Offer.fromDto` and, through
1221
+ * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
1222
+ * one Base token blanked production's offers list. Dropping costs that
1223
+ * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
1224
+ * so nobody could have looked it up anyway.
1225
+ *
1226
+ * Same shape as `TokenMetadata.fromRegistryDto`.
1227
+ */
1228
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
1229
+ };
1230
+
1231
+ // src/universal/types/trading.ts
1232
+ var Ticker = (value) => value;
1233
+ var Isin = (value) => value;
1234
+
1235
+ // src/universal/types/offer-detail.ts
1236
+ var AsyncOfferDetail = {
1237
+ /**
1238
+ * Narrows an offer fetched generically, e.g. on an offer page, to one with
1239
+ * something to claim.
1240
+ *
1241
+ * An exhaustive `switch` rather than a list of async types, so a new offer
1242
+ * type is a compile error here until someone decides whether it settles
1243
+ * later.
1244
+ */
1245
+ is: (offer) => {
1246
+ switch (offer.type) {
1247
+ case "centrifuge::vault":
1248
+ return true;
1249
+ case "ondo::swap":
1250
+ case "superstate::swap":
1251
+ case "coinlist::token_sale":
1252
+ return false;
1253
+ default: {
1254
+ const exhaustive = offer;
1255
+ return exhaustive;
1256
+ }
1257
+ }
1258
+ }
1259
+ };
1260
+ var OfferOptionId = (value) => value;
1261
+ var OfferOptionSlug = (value) => value;
1262
+ var OfferSwapContract = {
1263
+ fromDto: (dto) => ({
1264
+ chain: Chain(dto.chain),
1265
+ address: EvmContractAddress(dto.address)
1266
+ })
1267
+ };
1268
+ var OfferVaultContract = {
1269
+ fromDto: (dto) => ({
1270
+ chain: Chain(dto.chain),
1271
+ address: EvmContractAddress(dto.address)
1272
+ }),
1273
+ /**
1274
+ * Drops every proxy on a chain this SDK does not name, as
1275
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1276
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1277
+ * should not throw away the proxies the SDK can use.
1278
+ */
1279
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1280
+ };
1281
+ var OfferDetail = {
1282
+ fromDto: (dto) => {
1283
+ const fundingAssets = requiredArray(
1284
+ dto.funding_assets,
1285
+ "OfferDetail.funding_assets"
1286
+ );
1287
+ const options = requiredArray(dto.options, "OfferDetail.options");
1288
+ const terms = requiredArray(dto.terms, "OfferDetail.terms");
1289
+ const links = requiredArray(dto.links, "OfferDetail.links");
1290
+ const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
1291
+ const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
1292
+ const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
1293
+ const isin = notBlankStringOrNull(dto.isin);
1294
+ const ticker = notBlankStringOrNull(dto.ticker);
1295
+ const base2 = {
1296
+ id: OfferId(dto.id),
1297
+ slug: OfferSlug(dto.slug),
1298
+ name: dto.name,
1299
+ asset: Asset.fromDto(dto.asset),
1300
+ fundingAssets: fundingAssets.map(Asset.fromDto),
1301
+ tokens: OfferToken.listFromDto(tokens),
1302
+ about: notBlankStringOrNull(dto.about),
1303
+ category: dto.category,
1304
+ issuer: notBlankStringOrNull(dto.issuer),
1305
+ isin: isin === null ? null : Isin(isin),
1306
+ ticker: ticker === null ? null : Ticker(ticker),
1307
+ instrumentType: notBlankStringOrNull(dto.instrument_type),
1308
+ listingVenue: notBlankStringOrNull(dto.listing_venue),
1309
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1310
+ faqs: faqs.map(FaqItem.fromDto),
1311
+ links: links.map(Link.fromDto),
1312
+ milestones: milestones.map(Milestone.fromDto),
1313
+ options: options.map(OfferOption.fromDto),
1314
+ terms: terms.map(TermItem.fromDto)
1315
+ };
1316
+ switch (dto.type) {
1317
+ case "coinlist::token_sale":
1318
+ return {
1319
+ ...base2,
1320
+ ...OfferEditorial.fromDto(dto, "OfferDetail"),
1321
+ type: dto.type,
1322
+ logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
1323
+ };
1324
+ case "superstate::swap":
1325
+ return {
1326
+ ...base2,
1327
+ ...OfferEditorial.fromDto(dto, "OfferDetail"),
1328
+ type: dto.type,
1329
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1330
+ };
1331
+ // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
1332
+ // on the wire, as in `Offer.fromDto`.
1333
+ case "ondo::swap":
1334
+ return {
1335
+ ...base2,
1336
+ type: dto.type,
1337
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1338
+ swapContracts: requiredArray(
1339
+ dto.swap_contracts,
1340
+ "OfferDetail.swap_contracts"
1341
+ ).map(OfferSwapContract.fromDto)
1342
+ };
1343
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1344
+ // the same reason as `swap_contracts`: this is the spender a user
1345
+ // approves.
1346
+ case "centrifuge::vault":
1347
+ return {
1348
+ ...base2,
1349
+ type: dto.type,
1350
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1351
+ vaultContracts: OfferVaultContract.listFromDto(
1352
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1353
+ )
1354
+ };
1355
+ default:
1356
+ return unknownTypeError(dto, "OfferDetail");
1357
+ }
1358
+ }
1359
+ };
1360
+ var OfferOption = {
1361
+ fromDto: (dto) => ({
1362
+ id: OfferOptionId(dto.id),
1363
+ slug: OfferOptionSlug(dto.slug),
1364
+ bidIncrement: dto.bid_increment,
1365
+ floorPriceUsd: dto.floor_price_usd,
1366
+ minimumPurchaseUsd: dto.minimum_purchase_usd,
1367
+ priceUsd: dto.price_usd,
1368
+ saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
1369
+ totalTokenSupply: dto.total_token_supply
1370
+ })
1371
+ };
1372
+ var FaqItem = {
1373
+ fromDto: (dto) => ({
1374
+ question: notBlankStringOrNull(dto.question),
1375
+ answer: notBlankStringOrNull(dto.answer)
1376
+ })
1377
+ };
1378
+ var Link = {
1379
+ fromDto: (dto) => ({
1380
+ label: notBlankStringOrNull(dto.label),
1381
+ url: notBlankStringOrNull(dto.url)
1382
+ })
1383
+ };
1384
+ var TermItem = {
1385
+ fromDto: (dto) => ({
1386
+ key: notBlankStringOrNull(dto.key),
1387
+ value: notBlankStringOrNull(dto.value)
1388
+ })
1389
+ };
1390
+ var Milestone = {
1391
+ fromDto: (dto) => ({
1392
+ name: notBlankStringOrNull(dto.name),
1393
+ schedule: notBlankStringOrNull(dto.schedule),
1394
+ status: dto.status
1395
+ })
1396
+ };
1397
+
1398
+ // src/universal/types/pagination.ts
1399
+ var Cursor = (value) => value;
1400
+ var PaginatedResponse = {
1401
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1402
+ /**
1403
+ * For a mapper that decides the page as a whole - one that drops items it
1404
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1405
+ * cursors are the wire's either way: dropping an item changes what the
1406
+ * page holds, not where the next page starts.
1407
+ */
1408
+ fromDtoPage: (dto, pageMapper) => ({
1409
+ data: pageMapper(dto.data),
1410
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1411
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1412
+ })
1413
+ };
1414
+ var PaginationParams = {
1415
+ toQueryParams: (params) => {
1416
+ const queryParams = {};
1417
+ if (params.after) {
1418
+ queryParams.starting_after = params.after;
1419
+ }
1420
+ if (params.before) {
1421
+ queryParams.starting_before = params.before;
1422
+ }
1423
+ if (params.limit) {
1424
+ queryParams.limit = params.limit;
1425
+ }
1426
+ return queryParams;
1427
+ }
1428
+ };
1429
+
1430
+ // src/universal/types/providers/coin-list/token-sale.ts
1431
+ var ParticipationId = (value) => value;
1432
+ var Blockchain = (value) => value;
1433
+ var WalletAddress = (value) => value;
1434
+ var ParticipationsPaginationParams = {
1435
+ toQueryParams: (params) => {
1436
+ const queryParams = PaginationParams.toQueryParams(params);
1437
+ if (params.offerId) {
1438
+ queryParams["filters[0][field]"] = "offer_id";
1439
+ queryParams["filters[0][op]"] = "==";
1440
+ queryParams["filters[0][value]"] = params.offerId;
1441
+ }
1442
+ return queryParams;
1443
+ }
1444
+ };
1445
+ var Participation = {
1446
+ /** Maps API DTO shape into the SDK participation domain model. */
1447
+ fromDto: (dto) => {
1448
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
1449
+ return {
1450
+ id: ParticipationId(dto.id),
1451
+ offerId: OfferId(dto.offer_id),
1452
+ offerOptionId: OfferOptionId(dto.offer_option_id),
1453
+ status: dto.status,
1454
+ amount: dto.amount,
1455
+ displayAmount: dto.amount_string,
1456
+ asset: Asset.fromDto(dto.asset),
1457
+ chain: Blockchain(dto.chain),
1458
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1459
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1460
+ walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1461
+ };
1462
+ }
1463
+ };
1464
+ var CreateParticipationParams = {
1465
+ /** Maps participation creation params into API DTO payload. */
1466
+ toDto: (params) => ({
1467
+ offer_id: params.offerId,
1468
+ offer_option_id: params.offerOptionId,
1469
+ chain: params.chain,
1470
+ wallet_address: params.walletAddress,
1471
+ amount: params.amount,
1472
+ asset_id: params.assetId,
1473
+ approval_transaction_hash: params.approvalTransactionHash
1474
+ })
1475
+ };
1476
+
1477
+ // src/universal/api/pagination.ts
1478
+ async function fetchAllPages(fetchPage, baseParams) {
1479
+ const items = [];
1480
+ let cursor = null;
1481
+ do {
1482
+ const params = {
1483
+ ...baseParams ?? {},
1484
+ after: cursor ?? void 0
1485
+ };
1486
+ const page = await fetchPage(params);
1487
+ items.push(...page.data);
1488
+ cursor = page.startingAfter;
1489
+ } while (cursor);
1490
+ return items;
1491
+ }
1492
+
1493
+ // src/universal/api/frontline/providers/coin-list/token-sale.ts
1494
+ async function fetchParticipations(api, offerId) {
1495
+ return fetchAllPages(
1496
+ (params) => fetchParticipationsPage(api, params),
1497
+ { offerId }
1498
+ );
1499
+ }
1500
+ async function fetchParticipationsPage(api, params) {
1501
+ const pageDto = await api.send({
1502
+ method: "GET",
1503
+ url: "/v1/participations",
1504
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
1505
+ attributes: Attributes.protected()
1506
+ });
1507
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1508
+ }
1509
+ async function fetchParticipation(api, id) {
1510
+ const dto = await api.send({
1511
+ method: "GET",
1512
+ url: `/v1/participations/${id}`,
1513
+ attributes: Attributes.protected()
1514
+ });
1515
+ return Participation.fromDto(dto);
1516
+ }
1517
+ async function createParticipation(api, params) {
1518
+ const dto = await api.send({
1519
+ method: "POST",
1520
+ url: "/v1/participations",
1521
+ body: CreateParticipationParams.toDto(params),
1522
+ attributes: Attributes.protected()
1523
+ });
1524
+ return Participation.fromDto(dto);
1525
+ }
1526
+
1527
+ // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1528
+ var CoinListTokenSaleNamespaceImpl = class {
1529
+ constructor(ctx) {
1530
+ this.ctx = ctx;
1531
+ this.log = internalLogger(ctx.logger, "TOKEN_SALE");
1532
+ }
1533
+ async list(offerId) {
1534
+ return this.log.wrap("list", offerId, async () => {
1535
+ await this.ctx.ensureUserAuthenticated();
1536
+ return fetchParticipations(this.ctx.api, offerId);
1537
+ });
1538
+ }
1539
+ async listPage(params) {
1540
+ return this.log.wrap("listPage", params, async () => {
1541
+ await this.ctx.ensureUserAuthenticated();
1542
+ return fetchParticipationsPage(this.ctx.api, params);
1543
+ });
1544
+ }
1545
+ async get(id) {
1546
+ return this.log.wrap("get", id, async () => {
1547
+ await this.ctx.ensureUserAuthenticated();
1548
+ return fetchParticipation(this.ctx.api, id);
1549
+ });
1550
+ }
1551
+ async createParticipation(params) {
1552
+ return this.log.wrap("createParticipation", params, async () => {
1553
+ await this.ctx.ensureUserAuthenticated();
1554
+ return createParticipation(this.ctx.api, params);
1555
+ });
1556
+ }
1557
+ };
1558
+
1252
1559
  // src/universal/core/shared/blockchain/chain.ts
1253
1560
  import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
1254
1561
  var VIEM_CHAINS = {
@@ -1307,66 +1614,6 @@ function explorerBaseUrl(chain) {
1307
1614
  }
1308
1615
  }
1309
1616
 
1310
- // src/universal/core/shared/blockchain/math.ts
1311
- import { parseUnits } from "viem";
1312
- function blockchainAmountFromRawOrThrow({
1313
- label,
1314
- raw,
1315
- decimals
1316
- }) {
1317
- const trimmed = raw.trim();
1318
- if (trimmed === "") {
1319
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1320
- }
1321
- let value;
1322
- try {
1323
- value = BigInt(trimmed);
1324
- } catch {
1325
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1326
- }
1327
- try {
1328
- return BlockchainAmount({ raw: assertUint256(value), decimals });
1329
- } catch {
1330
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1331
- }
1332
- }
1333
- function parseBlockchainAmount(amount, decimals) {
1334
- const trimmed = amount.trim();
1335
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1336
- if (trimmed.startsWith("-")) {
1337
- return { valid: false, reason: { type: "negative" } };
1338
- }
1339
- if (/[eE]/.test(trimmed)) {
1340
- return { valid: false, reason: { type: "invalid-format" } };
1341
- }
1342
- if (trimmed === ".") {
1343
- return { valid: false, reason: { type: "invalid-format" } };
1344
- }
1345
- const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
1346
- if (!/^\d+(\.\d+)?$/.test(normalised)) {
1347
- return { valid: false, reason: { type: "invalid-format" } };
1348
- }
1349
- const [, fraction = ""] = normalised.split(".");
1350
- if (fraction.length > decimals) {
1351
- return {
1352
- valid: false,
1353
- reason: { type: "too-many-decimals", maxDecimals: decimals }
1354
- };
1355
- }
1356
- try {
1357
- const raw = parseUnits(normalised, decimals);
1358
- if (raw > MAX_UINT_256) {
1359
- return { valid: false, reason: { type: "overflow" } };
1360
- }
1361
- return {
1362
- valid: true,
1363
- amount: BlockchainAmount({ raw, decimals })
1364
- };
1365
- } catch {
1366
- return { valid: false, reason: { type: "invalid-format" } };
1367
- }
1368
- }
1369
-
1370
1617
  // src/universal/types/providers/ondo/ondo.ts
1371
1618
  var OndoTradingStatus = {
1372
1619
  fromDto: (dto) => {
@@ -1382,7 +1629,6 @@ var OndoTradingStatus = {
1382
1629
  };
1383
1630
  }
1384
1631
  };
1385
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
1386
1632
  var OndoQuote = {
1387
1633
  fromDto: (dto) => {
1388
1634
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -1660,6 +1906,101 @@ var OndoNamespaceImpl = class {
1660
1906
  }
1661
1907
  };
1662
1908
 
1909
+ // src/universal/types/providers/superstate/swap.ts
1910
+ var SwapPreview = {
1911
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
1912
+ fromContract: (preview) => ({
1913
+ inputAmount: parseUint256(preview.input, "SwapPreview.input"),
1914
+ fee: parseUint256(preview.fee, "SwapPreview.fee"),
1915
+ outputAmount: parseUint256(preview.output, "SwapPreview.output")
1916
+ })
1917
+ };
1918
+ var PauseFlags = (value) => value;
1919
+ var SwapStatus = {
1920
+ /**
1921
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
1922
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
1923
+ *
1924
+ * `flags` is carried onto the `paused` arm only. On the other two the
1925
+ * contract sets it to a self-identifying marker rather than to information -
1926
+ * so repeating it would invite a caller to read meaning into a constant.
1927
+ *
1928
+ * @throws ValidationError on a `state` outside the enum. A contract that has
1929
+ * grown a fourth state is one the SDK does not model, and guessing `active`
1930
+ * would let a halted swap read as a live one.
1931
+ */
1932
+ fromContract: (status) => {
1933
+ switch (status.state) {
1934
+ case 0:
1935
+ return { state: "active" };
1936
+ case 1:
1937
+ return { state: "paused", pausedLevels: PauseFlags(status.flags) };
1938
+ case 2:
1939
+ return { state: "stopped" };
1940
+ default:
1941
+ throw new ValidationError(
1942
+ `SwapStatus.state: unknown contract state (${status.state})`
1943
+ );
1944
+ }
1945
+ }
1946
+ };
1947
+ var AllowWalletResponse = {
1948
+ fromDto: (dto) => {
1949
+ switch (dto.action) {
1950
+ case "broadcast_transaction":
1951
+ return {
1952
+ action: "broadcast_transaction",
1953
+ to: EvmContractAddress(dto.to),
1954
+ data: HexEncodedTransactionData(dto.data)
1955
+ };
1956
+ case "none":
1957
+ return {
1958
+ action: "none",
1959
+ alreadyAllowed: dto.already_allowed
1960
+ };
1961
+ default: {
1962
+ const _exhaustive = dto;
1963
+ return _exhaustive;
1964
+ }
1965
+ }
1966
+ }
1967
+ };
1968
+
1969
+ // src/universal/core/checkout/superstate/blockchain/quote.ts
1970
+ var SwapQuote = {
1971
+ /**
1972
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
1973
+ * input and fee are denominated in the input token; the output in the output
1974
+ * token.
1975
+ */
1976
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
1977
+ inputTokenAmount: BlockchainAmount({
1978
+ raw: preview.inputAmount,
1979
+ decimals: inputDecimals
1980
+ }),
1981
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
1982
+ outputTokenAmount: BlockchainAmount({
1983
+ raw: preview.outputAmount,
1984
+ decimals: outputDecimals
1985
+ })
1986
+ })
1987
+ };
1988
+
1989
+ // src/universal/api/frontline/providers/superstate/swap.ts
1990
+ async function allowWallet(api, params) {
1991
+ const dto = await api.send({
1992
+ method: "POST",
1993
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
1994
+ body: {
1995
+ wallet_address: params.walletAddress,
1996
+ chain: params.chain,
1997
+ signature: params.signature
1998
+ },
1999
+ attributes: Attributes.protected()
2000
+ });
2001
+ return AllowWalletResponse.fromDto(dto);
2002
+ }
2003
+
1663
2004
  // src/universal/core/checkout/superstate/blockchain/abi.ts
1664
2005
  var SUPERSTATE_SWAP_ABI = [
1665
2006
  {
@@ -2513,100 +2854,125 @@ var SUPERSTATE_SWAP_ABI = [
2513
2854
  type: "error",
2514
2855
  name: "SwapFailed",
2515
2856
  inputs: [
2516
- {
2517
- name: "user",
2518
- type: "address",
2519
- internalType: "address"
2520
- },
2521
- {
2522
- name: "token",
2523
- type: "address",
2524
- internalType: "address"
2525
- }
2526
- ]
2857
+ {
2858
+ name: "user",
2859
+ type: "address",
2860
+ internalType: "address"
2861
+ },
2862
+ {
2863
+ name: "token",
2864
+ type: "address",
2865
+ internalType: "address"
2866
+ }
2867
+ ]
2868
+ },
2869
+ {
2870
+ type: "error",
2871
+ name: "Unauthorized",
2872
+ inputs: []
2873
+ }
2874
+ ];
2875
+
2876
+ // src/universal/core/shared/blockchain/erc20/abi.ts
2877
+ var ERC20_ABI = [
2878
+ {
2879
+ type: "function",
2880
+ name: "allowance",
2881
+ inputs: [
2882
+ { name: "owner", type: "address" },
2883
+ { name: "spender", type: "address" }
2884
+ ],
2885
+ outputs: [{ name: "", type: "uint256" }],
2886
+ stateMutability: "view"
2887
+ },
2888
+ {
2889
+ type: "function",
2890
+ name: "approve",
2891
+ inputs: [
2892
+ { name: "spender", type: "address" },
2893
+ { name: "amount", type: "uint256" }
2894
+ ],
2895
+ outputs: [{ name: "", type: "bool" }],
2896
+ stateMutability: "nonpayable"
2897
+ },
2898
+ {
2899
+ type: "function",
2900
+ name: "balanceOf",
2901
+ inputs: [{ name: "account", type: "address" }],
2902
+ outputs: [{ name: "", type: "uint256" }],
2903
+ stateMutability: "view"
2904
+ },
2905
+ {
2906
+ type: "function",
2907
+ name: "decimals",
2908
+ inputs: [],
2909
+ outputs: [{ name: "", type: "uint8" }],
2910
+ stateMutability: "view"
2911
+ },
2912
+ {
2913
+ type: "function",
2914
+ name: "name",
2915
+ inputs: [],
2916
+ outputs: [{ name: "", type: "string" }],
2917
+ stateMutability: "view"
2918
+ },
2919
+ {
2920
+ type: "function",
2921
+ name: "symbol",
2922
+ inputs: [],
2923
+ outputs: [{ name: "", type: "string" }],
2924
+ stateMutability: "view"
2925
+ },
2926
+ {
2927
+ type: "function",
2928
+ name: "totalSupply",
2929
+ inputs: [],
2930
+ outputs: [{ name: "", type: "uint256" }],
2931
+ stateMutability: "view"
2932
+ },
2933
+ {
2934
+ type: "function",
2935
+ name: "transfer",
2936
+ inputs: [
2937
+ { name: "recipient", type: "address" },
2938
+ { name: "amount", type: "uint256" }
2939
+ ],
2940
+ outputs: [{ name: "", type: "bool" }],
2941
+ stateMutability: "nonpayable"
2942
+ },
2943
+ {
2944
+ type: "function",
2945
+ name: "transferFrom",
2946
+ inputs: [
2947
+ { name: "sender", type: "address" },
2948
+ { name: "recipient", type: "address" },
2949
+ { name: "amount", type: "uint256" }
2950
+ ],
2951
+ outputs: [{ name: "", type: "bool" }],
2952
+ stateMutability: "nonpayable"
2953
+ },
2954
+ {
2955
+ type: "event",
2956
+ name: "Approval",
2957
+ inputs: [
2958
+ { name: "owner", type: "address", indexed: true },
2959
+ { name: "spender", type: "address", indexed: true },
2960
+ { name: "value", type: "uint256", indexed: false }
2961
+ ],
2962
+ anonymous: false
2527
2963
  },
2528
2964
  {
2529
- type: "error",
2530
- name: "Unauthorized",
2531
- inputs: []
2965
+ type: "event",
2966
+ name: "Transfer",
2967
+ inputs: [
2968
+ { name: "from", type: "address", indexed: true },
2969
+ { name: "to", type: "address", indexed: true },
2970
+ { name: "value", type: "uint256", indexed: false }
2971
+ ],
2972
+ anonymous: false
2532
2973
  }
2533
2974
  ];
2534
2975
 
2535
- // src/universal/types/providers/superstate/swap.ts
2536
- var SwapPreview = {
2537
- /** Maps the contract's `Preview { input, fee, output }` struct. */
2538
- fromContract: (preview) => ({
2539
- inputAmount: parseUint256(preview.input, "SwapPreview.input"),
2540
- fee: parseUint256(preview.fee, "SwapPreview.fee"),
2541
- outputAmount: parseUint256(preview.output, "SwapPreview.output")
2542
- })
2543
- };
2544
- var PauseFlags = (value) => value;
2545
- var SwapStatus = {
2546
- /**
2547
- * Maps the contract's `Status { uint32 flags; State state }` struct, where
2548
- * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2549
- *
2550
- * `flags` is carried onto the `paused` arm only. On the other two the
2551
- * contract sets it to a self-identifying marker rather than to information -
2552
- * so repeating it would invite a caller to read meaning into a constant.
2553
- *
2554
- * @throws ValidationError on a `state` outside the enum. A contract that has
2555
- * grown a fourth state is one the SDK does not model, and guessing `active`
2556
- * would let a halted swap read as a live one.
2557
- */
2558
- fromContract: (status) => {
2559
- switch (status.state) {
2560
- case 0:
2561
- return { state: "active" };
2562
- case 1:
2563
- return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2564
- case 2:
2565
- return { state: "stopped" };
2566
- default:
2567
- throw new ValidationError(
2568
- `SwapStatus.state: unknown contract state (${status.state})`
2569
- );
2570
- }
2571
- }
2572
- };
2573
- var AllowWalletResponse = {
2574
- fromDto: (dto) => {
2575
- switch (dto.action) {
2576
- case "broadcast_transaction":
2577
- return {
2578
- action: "broadcast_transaction",
2579
- to: EvmContractAddress(dto.to),
2580
- data: HexEncodedTransactionData(dto.data)
2581
- };
2582
- case "none":
2583
- return {
2584
- action: "none",
2585
- alreadyAllowed: dto.already_allowed
2586
- };
2587
- default: {
2588
- const _exhaustive = dto;
2589
- return _exhaustive;
2590
- }
2591
- }
2592
- }
2593
- };
2594
-
2595
- // src/universal/api/frontline/providers/superstate/swap.ts
2596
- async function allowWallet(api, params) {
2597
- const dto = await api.send({
2598
- method: "POST",
2599
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2600
- body: {
2601
- wallet_address: params.walletAddress,
2602
- chain: params.chain,
2603
- signature: params.signature
2604
- },
2605
- attributes: Attributes.protected()
2606
- });
2607
- return AllowWalletResponse.fromDto(dto);
2608
- }
2609
-
2610
2976
  // src/universal/api/rpc/providers/superstate/swap.ts
2611
2977
  async function getSwapAuthorization(clients, params) {
2612
2978
  return clients(params.chain).readContract({
@@ -2676,6 +3042,20 @@ var SuperstateSwapNamespaceImpl = class {
2676
3042
  async () => getSwapPreview(this.ctx.rpc, params)
2677
3043
  );
2678
3044
  }
3045
+ async getQuote(params) {
3046
+ return this.log.wrap("getQuote", params, async () => {
3047
+ const { amount, outputTokenDecimals, ...ref } = params;
3048
+ const preview = await getSwapPreview(this.ctx.rpc, {
3049
+ ...ref,
3050
+ amount: amount.raw
3051
+ });
3052
+ return SwapQuote.fromPreview(
3053
+ preview,
3054
+ amount.decimals,
3055
+ outputTokenDecimals
3056
+ );
3057
+ });
3058
+ }
2679
3059
  async getStatus(params) {
2680
3060
  return this.log.wrap(
2681
3061
  "getStatus",
@@ -2827,47 +3207,188 @@ async function fetchRequirementStatuses(api, offerId) {
2827
3207
  var RequirementsNamespaceImpl = class {
2828
3208
  constructor(ctx) {
2829
3209
  this.ctx = ctx;
2830
- this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3210
+ this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3211
+ }
3212
+ async forOffer(offerId) {
3213
+ return this.log.wrap("forOffer", offerId, async () => {
3214
+ await this.ctx.ensureUserAuthenticated();
3215
+ return fetchOfferRequirements(
3216
+ this.ctx.api,
3217
+ offerId,
3218
+ void 0
3219
+ );
3220
+ });
3221
+ }
3222
+ async statuses(offerId) {
3223
+ return this.log.wrap("statuses", offerId, async () => {
3224
+ await this.ctx.ensureUserAuthenticated();
3225
+ return fetchRequirementStatuses(this.ctx.api, offerId);
3226
+ });
3227
+ }
3228
+ async createKycToken(params) {
3229
+ return this.log.wrap("createKycToken", params, async () => {
3230
+ await this.ctx.ensureUserAuthenticated();
3231
+ return createKycToken(
3232
+ this.ctx.api,
3233
+ params?.levelName,
3234
+ params?.reset
3235
+ );
3236
+ });
3237
+ }
3238
+ async getPii() {
3239
+ return this.log.wrap("getPii", void 0, async () => {
3240
+ await this.ctx.ensureUserAuthenticated();
3241
+ return fetchPii(this.ctx.api);
3242
+ });
3243
+ }
3244
+ async submitDocument(params) {
3245
+ return this.log.wrap("submitDocument", params, async () => {
3246
+ await this.ctx.ensureUserAuthenticated();
3247
+ return submitDocument(
3248
+ this.ctx.api,
3249
+ params.documentType,
3250
+ params.fields
3251
+ );
3252
+ });
3253
+ }
3254
+ };
3255
+
3256
+ // src/universal/types/offer-option-address.ts
3257
+ var OfferOptionAddressId = (value) => value;
3258
+ var OfferOptionAddress = {
3259
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
3260
+ fromDto: (dto) => ({
3261
+ id: OfferOptionAddressId(dto.id),
3262
+ offerOptionId: OfferOptionId(dto.offer_option_id),
3263
+ address: EvmWalletAddress(dto.address),
3264
+ protocol: dto.protocol,
3265
+ createdAt: new Date(dto.created_at)
3266
+ })
3267
+ };
3268
+ var ConnectExternalWalletParams = {
3269
+ /** Maps connect-wallet params into the API DTO payload. */
3270
+ toDto: (params) => ({
3271
+ offer_option_id: params.offerOptionId,
3272
+ wallet_address: params.walletAddress,
3273
+ chain: params.chain,
3274
+ signature: params.signature
3275
+ })
3276
+ };
3277
+
3278
+ // src/universal/types/wallet-ownership-challenge.ts
3279
+ var WalletOwnershipChallenge = {
3280
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3281
+ fromDto: (dto) => ({
3282
+ message: dto.message,
3283
+ expiresAt: new Date(dto.expires_at)
3284
+ })
3285
+ };
3286
+ var CreateWalletOwnershipChallengeParams = {
3287
+ /**
3288
+ * Maps challenge-request params into the API DTO payload. The discriminated
3289
+ * union guarantees SIWE fields are present exactly when `challengeType` is
3290
+ * `siwe`, so the mapping narrows on the discriminant.
3291
+ */
3292
+ toDto: (params) => {
3293
+ switch (params.challengeType) {
3294
+ case "plain":
3295
+ return {
3296
+ wallet_address: params.walletAddress,
3297
+ chain: params.chain,
3298
+ challenge_type: "plain"
3299
+ };
3300
+ case "siwe":
3301
+ return {
3302
+ wallet_address: params.walletAddress,
3303
+ chain: params.chain,
3304
+ challenge_type: "siwe",
3305
+ domain: params.domain,
3306
+ uri: params.uri,
3307
+ statement: params.statement
3308
+ };
3309
+ default: {
3310
+ const _exhaustive = params;
3311
+ return _exhaustive;
3312
+ }
3313
+ }
3314
+ }
3315
+ };
3316
+
3317
+ // src/universal/api/frontline/wallet-connect.ts
3318
+ async function createWalletOwnershipChallenge(api, params) {
3319
+ const dto = await api.send({
3320
+ method: "POST",
3321
+ url: "/v1/wallet-ownership",
3322
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
3323
+ attributes: Attributes.protected()
3324
+ });
3325
+ return WalletOwnershipChallenge.fromDto(dto);
3326
+ }
3327
+ async function connectExternalWallet(api, params) {
3328
+ const dto = await api.send({
3329
+ method: "POST",
3330
+ url: `/v1/offers/${params.offerId}/addresses`,
3331
+ body: ConnectExternalWalletParams.toDto(params),
3332
+ attributes: Attributes.protected()
3333
+ });
3334
+ return OfferOptionAddress.fromDto(dto);
3335
+ }
3336
+ async function listOptionAddresses(api, offerId, offerOptionId) {
3337
+ const { data } = await api.send({
3338
+ method: "GET",
3339
+ url: `/v1/offers/${offerId}/addresses`,
3340
+ queryParams: { offer_option_id: offerOptionId },
3341
+ attributes: Attributes.protected()
3342
+ });
3343
+ return data.map(OfferOptionAddress.fromDto);
3344
+ }
3345
+ async function removeOptionAddress(api, offerId, addressId) {
3346
+ const dto = await api.send({
3347
+ method: "DELETE",
3348
+ url: `/v1/offers/${offerId}/addresses/${addressId}`,
3349
+ attributes: Attributes.protected()
3350
+ });
3351
+ return OfferOptionAddress.fromDto(dto);
3352
+ }
3353
+
3354
+ // src/universal/core/wallets/wallets-namespace.ts
3355
+ var WalletsNamespaceImpl = class {
3356
+ constructor(ctx) {
3357
+ this.ctx = ctx;
3358
+ this.log = internalLogger(ctx.logger, "WALLETS");
2831
3359
  }
2832
- async forOffer(offerId) {
2833
- return this.log.wrap("forOffer", offerId, async () => {
3360
+ async createOwnershipChallenge(params) {
3361
+ return this.log.wrap("createOwnershipChallenge", params, async () => {
2834
3362
  await this.ctx.ensureUserAuthenticated();
2835
- return fetchOfferRequirements(
3363
+ return createWalletOwnershipChallenge(
2836
3364
  this.ctx.api,
2837
- offerId,
2838
- void 0
3365
+ params
2839
3366
  );
2840
3367
  });
2841
3368
  }
2842
- async statuses(offerId) {
2843
- return this.log.wrap("statuses", offerId, async () => {
3369
+ async connectExternal(params) {
3370
+ return this.log.wrap("connectExternal", params, async () => {
2844
3371
  await this.ctx.ensureUserAuthenticated();
2845
- return fetchRequirementStatuses(this.ctx.api, offerId);
3372
+ return connectExternalWallet(this.ctx.api, params);
2846
3373
  });
2847
3374
  }
2848
- async createKycToken(params) {
2849
- return this.log.wrap("createKycToken", params, async () => {
3375
+ async list(params) {
3376
+ return this.log.wrap("list", params, async () => {
2850
3377
  await this.ctx.ensureUserAuthenticated();
2851
- return createKycToken(
3378
+ return listOptionAddresses(
2852
3379
  this.ctx.api,
2853
- params?.levelName,
2854
- params?.reset
3380
+ params.offerId,
3381
+ params.offerOptionId
2855
3382
  );
2856
3383
  });
2857
3384
  }
2858
- async getPii() {
2859
- return this.log.wrap("getPii", void 0, async () => {
2860
- await this.ctx.ensureUserAuthenticated();
2861
- return fetchPii(this.ctx.api);
2862
- });
2863
- }
2864
- async submitDocument(params) {
2865
- return this.log.wrap("submitDocument", params, async () => {
3385
+ async remove(params) {
3386
+ return this.log.wrap("remove", params, async () => {
2866
3387
  await this.ctx.ensureUserAuthenticated();
2867
- return submitDocument(
3388
+ return removeOptionAddress(
2868
3389
  this.ctx.api,
2869
- params.documentType,
2870
- params.fields
3390
+ params.offerId,
3391
+ params.addressId
2871
3392
  );
2872
3393
  });
2873
3394
  }
@@ -3295,163 +3816,6 @@ var TokensNamespaceImpl = class {
3295
3816
  }
3296
3817
  };
3297
3818
 
3298
- // src/universal/types/offer-option-address.ts
3299
- var OfferOptionAddressId = (value) => value;
3300
- var OfferOptionAddress = {
3301
- /** Maps the API DTO into the SDK offer-option-address domain model. */
3302
- fromDto: (dto) => ({
3303
- id: OfferOptionAddressId(dto.id),
3304
- offerOptionId: OfferOptionId(dto.offer_option_id),
3305
- address: EvmWalletAddress(dto.address),
3306
- protocol: dto.protocol,
3307
- createdAt: new Date(dto.created_at)
3308
- })
3309
- };
3310
- var ConnectExternalWalletParams = {
3311
- /** Maps connect-wallet params into the API DTO payload. */
3312
- toDto: (params) => ({
3313
- offer_option_id: params.offerOptionId,
3314
- wallet_address: params.walletAddress,
3315
- chain: params.chain,
3316
- signature: params.signature
3317
- })
3318
- };
3319
-
3320
- // src/universal/types/wallet-ownership-challenge.ts
3321
- var WalletOwnershipChallenge = {
3322
- /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3323
- fromDto: (dto) => ({
3324
- message: dto.message,
3325
- expiresAt: new Date(dto.expires_at)
3326
- })
3327
- };
3328
- var CreateWalletOwnershipChallengeParams = {
3329
- /**
3330
- * Maps challenge-request params into the API DTO payload. The discriminated
3331
- * union guarantees SIWE fields are present exactly when `challengeType` is
3332
- * `siwe`, so the mapping narrows on the discriminant.
3333
- */
3334
- toDto: (params) => {
3335
- switch (params.challengeType) {
3336
- case "plain":
3337
- return {
3338
- wallet_address: params.walletAddress,
3339
- chain: params.chain,
3340
- challenge_type: "plain"
3341
- };
3342
- case "siwe":
3343
- return {
3344
- wallet_address: params.walletAddress,
3345
- chain: params.chain,
3346
- challenge_type: "siwe",
3347
- domain: params.domain,
3348
- uri: params.uri,
3349
- statement: params.statement
3350
- };
3351
- default: {
3352
- const _exhaustive = params;
3353
- return _exhaustive;
3354
- }
3355
- }
3356
- }
3357
- };
3358
-
3359
- // src/universal/api/frontline/wallet-connect.ts
3360
- async function createWalletOwnershipChallenge(api, params) {
3361
- const dto = await api.send({
3362
- method: "POST",
3363
- url: "/v1/wallet-ownership",
3364
- body: CreateWalletOwnershipChallengeParams.toDto(params),
3365
- attributes: Attributes.protected()
3366
- });
3367
- return WalletOwnershipChallenge.fromDto(dto);
3368
- }
3369
- async function connectExternalWallet(api, params) {
3370
- const dto = await api.send({
3371
- method: "POST",
3372
- url: `/v1/offers/${params.offerId}/addresses`,
3373
- body: ConnectExternalWalletParams.toDto(params),
3374
- attributes: Attributes.protected()
3375
- });
3376
- return OfferOptionAddress.fromDto(dto);
3377
- }
3378
- async function listOptionAddresses(api, offerId, offerOptionId) {
3379
- const { data } = await api.send({
3380
- method: "GET",
3381
- url: `/v1/offers/${offerId}/addresses`,
3382
- queryParams: { offer_option_id: offerOptionId },
3383
- attributes: Attributes.protected()
3384
- });
3385
- return data.map(OfferOptionAddress.fromDto);
3386
- }
3387
- async function removeOptionAddress(api, offerId, addressId) {
3388
- const dto = await api.send({
3389
- method: "DELETE",
3390
- url: `/v1/offers/${offerId}/addresses/${addressId}`,
3391
- attributes: Attributes.protected()
3392
- });
3393
- return OfferOptionAddress.fromDto(dto);
3394
- }
3395
-
3396
- // src/universal/core/wallets/wallets-namespace.ts
3397
- var WalletsNamespaceImpl = class {
3398
- constructor(ctx) {
3399
- this.ctx = ctx;
3400
- this.log = internalLogger(ctx.logger, "WALLETS");
3401
- }
3402
- async createOwnershipChallenge(params) {
3403
- return this.log.wrap("createOwnershipChallenge", params, async () => {
3404
- await this.ctx.ensureUserAuthenticated();
3405
- return createWalletOwnershipChallenge(
3406
- this.ctx.api,
3407
- params
3408
- );
3409
- });
3410
- }
3411
- async connectExternal(params) {
3412
- return this.log.wrap("connectExternal", params, async () => {
3413
- await this.ctx.ensureUserAuthenticated();
3414
- return connectExternalWallet(this.ctx.api, params);
3415
- });
3416
- }
3417
- async list(params) {
3418
- return this.log.wrap("list", params, async () => {
3419
- await this.ctx.ensureUserAuthenticated();
3420
- return listOptionAddresses(
3421
- this.ctx.api,
3422
- params.offerId,
3423
- params.offerOptionId
3424
- );
3425
- });
3426
- }
3427
- async remove(params) {
3428
- return this.log.wrap("remove", params, async () => {
3429
- await this.ctx.ensureUserAuthenticated();
3430
- return removeOptionAddress(
3431
- this.ctx.api,
3432
- params.offerId,
3433
- params.addressId
3434
- );
3435
- });
3436
- }
3437
- };
3438
-
3439
- // src/universal/types/oauth-session.ts
3440
- var ClientCredentialsOAuth = (value) => value;
3441
- var OAuthRefreshToken = (value) => value;
3442
- var OAuthSession = {
3443
- fromDto: (dto) => {
3444
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
3445
- return {
3446
- accessToken: {
3447
- value: dto.access_token,
3448
- expiresAt
3449
- },
3450
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
3451
- };
3452
- }
3453
- };
3454
-
3455
3819
  // src/universal/api/frontline/offers.ts
3456
3820
  async function fetchOffers(api, clientCreds) {
3457
3821
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
@@ -3516,13 +3880,6 @@ export {
3516
3880
  Seconds,
3517
3881
  isExpired,
3518
3882
  ERC20_ABI,
3519
- fetchAllPages,
3520
- Cursor,
3521
- PaginatedResponse,
3522
- PaginationParams,
3523
- AssetId,
3524
- AssetCode,
3525
- Asset,
3526
3883
  ETHEREUM_CHAINS,
3527
3884
  EthereumChain,
3528
3885
  SOLANA_CHAINS,
@@ -3544,6 +3901,36 @@ export {
3544
3901
  StablecoinSymbol,
3545
3902
  KnownAssetSymbol,
3546
3903
  Bps,
3904
+ blockchainAmountFromRawOrThrow,
3905
+ parseBlockchainAmount,
3906
+ CentrifugeVaultStatus,
3907
+ CentrifugeVaultBuyTransaction,
3908
+ CentrifugeVaultClaimTransaction,
3909
+ CentrifugeVaultPosition,
3910
+ CentrifugeVaultRedeemPosition,
3911
+ CentrifugeVaultLeg,
3912
+ CentrifugeVaultLegId,
3913
+ CentrifugeVaultClaimProceedsTransaction,
3914
+ CentrifugeNamespaceImpl,
3915
+ FormattedAmountUi,
3916
+ FormattedPercentUi,
3917
+ TxExplorerUrl,
3918
+ ShortenedWalletAddress,
3919
+ FormattedAmountAssetUi,
3920
+ AssetIconUrl,
3921
+ shortenAddress,
3922
+ formatAmount,
3923
+ formatRawAmount,
3924
+ formatCompactAmount,
3925
+ formatBpsAsPercent,
3926
+ usdAmount,
3927
+ assetAmount,
3928
+ NA_AMOUNT_ASSET_UI,
3929
+ formatShareAmount,
3930
+ formattedUsdPrice,
3931
+ AssetId,
3932
+ AssetCode,
3933
+ Asset,
3547
3934
  OfferId,
3548
3935
  OfferSlug,
3549
3936
  isOfferType,
@@ -3552,15 +3939,20 @@ export {
3552
3939
  OfferToken,
3553
3940
  Ticker,
3554
3941
  Isin,
3942
+ AsyncOfferDetail,
3555
3943
  OfferOptionId,
3556
3944
  OfferOptionSlug,
3557
3945
  OfferSwapContract,
3946
+ OfferVaultContract,
3558
3947
  OfferDetail,
3559
3948
  OfferOption,
3560
3949
  FaqItem,
3561
3950
  Link,
3562
3951
  TermItem,
3563
3952
  Milestone,
3953
+ Cursor,
3954
+ PaginatedResponse,
3955
+ PaginationParams,
3564
3956
  ParticipationId,
3565
3957
  Blockchain,
3566
3958
  WalletAddress,
@@ -3568,29 +3960,11 @@ export {
3568
3960
  Participation,
3569
3961
  CreateParticipationParams,
3570
3962
  CoinListTokenSaleNamespaceImpl,
3571
- FormattedAmountUi,
3572
- FormattedPercentUi,
3573
- TxExplorerUrl,
3574
- ShortenedWalletAddress,
3575
- FormattedAmountAssetUi,
3576
- AssetIconUrl,
3577
- shortenAddress,
3578
- formatAmount,
3579
- formatRawAmount,
3580
- formatCompactAmount,
3581
- formatBpsAsPercent,
3582
- usdAmount,
3583
- assetAmount,
3584
- NA_AMOUNT_ASSET_UI,
3585
- formatShareAmount,
3586
- formattedUsdPrice,
3587
3963
  viemChain,
3588
3964
  getChainId,
3589
3965
  chainFromId,
3590
3966
  getNetworkName,
3591
3967
  txExplorerUrl,
3592
- blockchainAmountFromRawOrThrow,
3593
- parseBlockchainAmount,
3594
3968
  OndoTradingStatus,
3595
3969
  OndoQuote,
3596
3970
  OndoBuyTransaction,
@@ -3601,10 +3975,8 @@ export {
3601
3975
  PauseFlags,
3602
3976
  SwapStatus,
3603
3977
  AllowWalletResponse,
3978
+ SwapQuote,
3604
3979
  SuperstateSwapNamespaceImpl,
3605
- fetchOffers,
3606
- fetchOffersPage,
3607
- fetchOfferDetails,
3608
3980
  DocumentSubmission,
3609
3981
  KycToken,
3610
3982
  Iso2CountryCode,
@@ -3616,19 +3988,19 @@ export {
3616
3988
  RequirementStatusInfo,
3617
3989
  fetchOfferRequirements,
3618
3990
  RequirementsNamespaceImpl,
3619
- Erc20NamespaceImpl,
3620
- TokenLogoUrl,
3621
- TokenLogo,
3622
- TokenMetadata,
3623
- TokensNamespaceImpl,
3624
3991
  OfferOptionAddressId,
3625
3992
  OfferOptionAddress,
3626
3993
  ConnectExternalWalletParams,
3627
3994
  WalletOwnershipChallenge,
3628
3995
  CreateWalletOwnershipChallengeParams,
3629
3996
  WalletsNamespaceImpl,
3630
- ClientCredentialsOAuth,
3631
- OAuthRefreshToken,
3632
- OAuthSession
3997
+ fetchOffers,
3998
+ fetchOffersPage,
3999
+ fetchOfferDetails,
4000
+ Erc20NamespaceImpl,
4001
+ TokenLogoUrl,
4002
+ TokenLogo,
4003
+ TokenMetadata,
4004
+ TokensNamespaceImpl
3633
4005
  };
3634
- //# sourceMappingURL=chunk-BNMF2HMW.js.map
4006
+ //# sourceMappingURL=chunk-GOUUYOPZ.js.map