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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-STAHYDLY.js → chunk-6NCNF5GF.js} +2 -2
  2. package/dist/{chunk-KRA6EM2L.js → chunk-VUIDJYHY.js} +18 -3
  3. package/dist/chunk-VUIDJYHY.js.map +1 -0
  4. package/dist/{chunk-BNMF2HMW.js → chunk-XCRU3YE2.js} +628 -402
  5. package/dist/chunk-XCRU3YE2.js.map +1 -0
  6. package/dist/client/index.cjs +605 -160
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +271 -29
  9. package/dist/client/index.d.ts +271 -29
  10. package/dist/client/index.js +294 -21
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +216 -62
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +10 -2
  15. package/dist/server/index.d.ts +10 -2
  16. package/dist/server/index.js +4 -2
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/{time-B5YOQxuh.d.ts → time-CTuVDTx6.d.ts} +1 -1
  19. package/dist/{time-BY3apBpc.d.cts → time-Dv1dejVB.d.cts} +1 -1
  20. package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +9 -7
  21. package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +9 -7
  22. package/dist/{tokens-namespace-BJfFeowE.d.cts → tokens-namespace-CcvHrw-k.d.cts} +462 -20
  23. package/dist/{tokens-namespace-BJfFeowE.d.ts → tokens-namespace-CcvHrw-k.d.ts} +462 -20
  24. package/dist/universal/index.cjs +568 -316
  25. package/dist/universal/index.cjs.map +1 -1
  26. package/dist/universal/index.d.cts +38 -6
  27. package/dist/universal/index.d.ts +38 -6
  28. package/dist/universal/index.js +22 -2
  29. package/package.json +1 -1
  30. package/dist/chunk-BNMF2HMW.js.map +0 -1
  31. package/dist/chunk-KRA6EM2L.js.map +0 -1
  32. /package/dist/{chunk-STAHYDLY.js.map → chunk-6NCNF5GF.js.map} +0 -0
@@ -32,6 +32,13 @@ __export(universal_exports, {
32
32
  Blockchain: () => Blockchain,
33
33
  BlockchainAmount: () => BlockchainAmount,
34
34
  Bps: () => Bps,
35
+ CENTRIFUGE_POLL_INTERVAL_MS: () => CENTRIFUGE_POLL_INTERVAL_MS,
36
+ CentrifugeNamespaceImpl: () => CentrifugeNamespaceImpl,
37
+ CentrifugeVaultBuyTransaction: () => CentrifugeVaultBuyTransaction,
38
+ CentrifugeVaultClaimTransaction: () => CentrifugeVaultClaimTransaction,
39
+ CentrifugeVaultPosition: () => CentrifugeVaultPosition,
40
+ CentrifugeVaultQuote: () => CentrifugeVaultQuote,
41
+ CentrifugeVaultStatus: () => CentrifugeVaultStatus,
35
42
  Chain: () => Chain,
36
43
  ClientCredentialsOAuth: () => ClientCredentialsOAuth,
37
44
  ClientId: () => ClientId,
@@ -78,6 +85,7 @@ __export(universal_exports, {
78
85
  NotImplementedError: () => NotImplementedError,
79
86
  OAuthRefreshToken: () => OAuthRefreshToken,
80
87
  OAuthSession: () => OAuthSession,
88
+ ONDO_NOT_TRADABLE_CODE: () => ONDO_NOT_TRADABLE_CODE,
81
89
  ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
82
90
  ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
83
91
  ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
@@ -94,6 +102,7 @@ __export(universal_exports, {
94
102
  OfferSlug: () => OfferSlug,
95
103
  OfferSwapContract: () => OfferSwapContract,
96
104
  OfferToken: () => OfferToken,
105
+ OfferVaultContract: () => OfferVaultContract,
97
106
  OffersNamespaceImpl: () => OffersNamespaceImpl,
98
107
  OndoBuyTransaction: () => OndoBuyTransaction,
99
108
  OndoNamespaceImpl: () => OndoNamespaceImpl,
@@ -178,6 +187,7 @@ __export(universal_exports, {
178
187
  isChain: () => isChain,
179
188
  isExpired: () => isExpired,
180
189
  isOfferType: () => isOfferType,
190
+ isOndoNotTradableError: () => isOndoNotTradableError,
181
191
  isSwapAvailable: () => isSwapAvailable,
182
192
  offerDisplayTokens: () => offerDisplayTokens,
183
193
  ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
@@ -454,49 +464,8 @@ async function generatePKCEParams(config) {
454
464
  };
455
465
  }
456
466
 
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
- };
467
+ // src/universal/core/shared/blockchain/math.ts
468
+ var import_viem = require("viem");
500
469
 
501
470
  // src/universal/types/errors.ts
502
471
  var NotImplementedError = class extends Error {
@@ -530,40 +499,6 @@ var MathError = class extends Error {
530
499
  }
531
500
  };
532
501
 
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
502
  // src/universal/types/blockchain/core.ts
568
503
  var ETHEREUM_CHAINS = {
569
504
  ethereum_mainnet: true,
@@ -661,13 +596,521 @@ var StablecoinSymbol = (value) => value;
661
596
  var KnownAssetSymbol = StablecoinSymbol;
662
597
  var Bps = (value) => value;
663
598
 
599
+ // src/universal/core/shared/blockchain/math.ts
600
+ function blockchainAmountFromRawOrThrow({
601
+ label,
602
+ raw,
603
+ decimals
604
+ }) {
605
+ const trimmed = raw.trim();
606
+ if (trimmed === "") {
607
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
608
+ }
609
+ let value;
610
+ try {
611
+ value = BigInt(trimmed);
612
+ } catch {
613
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
614
+ }
615
+ try {
616
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
617
+ } catch {
618
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
619
+ }
620
+ }
621
+ function parseBlockchainAmount(amount, decimals) {
622
+ const trimmed = amount.trim();
623
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
624
+ if (trimmed.startsWith("-")) {
625
+ return { valid: false, reason: { type: "negative" } };
626
+ }
627
+ if (/[eE]/.test(trimmed)) {
628
+ return { valid: false, reason: { type: "invalid-format" } };
629
+ }
630
+ if (trimmed === ".") {
631
+ return { valid: false, reason: { type: "invalid-format" } };
632
+ }
633
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
634
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
635
+ return { valid: false, reason: { type: "invalid-format" } };
636
+ }
637
+ const [, fraction = ""] = normalised.split(".");
638
+ if (fraction.length > decimals) {
639
+ return {
640
+ valid: false,
641
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
642
+ };
643
+ }
644
+ try {
645
+ const raw = (0, import_viem.parseUnits)(normalised, decimals);
646
+ if (raw > MAX_UINT_256) {
647
+ return { valid: false, reason: { type: "overflow" } };
648
+ }
649
+ return {
650
+ valid: true,
651
+ amount: BlockchainAmount({ raw, decimals })
652
+ };
653
+ } catch {
654
+ return { valid: false, reason: { type: "invalid-format" } };
655
+ }
656
+ }
657
+
658
+ // src/universal/core/shared/utils/wire.ts
659
+ function unknownTypeError(dto, model) {
660
+ const type = dto.type;
661
+ throw new ValidationError(
662
+ `${model}.type: unknown type ${JSON.stringify(type)}`
663
+ );
664
+ }
665
+ function requiredString(value, field) {
666
+ const text = notBlankStringOrNull(value);
667
+ if (text === null) {
668
+ throw new ValidationError(
669
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
670
+ );
671
+ }
672
+ return text;
673
+ }
674
+ function requiredDate(value, field) {
675
+ const date = typeof value === "string" ? new Date(value) : null;
676
+ if (date === null || Number.isNaN(date.getTime())) {
677
+ throw new ValidationError(
678
+ `${field}: expected a date, got ${JSON.stringify(value)}`
679
+ );
680
+ }
681
+ return date;
682
+ }
683
+ function dateOrNull(value, field) {
684
+ return value === null ? null : requiredDate(value, field);
685
+ }
686
+ function decimalOrNull(value) {
687
+ return value === null ? null : DecimalString(value);
688
+ }
689
+ function requiredArray(value, field) {
690
+ if (!Array.isArray(value)) {
691
+ throw new ValidationError(
692
+ `${field}: expected an array, got ${typeof value}`
693
+ );
694
+ }
695
+ return value;
696
+ }
697
+
698
+ // src/universal/types/providers/centrifuge/centrifuge.ts
699
+ var CentrifugeVaultQuote = {
700
+ fromDto: (dto) => {
701
+ const spendDecimals = AssetDecimals(dto.spend_input_decimals);
702
+ const shareDecimals = AssetDecimals(dto.share_decimals);
703
+ return {
704
+ chain: EthereumChain(dto.chain),
705
+ symbol: AssetSymbol(dto.symbol),
706
+ spendInputAmount: blockchainAmountFromRawOrThrow({
707
+ label: "spend_input_amount",
708
+ raw: dto.spend_input_amount,
709
+ decimals: spendDecimals
710
+ }),
711
+ estimatedShares: blockchainAmountFromRawOrThrow({
712
+ label: "estimated_shares",
713
+ raw: dto.estimated_shares,
714
+ decimals: shareDecimals
715
+ }),
716
+ indicativePrice: decimalOrNull(dto.indicative_price),
717
+ minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
718
+ label: "minimum_input_amount",
719
+ raw: dto.minimum_input_amount,
720
+ decimals: spendDecimals
721
+ }),
722
+ orderability: parseOrderability(
723
+ dto.can_order,
724
+ dto.reasons,
725
+ "CentrifugeVaultQuote"
726
+ )
727
+ };
728
+ }
729
+ };
730
+ var CentrifugeVaultStatus = {
731
+ fromDto: (dto) => ({
732
+ chain: EthereumChain(dto.chain),
733
+ symbol: AssetSymbol(dto.symbol),
734
+ vaultAddress: EvmContractAddress(dto.vault_address),
735
+ linked: dto.linked,
736
+ permissioned: dto.permissioned,
737
+ membershipValidUntil: dateOrNull(
738
+ dto.membership_valid_until,
739
+ "CentrifugeVaultStatus.membership_valid_until"
740
+ ),
741
+ halted: dto.halted,
742
+ priceUpdatedAt: dateOrNull(
743
+ dto.price_updated_at,
744
+ "CentrifugeVaultStatus.price_updated_at"
745
+ ),
746
+ orderability: parseOrderability(
747
+ dto.can_order,
748
+ dto.reasons,
749
+ "CentrifugeVaultStatus"
750
+ ),
751
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
752
+ })
753
+ };
754
+ var CentrifugeVaultBuyTransaction = {
755
+ fromDto: (dto) => {
756
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
757
+ label: "spend_input_amount",
758
+ raw: dto.spend_input_amount,
759
+ decimals: AssetDecimals(dto.spend_input_decimals)
760
+ });
761
+ if (spendInputAmount.raw <= 0n) {
762
+ throw new ValidationError(
763
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
764
+ );
765
+ }
766
+ return {
767
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
768
+ spendInputAmount,
769
+ estimatedShares: blockchainAmountFromRawOrThrow({
770
+ label: "estimated_shares",
771
+ raw: dto.estimated_shares,
772
+ decimals: AssetDecimals(dto.share_decimals)
773
+ })
774
+ };
775
+ }
776
+ };
777
+ var CentrifugeVaultClaimTransaction = {
778
+ fromDto: (dto) => ({
779
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
780
+ claimableShares: blockchainAmountFromRawOrThrow({
781
+ label: "claimable_shares",
782
+ raw: dto.claimable_shares,
783
+ decimals: AssetDecimals(dto.share_decimals)
784
+ })
785
+ })
786
+ };
787
+ var CentrifugeVaultPosition = {
788
+ fromDto: (dto) => {
789
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
790
+ const shareDecimals = AssetDecimals(dto.share_decimals);
791
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
792
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
793
+ return {
794
+ chain: EthereumChain(dto.chain),
795
+ symbol: AssetSymbol(dto.symbol),
796
+ walletAddress: EvmWalletAddress(dto.wallet_address),
797
+ status: dto.status,
798
+ requested: asset("requested", dto.requested),
799
+ pending: asset("pending", dto.pending),
800
+ filledAssets: asset("filled_assets", dto.filled_assets),
801
+ earnedShares: shares("earned_shares", dto.earned_shares),
802
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
803
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
804
+ shareBalance: shares("share_balance", dto.share_balance),
805
+ averagePrice: decimalOrNull(dto.average_price),
806
+ frozen: dto.frozen,
807
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
808
+ };
809
+ }
810
+ };
811
+ function parseOrderability(canOrder, reasons, model) {
812
+ const [first, ...rest] = reasons;
813
+ if (canOrder) {
814
+ if (first !== void 0) {
815
+ throw new ValidationError(
816
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
817
+ );
818
+ }
819
+ return { type: "orderable" };
820
+ }
821
+ if (first === void 0) {
822
+ throw new ValidationError(
823
+ `${model}.reasons: expected at least one when can_order is false`
824
+ );
825
+ }
826
+ return { type: "blocked", reasons: [first, ...rest] };
827
+ }
828
+ function parseTransactionCore(dto, model) {
829
+ return {
830
+ tx: {
831
+ to: EvmContractAddress(dto.to),
832
+ data: HexEncodedTransactionData(dto.data)
833
+ },
834
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
835
+ };
836
+ }
837
+
838
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
839
+ async function getCentrifugeVaultQuote(api, params) {
840
+ const dto = await api.send({
841
+ method: "GET",
842
+ url: "/v1/centrifuge/vault/quote",
843
+ queryParams: {
844
+ symbol: params.symbol,
845
+ chain: params.chain,
846
+ amount: params.amount.raw.toString()
847
+ },
848
+ attributes: Attributes.protected()
849
+ });
850
+ return CentrifugeVaultQuote.fromDto(dto);
851
+ }
852
+ async function getCentrifugeVaultStatus(api, params) {
853
+ const dto = await api.send({
854
+ method: "GET",
855
+ url: "/v1/centrifuge/vault/status",
856
+ queryParams: {
857
+ symbol: params.symbol,
858
+ chain: params.chain
859
+ },
860
+ attributes: Attributes.protected()
861
+ });
862
+ return CentrifugeVaultStatus.fromDto(dto);
863
+ }
864
+
865
+ // src/universal/core/shared/observability/log-cause.ts
866
+ var import_viem2 = require("viem");
867
+ function classifyLogCause(error) {
868
+ if (error instanceof HttpError) {
869
+ return httpCause(error);
870
+ }
871
+ if (error instanceof ValidationError) {
872
+ return { type: "validation", message: error.message };
873
+ }
874
+ if (error instanceof InvariantError) {
875
+ return { type: "invariant", message: error.message };
876
+ }
877
+ if (error instanceof MathError) {
878
+ return { type: "math", message: error.message };
879
+ }
880
+ if (error instanceof NotAuthenticatedError) {
881
+ return { type: "not-authenticated" };
882
+ }
883
+ if (error instanceof NotImplementedError) {
884
+ return { type: "not-implemented" };
885
+ }
886
+ if (error instanceof import_viem2.BaseError) {
887
+ const http = error.walk((e) => e instanceof HttpError);
888
+ if (http instanceof HttpError) {
889
+ return httpCause(http);
890
+ }
891
+ return { type: "rpc", reason: rpcFailureReason(error) };
892
+ }
893
+ return { type: "generic-error", name: errorName(error) };
894
+ }
895
+ function rpcFailureReason(error) {
896
+ if (error.walk((e) => e instanceof import_viem2.ContractFunctionRevertedError)) {
897
+ return "reverted";
898
+ }
899
+ if (error.walk((e) => e instanceof import_viem2.RpcError)) {
900
+ return "node-rejected";
901
+ }
902
+ if (error.walk(
903
+ (e) => e instanceof import_viem2.HttpRequestError || e instanceof import_viem2.WebSocketRequestError || e instanceof import_viem2.SocketClosedError || e instanceof import_viem2.TimeoutError
904
+ )) {
905
+ return "transport";
906
+ }
907
+ if (error instanceof import_viem2.ContractFunctionExecutionError) {
908
+ return "malformed-response";
909
+ }
910
+ return "unknown";
911
+ }
912
+ function describeErrorUnredacted(error) {
913
+ if (error instanceof HttpError) {
914
+ return describeHttpErrorRedacted(error);
915
+ }
916
+ if (error instanceof Error) {
917
+ return `${error.name}: ${error.message}`;
918
+ }
919
+ return `thrown non-error: ${stringifyUnredacted(error)}`;
920
+ }
921
+ function stringifyUnredacted(value) {
922
+ if (value === void 0) return "";
923
+ try {
924
+ return JSON.stringify(
925
+ value,
926
+ (_key, item) => typeof item === "bigint" ? `${item}` : item
927
+ ) ?? String(value);
928
+ } catch (_) {
929
+ return "<unserializable>";
930
+ }
931
+ }
932
+ function describeHttpErrorRedacted(error) {
933
+ const code = apiErrorCode(error);
934
+ const status = error.response.status;
935
+ return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
936
+ }
937
+ function errorName(error) {
938
+ return error instanceof Error ? error.name : `non-error ${typeof error}`;
939
+ }
940
+ function httpCause(error) {
941
+ return {
942
+ type: "http",
943
+ requestId: error.requestId,
944
+ status: error.response.status,
945
+ code: apiErrorCode(error),
946
+ eventId: apiErrorEventId(error)
947
+ };
948
+ }
949
+ function apiErrorEventId(error) {
950
+ const body = error.response.body;
951
+ if (typeof body !== "object" || body === null) return null;
952
+ const eventId = body.event_id;
953
+ return typeof eventId === "string" ? eventId : null;
954
+ }
955
+
956
+ // src/universal/core/shared/observability/internal-logger.ts
957
+ function internalLogger(logger, scope) {
958
+ return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
959
+ }
960
+ var LEVEL_RANK = {
961
+ none: 0,
962
+ error: 1,
963
+ warn: 2,
964
+ info: 3,
965
+ debug: 4
966
+ };
967
+ function scopedLogger(logger, scope, bindings) {
968
+ const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
969
+ const safe = (event) => ({
970
+ msg: event.msg,
971
+ scope,
972
+ bindings,
973
+ fields: event.fields ?? {},
974
+ ...event.cause === void 0 ? {} : { cause: event.cause }
975
+ });
976
+ const unredacted = (event) => ({
977
+ msg: event.msg,
978
+ scope,
979
+ bindings,
980
+ fields: event.fields ?? {}
981
+ });
982
+ const self = {
983
+ child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
984
+ debug: (event) => {
985
+ if (admits("debug")) logger.debug(() => unredacted(event()));
986
+ },
987
+ info: (event) => {
988
+ if (admits("info")) logger.info(() => safe(event()));
989
+ },
990
+ warn: (event) => {
991
+ if (admits("warn")) logger.warn(() => safe(event()));
992
+ },
993
+ error: (event) => {
994
+ if (admits("error")) logger.error(() => safe(event()));
995
+ },
996
+ failure: (event, error) => {
997
+ if (admits("debug"))
998
+ logger.debug(() => unredacted(verbatim(event(), error)));
999
+ if (admits("error")) logger.error(() => safe(classified(event(), error)));
1000
+ },
1001
+ warning: (event, error) => {
1002
+ if (admits("debug"))
1003
+ logger.debug(() => unredacted(verbatim(event(), error)));
1004
+ if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1005
+ },
1006
+ wrap: async (op, params, run) => {
1007
+ const opLog = self.child({ op });
1008
+ opLog.debug(() => ({ msg: "call", fields: { params } }));
1009
+ try {
1010
+ return await run();
1011
+ } catch (error) {
1012
+ opLog.failure(() => ({ msg: "call failed" }), error);
1013
+ throw error;
1014
+ }
1015
+ }
1016
+ };
1017
+ return self;
1018
+ }
1019
+ function verbatim(event, error) {
1020
+ return {
1021
+ msg: event.msg,
1022
+ fields: { ...event.fields, error: describeErrorUnredacted(error) }
1023
+ };
1024
+ }
1025
+ function classified(event, error) {
1026
+ return { ...event, cause: event.cause ?? classifyLogCause(error) };
1027
+ }
1028
+ var noopInternalLogger = {
1029
+ child: () => noopInternalLogger,
1030
+ debug: () => void 0,
1031
+ info: () => void 0,
1032
+ warn: () => void 0,
1033
+ error: () => void 0,
1034
+ failure: () => void 0,
1035
+ warning: () => void 0,
1036
+ wrap: (_op, _params, run) => run()
1037
+ };
1038
+
1039
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
1040
+ var CentrifugeNamespaceImpl = class {
1041
+ constructor(ctx) {
1042
+ this.ctx = ctx;
1043
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
1044
+ }
1045
+ async getQuote(params) {
1046
+ return this.log.wrap("getQuote", params, async () => {
1047
+ await this.ctx.ensureUserAuthenticated();
1048
+ return getCentrifugeVaultQuote(this.ctx.api, params);
1049
+ });
1050
+ }
1051
+ async getVaultStatus(params) {
1052
+ return this.log.wrap("getVaultStatus", params, async () => {
1053
+ await this.ctx.ensureUserAuthenticated();
1054
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1055
+ });
1056
+ }
1057
+ };
1058
+
1059
+ // src/universal/core/checkout/centrifuge/constants.ts
1060
+ var CENTRIFUGE_POLL_INTERVAL_MS = 15e3;
1061
+
1062
+ // src/universal/types/pagination.ts
1063
+ var Cursor = (value) => value;
1064
+ var PaginatedResponse = {
1065
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1066
+ /**
1067
+ * For a mapper that decides the page as a whole - one that drops items it
1068
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1069
+ * cursors are the wire's either way: dropping an item changes what the
1070
+ * page holds, not where the next page starts.
1071
+ */
1072
+ fromDtoPage: (dto, pageMapper) => ({
1073
+ data: pageMapper(dto.data),
1074
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1075
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1076
+ })
1077
+ };
1078
+ var PaginationParams = {
1079
+ toQueryParams: (params) => {
1080
+ const queryParams = {};
1081
+ if (params.after) {
1082
+ queryParams.starting_after = params.after;
1083
+ }
1084
+ if (params.before) {
1085
+ queryParams.starting_before = params.before;
1086
+ }
1087
+ if (params.limit) {
1088
+ queryParams.limit = params.limit;
1089
+ }
1090
+ return queryParams;
1091
+ }
1092
+ };
1093
+
1094
+ // src/universal/types/asset.ts
1095
+ var AssetId = (value) => value;
1096
+ var AssetCode = (value) => value;
1097
+ var Asset = {
1098
+ fromDto: (dto) => ({
1099
+ id: AssetId(dto.id),
1100
+ code: AssetCode(dto.code),
1101
+ name: dto.name,
1102
+ fractionalDigits: dto.fractional_digits
1103
+ })
1104
+ };
1105
+
664
1106
  // src/universal/types/offer.ts
665
1107
  var OfferId = (value) => value;
666
1108
  var OfferSlug = (value) => value;
667
1109
  var OFFER_TYPES = {
668
1110
  "coinlist::token_sale": true,
669
1111
  "superstate::swap": true,
670
- "ondo::swap": true
1112
+ "ondo::swap": true,
1113
+ "centrifuge::vault": true
671
1114
  };
672
1115
  var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
673
1116
  var OfferEditorial = {
@@ -709,6 +1152,7 @@ var Offer = {
709
1152
  // on the wire: copying them would hand every consumer a `startsAt` that
710
1153
  // is 1970 for one variant and a date for the others.
711
1154
  case "ondo::swap":
1155
+ case "centrifuge::vault":
712
1156
  return {
713
1157
  ...base2,
714
1158
  type: dto.type,
@@ -761,6 +1205,19 @@ var OfferSwapContract = {
761
1205
  address: EvmContractAddress(dto.address)
762
1206
  })
763
1207
  };
1208
+ var OfferVaultContract = {
1209
+ fromDto: (dto) => ({
1210
+ chain: Chain(dto.chain),
1211
+ address: EvmContractAddress(dto.address)
1212
+ }),
1213
+ /**
1214
+ * Drops every proxy on a chain this SDK does not name, as
1215
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1216
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1217
+ * should not throw away the proxies the SDK can use.
1218
+ */
1219
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1220
+ };
764
1221
  var OfferDetail = {
765
1222
  fromDto: (dto) => {
766
1223
  const fundingAssets = requiredArray(
@@ -823,6 +1280,18 @@ var OfferDetail = {
823
1280
  "OfferDetail.swap_contracts"
824
1281
  ).map(OfferSwapContract.fromDto)
825
1282
  };
1283
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1284
+ // the same reason as `swap_contracts`: this is the spender a user
1285
+ // approves.
1286
+ case "centrifuge::vault":
1287
+ return {
1288
+ ...base2,
1289
+ type: dto.type,
1290
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1291
+ vaultContracts: OfferVaultContract.listFromDto(
1292
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1293
+ )
1294
+ };
826
1295
  default:
827
1296
  return unknownTypeError(dto, "OfferDetail");
828
1297
  }
@@ -947,180 +1416,6 @@ async function createParticipation(api, params) {
947
1416
  return Participation.fromDto(dto);
948
1417
  }
949
1418
 
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
1419
  // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1125
1420
  var CoinListTokenSaleNamespaceImpl = class {
1126
1421
  constructor(ctx) {
@@ -1269,8 +1564,14 @@ function assertPriceFits(raw) {
1269
1564
  }
1270
1565
  }
1271
1566
 
1567
+ // src/universal/core/checkout/ondo/not-tradable.ts
1568
+ var ONDO_NOT_TRADABLE_CODE = "not_tradable";
1569
+ function isOndoNotTradableError(error) {
1570
+ return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
1571
+ }
1572
+
1272
1573
  // src/universal/core/shared/blockchain/formatters.ts
1273
- var import_viem2 = require("viem");
1574
+ var import_viem3 = require("viem");
1274
1575
 
1275
1576
  // src/universal/types/blockchain/ui.ts
1276
1577
  var FormattedAmountUi = (value) => value;
@@ -1341,7 +1642,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1341
1642
  };
1342
1643
  }
1343
1644
  function formatRawAmount(amount) {
1344
- return (0, import_viem2.formatUnits)(amount.raw, amount.decimals);
1645
+ return (0, import_viem3.formatUnits)(amount.raw, amount.decimals);
1345
1646
  }
1346
1647
  function formatCompactAmount(amount, locale) {
1347
1648
  const value = Number(formatRawAmount(amount));
@@ -1445,66 +1746,6 @@ function explorerBaseUrl(chain) {
1445
1746
  }
1446
1747
  }
1447
1748
 
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
1749
  // src/universal/types/providers/ondo/ondo.ts
1509
1750
  var OndoTradingStatus = {
1510
1751
  fromDto: (dto) => {
@@ -1520,7 +1761,6 @@ var OndoTradingStatus = {
1520
1761
  };
1521
1762
  }
1522
1763
  };
1523
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
1524
1764
  var OndoQuote = {
1525
1765
  fromDto: (dto) => {
1526
1766
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -3351,7 +3591,9 @@ var TokenRegistrySnapshot = {
3351
3591
  }
3352
3592
  };
3353
3593
  function offerDisplayTokens(offer) {
3354
- const swaps = offer.tokens.filter((token) => token.role === "swap");
3594
+ const swaps = offer.tokens.filter(
3595
+ (token) => token.role === "swap" || token.role === "vault"
3596
+ );
3355
3597
  const distributions = offer.tokens.filter(
3356
3598
  (token) => token.role === "distribution"
3357
3599
  );
@@ -3964,6 +4206,13 @@ var User = {
3964
4206
  Blockchain,
3965
4207
  BlockchainAmount,
3966
4208
  Bps,
4209
+ CENTRIFUGE_POLL_INTERVAL_MS,
4210
+ CentrifugeNamespaceImpl,
4211
+ CentrifugeVaultBuyTransaction,
4212
+ CentrifugeVaultClaimTransaction,
4213
+ CentrifugeVaultPosition,
4214
+ CentrifugeVaultQuote,
4215
+ CentrifugeVaultStatus,
3967
4216
  Chain,
3968
4217
  ClientCredentialsOAuth,
3969
4218
  ClientId,
@@ -4010,6 +4259,7 @@ var User = {
4010
4259
  NotImplementedError,
4011
4260
  OAuthRefreshToken,
4012
4261
  OAuthSession,
4262
+ ONDO_NOT_TRADABLE_CODE,
4013
4263
  ONDO_POLL_INTERVAL_MS,
4014
4264
  ONDO_QUOTE_MAX_TTL_MS,
4015
4265
  ONDO_SETTLEMENT_ASSET,
@@ -4026,6 +4276,7 @@ var User = {
4026
4276
  OfferSlug,
4027
4277
  OfferSwapContract,
4028
4278
  OfferToken,
4279
+ OfferVaultContract,
4029
4280
  OffersNamespaceImpl,
4030
4281
  OndoBuyTransaction,
4031
4282
  OndoNamespaceImpl,
@@ -4110,6 +4361,7 @@ var User = {
4110
4361
  isChain,
4111
4362
  isExpired,
4112
4363
  isOfferType,
4364
+ isOndoNotTradableError,
4113
4365
  isSwapAvailable,
4114
4366
  offerDisplayTokens,
4115
4367
  ondoQuoteOfferDeadline,