@coinlist-co/react 0.12.2-rc.9fb6364 → 0.12.2-rc.aa91ce3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-KRA6EM2L.js → chunk-3OTYQADF.js} +78 -4
  2. package/dist/chunk-3OTYQADF.js.map +1 -0
  3. package/dist/{chunk-BNMF2HMW.js → chunk-IAY3F42Q.js} +892 -512
  4. package/dist/chunk-IAY3F42Q.js.map +1 -0
  5. package/dist/{chunk-STAHYDLY.js → chunk-QRVIBG6H.js} +2 -2
  6. package/dist/client/index.cjs +5891 -3786
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +845 -30
  9. package/dist/client/index.d.ts +845 -30
  10. package/dist/client/index.js +2598 -910
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +361 -66
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +27 -5
  15. package/dist/server/index.d.ts +27 -5
  16. package/dist/server/index.js +9 -6
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/{tokens-namespace-BJfFeowE.d.cts → time-DyjvzWso.d.cts} +735 -59
  19. package/dist/{tokens-namespace-BJfFeowE.d.ts → time-DyjvzWso.d.ts} +735 -59
  20. package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-Bldj1r5X.d.ts} +74 -8
  21. package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-CbNCYP_5.d.cts} +74 -8
  22. package/dist/universal/index.cjs +848 -377
  23. package/dist/universal/index.cjs.map +1 -1
  24. package/dist/universal/index.d.cts +79 -6
  25. package/dist/universal/index.d.ts +79 -6
  26. package/dist/universal/index.js +36 -2
  27. package/package.json +1 -1
  28. package/dist/chunk-BNMF2HMW.js.map +0 -1
  29. package/dist/chunk-KRA6EM2L.js.map +0 -1
  30. package/dist/time-B5YOQxuh.d.ts +0 -50
  31. package/dist/time-BY3apBpc.d.cts +0 -50
  32. /package/dist/{chunk-STAHYDLY.js.map → chunk-QRVIBG6H.js.map} +0 -0
@@ -27,11 +27,23 @@ __export(universal_exports, {
27
27
  AssetIconUrl: () => AssetIconUrl,
28
28
  AssetId: () => AssetId,
29
29
  AssetSymbol: () => AssetSymbol,
30
+ AsyncOfferDetail: () => AsyncOfferDetail,
30
31
  AuthorizationCode: () => AuthorizationCode,
31
32
  BPS_DENOM: () => BPS_DENOM,
32
33
  Blockchain: () => Blockchain,
33
34
  BlockchainAmount: () => BlockchainAmount,
34
35
  Bps: () => Bps,
36
+ CENTRIFUGE_POLL_INTERVAL_MS: () => CENTRIFUGE_POLL_INTERVAL_MS,
37
+ CentrifugeNamespaceImpl: () => CentrifugeNamespaceImpl,
38
+ CentrifugeVaultBuyTransaction: () => CentrifugeVaultBuyTransaction,
39
+ CentrifugeVaultClaimProceedsTransaction: () => CentrifugeVaultClaimProceedsTransaction,
40
+ CentrifugeVaultClaimTransaction: () => CentrifugeVaultClaimTransaction,
41
+ CentrifugeVaultLeg: () => CentrifugeVaultLeg,
42
+ CentrifugeVaultLegId: () => CentrifugeVaultLegId,
43
+ CentrifugeVaultPosition: () => CentrifugeVaultPosition,
44
+ CentrifugeVaultQuote: () => CentrifugeVaultQuote,
45
+ CentrifugeVaultRedeemPosition: () => CentrifugeVaultRedeemPosition,
46
+ CentrifugeVaultStatus: () => CentrifugeVaultStatus,
35
47
  Chain: () => Chain,
36
48
  ClientCredentialsOAuth: () => ClientCredentialsOAuth,
37
49
  ClientId: () => ClientId,
@@ -78,6 +90,7 @@ __export(universal_exports, {
78
90
  NotImplementedError: () => NotImplementedError,
79
91
  OAuthRefreshToken: () => OAuthRefreshToken,
80
92
  OAuthSession: () => OAuthSession,
93
+ ONDO_NOT_TRADABLE_CODE: () => ONDO_NOT_TRADABLE_CODE,
81
94
  ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
82
95
  ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
83
96
  ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
@@ -94,6 +107,7 @@ __export(universal_exports, {
94
107
  OfferSlug: () => OfferSlug,
95
108
  OfferSwapContract: () => OfferSwapContract,
96
109
  OfferToken: () => OfferToken,
110
+ OfferVaultContract: () => OfferVaultContract,
97
111
  OffersNamespaceImpl: () => OffersNamespaceImpl,
98
112
  OndoBuyTransaction: () => OndoBuyTransaction,
99
113
  OndoNamespaceImpl: () => OndoNamespaceImpl,
@@ -152,6 +166,7 @@ __export(universal_exports, {
152
166
  ValidationError: () => ValidationError,
153
167
  WalletAddress: () => WalletAddress,
154
168
  WalletOwnershipChallenge: () => WalletOwnershipChallenge,
169
+ WalletSelection: () => WalletSelection,
155
170
  WalletsNamespaceImpl: () => WalletsNamespaceImpl,
156
171
  apiErrorCode: () => apiErrorCode,
157
172
  applyBps: () => applyBps,
@@ -178,11 +193,13 @@ __export(universal_exports, {
178
193
  isChain: () => isChain,
179
194
  isExpired: () => isExpired,
180
195
  isOfferType: () => isOfferType,
196
+ isOndoNotTradableError: () => isOndoNotTradableError,
181
197
  isSwapAvailable: () => isSwapAvailable,
182
198
  offerDisplayTokens: () => offerDisplayTokens,
183
199
  ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
184
200
  parseBlockchainAmount: () => parseBlockchainAmount,
185
201
  parseUint256: () => parseUint256,
202
+ resolveCentrifugeVaults: () => resolveCentrifugeVaults,
186
203
  shortenAddress: () => shortenAddress,
187
204
  superstateSwapContractAddress: () => superstateSwapContractAddress,
188
205
  swapSpender: () => swapSpender,
@@ -454,49 +471,8 @@ async function generatePKCEParams(config) {
454
471
  };
455
472
  }
456
473
 
457
- // src/universal/types/pagination.ts
458
- var Cursor = (value) => value;
459
- var PaginatedResponse = {
460
- fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
461
- /**
462
- * For a mapper that decides the page as a whole - one that drops items it
463
- * cannot map, such as `Offer.listFromDto` - rather than item by item. The
464
- * cursors are the wire's either way: dropping an item changes what the
465
- * page holds, not where the next page starts.
466
- */
467
- fromDtoPage: (dto, pageMapper) => ({
468
- data: pageMapper(dto.data),
469
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
470
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
471
- })
472
- };
473
- var PaginationParams = {
474
- toQueryParams: (params) => {
475
- const queryParams = {};
476
- if (params.after) {
477
- queryParams.starting_after = params.after;
478
- }
479
- if (params.before) {
480
- queryParams.starting_before = params.before;
481
- }
482
- if (params.limit) {
483
- queryParams.limit = params.limit;
484
- }
485
- return queryParams;
486
- }
487
- };
488
-
489
- // src/universal/types/asset.ts
490
- var AssetId = (value) => value;
491
- var AssetCode = (value) => value;
492
- var Asset = {
493
- fromDto: (dto) => ({
494
- id: AssetId(dto.id),
495
- code: AssetCode(dto.code),
496
- name: dto.name,
497
- fractionalDigits: dto.fractional_digits
498
- })
499
- };
474
+ // src/universal/core/shared/blockchain/math.ts
475
+ var import_viem = require("viem");
500
476
 
501
477
  // src/universal/types/errors.ts
502
478
  var NotImplementedError = class extends Error {
@@ -530,40 +506,6 @@ var MathError = class extends Error {
530
506
  }
531
507
  };
532
508
 
533
- // src/universal/core/shared/utils/wire.ts
534
- function unknownTypeError(dto, model) {
535
- const type = dto.type;
536
- throw new ValidationError(
537
- `${model}.type: unknown type ${JSON.stringify(type)}`
538
- );
539
- }
540
- function requiredString(value, field) {
541
- const text = notBlankStringOrNull(value);
542
- if (text === null) {
543
- throw new ValidationError(
544
- `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
545
- );
546
- }
547
- return text;
548
- }
549
- function requiredDate(value, field) {
550
- const date = typeof value === "string" ? new Date(value) : null;
551
- if (date === null || Number.isNaN(date.getTime())) {
552
- throw new ValidationError(
553
- `${field}: expected a date, got ${JSON.stringify(value)}`
554
- );
555
- }
556
- return date;
557
- }
558
- function requiredArray(value, field) {
559
- if (!Array.isArray(value)) {
560
- throw new ValidationError(
561
- `${field}: expected an array, got ${typeof value}`
562
- );
563
- }
564
- return value;
565
- }
566
-
567
509
  // src/universal/types/blockchain/core.ts
568
510
  var ETHEREUM_CHAINS = {
569
511
  ethereum_mainnet: true,
@@ -661,74 +603,743 @@ var StablecoinSymbol = (value) => value;
661
603
  var KnownAssetSymbol = StablecoinSymbol;
662
604
  var Bps = (value) => value;
663
605
 
664
- // src/universal/types/offer.ts
665
- var OfferId = (value) => value;
666
- var OfferSlug = (value) => value;
667
- var OFFER_TYPES = {
668
- "coinlist::token_sale": true,
669
- "superstate::swap": true,
670
- "ondo::swap": true
606
+ // src/universal/core/shared/blockchain/math.ts
607
+ function blockchainAmountFromRawOrThrow({
608
+ label,
609
+ raw,
610
+ decimals
611
+ }) {
612
+ const trimmed = raw.trim();
613
+ if (trimmed === "") {
614
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
615
+ }
616
+ let value;
617
+ try {
618
+ value = BigInt(trimmed);
619
+ } catch {
620
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
621
+ }
622
+ try {
623
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
624
+ } catch {
625
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
626
+ }
627
+ }
628
+ function parseBlockchainAmount(amount, decimals) {
629
+ const trimmed = amount.trim();
630
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
631
+ if (trimmed.startsWith("-")) {
632
+ return { valid: false, reason: { type: "negative" } };
633
+ }
634
+ if (/[eE]/.test(trimmed)) {
635
+ return { valid: false, reason: { type: "invalid-format" } };
636
+ }
637
+ if (trimmed === ".") {
638
+ return { valid: false, reason: { type: "invalid-format" } };
639
+ }
640
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
641
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
642
+ return { valid: false, reason: { type: "invalid-format" } };
643
+ }
644
+ const [, fraction = ""] = normalised.split(".");
645
+ if (fraction.length > decimals) {
646
+ return {
647
+ valid: false,
648
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
649
+ };
650
+ }
651
+ try {
652
+ const raw = (0, import_viem.parseUnits)(normalised, decimals);
653
+ if (raw > MAX_UINT_256) {
654
+ return { valid: false, reason: { type: "overflow" } };
655
+ }
656
+ return {
657
+ valid: true,
658
+ amount: BlockchainAmount({ raw, decimals })
659
+ };
660
+ } catch {
661
+ return { valid: false, reason: { type: "invalid-format" } };
662
+ }
663
+ }
664
+
665
+ // src/universal/core/shared/utils/wire.ts
666
+ function unknownTypeError(dto, model) {
667
+ const type = dto.type;
668
+ throw new ValidationError(
669
+ `${model}.type: unknown type ${JSON.stringify(type)}`
670
+ );
671
+ }
672
+ function requiredString(value, field) {
673
+ const text = notBlankStringOrNull(value);
674
+ if (text === null) {
675
+ throw new ValidationError(
676
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
677
+ );
678
+ }
679
+ return text;
680
+ }
681
+ function requiredDate(value, field) {
682
+ const date = typeof value === "string" ? new Date(value) : null;
683
+ if (date === null || Number.isNaN(date.getTime())) {
684
+ throw new ValidationError(
685
+ `${field}: expected a date, got ${JSON.stringify(value)}`
686
+ );
687
+ }
688
+ return date;
689
+ }
690
+ function dateOrNull(value, field) {
691
+ return value === null ? null : requiredDate(value, field);
692
+ }
693
+ function decimalOrNull(value) {
694
+ return value === null ? null : DecimalString(value);
695
+ }
696
+ function requiredArray(value, field) {
697
+ if (!Array.isArray(value)) {
698
+ throw new ValidationError(
699
+ `${field}: expected an array, got ${typeof value}`
700
+ );
701
+ }
702
+ return value;
703
+ }
704
+
705
+ // src/universal/types/providers/centrifuge/centrifuge.ts
706
+ var CentrifugeVaultQuote = {
707
+ fromDto: (dto) => {
708
+ const spendDecimals = AssetDecimals(dto.spend_input_decimals);
709
+ const shareDecimals = AssetDecimals(dto.share_decimals);
710
+ return {
711
+ chain: EthereumChain(dto.chain),
712
+ symbol: AssetSymbol(dto.symbol),
713
+ spendInputAmount: blockchainAmountFromRawOrThrow({
714
+ label: "spend_input_amount",
715
+ raw: dto.spend_input_amount,
716
+ decimals: spendDecimals
717
+ }),
718
+ estimatedShares: blockchainAmountFromRawOrThrow({
719
+ label: "estimated_shares",
720
+ raw: dto.estimated_shares,
721
+ decimals: shareDecimals
722
+ }),
723
+ indicativePrice: decimalOrNull(dto.indicative_price),
724
+ minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
725
+ label: "minimum_input_amount",
726
+ raw: dto.minimum_input_amount,
727
+ decimals: spendDecimals
728
+ }),
729
+ orderability: parseOrderability(
730
+ dto.can_order,
731
+ dto.reasons,
732
+ "CentrifugeVaultQuote"
733
+ )
734
+ };
735
+ }
671
736
  };
672
- var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
673
- var OfferEditorial = {
674
- /**
675
- * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
676
- * the same three checks name the payload that failed them.
677
- */
678
- fromDto: (dto, model) => ({
679
- tagline: requiredString(dto.tagline, `${model}.tagline`),
680
- bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
681
- startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
737
+ var CentrifugeVaultStatus = {
738
+ fromDto: (dto) => ({
739
+ chain: EthereumChain(dto.chain),
740
+ symbol: AssetSymbol(dto.symbol),
741
+ vaultAddress: EvmContractAddress(dto.vault_address),
742
+ linked: dto.linked,
743
+ permissioned: dto.permissioned,
744
+ membershipValidUntil: dateOrNull(
745
+ dto.membership_valid_until,
746
+ "CentrifugeVaultStatus.membership_valid_until"
747
+ ),
748
+ halted: dto.halted,
749
+ priceUpdatedAt: dateOrNull(
750
+ dto.price_updated_at,
751
+ "CentrifugeVaultStatus.price_updated_at"
752
+ ),
753
+ orderability: parseOrderability(
754
+ dto.can_order,
755
+ dto.reasons,
756
+ "CentrifugeVaultStatus"
757
+ ),
758
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
682
759
  })
683
760
  };
684
- var Offer = {
761
+ var CentrifugeVaultBuyTransaction = {
685
762
  fromDto: (dto) => {
686
- const tokens = requiredArray(dto.tokens, "Offer.tokens");
687
- const base2 = {
688
- id: OfferId(dto.id),
689
- slug: OfferSlug(dto.slug),
690
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
691
- tokens: OfferToken.listFromDto(tokens)
692
- };
693
- switch (dto.type) {
694
- case "coinlist::token_sale":
695
- return {
696
- ...base2,
697
- ...OfferEditorial.fromDto(dto, "Offer"),
698
- type: dto.type,
699
- logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
700
- };
701
- case "superstate::swap":
702
- return {
703
- ...base2,
704
- ...OfferEditorial.fromDto(dto, "Offer"),
705
- type: dto.type,
706
- logoUrl: notBlankStringOrNull(dto.logo_url)
707
- };
708
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
709
- // on the wire: copying them would hand every consumer a `startsAt` that
710
- // is 1970 for one variant and a date for the others.
711
- case "ondo::swap":
712
- return {
713
- ...base2,
714
- type: dto.type,
715
- logoUrl: notBlankStringOrNull(dto.logo_url)
716
- };
717
- default:
718
- return unknownTypeError(dto, "Offer");
763
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
764
+ label: "spend_input_amount",
765
+ raw: dto.spend_input_amount,
766
+ decimals: AssetDecimals(dto.spend_input_decimals)
767
+ });
768
+ if (spendInputAmount.raw <= 0n) {
769
+ throw new ValidationError(
770
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
771
+ );
719
772
  }
720
- },
721
- /**
722
- * Maps a page of offers, dropping every offer whose `type` this SDK does not
723
- * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
724
- * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
725
- * reject the whole page, so one offer of an unknown type would blank the
726
- * grid for every offer beside it. A single offer fetched by id still
727
- * throws, because there is nothing beside it to keep.
728
- */
729
- listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
773
+ return {
774
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
775
+ spendInputAmount,
776
+ estimatedShares: blockchainAmountFromRawOrThrow({
777
+ label: "estimated_shares",
778
+ raw: dto.estimated_shares,
779
+ decimals: AssetDecimals(dto.share_decimals)
780
+ })
781
+ };
782
+ }
730
783
  };
731
- var OfferToken = {
784
+ var CentrifugeVaultClaimTransaction = {
785
+ fromDto: (dto) => ({
786
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
787
+ claimableShares: blockchainAmountFromRawOrThrow({
788
+ label: "claimable_shares",
789
+ raw: dto.claimable_shares,
790
+ decimals: AssetDecimals(dto.share_decimals)
791
+ })
792
+ })
793
+ };
794
+ var CentrifugeVaultPosition = {
795
+ fromDto: (dto) => {
796
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
797
+ const shareDecimals = AssetDecimals(dto.share_decimals);
798
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
799
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
800
+ return {
801
+ chain: EthereumChain(dto.chain),
802
+ symbol: AssetSymbol(dto.symbol),
803
+ walletAddress: EvmWalletAddress(dto.wallet_address),
804
+ status: dto.status,
805
+ requested: asset("requested", dto.requested),
806
+ pending: asset("pending", dto.pending),
807
+ filledAssets: asset("filled_assets", dto.filled_assets),
808
+ earnedShares: shares("earned_shares", dto.earned_shares),
809
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
810
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
811
+ shareBalance: shares("share_balance", dto.share_balance),
812
+ averagePrice: decimalOrNull(dto.average_price),
813
+ frozen: dto.frozen,
814
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
815
+ };
816
+ }
817
+ };
818
+ var CentrifugeVaultRedeemPosition = {
819
+ fromDto: (dto) => ({
820
+ chain: EthereumChain(dto.chain),
821
+ symbol: AssetSymbol(dto.symbol),
822
+ walletAddress: EvmWalletAddress(dto.wallet_address),
823
+ status: dto.status,
824
+ pending: blockchainAmountFromRawOrThrow({
825
+ label: "pending",
826
+ raw: dto.pending,
827
+ decimals: AssetDecimals(dto.share_decimals)
828
+ }),
829
+ claimableAssets: blockchainAmountFromRawOrThrow({
830
+ label: "claimable_assets",
831
+ raw: dto.claimable_assets,
832
+ decimals: AssetDecimals(dto.asset_decimals)
833
+ }),
834
+ frozen: dto.frozen,
835
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
836
+ })
837
+ };
838
+ var CentrifugeVaultLeg = {
839
+ /**
840
+ * What a claim on the leg would collect: shares for `invest`, the funding
841
+ * token for `redeem`.
842
+ */
843
+ claimable: (leg) => {
844
+ switch (leg.direction) {
845
+ case "invest":
846
+ return leg.position.claimableShares;
847
+ case "redeem":
848
+ return leg.position.claimableAssets;
849
+ default: {
850
+ const exhaustive = leg;
851
+ return exhaustive;
852
+ }
853
+ }
854
+ },
855
+ /** Whether the leg has anything queued or anything ready to claim. */
856
+ isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
857
+ };
858
+ var CentrifugeVaultLegId = {
859
+ /** Addresses compare case-insensitively: frontline echoes them lower case. */
860
+ of: (leg) => [
861
+ leg.direction,
862
+ leg.position.chain,
863
+ leg.position.walletAddress.toLowerCase()
864
+ ].join(":")
865
+ };
866
+ var CentrifugeVaultClaimProceedsTransaction = {
867
+ fromDto: (dto) => ({
868
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
869
+ claimableAssets: blockchainAmountFromRawOrThrow({
870
+ label: "claimable_assets",
871
+ raw: dto.claimable_assets,
872
+ decimals: AssetDecimals(dto.asset_decimals)
873
+ })
874
+ })
875
+ };
876
+ function parseOrderability(canOrder, reasons, model) {
877
+ const [first, ...rest] = reasons;
878
+ if (canOrder) {
879
+ if (first !== void 0) {
880
+ throw new ValidationError(
881
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
882
+ );
883
+ }
884
+ return { type: "orderable" };
885
+ }
886
+ if (first === void 0) {
887
+ throw new ValidationError(
888
+ `${model}.reasons: expected at least one when can_order is false`
889
+ );
890
+ }
891
+ return { type: "blocked", reasons: [first, ...rest] };
892
+ }
893
+ function parseTransactionCore(dto, model) {
894
+ return {
895
+ tx: {
896
+ to: EvmContractAddress(dto.to),
897
+ data: HexEncodedTransactionData(dto.data)
898
+ },
899
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
900
+ };
901
+ }
902
+
903
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
904
+ async function getCentrifugeVaultQuote(api, params) {
905
+ const dto = await api.send({
906
+ method: "GET",
907
+ url: "/v1/centrifuge/vault/quote",
908
+ queryParams: {
909
+ symbol: params.symbol,
910
+ chain: params.chain,
911
+ amount: params.amount.raw.toString()
912
+ },
913
+ attributes: Attributes.protected()
914
+ });
915
+ return CentrifugeVaultQuote.fromDto(dto);
916
+ }
917
+ async function getCentrifugeVaultStatus(api, params) {
918
+ const dto = await api.send({
919
+ method: "GET",
920
+ url: "/v1/centrifuge/vault/status",
921
+ queryParams: {
922
+ symbol: params.symbol,
923
+ chain: params.chain
924
+ },
925
+ attributes: Attributes.protected()
926
+ });
927
+ return CentrifugeVaultStatus.fromDto(dto);
928
+ }
929
+ async function getCentrifugeVaultPosition(api, params) {
930
+ const dto = await api.send({
931
+ method: "GET",
932
+ url: "/v1/centrifuge/vault/position",
933
+ queryParams: walletFields(params),
934
+ attributes: Attributes.protected()
935
+ });
936
+ return CentrifugeVaultPosition.fromDto(dto);
937
+ }
938
+ async function getCentrifugeVaultRedeemPosition(api, params) {
939
+ const dto = await api.send({
940
+ method: "GET",
941
+ url: "/v1/centrifuge/vault/redeem-position",
942
+ queryParams: walletFields(params),
943
+ attributes: Attributes.protected()
944
+ });
945
+ return CentrifugeVaultRedeemPosition.fromDto(dto);
946
+ }
947
+ async function createCentrifugeVaultClaim(api, params) {
948
+ const dto = await api.send({
949
+ method: "POST",
950
+ url: "/v1/centrifuge/vault/claim",
951
+ body: walletFields(params),
952
+ attributes: Attributes.protected()
953
+ });
954
+ return CentrifugeVaultClaimTransaction.fromDto(dto);
955
+ }
956
+ async function createCentrifugeVaultClaimProceeds(api, params) {
957
+ const dto = await api.send({
958
+ method: "POST",
959
+ url: "/v1/centrifuge/vault/claim-proceeds",
960
+ body: walletFields(params),
961
+ attributes: Attributes.protected()
962
+ });
963
+ return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
964
+ }
965
+ function walletFields(params) {
966
+ return {
967
+ symbol: params.symbol,
968
+ chain: params.chain,
969
+ wallet_address: params.walletAddress
970
+ };
971
+ }
972
+
973
+ // src/universal/core/shared/observability/log-cause.ts
974
+ var import_viem2 = require("viem");
975
+ function classifyLogCause(error) {
976
+ if (error instanceof HttpError) {
977
+ return httpCause(error);
978
+ }
979
+ if (error instanceof ValidationError) {
980
+ return { type: "validation", message: error.message };
981
+ }
982
+ if (error instanceof InvariantError) {
983
+ return { type: "invariant", message: error.message };
984
+ }
985
+ if (error instanceof MathError) {
986
+ return { type: "math", message: error.message };
987
+ }
988
+ if (error instanceof NotAuthenticatedError) {
989
+ return { type: "not-authenticated" };
990
+ }
991
+ if (error instanceof NotImplementedError) {
992
+ return { type: "not-implemented" };
993
+ }
994
+ if (error instanceof import_viem2.BaseError) {
995
+ const http = error.walk((e) => e instanceof HttpError);
996
+ if (http instanceof HttpError) {
997
+ return httpCause(http);
998
+ }
999
+ return { type: "rpc", reason: rpcFailureReason(error) };
1000
+ }
1001
+ return { type: "generic-error", name: errorName(error) };
1002
+ }
1003
+ function rpcFailureReason(error) {
1004
+ if (error.walk((e) => e instanceof import_viem2.ContractFunctionRevertedError)) {
1005
+ return "reverted";
1006
+ }
1007
+ if (error.walk((e) => e instanceof import_viem2.RpcError)) {
1008
+ return "node-rejected";
1009
+ }
1010
+ if (error.walk(
1011
+ (e) => e instanceof import_viem2.HttpRequestError || e instanceof import_viem2.WebSocketRequestError || e instanceof import_viem2.SocketClosedError || e instanceof import_viem2.TimeoutError
1012
+ )) {
1013
+ return "transport";
1014
+ }
1015
+ if (error instanceof import_viem2.ContractFunctionExecutionError) {
1016
+ return "malformed-response";
1017
+ }
1018
+ return "unknown";
1019
+ }
1020
+ function describeErrorUnredacted(error) {
1021
+ if (error instanceof HttpError) {
1022
+ return describeHttpErrorRedacted(error);
1023
+ }
1024
+ if (error instanceof Error) {
1025
+ return `${error.name}: ${error.message}`;
1026
+ }
1027
+ return `thrown non-error: ${stringifyUnredacted(error)}`;
1028
+ }
1029
+ function stringifyUnredacted(value) {
1030
+ if (value === void 0) return "";
1031
+ try {
1032
+ return JSON.stringify(
1033
+ value,
1034
+ (_key, item) => typeof item === "bigint" ? `${item}` : item
1035
+ ) ?? String(value);
1036
+ } catch (_) {
1037
+ return "<unserializable>";
1038
+ }
1039
+ }
1040
+ function describeHttpErrorRedacted(error) {
1041
+ const code = apiErrorCode(error);
1042
+ const status = error.response.status;
1043
+ return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
1044
+ }
1045
+ function errorName(error) {
1046
+ return error instanceof Error ? error.name : `non-error ${typeof error}`;
1047
+ }
1048
+ function httpCause(error) {
1049
+ return {
1050
+ type: "http",
1051
+ requestId: error.requestId,
1052
+ status: error.response.status,
1053
+ code: apiErrorCode(error),
1054
+ eventId: apiErrorEventId(error)
1055
+ };
1056
+ }
1057
+ function apiErrorEventId(error) {
1058
+ const body = error.response.body;
1059
+ if (typeof body !== "object" || body === null) return null;
1060
+ const eventId = body.event_id;
1061
+ return typeof eventId === "string" ? eventId : null;
1062
+ }
1063
+
1064
+ // src/universal/core/shared/observability/internal-logger.ts
1065
+ function internalLogger(logger, scope) {
1066
+ return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1067
+ }
1068
+ var LEVEL_RANK = {
1069
+ none: 0,
1070
+ error: 1,
1071
+ warn: 2,
1072
+ info: 3,
1073
+ debug: 4
1074
+ };
1075
+ function scopedLogger(logger, scope, bindings) {
1076
+ const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
1077
+ const safe = (event) => ({
1078
+ msg: event.msg,
1079
+ scope,
1080
+ bindings,
1081
+ fields: event.fields ?? {},
1082
+ ...event.cause === void 0 ? {} : { cause: event.cause }
1083
+ });
1084
+ const unredacted = (event) => ({
1085
+ msg: event.msg,
1086
+ scope,
1087
+ bindings,
1088
+ fields: event.fields ?? {}
1089
+ });
1090
+ const self = {
1091
+ child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
1092
+ debug: (event) => {
1093
+ if (admits("debug")) logger.debug(() => unredacted(event()));
1094
+ },
1095
+ info: (event) => {
1096
+ if (admits("info")) logger.info(() => safe(event()));
1097
+ },
1098
+ warn: (event) => {
1099
+ if (admits("warn")) logger.warn(() => safe(event()));
1100
+ },
1101
+ error: (event) => {
1102
+ if (admits("error")) logger.error(() => safe(event()));
1103
+ },
1104
+ failure: (event, error) => {
1105
+ if (admits("debug"))
1106
+ logger.debug(() => unredacted(verbatim(event(), error)));
1107
+ if (admits("error")) logger.error(() => safe(classified(event(), error)));
1108
+ },
1109
+ warning: (event, error) => {
1110
+ if (admits("debug"))
1111
+ logger.debug(() => unredacted(verbatim(event(), error)));
1112
+ if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1113
+ },
1114
+ wrap: async (op, params, run) => {
1115
+ const opLog = self.child({ op });
1116
+ opLog.debug(() => ({ msg: "call", fields: { params } }));
1117
+ try {
1118
+ return await run();
1119
+ } catch (error) {
1120
+ opLog.failure(() => ({ msg: "call failed" }), error);
1121
+ throw error;
1122
+ }
1123
+ }
1124
+ };
1125
+ return self;
1126
+ }
1127
+ function verbatim(event, error) {
1128
+ return {
1129
+ msg: event.msg,
1130
+ fields: { ...event.fields, error: describeErrorUnredacted(error) }
1131
+ };
1132
+ }
1133
+ function classified(event, error) {
1134
+ return { ...event, cause: event.cause ?? classifyLogCause(error) };
1135
+ }
1136
+ var noopInternalLogger = {
1137
+ child: () => noopInternalLogger,
1138
+ debug: () => void 0,
1139
+ info: () => void 0,
1140
+ warn: () => void 0,
1141
+ error: () => void 0,
1142
+ failure: () => void 0,
1143
+ warning: () => void 0,
1144
+ wrap: (_op, _params, run) => run()
1145
+ };
1146
+
1147
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
1148
+ var CentrifugeNamespaceImpl = class {
1149
+ constructor(ctx) {
1150
+ this.ctx = ctx;
1151
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
1152
+ }
1153
+ async getQuote(params) {
1154
+ return this.log.wrap("getQuote", params, async () => {
1155
+ await this.ctx.ensureUserAuthenticated();
1156
+ return getCentrifugeVaultQuote(this.ctx.api, params);
1157
+ });
1158
+ }
1159
+ async getVaultStatus(params) {
1160
+ return this.log.wrap("getVaultStatus", params, async () => {
1161
+ await this.ctx.ensureUserAuthenticated();
1162
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1163
+ });
1164
+ }
1165
+ async getPosition(params) {
1166
+ return this.log.wrap("getPosition", params, async () => {
1167
+ await this.ctx.ensureUserAuthenticated();
1168
+ return getCentrifugeVaultPosition(this.ctx.api, params);
1169
+ });
1170
+ }
1171
+ async getRedeemPosition(params) {
1172
+ return this.log.wrap("getRedeemPosition", params, async () => {
1173
+ await this.ctx.ensureUserAuthenticated();
1174
+ return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
1175
+ });
1176
+ }
1177
+ async createClaim(params) {
1178
+ return this.log.wrap("createClaim", params, async () => {
1179
+ await this.ctx.ensureUserAuthenticated();
1180
+ return createCentrifugeVaultClaim(this.ctx.api, params);
1181
+ });
1182
+ }
1183
+ async createClaimProceeds(params) {
1184
+ return this.log.wrap("createClaimProceeds", params, async () => {
1185
+ await this.ctx.ensureUserAuthenticated();
1186
+ return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
1187
+ });
1188
+ }
1189
+ };
1190
+
1191
+ // src/universal/core/checkout/centrifuge/constants.ts
1192
+ var CENTRIFUGE_POLL_INTERVAL_MS = 15e3;
1193
+
1194
+ // src/universal/core/checkout/centrifuge/vaults.ts
1195
+ function resolveCentrifugeVaults(offer, lookup) {
1196
+ return offer.vaultContracts.map((contract) => {
1197
+ const { chain } = contract;
1198
+ if (!isEthereumChain(chain)) {
1199
+ return { type: "unresolved", chain, missing: "evm-chain" };
1200
+ }
1201
+ const onChain = (role) => offer.tokens.filter(
1202
+ (token) => token.role === role && token.chain === chain
1203
+ );
1204
+ const share = firstKnown(onChain("vault"), lookup);
1205
+ if (share === null) {
1206
+ return { type: "unresolved", chain, missing: "share-token" };
1207
+ }
1208
+ const funding = firstKnown(onChain("funding"), lookup);
1209
+ if (funding === null) {
1210
+ return { type: "unresolved", chain, missing: "funding-token" };
1211
+ }
1212
+ return {
1213
+ type: "resolved",
1214
+ vault: { chain, proxy: contract.address, share, funding }
1215
+ };
1216
+ });
1217
+ }
1218
+ function firstKnown(tokens, lookup) {
1219
+ for (const token of tokens) {
1220
+ const metadata = lookup(token);
1221
+ if (metadata !== null) return metadata;
1222
+ }
1223
+ return null;
1224
+ }
1225
+ function isEthereumChain(chain) {
1226
+ return chain in ETHEREUM_CHAINS;
1227
+ }
1228
+
1229
+ // src/universal/types/pagination.ts
1230
+ var Cursor = (value) => value;
1231
+ var PaginatedResponse = {
1232
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1233
+ /**
1234
+ * For a mapper that decides the page as a whole - one that drops items it
1235
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1236
+ * cursors are the wire's either way: dropping an item changes what the
1237
+ * page holds, not where the next page starts.
1238
+ */
1239
+ fromDtoPage: (dto, pageMapper) => ({
1240
+ data: pageMapper(dto.data),
1241
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1242
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1243
+ })
1244
+ };
1245
+ var PaginationParams = {
1246
+ toQueryParams: (params) => {
1247
+ const queryParams = {};
1248
+ if (params.after) {
1249
+ queryParams.starting_after = params.after;
1250
+ }
1251
+ if (params.before) {
1252
+ queryParams.starting_before = params.before;
1253
+ }
1254
+ if (params.limit) {
1255
+ queryParams.limit = params.limit;
1256
+ }
1257
+ return queryParams;
1258
+ }
1259
+ };
1260
+
1261
+ // src/universal/types/asset.ts
1262
+ var AssetId = (value) => value;
1263
+ var AssetCode = (value) => value;
1264
+ var Asset = {
1265
+ fromDto: (dto) => ({
1266
+ id: AssetId(dto.id),
1267
+ code: AssetCode(dto.code),
1268
+ name: dto.name,
1269
+ fractionalDigits: dto.fractional_digits
1270
+ })
1271
+ };
1272
+
1273
+ // src/universal/types/offer.ts
1274
+ var OfferId = (value) => value;
1275
+ var OfferSlug = (value) => value;
1276
+ var OFFER_TYPES = {
1277
+ "coinlist::token_sale": true,
1278
+ "superstate::swap": true,
1279
+ "ondo::swap": true,
1280
+ "centrifuge::vault": true
1281
+ };
1282
+ var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
1283
+ var OfferEditorial = {
1284
+ /**
1285
+ * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
1286
+ * the same three checks name the payload that failed them.
1287
+ */
1288
+ fromDto: (dto, model) => ({
1289
+ tagline: requiredString(dto.tagline, `${model}.tagline`),
1290
+ bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
1291
+ startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
1292
+ })
1293
+ };
1294
+ var Offer = {
1295
+ fromDto: (dto) => {
1296
+ const tokens = requiredArray(dto.tokens, "Offer.tokens");
1297
+ const base2 = {
1298
+ id: OfferId(dto.id),
1299
+ slug: OfferSlug(dto.slug),
1300
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1301
+ tokens: OfferToken.listFromDto(tokens)
1302
+ };
1303
+ switch (dto.type) {
1304
+ case "coinlist::token_sale":
1305
+ return {
1306
+ ...base2,
1307
+ ...OfferEditorial.fromDto(dto, "Offer"),
1308
+ type: dto.type,
1309
+ logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
1310
+ };
1311
+ case "superstate::swap":
1312
+ return {
1313
+ ...base2,
1314
+ ...OfferEditorial.fromDto(dto, "Offer"),
1315
+ type: dto.type,
1316
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1317
+ };
1318
+ // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
1319
+ // on the wire: copying them would hand every consumer a `startsAt` that
1320
+ // is 1970 for one variant and a date for the others.
1321
+ case "ondo::swap":
1322
+ case "centrifuge::vault":
1323
+ return {
1324
+ ...base2,
1325
+ type: dto.type,
1326
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1327
+ };
1328
+ default:
1329
+ return unknownTypeError(dto, "Offer");
1330
+ }
1331
+ },
1332
+ /**
1333
+ * Maps a page of offers, dropping every offer whose `type` this SDK does not
1334
+ * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
1335
+ * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
1336
+ * reject the whole page, so one offer of an unknown type would blank the
1337
+ * grid for every offer beside it. A single offer fetched by id still
1338
+ * throws, because there is nothing beside it to keep.
1339
+ */
1340
+ listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
1341
+ };
1342
+ var OfferToken = {
732
1343
  fromDto: (dto) => ({
733
1344
  role: dto.role,
734
1345
  chain: Chain(dto.chain),
@@ -753,6 +1364,30 @@ var Ticker = (value) => value;
753
1364
  var Isin = (value) => value;
754
1365
 
755
1366
  // src/universal/types/offer-detail.ts
1367
+ var AsyncOfferDetail = {
1368
+ /**
1369
+ * Narrows an offer fetched generically, e.g. on an offer page, to one with
1370
+ * something to claim.
1371
+ *
1372
+ * An exhaustive `switch` rather than a list of async types, so a new offer
1373
+ * type is a compile error here until someone decides whether it settles
1374
+ * later.
1375
+ */
1376
+ is: (offer) => {
1377
+ switch (offer.type) {
1378
+ case "centrifuge::vault":
1379
+ return true;
1380
+ case "ondo::swap":
1381
+ case "superstate::swap":
1382
+ case "coinlist::token_sale":
1383
+ return false;
1384
+ default: {
1385
+ const exhaustive = offer;
1386
+ return exhaustive;
1387
+ }
1388
+ }
1389
+ }
1390
+ };
756
1391
  var OfferOptionId = (value) => value;
757
1392
  var OfferOptionSlug = (value) => value;
758
1393
  var OfferSwapContract = {
@@ -761,6 +1396,19 @@ var OfferSwapContract = {
761
1396
  address: EvmContractAddress(dto.address)
762
1397
  })
763
1398
  };
1399
+ var OfferVaultContract = {
1400
+ fromDto: (dto) => ({
1401
+ chain: Chain(dto.chain),
1402
+ address: EvmContractAddress(dto.address)
1403
+ }),
1404
+ /**
1405
+ * Drops every proxy on a chain this SDK does not name, as
1406
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1407
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1408
+ * should not throw away the proxies the SDK can use.
1409
+ */
1410
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1411
+ };
764
1412
  var OfferDetail = {
765
1413
  fromDto: (dto) => {
766
1414
  const fundingAssets = requiredArray(
@@ -823,6 +1471,18 @@ var OfferDetail = {
823
1471
  "OfferDetail.swap_contracts"
824
1472
  ).map(OfferSwapContract.fromDto)
825
1473
  };
1474
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1475
+ // the same reason as `swap_contracts`: this is the spender a user
1476
+ // approves.
1477
+ case "centrifuge::vault":
1478
+ return {
1479
+ ...base2,
1480
+ type: dto.type,
1481
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1482
+ vaultContracts: OfferVaultContract.listFromDto(
1483
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1484
+ )
1485
+ };
826
1486
  default:
827
1487
  return unknownTypeError(dto, "OfferDetail");
828
1488
  }
@@ -947,180 +1607,6 @@ async function createParticipation(api, params) {
947
1607
  return Participation.fromDto(dto);
948
1608
  }
949
1609
 
950
- // src/universal/core/shared/observability/log-cause.ts
951
- var import_viem = require("viem");
952
- function classifyLogCause(error) {
953
- if (error instanceof HttpError) {
954
- return httpCause(error);
955
- }
956
- if (error instanceof ValidationError) {
957
- return { type: "validation", message: error.message };
958
- }
959
- if (error instanceof InvariantError) {
960
- return { type: "invariant", message: error.message };
961
- }
962
- if (error instanceof MathError) {
963
- return { type: "math", message: error.message };
964
- }
965
- if (error instanceof NotAuthenticatedError) {
966
- return { type: "not-authenticated" };
967
- }
968
- if (error instanceof NotImplementedError) {
969
- return { type: "not-implemented" };
970
- }
971
- if (error instanceof import_viem.BaseError) {
972
- const http = error.walk((e) => e instanceof HttpError);
973
- if (http instanceof HttpError) {
974
- return httpCause(http);
975
- }
976
- return { type: "rpc", reason: rpcFailureReason(error) };
977
- }
978
- return { type: "generic-error", name: errorName(error) };
979
- }
980
- function rpcFailureReason(error) {
981
- if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
982
- return "reverted";
983
- }
984
- if (error.walk((e) => e instanceof import_viem.RpcError)) {
985
- return "node-rejected";
986
- }
987
- if (error.walk(
988
- (e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
989
- )) {
990
- return "transport";
991
- }
992
- if (error instanceof import_viem.ContractFunctionExecutionError) {
993
- return "malformed-response";
994
- }
995
- return "unknown";
996
- }
997
- function describeErrorUnredacted(error) {
998
- if (error instanceof HttpError) {
999
- return describeHttpErrorRedacted(error);
1000
- }
1001
- if (error instanceof Error) {
1002
- return `${error.name}: ${error.message}`;
1003
- }
1004
- return `thrown non-error: ${stringifyUnredacted(error)}`;
1005
- }
1006
- function stringifyUnredacted(value) {
1007
- if (value === void 0) return "";
1008
- try {
1009
- return JSON.stringify(
1010
- value,
1011
- (_key, item) => typeof item === "bigint" ? `${item}` : item
1012
- ) ?? String(value);
1013
- } catch (_) {
1014
- return "<unserializable>";
1015
- }
1016
- }
1017
- function describeHttpErrorRedacted(error) {
1018
- const code = apiErrorCode(error);
1019
- const status = error.response.status;
1020
- return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
1021
- }
1022
- function errorName(error) {
1023
- return error instanceof Error ? error.name : `non-error ${typeof error}`;
1024
- }
1025
- function httpCause(error) {
1026
- return {
1027
- type: "http",
1028
- requestId: error.requestId,
1029
- status: error.response.status,
1030
- code: apiErrorCode(error),
1031
- eventId: apiErrorEventId(error)
1032
- };
1033
- }
1034
- function apiErrorEventId(error) {
1035
- const body = error.response.body;
1036
- if (typeof body !== "object" || body === null) return null;
1037
- const eventId = body.event_id;
1038
- return typeof eventId === "string" ? eventId : null;
1039
- }
1040
-
1041
- // src/universal/core/shared/observability/internal-logger.ts
1042
- function internalLogger(logger, scope) {
1043
- return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1044
- }
1045
- var LEVEL_RANK = {
1046
- none: 0,
1047
- error: 1,
1048
- warn: 2,
1049
- info: 3,
1050
- debug: 4
1051
- };
1052
- function scopedLogger(logger, scope, bindings) {
1053
- const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
1054
- const safe = (event) => ({
1055
- msg: event.msg,
1056
- scope,
1057
- bindings,
1058
- fields: event.fields ?? {},
1059
- ...event.cause === void 0 ? {} : { cause: event.cause }
1060
- });
1061
- const unredacted = (event) => ({
1062
- msg: event.msg,
1063
- scope,
1064
- bindings,
1065
- fields: event.fields ?? {}
1066
- });
1067
- const self = {
1068
- child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
1069
- debug: (event) => {
1070
- if (admits("debug")) logger.debug(() => unredacted(event()));
1071
- },
1072
- info: (event) => {
1073
- if (admits("info")) logger.info(() => safe(event()));
1074
- },
1075
- warn: (event) => {
1076
- if (admits("warn")) logger.warn(() => safe(event()));
1077
- },
1078
- error: (event) => {
1079
- if (admits("error")) logger.error(() => safe(event()));
1080
- },
1081
- failure: (event, error) => {
1082
- if (admits("debug"))
1083
- logger.debug(() => unredacted(verbatim(event(), error)));
1084
- if (admits("error")) logger.error(() => safe(classified(event(), error)));
1085
- },
1086
- warning: (event, error) => {
1087
- if (admits("debug"))
1088
- logger.debug(() => unredacted(verbatim(event(), error)));
1089
- if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1090
- },
1091
- wrap: async (op, params, run) => {
1092
- const opLog = self.child({ op });
1093
- opLog.debug(() => ({ msg: "call", fields: { params } }));
1094
- try {
1095
- return await run();
1096
- } catch (error) {
1097
- opLog.failure(() => ({ msg: "call failed" }), error);
1098
- throw error;
1099
- }
1100
- }
1101
- };
1102
- return self;
1103
- }
1104
- function verbatim(event, error) {
1105
- return {
1106
- msg: event.msg,
1107
- fields: { ...event.fields, error: describeErrorUnredacted(error) }
1108
- };
1109
- }
1110
- function classified(event, error) {
1111
- return { ...event, cause: event.cause ?? classifyLogCause(error) };
1112
- }
1113
- var noopInternalLogger = {
1114
- child: () => noopInternalLogger,
1115
- debug: () => void 0,
1116
- info: () => void 0,
1117
- warn: () => void 0,
1118
- error: () => void 0,
1119
- failure: () => void 0,
1120
- warning: () => void 0,
1121
- wrap: (_op, _params, run) => run()
1122
- };
1123
-
1124
1610
  // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1125
1611
  var CoinListTokenSaleNamespaceImpl = class {
1126
1612
  constructor(ctx) {
@@ -1269,8 +1755,14 @@ function assertPriceFits(raw) {
1269
1755
  }
1270
1756
  }
1271
1757
 
1758
+ // src/universal/core/checkout/ondo/not-tradable.ts
1759
+ var ONDO_NOT_TRADABLE_CODE = "not_tradable";
1760
+ function isOndoNotTradableError(error) {
1761
+ return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
1762
+ }
1763
+
1272
1764
  // src/universal/core/shared/blockchain/formatters.ts
1273
- var import_viem2 = require("viem");
1765
+ var import_viem3 = require("viem");
1274
1766
 
1275
1767
  // src/universal/types/blockchain/ui.ts
1276
1768
  var FormattedAmountUi = (value) => value;
@@ -1341,7 +1833,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1341
1833
  };
1342
1834
  }
1343
1835
  function formatRawAmount(amount) {
1344
- return (0, import_viem2.formatUnits)(amount.raw, amount.decimals);
1836
+ return (0, import_viem3.formatUnits)(amount.raw, amount.decimals);
1345
1837
  }
1346
1838
  function formatCompactAmount(amount, locale) {
1347
1839
  const value = Number(formatRawAmount(amount));
@@ -1445,66 +1937,6 @@ function explorerBaseUrl(chain) {
1445
1937
  }
1446
1938
  }
1447
1939
 
1448
- // src/universal/core/shared/blockchain/math.ts
1449
- var import_viem3 = require("viem");
1450
- function blockchainAmountFromRawOrThrow({
1451
- label,
1452
- raw,
1453
- decimals
1454
- }) {
1455
- const trimmed = raw.trim();
1456
- if (trimmed === "") {
1457
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1458
- }
1459
- let value;
1460
- try {
1461
- value = BigInt(trimmed);
1462
- } catch {
1463
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1464
- }
1465
- try {
1466
- return BlockchainAmount({ raw: assertUint256(value), decimals });
1467
- } catch {
1468
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1469
- }
1470
- }
1471
- function parseBlockchainAmount(amount, decimals) {
1472
- const trimmed = amount.trim();
1473
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1474
- if (trimmed.startsWith("-")) {
1475
- return { valid: false, reason: { type: "negative" } };
1476
- }
1477
- if (/[eE]/.test(trimmed)) {
1478
- return { valid: false, reason: { type: "invalid-format" } };
1479
- }
1480
- if (trimmed === ".") {
1481
- return { valid: false, reason: { type: "invalid-format" } };
1482
- }
1483
- const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
1484
- if (!/^\d+(\.\d+)?$/.test(normalised)) {
1485
- return { valid: false, reason: { type: "invalid-format" } };
1486
- }
1487
- const [, fraction = ""] = normalised.split(".");
1488
- if (fraction.length > decimals) {
1489
- return {
1490
- valid: false,
1491
- reason: { type: "too-many-decimals", maxDecimals: decimals }
1492
- };
1493
- }
1494
- try {
1495
- const raw = (0, import_viem3.parseUnits)(normalised, decimals);
1496
- if (raw > MAX_UINT_256) {
1497
- return { valid: false, reason: { type: "overflow" } };
1498
- }
1499
- return {
1500
- valid: true,
1501
- amount: BlockchainAmount({ raw, decimals })
1502
- };
1503
- } catch {
1504
- return { valid: false, reason: { type: "invalid-format" } };
1505
- }
1506
- }
1507
-
1508
1940
  // src/universal/types/providers/ondo/ondo.ts
1509
1941
  var OndoTradingStatus = {
1510
1942
  fromDto: (dto) => {
@@ -1520,7 +1952,6 @@ var OndoTradingStatus = {
1520
1952
  };
1521
1953
  }
1522
1954
  };
1523
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
1524
1955
  var OndoQuote = {
1525
1956
  fromDto: (dto) => {
1526
1957
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -3351,7 +3782,9 @@ var TokenRegistrySnapshot = {
3351
3782
  }
3352
3783
  };
3353
3784
  function offerDisplayTokens(offer) {
3354
- const swaps = offer.tokens.filter((token) => token.role === "swap");
3785
+ const swaps = offer.tokens.filter(
3786
+ (token) => token.role === "swap" || token.role === "vault"
3787
+ );
3355
3788
  const distributions = offer.tokens.filter(
3356
3789
  (token) => token.role === "distribution"
3357
3790
  );
@@ -3877,6 +4310,27 @@ var RedactedWalletError = {
3877
4310
  fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
3878
4311
  };
3879
4312
 
4313
+ // src/universal/types/blockchain/wallet-selection.ts
4314
+ var WalletSelection = {
4315
+ /**
4316
+ * Every wallet in display order - embedded first, then the external one -
4317
+ * each address once. Addresses compare case-insensitively, so a host that
4318
+ * hands the same wallet over as both embedded and external sees it once.
4319
+ */
4320
+ all: (selection) => {
4321
+ const seen = /* @__PURE__ */ new Set();
4322
+ return [
4323
+ ...selection.embedded,
4324
+ ...selection.external === null ? [] : [selection.external]
4325
+ ].filter((wallet) => {
4326
+ const key = wallet.address.toLowerCase();
4327
+ if (seen.has(key)) return false;
4328
+ seen.add(key);
4329
+ return true;
4330
+ });
4331
+ }
4332
+ };
4333
+
3880
4334
  // src/universal/types/oauth-session.ts
3881
4335
  var ClientCredentialsOAuth = (value) => value;
3882
4336
  var OAuthRefreshToken = (value) => value;
@@ -3959,11 +4413,23 @@ var User = {
3959
4413
  AssetIconUrl,
3960
4414
  AssetId,
3961
4415
  AssetSymbol,
4416
+ AsyncOfferDetail,
3962
4417
  AuthorizationCode,
3963
4418
  BPS_DENOM,
3964
4419
  Blockchain,
3965
4420
  BlockchainAmount,
3966
4421
  Bps,
4422
+ CENTRIFUGE_POLL_INTERVAL_MS,
4423
+ CentrifugeNamespaceImpl,
4424
+ CentrifugeVaultBuyTransaction,
4425
+ CentrifugeVaultClaimProceedsTransaction,
4426
+ CentrifugeVaultClaimTransaction,
4427
+ CentrifugeVaultLeg,
4428
+ CentrifugeVaultLegId,
4429
+ CentrifugeVaultPosition,
4430
+ CentrifugeVaultQuote,
4431
+ CentrifugeVaultRedeemPosition,
4432
+ CentrifugeVaultStatus,
3967
4433
  Chain,
3968
4434
  ClientCredentialsOAuth,
3969
4435
  ClientId,
@@ -4010,6 +4476,7 @@ var User = {
4010
4476
  NotImplementedError,
4011
4477
  OAuthRefreshToken,
4012
4478
  OAuthSession,
4479
+ ONDO_NOT_TRADABLE_CODE,
4013
4480
  ONDO_POLL_INTERVAL_MS,
4014
4481
  ONDO_QUOTE_MAX_TTL_MS,
4015
4482
  ONDO_SETTLEMENT_ASSET,
@@ -4026,6 +4493,7 @@ var User = {
4026
4493
  OfferSlug,
4027
4494
  OfferSwapContract,
4028
4495
  OfferToken,
4496
+ OfferVaultContract,
4029
4497
  OffersNamespaceImpl,
4030
4498
  OndoBuyTransaction,
4031
4499
  OndoNamespaceImpl,
@@ -4084,6 +4552,7 @@ var User = {
4084
4552
  ValidationError,
4085
4553
  WalletAddress,
4086
4554
  WalletOwnershipChallenge,
4555
+ WalletSelection,
4087
4556
  WalletsNamespaceImpl,
4088
4557
  apiErrorCode,
4089
4558
  applyBps,
@@ -4110,11 +4579,13 @@ var User = {
4110
4579
  isChain,
4111
4580
  isExpired,
4112
4581
  isOfferType,
4582
+ isOndoNotTradableError,
4113
4583
  isSwapAvailable,
4114
4584
  offerDisplayTokens,
4115
4585
  ondoQuoteOfferDeadline,
4116
4586
  parseBlockchainAmount,
4117
4587
  parseUint256,
4588
+ resolveCentrifugeVaults,
4118
4589
  shortenAddress,
4119
4590
  superstateSwapContractAddress,
4120
4591
  swapSpender,