@coinlist-co/react 0.12.2-rc.31c2f50 → 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-4IZ2F732.js → chunk-6NCNF5GF.js} +2 -2
  2. package/dist/{chunk-UJYSXXJF.js → chunk-VUIDJYHY.js} +6 -156
  3. package/dist/chunk-VUIDJYHY.js.map +1 -0
  4. package/dist/{chunk-NBO5E2RO.js → chunk-XCRU3YE2.js} +599 -409
  5. package/dist/chunk-XCRU3YE2.js.map +1 -0
  6. package/dist/client/index.cjs +458 -111
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +184 -5
  9. package/dist/client/index.d.ts +184 -5
  10. package/dist/client/index.js +222 -9
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +151 -26
  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-DvgN98Q9.d.ts → time-CTuVDTx6.d.ts} +1 -1
  19. package/dist/{time-CFocgYyl.d.cts → time-Dv1dejVB.d.cts} +1 -1
  20. package/dist/{token-registry-snapshot-Cc_eA5zM.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +1 -1
  21. package/dist/{token-registry-snapshot-BsAfBL_b.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +1 -1
  22. package/dist/{tokens-namespace-D_XSpiS-.d.cts → tokens-namespace-CcvHrw-k.d.cts} +361 -2
  23. package/dist/{tokens-namespace-D_XSpiS-.d.ts → tokens-namespace-CcvHrw-k.d.ts} +361 -2
  24. package/dist/universal/index.cjs +528 -472
  25. package/dist/universal/index.cjs.map +1 -1
  26. package/dist/universal/index.d.cts +18 -321
  27. package/dist/universal/index.d.ts +18 -321
  28. package/dist/universal/index.js +11 -7
  29. package/package.json +1 -1
  30. package/dist/chunk-NBO5E2RO.js.map +0 -1
  31. package/dist/chunk-UJYSXXJF.js.map +0 -1
  32. /package/dist/{chunk-4IZ2F732.js.map → chunk-6NCNF5GF.js.map} +0 -0
@@ -407,50 +407,6 @@ async function fetchAllPages(fetchPage, baseParams) {
407
407
  return items;
408
408
  }
409
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
410
  // src/universal/types/blockchain/core.ts
455
411
  var ETHEREUM_CHAINS = {
456
412
  ethereum_mainnet: true,
@@ -548,6 +504,66 @@ var StablecoinSymbol = (value) => value;
548
504
  var KnownAssetSymbol = StablecoinSymbol;
549
505
  var Bps = (value) => value;
550
506
 
507
+ // src/universal/core/shared/blockchain/math.ts
508
+ import { parseUnits } from "viem";
509
+ function blockchainAmountFromRawOrThrow({
510
+ label,
511
+ raw,
512
+ decimals
513
+ }) {
514
+ const trimmed = raw.trim();
515
+ if (trimmed === "") {
516
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
517
+ }
518
+ let value;
519
+ try {
520
+ value = BigInt(trimmed);
521
+ } catch {
522
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
523
+ }
524
+ try {
525
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
526
+ } catch {
527
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
528
+ }
529
+ }
530
+ function parseBlockchainAmount(amount, decimals) {
531
+ const trimmed = amount.trim();
532
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
533
+ if (trimmed.startsWith("-")) {
534
+ return { valid: false, reason: { type: "negative" } };
535
+ }
536
+ if (/[eE]/.test(trimmed)) {
537
+ return { valid: false, reason: { type: "invalid-format" } };
538
+ }
539
+ if (trimmed === ".") {
540
+ return { valid: false, reason: { type: "invalid-format" } };
541
+ }
542
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
543
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
544
+ return { valid: false, reason: { type: "invalid-format" } };
545
+ }
546
+ const [, fraction = ""] = normalised.split(".");
547
+ if (fraction.length > decimals) {
548
+ return {
549
+ valid: false,
550
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
551
+ };
552
+ }
553
+ try {
554
+ const raw = parseUnits(normalised, decimals);
555
+ if (raw > MAX_UINT_256) {
556
+ return { valid: false, reason: { type: "overflow" } };
557
+ }
558
+ return {
559
+ valid: true,
560
+ amount: BlockchainAmount({ raw, decimals })
561
+ };
562
+ } catch {
563
+ return { valid: false, reason: { type: "invalid-format" } };
564
+ }
565
+ }
566
+
551
567
  // src/universal/core/shared/utils/crypto.ts
552
568
  async function sha256(data) {
553
569
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
@@ -590,53 +606,467 @@ function getUUIDv4() {
590
606
  }
591
607
  return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
592
608
  }
593
- function notBlankStringOrNull(value) {
594
- if (value?.trim()) {
595
- return value;
596
- } else {
597
- return null;
598
- }
609
+ function notBlankStringOrNull(value) {
610
+ if (value?.trim()) {
611
+ return value;
612
+ } else {
613
+ return null;
614
+ }
615
+ }
616
+
617
+ // src/universal/core/shared/utils/wire.ts
618
+ function unknownTypeError(dto, model) {
619
+ const type = dto.type;
620
+ throw new ValidationError(
621
+ `${model}.type: unknown type ${JSON.stringify(type)}`
622
+ );
623
+ }
624
+ function requiredString(value, field) {
625
+ const text = notBlankStringOrNull(value);
626
+ if (text === null) {
627
+ throw new ValidationError(
628
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
629
+ );
630
+ }
631
+ return text;
632
+ }
633
+ function requiredDate(value, field) {
634
+ const date = typeof value === "string" ? new Date(value) : null;
635
+ if (date === null || Number.isNaN(date.getTime())) {
636
+ throw new ValidationError(
637
+ `${field}: expected a date, got ${JSON.stringify(value)}`
638
+ );
639
+ }
640
+ return date;
641
+ }
642
+ function dateOrNull(value, field) {
643
+ return value === null ? null : requiredDate(value, field);
644
+ }
645
+ function decimalOrNull(value) {
646
+ return value === null ? null : DecimalString(value);
647
+ }
648
+ function requiredArray(value, field) {
649
+ if (!Array.isArray(value)) {
650
+ throw new ValidationError(
651
+ `${field}: expected an array, got ${typeof value}`
652
+ );
653
+ }
654
+ return value;
655
+ }
656
+
657
+ // src/universal/types/providers/centrifuge/centrifuge.ts
658
+ var CentrifugeVaultQuote = {
659
+ fromDto: (dto) => {
660
+ const spendDecimals = AssetDecimals(dto.spend_input_decimals);
661
+ const shareDecimals = AssetDecimals(dto.share_decimals);
662
+ return {
663
+ chain: EthereumChain(dto.chain),
664
+ symbol: AssetSymbol(dto.symbol),
665
+ spendInputAmount: blockchainAmountFromRawOrThrow({
666
+ label: "spend_input_amount",
667
+ raw: dto.spend_input_amount,
668
+ decimals: spendDecimals
669
+ }),
670
+ estimatedShares: blockchainAmountFromRawOrThrow({
671
+ label: "estimated_shares",
672
+ raw: dto.estimated_shares,
673
+ decimals: shareDecimals
674
+ }),
675
+ indicativePrice: decimalOrNull(dto.indicative_price),
676
+ minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
677
+ label: "minimum_input_amount",
678
+ raw: dto.minimum_input_amount,
679
+ decimals: spendDecimals
680
+ }),
681
+ orderability: parseOrderability(
682
+ dto.can_order,
683
+ dto.reasons,
684
+ "CentrifugeVaultQuote"
685
+ )
686
+ };
687
+ }
688
+ };
689
+ var CentrifugeVaultStatus = {
690
+ fromDto: (dto) => ({
691
+ chain: EthereumChain(dto.chain),
692
+ symbol: AssetSymbol(dto.symbol),
693
+ vaultAddress: EvmContractAddress(dto.vault_address),
694
+ linked: dto.linked,
695
+ permissioned: dto.permissioned,
696
+ membershipValidUntil: dateOrNull(
697
+ dto.membership_valid_until,
698
+ "CentrifugeVaultStatus.membership_valid_until"
699
+ ),
700
+ halted: dto.halted,
701
+ priceUpdatedAt: dateOrNull(
702
+ dto.price_updated_at,
703
+ "CentrifugeVaultStatus.price_updated_at"
704
+ ),
705
+ orderability: parseOrderability(
706
+ dto.can_order,
707
+ dto.reasons,
708
+ "CentrifugeVaultStatus"
709
+ ),
710
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
711
+ })
712
+ };
713
+ var CentrifugeVaultBuyTransaction = {
714
+ fromDto: (dto) => {
715
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
716
+ label: "spend_input_amount",
717
+ raw: dto.spend_input_amount,
718
+ decimals: AssetDecimals(dto.spend_input_decimals)
719
+ });
720
+ if (spendInputAmount.raw <= 0n) {
721
+ throw new ValidationError(
722
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
723
+ );
724
+ }
725
+ return {
726
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
727
+ spendInputAmount,
728
+ estimatedShares: blockchainAmountFromRawOrThrow({
729
+ label: "estimated_shares",
730
+ raw: dto.estimated_shares,
731
+ decimals: AssetDecimals(dto.share_decimals)
732
+ })
733
+ };
734
+ }
735
+ };
736
+ var CentrifugeVaultClaimTransaction = {
737
+ fromDto: (dto) => ({
738
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
739
+ claimableShares: blockchainAmountFromRawOrThrow({
740
+ label: "claimable_shares",
741
+ raw: dto.claimable_shares,
742
+ decimals: AssetDecimals(dto.share_decimals)
743
+ })
744
+ })
745
+ };
746
+ var CentrifugeVaultPosition = {
747
+ fromDto: (dto) => {
748
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
749
+ const shareDecimals = AssetDecimals(dto.share_decimals);
750
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
751
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
752
+ return {
753
+ chain: EthereumChain(dto.chain),
754
+ symbol: AssetSymbol(dto.symbol),
755
+ walletAddress: EvmWalletAddress(dto.wallet_address),
756
+ status: dto.status,
757
+ requested: asset("requested", dto.requested),
758
+ pending: asset("pending", dto.pending),
759
+ filledAssets: asset("filled_assets", dto.filled_assets),
760
+ earnedShares: shares("earned_shares", dto.earned_shares),
761
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
762
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
763
+ shareBalance: shares("share_balance", dto.share_balance),
764
+ averagePrice: decimalOrNull(dto.average_price),
765
+ frozen: dto.frozen,
766
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
767
+ };
768
+ }
769
+ };
770
+ function parseOrderability(canOrder, reasons, model) {
771
+ const [first, ...rest] = reasons;
772
+ if (canOrder) {
773
+ if (first !== void 0) {
774
+ throw new ValidationError(
775
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
776
+ );
777
+ }
778
+ return { type: "orderable" };
779
+ }
780
+ if (first === void 0) {
781
+ throw new ValidationError(
782
+ `${model}.reasons: expected at least one when can_order is false`
783
+ );
784
+ }
785
+ return { type: "blocked", reasons: [first, ...rest] };
786
+ }
787
+ function parseTransactionCore(dto, model) {
788
+ return {
789
+ tx: {
790
+ to: EvmContractAddress(dto.to),
791
+ data: HexEncodedTransactionData(dto.data)
792
+ },
793
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
794
+ };
795
+ }
796
+
797
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
798
+ async function getCentrifugeVaultQuote(api, params) {
799
+ const dto = await api.send({
800
+ method: "GET",
801
+ url: "/v1/centrifuge/vault/quote",
802
+ queryParams: {
803
+ symbol: params.symbol,
804
+ chain: params.chain,
805
+ amount: params.amount.raw.toString()
806
+ },
807
+ attributes: Attributes.protected()
808
+ });
809
+ return CentrifugeVaultQuote.fromDto(dto);
810
+ }
811
+ async function getCentrifugeVaultStatus(api, params) {
812
+ const dto = await api.send({
813
+ method: "GET",
814
+ url: "/v1/centrifuge/vault/status",
815
+ queryParams: {
816
+ symbol: params.symbol,
817
+ chain: params.chain
818
+ },
819
+ attributes: Attributes.protected()
820
+ });
821
+ return CentrifugeVaultStatus.fromDto(dto);
822
+ }
823
+
824
+ // src/universal/core/shared/observability/log-cause.ts
825
+ import {
826
+ BaseError,
827
+ ContractFunctionExecutionError,
828
+ ContractFunctionRevertedError,
829
+ HttpRequestError,
830
+ RpcError,
831
+ SocketClosedError,
832
+ TimeoutError,
833
+ WebSocketRequestError
834
+ } from "viem";
835
+ function classifyLogCause(error) {
836
+ if (error instanceof HttpError) {
837
+ return httpCause(error);
838
+ }
839
+ if (error instanceof ValidationError) {
840
+ return { type: "validation", message: error.message };
841
+ }
842
+ if (error instanceof InvariantError) {
843
+ return { type: "invariant", message: error.message };
844
+ }
845
+ if (error instanceof MathError) {
846
+ return { type: "math", message: error.message };
847
+ }
848
+ if (error instanceof NotAuthenticatedError) {
849
+ return { type: "not-authenticated" };
850
+ }
851
+ if (error instanceof NotImplementedError) {
852
+ return { type: "not-implemented" };
853
+ }
854
+ if (error instanceof BaseError) {
855
+ const http = error.walk((e) => e instanceof HttpError);
856
+ if (http instanceof HttpError) {
857
+ return httpCause(http);
858
+ }
859
+ return { type: "rpc", reason: rpcFailureReason(error) };
860
+ }
861
+ return { type: "generic-error", name: errorName(error) };
862
+ }
863
+ function rpcFailureReason(error) {
864
+ if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
865
+ return "reverted";
866
+ }
867
+ if (error.walk((e) => e instanceof RpcError)) {
868
+ return "node-rejected";
869
+ }
870
+ if (error.walk(
871
+ (e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
872
+ )) {
873
+ return "transport";
874
+ }
875
+ if (error instanceof ContractFunctionExecutionError) {
876
+ return "malformed-response";
877
+ }
878
+ return "unknown";
879
+ }
880
+ function describeErrorUnredacted(error) {
881
+ if (error instanceof HttpError) {
882
+ return describeHttpErrorRedacted(error);
883
+ }
884
+ if (error instanceof Error) {
885
+ return `${error.name}: ${error.message}`;
886
+ }
887
+ return `thrown non-error: ${stringifyUnredacted(error)}`;
888
+ }
889
+ function stringifyUnredacted(value) {
890
+ if (value === void 0) return "";
891
+ try {
892
+ return JSON.stringify(
893
+ value,
894
+ (_key, item) => typeof item === "bigint" ? `${item}` : item
895
+ ) ?? String(value);
896
+ } catch (_) {
897
+ return "<unserializable>";
898
+ }
899
+ }
900
+ function describeHttpErrorRedacted(error) {
901
+ const code = apiErrorCode(error);
902
+ const status = error.response.status;
903
+ return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
904
+ }
905
+ function errorName(error) {
906
+ return error instanceof Error ? error.name : `non-error ${typeof error}`;
907
+ }
908
+ function httpCause(error) {
909
+ return {
910
+ type: "http",
911
+ requestId: error.requestId,
912
+ status: error.response.status,
913
+ code: apiErrorCode(error),
914
+ eventId: apiErrorEventId(error)
915
+ };
916
+ }
917
+ function apiErrorEventId(error) {
918
+ const body = error.response.body;
919
+ if (typeof body !== "object" || body === null) return null;
920
+ const eventId = body.event_id;
921
+ return typeof eventId === "string" ? eventId : null;
922
+ }
923
+
924
+ // src/universal/core/shared/observability/internal-logger.ts
925
+ function internalLogger(logger, scope) {
926
+ return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
927
+ }
928
+ var LEVEL_RANK = {
929
+ none: 0,
930
+ error: 1,
931
+ warn: 2,
932
+ info: 3,
933
+ debug: 4
934
+ };
935
+ function scopedLogger(logger, scope, bindings) {
936
+ const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
937
+ const safe = (event) => ({
938
+ msg: event.msg,
939
+ scope,
940
+ bindings,
941
+ fields: event.fields ?? {},
942
+ ...event.cause === void 0 ? {} : { cause: event.cause }
943
+ });
944
+ const unredacted = (event) => ({
945
+ msg: event.msg,
946
+ scope,
947
+ bindings,
948
+ fields: event.fields ?? {}
949
+ });
950
+ const self = {
951
+ child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
952
+ debug: (event) => {
953
+ if (admits("debug")) logger.debug(() => unredacted(event()));
954
+ },
955
+ info: (event) => {
956
+ if (admits("info")) logger.info(() => safe(event()));
957
+ },
958
+ warn: (event) => {
959
+ if (admits("warn")) logger.warn(() => safe(event()));
960
+ },
961
+ error: (event) => {
962
+ if (admits("error")) logger.error(() => safe(event()));
963
+ },
964
+ failure: (event, error) => {
965
+ if (admits("debug"))
966
+ logger.debug(() => unredacted(verbatim(event(), error)));
967
+ if (admits("error")) logger.error(() => safe(classified(event(), error)));
968
+ },
969
+ warning: (event, error) => {
970
+ if (admits("debug"))
971
+ logger.debug(() => unredacted(verbatim(event(), error)));
972
+ if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
973
+ },
974
+ wrap: async (op, params, run) => {
975
+ const opLog = self.child({ op });
976
+ opLog.debug(() => ({ msg: "call", fields: { params } }));
977
+ try {
978
+ return await run();
979
+ } catch (error) {
980
+ opLog.failure(() => ({ msg: "call failed" }), error);
981
+ throw error;
982
+ }
983
+ }
984
+ };
985
+ return self;
986
+ }
987
+ function verbatim(event, error) {
988
+ return {
989
+ msg: event.msg,
990
+ fields: { ...event.fields, error: describeErrorUnredacted(error) }
991
+ };
599
992
  }
600
-
601
- // src/universal/core/shared/utils/wire.ts
602
- function unknownTypeError(dto, model) {
603
- const type = dto.type;
604
- throw new ValidationError(
605
- `${model}.type: unknown type ${JSON.stringify(type)}`
606
- );
993
+ function classified(event, error) {
994
+ return { ...event, cause: event.cause ?? classifyLogCause(error) };
607
995
  }
608
- function requiredString(value, field) {
609
- const text = notBlankStringOrNull(value);
610
- if (text === null) {
611
- throw new ValidationError(
612
- `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
613
- );
996
+ var noopInternalLogger = {
997
+ child: () => noopInternalLogger,
998
+ debug: () => void 0,
999
+ info: () => void 0,
1000
+ warn: () => void 0,
1001
+ error: () => void 0,
1002
+ failure: () => void 0,
1003
+ warning: () => void 0,
1004
+ wrap: (_op, _params, run) => run()
1005
+ };
1006
+
1007
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
1008
+ var CentrifugeNamespaceImpl = class {
1009
+ constructor(ctx) {
1010
+ this.ctx = ctx;
1011
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
614
1012
  }
615
- return text;
616
- }
617
- function requiredDate(value, field) {
618
- const date = typeof value === "string" ? new Date(value) : null;
619
- if (date === null || Number.isNaN(date.getTime())) {
620
- throw new ValidationError(
621
- `${field}: expected a date, got ${JSON.stringify(value)}`
622
- );
1013
+ async getQuote(params) {
1014
+ return this.log.wrap("getQuote", params, async () => {
1015
+ await this.ctx.ensureUserAuthenticated();
1016
+ return getCentrifugeVaultQuote(this.ctx.api, params);
1017
+ });
623
1018
  }
624
- return date;
625
- }
626
- function dateOrNull(value, field) {
627
- return value === null ? null : requiredDate(value, field);
628
- }
629
- function decimalOrNull(value) {
630
- return value === null ? null : DecimalString(value);
631
- }
632
- function requiredArray(value, field) {
633
- if (!Array.isArray(value)) {
634
- throw new ValidationError(
635
- `${field}: expected an array, got ${typeof value}`
636
- );
1019
+ async getVaultStatus(params) {
1020
+ return this.log.wrap("getVaultStatus", params, async () => {
1021
+ await this.ctx.ensureUserAuthenticated();
1022
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1023
+ });
637
1024
  }
638
- return value;
639
- }
1025
+ };
1026
+
1027
+ // src/universal/types/pagination.ts
1028
+ var Cursor = (value) => value;
1029
+ var PaginatedResponse = {
1030
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1031
+ /**
1032
+ * For a mapper that decides the page as a whole - one that drops items it
1033
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1034
+ * cursors are the wire's either way: dropping an item changes what the
1035
+ * page holds, not where the next page starts.
1036
+ */
1037
+ fromDtoPage: (dto, pageMapper) => ({
1038
+ data: pageMapper(dto.data),
1039
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1040
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1041
+ })
1042
+ };
1043
+ var PaginationParams = {
1044
+ toQueryParams: (params) => {
1045
+ const queryParams = {};
1046
+ if (params.after) {
1047
+ queryParams.starting_after = params.after;
1048
+ }
1049
+ if (params.before) {
1050
+ queryParams.starting_before = params.before;
1051
+ }
1052
+ if (params.limit) {
1053
+ queryParams.limit = params.limit;
1054
+ }
1055
+ return queryParams;
1056
+ }
1057
+ };
1058
+
1059
+ // src/universal/types/asset.ts
1060
+ var AssetId = (value) => value;
1061
+ var AssetCode = (value) => value;
1062
+ var Asset = {
1063
+ fromDto: (dto) => ({
1064
+ id: AssetId(dto.id),
1065
+ code: AssetCode(dto.code),
1066
+ name: dto.name,
1067
+ fractionalDigits: dto.fractional_digits
1068
+ })
1069
+ };
640
1070
 
641
1071
  // src/universal/types/offer.ts
642
1072
  var OfferId = (value) => value;
@@ -874,265 +1304,82 @@ var Milestone = {
874
1304
  var ParticipationId = (value) => value;
875
1305
  var Blockchain = (value) => value;
876
1306
  var WalletAddress = (value) => value;
877
- var ParticipationsPaginationParams = {
878
- toQueryParams: (params) => {
879
- const queryParams = PaginationParams.toQueryParams(params);
880
- if (params.offerId) {
881
- queryParams["filters[0][field]"] = "offer_id";
882
- queryParams["filters[0][op]"] = "==";
883
- queryParams["filters[0][value]"] = params.offerId;
884
- }
885
- return queryParams;
886
- }
887
- };
888
- var Participation = {
889
- /** Maps API DTO shape into the SDK participation domain model. */
890
- fromDto: (dto) => {
891
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
892
- return {
893
- id: ParticipationId(dto.id),
894
- offerId: OfferId(dto.offer_id),
895
- offerOptionId: OfferOptionId(dto.offer_option_id),
896
- status: dto.status,
897
- amount: dto.amount,
898
- displayAmount: dto.amount_string,
899
- asset: Asset.fromDto(dto.asset),
900
- chain: Blockchain(dto.chain),
901
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
902
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
903
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
904
- };
905
- }
906
- };
907
- var CreateParticipationParams = {
908
- /** Maps participation creation params into API DTO payload. */
909
- toDto: (params) => ({
910
- offer_id: params.offerId,
911
- offer_option_id: params.offerOptionId,
912
- chain: params.chain,
913
- wallet_address: params.walletAddress,
914
- amount: params.amount,
915
- asset_id: params.assetId,
916
- approval_transaction_hash: params.approvalTransactionHash
917
- })
918
- };
919
-
920
- // src/universal/api/frontline/providers/coin-list/token-sale.ts
921
- async function fetchParticipations(api, offerId) {
922
- return fetchAllPages(
923
- (params) => fetchParticipationsPage(api, params),
924
- { offerId }
925
- );
926
- }
927
- async function fetchParticipationsPage(api, params) {
928
- const pageDto = await api.send({
929
- method: "GET",
930
- url: "/v1/participations",
931
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
932
- attributes: Attributes.protected()
933
- });
934
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
935
- }
936
- async function fetchParticipation(api, id) {
937
- const dto = await api.send({
938
- method: "GET",
939
- url: `/v1/participations/${id}`,
940
- attributes: Attributes.protected()
941
- });
942
- return Participation.fromDto(dto);
943
- }
944
- async function createParticipation(api, params) {
945
- const dto = await api.send({
946
- method: "POST",
947
- url: "/v1/participations",
948
- body: CreateParticipationParams.toDto(params),
949
- attributes: Attributes.protected()
950
- });
951
- return Participation.fromDto(dto);
952
- }
953
-
954
- // src/universal/core/shared/observability/log-cause.ts
955
- import {
956
- BaseError,
957
- ContractFunctionExecutionError,
958
- ContractFunctionRevertedError,
959
- HttpRequestError,
960
- RpcError,
961
- SocketClosedError,
962
- TimeoutError,
963
- WebSocketRequestError
964
- } from "viem";
965
- function classifyLogCause(error) {
966
- if (error instanceof HttpError) {
967
- return httpCause(error);
968
- }
969
- if (error instanceof ValidationError) {
970
- return { type: "validation", message: error.message };
971
- }
972
- if (error instanceof InvariantError) {
973
- return { type: "invariant", message: error.message };
974
- }
975
- if (error instanceof MathError) {
976
- return { type: "math", message: error.message };
977
- }
978
- if (error instanceof NotAuthenticatedError) {
979
- return { type: "not-authenticated" };
980
- }
981
- if (error instanceof NotImplementedError) {
982
- return { type: "not-implemented" };
983
- }
984
- if (error instanceof BaseError) {
985
- const http = error.walk((e) => e instanceof HttpError);
986
- if (http instanceof HttpError) {
987
- return httpCause(http);
988
- }
989
- return { type: "rpc", reason: rpcFailureReason(error) };
990
- }
991
- return { type: "generic-error", name: errorName(error) };
992
- }
993
- function rpcFailureReason(error) {
994
- if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
995
- return "reverted";
996
- }
997
- if (error.walk((e) => e instanceof RpcError)) {
998
- return "node-rejected";
999
- }
1000
- if (error.walk(
1001
- (e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
1002
- )) {
1003
- return "transport";
1004
- }
1005
- if (error instanceof ContractFunctionExecutionError) {
1006
- return "malformed-response";
1007
- }
1008
- return "unknown";
1009
- }
1010
- function describeErrorUnredacted(error) {
1011
- if (error instanceof HttpError) {
1012
- return describeHttpErrorRedacted(error);
1013
- }
1014
- if (error instanceof Error) {
1015
- return `${error.name}: ${error.message}`;
1307
+ var ParticipationsPaginationParams = {
1308
+ toQueryParams: (params) => {
1309
+ const queryParams = PaginationParams.toQueryParams(params);
1310
+ if (params.offerId) {
1311
+ queryParams["filters[0][field]"] = "offer_id";
1312
+ queryParams["filters[0][op]"] = "==";
1313
+ queryParams["filters[0][value]"] = params.offerId;
1314
+ }
1315
+ return queryParams;
1016
1316
  }
1017
- return `thrown non-error: ${stringifyUnredacted(error)}`;
1018
- }
1019
- function stringifyUnredacted(value) {
1020
- if (value === void 0) return "";
1021
- try {
1022
- return JSON.stringify(
1023
- value,
1024
- (_key, item) => typeof item === "bigint" ? `${item}` : item
1025
- ) ?? String(value);
1026
- } catch (_) {
1027
- return "<unserializable>";
1317
+ };
1318
+ var Participation = {
1319
+ /** Maps API DTO shape into the SDK participation domain model. */
1320
+ fromDto: (dto) => {
1321
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
1322
+ return {
1323
+ id: ParticipationId(dto.id),
1324
+ offerId: OfferId(dto.offer_id),
1325
+ offerOptionId: OfferOptionId(dto.offer_option_id),
1326
+ status: dto.status,
1327
+ amount: dto.amount,
1328
+ displayAmount: dto.amount_string,
1329
+ asset: Asset.fromDto(dto.asset),
1330
+ chain: Blockchain(dto.chain),
1331
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1332
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1333
+ walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1334
+ };
1028
1335
  }
1029
- }
1030
- function describeHttpErrorRedacted(error) {
1031
- const code = apiErrorCode(error);
1032
- const status = error.response.status;
1033
- return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
1034
- }
1035
- function errorName(error) {
1036
- return error instanceof Error ? error.name : `non-error ${typeof error}`;
1037
- }
1038
- function httpCause(error) {
1039
- return {
1040
- type: "http",
1041
- requestId: error.requestId,
1042
- status: error.response.status,
1043
- code: apiErrorCode(error),
1044
- eventId: apiErrorEventId(error)
1045
- };
1046
- }
1047
- function apiErrorEventId(error) {
1048
- const body = error.response.body;
1049
- if (typeof body !== "object" || body === null) return null;
1050
- const eventId = body.event_id;
1051
- return typeof eventId === "string" ? eventId : null;
1052
- }
1336
+ };
1337
+ var CreateParticipationParams = {
1338
+ /** Maps participation creation params into API DTO payload. */
1339
+ toDto: (params) => ({
1340
+ offer_id: params.offerId,
1341
+ offer_option_id: params.offerOptionId,
1342
+ chain: params.chain,
1343
+ wallet_address: params.walletAddress,
1344
+ amount: params.amount,
1345
+ asset_id: params.assetId,
1346
+ approval_transaction_hash: params.approvalTransactionHash
1347
+ })
1348
+ };
1053
1349
 
1054
- // src/universal/core/shared/observability/internal-logger.ts
1055
- function internalLogger(logger, scope) {
1056
- return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1350
+ // src/universal/api/frontline/providers/coin-list/token-sale.ts
1351
+ async function fetchParticipations(api, offerId) {
1352
+ return fetchAllPages(
1353
+ (params) => fetchParticipationsPage(api, params),
1354
+ { offerId }
1355
+ );
1057
1356
  }
1058
- var LEVEL_RANK = {
1059
- none: 0,
1060
- error: 1,
1061
- warn: 2,
1062
- info: 3,
1063
- debug: 4
1064
- };
1065
- function scopedLogger(logger, scope, bindings) {
1066
- const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
1067
- const safe = (event) => ({
1068
- msg: event.msg,
1069
- scope,
1070
- bindings,
1071
- fields: event.fields ?? {},
1072
- ...event.cause === void 0 ? {} : { cause: event.cause }
1073
- });
1074
- const unredacted = (event) => ({
1075
- msg: event.msg,
1076
- scope,
1077
- bindings,
1078
- fields: event.fields ?? {}
1357
+ async function fetchParticipationsPage(api, params) {
1358
+ const pageDto = await api.send({
1359
+ method: "GET",
1360
+ url: "/v1/participations",
1361
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
1362
+ attributes: Attributes.protected()
1079
1363
  });
1080
- const self = {
1081
- child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
1082
- debug: (event) => {
1083
- if (admits("debug")) logger.debug(() => unredacted(event()));
1084
- },
1085
- info: (event) => {
1086
- if (admits("info")) logger.info(() => safe(event()));
1087
- },
1088
- warn: (event) => {
1089
- if (admits("warn")) logger.warn(() => safe(event()));
1090
- },
1091
- error: (event) => {
1092
- if (admits("error")) logger.error(() => safe(event()));
1093
- },
1094
- failure: (event, error) => {
1095
- if (admits("debug"))
1096
- logger.debug(() => unredacted(verbatim(event(), error)));
1097
- if (admits("error")) logger.error(() => safe(classified(event(), error)));
1098
- },
1099
- warning: (event, error) => {
1100
- if (admits("debug"))
1101
- logger.debug(() => unredacted(verbatim(event(), error)));
1102
- if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
1103
- },
1104
- wrap: async (op, params, run) => {
1105
- const opLog = self.child({ op });
1106
- opLog.debug(() => ({ msg: "call", fields: { params } }));
1107
- try {
1108
- return await run();
1109
- } catch (error) {
1110
- opLog.failure(() => ({ msg: "call failed" }), error);
1111
- throw error;
1112
- }
1113
- }
1114
- };
1115
- return self;
1364
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1116
1365
  }
1117
- function verbatim(event, error) {
1118
- return {
1119
- msg: event.msg,
1120
- fields: { ...event.fields, error: describeErrorUnredacted(error) }
1121
- };
1366
+ async function fetchParticipation(api, id) {
1367
+ const dto = await api.send({
1368
+ method: "GET",
1369
+ url: `/v1/participations/${id}`,
1370
+ attributes: Attributes.protected()
1371
+ });
1372
+ return Participation.fromDto(dto);
1122
1373
  }
1123
- function classified(event, error) {
1124
- return { ...event, cause: event.cause ?? classifyLogCause(error) };
1374
+ async function createParticipation(api, params) {
1375
+ const dto = await api.send({
1376
+ method: "POST",
1377
+ url: "/v1/participations",
1378
+ body: CreateParticipationParams.toDto(params),
1379
+ attributes: Attributes.protected()
1380
+ });
1381
+ return Participation.fromDto(dto);
1125
1382
  }
1126
- var noopInternalLogger = {
1127
- child: () => noopInternalLogger,
1128
- debug: () => void 0,
1129
- info: () => void 0,
1130
- warn: () => void 0,
1131
- error: () => void 0,
1132
- failure: () => void 0,
1133
- warning: () => void 0,
1134
- wrap: (_op, _params, run) => run()
1135
- };
1136
1383
 
1137
1384
  // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1138
1385
  var CoinListTokenSaleNamespaceImpl = class {
@@ -1340,66 +1587,6 @@ function explorerBaseUrl(chain) {
1340
1587
  }
1341
1588
  }
1342
1589
 
1343
- // src/universal/core/shared/blockchain/math.ts
1344
- import { parseUnits } from "viem";
1345
- function blockchainAmountFromRawOrThrow({
1346
- label,
1347
- raw,
1348
- decimals
1349
- }) {
1350
- const trimmed = raw.trim();
1351
- if (trimmed === "") {
1352
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1353
- }
1354
- let value;
1355
- try {
1356
- value = BigInt(trimmed);
1357
- } catch {
1358
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1359
- }
1360
- try {
1361
- return BlockchainAmount({ raw: assertUint256(value), decimals });
1362
- } catch {
1363
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1364
- }
1365
- }
1366
- function parseBlockchainAmount(amount, decimals) {
1367
- const trimmed = amount.trim();
1368
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1369
- if (trimmed.startsWith("-")) {
1370
- return { valid: false, reason: { type: "negative" } };
1371
- }
1372
- if (/[eE]/.test(trimmed)) {
1373
- return { valid: false, reason: { type: "invalid-format" } };
1374
- }
1375
- if (trimmed === ".") {
1376
- return { valid: false, reason: { type: "invalid-format" } };
1377
- }
1378
- const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
1379
- if (!/^\d+(\.\d+)?$/.test(normalised)) {
1380
- return { valid: false, reason: { type: "invalid-format" } };
1381
- }
1382
- const [, fraction = ""] = normalised.split(".");
1383
- if (fraction.length > decimals) {
1384
- return {
1385
- valid: false,
1386
- reason: { type: "too-many-decimals", maxDecimals: decimals }
1387
- };
1388
- }
1389
- try {
1390
- const raw = parseUnits(normalised, decimals);
1391
- if (raw > MAX_UINT_256) {
1392
- return { valid: false, reason: { type: "overflow" } };
1393
- }
1394
- return {
1395
- valid: true,
1396
- amount: BlockchainAmount({ raw, decimals })
1397
- };
1398
- } catch {
1399
- return { valid: false, reason: { type: "invalid-format" } };
1400
- }
1401
- }
1402
-
1403
1590
  // src/universal/types/providers/ondo/ondo.ts
1404
1591
  var OndoTradingStatus = {
1405
1592
  fromDto: (dto) => {
@@ -3549,12 +3736,6 @@ export {
3549
3736
  isExpired,
3550
3737
  ERC20_ABI,
3551
3738
  fetchAllPages,
3552
- Cursor,
3553
- PaginatedResponse,
3554
- PaginationParams,
3555
- AssetId,
3556
- AssetCode,
3557
- Asset,
3558
3739
  ETHEREUM_CHAINS,
3559
3740
  EthereumChain,
3560
3741
  SOLANA_CHAINS,
@@ -3576,9 +3757,20 @@ export {
3576
3757
  StablecoinSymbol,
3577
3758
  KnownAssetSymbol,
3578
3759
  Bps,
3579
- requiredDate,
3580
- dateOrNull,
3581
- decimalOrNull,
3760
+ blockchainAmountFromRawOrThrow,
3761
+ parseBlockchainAmount,
3762
+ CentrifugeVaultQuote,
3763
+ CentrifugeVaultStatus,
3764
+ CentrifugeVaultBuyTransaction,
3765
+ CentrifugeVaultClaimTransaction,
3766
+ CentrifugeVaultPosition,
3767
+ CentrifugeNamespaceImpl,
3768
+ Cursor,
3769
+ PaginatedResponse,
3770
+ PaginationParams,
3771
+ AssetId,
3772
+ AssetCode,
3773
+ Asset,
3582
3774
  OfferId,
3583
3775
  OfferSlug,
3584
3776
  isOfferType,
@@ -3625,8 +3817,6 @@ export {
3625
3817
  chainFromId,
3626
3818
  getNetworkName,
3627
3819
  txExplorerUrl,
3628
- blockchainAmountFromRawOrThrow,
3629
- parseBlockchainAmount,
3630
3820
  OndoTradingStatus,
3631
3821
  OndoQuote,
3632
3822
  OndoBuyTransaction,
@@ -3667,4 +3857,4 @@ export {
3667
3857
  OAuthRefreshToken,
3668
3858
  OAuthSession
3669
3859
  };
3670
- //# sourceMappingURL=chunk-NBO5E2RO.js.map
3860
+ //# sourceMappingURL=chunk-XCRU3YE2.js.map