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

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-4IZ2F732.js} +2 -2
  2. package/dist/{chunk-BNMF2HMW.js → chunk-NBO5E2RO.js} +39 -3
  3. package/dist/chunk-NBO5E2RO.js.map +1 -0
  4. package/dist/{chunk-KRA6EM2L.js → chunk-UJYSXXJF.js} +168 -3
  5. package/dist/chunk-UJYSXXJF.js.map +1 -0
  6. package/dist/client/index.cjs +147 -49
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +92 -29
  9. package/dist/client/index.d.ts +92 -29
  10. package/dist/client/index.js +75 -15
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +70 -40
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +20 -5
  15. package/dist/server/index.d.ts +20 -5
  16. package/dist/server/index.js +7 -6
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/{time-BY3apBpc.d.cts → time-CFocgYyl.d.cts} +1 -1
  19. package/dist/{time-B5YOQxuh.d.ts → time-DvgN98Q9.d.ts} +1 -1
  20. package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-BsAfBL_b.d.ts} +9 -7
  21. package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-Cc_eA5zM.d.cts} +9 -7
  22. package/dist/{tokens-namespace-BJfFeowE.d.cts → tokens-namespace-D_XSpiS-.d.cts} +102 -19
  23. package/dist/{tokens-namespace-BJfFeowE.d.ts → tokens-namespace-D_XSpiS-.d.ts} +102 -19
  24. package/dist/universal/index.cjs +233 -37
  25. package/dist/universal/index.cjs.map +1 -1
  26. package/dist/universal/index.d.cts +341 -6
  27. package/dist/universal/index.d.ts +341 -6
  28. package/dist/universal/index.js +18 -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-4IZ2F732.js.map} +0 -0
@@ -32,6 +32,11 @@ __export(universal_exports, {
32
32
  Blockchain: () => Blockchain,
33
33
  BlockchainAmount: () => BlockchainAmount,
34
34
  Bps: () => Bps,
35
+ CentrifugeVaultBuyTransaction: () => CentrifugeVaultBuyTransaction,
36
+ CentrifugeVaultClaimTransaction: () => CentrifugeVaultClaimTransaction,
37
+ CentrifugeVaultPosition: () => CentrifugeVaultPosition,
38
+ CentrifugeVaultQuote: () => CentrifugeVaultQuote,
39
+ CentrifugeVaultStatus: () => CentrifugeVaultStatus,
35
40
  Chain: () => Chain,
36
41
  ClientCredentialsOAuth: () => ClientCredentialsOAuth,
37
42
  ClientId: () => ClientId,
@@ -78,6 +83,7 @@ __export(universal_exports, {
78
83
  NotImplementedError: () => NotImplementedError,
79
84
  OAuthRefreshToken: () => OAuthRefreshToken,
80
85
  OAuthSession: () => OAuthSession,
86
+ ONDO_NOT_TRADABLE_CODE: () => ONDO_NOT_TRADABLE_CODE,
81
87
  ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
82
88
  ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
83
89
  ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
@@ -94,6 +100,7 @@ __export(universal_exports, {
94
100
  OfferSlug: () => OfferSlug,
95
101
  OfferSwapContract: () => OfferSwapContract,
96
102
  OfferToken: () => OfferToken,
103
+ OfferVaultContract: () => OfferVaultContract,
97
104
  OffersNamespaceImpl: () => OffersNamespaceImpl,
98
105
  OndoBuyTransaction: () => OndoBuyTransaction,
99
106
  OndoNamespaceImpl: () => OndoNamespaceImpl,
@@ -178,6 +185,7 @@ __export(universal_exports, {
178
185
  isChain: () => isChain,
179
186
  isExpired: () => isExpired,
180
187
  isOfferType: () => isOfferType,
188
+ isOndoNotTradableError: () => isOndoNotTradableError,
181
189
  isSwapAvailable: () => isSwapAvailable,
182
190
  offerDisplayTokens: () => offerDisplayTokens,
183
191
  ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
@@ -530,40 +538,6 @@ var MathError = class extends Error {
530
538
  }
531
539
  };
532
540
 
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
541
  // src/universal/types/blockchain/core.ts
568
542
  var ETHEREUM_CHAINS = {
569
543
  ethereum_mainnet: true,
@@ -661,13 +635,54 @@ var StablecoinSymbol = (value) => value;
661
635
  var KnownAssetSymbol = StablecoinSymbol;
662
636
  var Bps = (value) => value;
663
637
 
638
+ // src/universal/core/shared/utils/wire.ts
639
+ function unknownTypeError(dto, model) {
640
+ const type = dto.type;
641
+ throw new ValidationError(
642
+ `${model}.type: unknown type ${JSON.stringify(type)}`
643
+ );
644
+ }
645
+ function requiredString(value, field) {
646
+ const text = notBlankStringOrNull(value);
647
+ if (text === null) {
648
+ throw new ValidationError(
649
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
650
+ );
651
+ }
652
+ return text;
653
+ }
654
+ function requiredDate(value, field) {
655
+ const date = typeof value === "string" ? new Date(value) : null;
656
+ if (date === null || Number.isNaN(date.getTime())) {
657
+ throw new ValidationError(
658
+ `${field}: expected a date, got ${JSON.stringify(value)}`
659
+ );
660
+ }
661
+ return date;
662
+ }
663
+ function dateOrNull(value, field) {
664
+ return value === null ? null : requiredDate(value, field);
665
+ }
666
+ function decimalOrNull(value) {
667
+ return value === null ? null : DecimalString(value);
668
+ }
669
+ function requiredArray(value, field) {
670
+ if (!Array.isArray(value)) {
671
+ throw new ValidationError(
672
+ `${field}: expected an array, got ${typeof value}`
673
+ );
674
+ }
675
+ return value;
676
+ }
677
+
664
678
  // src/universal/types/offer.ts
665
679
  var OfferId = (value) => value;
666
680
  var OfferSlug = (value) => value;
667
681
  var OFFER_TYPES = {
668
682
  "coinlist::token_sale": true,
669
683
  "superstate::swap": true,
670
- "ondo::swap": true
684
+ "ondo::swap": true,
685
+ "centrifuge::vault": true
671
686
  };
672
687
  var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
673
688
  var OfferEditorial = {
@@ -709,6 +724,7 @@ var Offer = {
709
724
  // on the wire: copying them would hand every consumer a `startsAt` that
710
725
  // is 1970 for one variant and a date for the others.
711
726
  case "ondo::swap":
727
+ case "centrifuge::vault":
712
728
  return {
713
729
  ...base2,
714
730
  type: dto.type,
@@ -761,6 +777,19 @@ var OfferSwapContract = {
761
777
  address: EvmContractAddress(dto.address)
762
778
  })
763
779
  };
780
+ var OfferVaultContract = {
781
+ fromDto: (dto) => ({
782
+ chain: Chain(dto.chain),
783
+ address: EvmContractAddress(dto.address)
784
+ }),
785
+ /**
786
+ * Drops every proxy on a chain this SDK does not name, as
787
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
788
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
789
+ * should not throw away the proxies the SDK can use.
790
+ */
791
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
792
+ };
764
793
  var OfferDetail = {
765
794
  fromDto: (dto) => {
766
795
  const fundingAssets = requiredArray(
@@ -823,6 +852,18 @@ var OfferDetail = {
823
852
  "OfferDetail.swap_contracts"
824
853
  ).map(OfferSwapContract.fromDto)
825
854
  };
855
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
856
+ // the same reason as `swap_contracts`: this is the spender a user
857
+ // approves.
858
+ case "centrifuge::vault":
859
+ return {
860
+ ...base2,
861
+ type: dto.type,
862
+ logoUrl: notBlankStringOrNull(dto.logo_url),
863
+ vaultContracts: OfferVaultContract.listFromDto(
864
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
865
+ )
866
+ };
826
867
  default:
827
868
  return unknownTypeError(dto, "OfferDetail");
828
869
  }
@@ -1269,6 +1310,12 @@ function assertPriceFits(raw) {
1269
1310
  }
1270
1311
  }
1271
1312
 
1313
+ // src/universal/core/checkout/ondo/not-tradable.ts
1314
+ var ONDO_NOT_TRADABLE_CODE = "not_tradable";
1315
+ function isOndoNotTradableError(error) {
1316
+ return apiErrorCode(error) === ONDO_NOT_TRADABLE_CODE;
1317
+ }
1318
+
1272
1319
  // src/universal/core/shared/blockchain/formatters.ts
1273
1320
  var import_viem2 = require("viem");
1274
1321
 
@@ -1520,7 +1567,6 @@ var OndoTradingStatus = {
1520
1567
  };
1521
1568
  }
1522
1569
  };
1523
- var decimalOrNull = (value) => value === null ? null : DecimalString(value);
1524
1570
  var OndoQuote = {
1525
1571
  fromDto: (dto) => {
1526
1572
  const assetDecimals = AssetDecimals(dto.asset_decimals);
@@ -3351,7 +3397,9 @@ var TokenRegistrySnapshot = {
3351
3397
  }
3352
3398
  };
3353
3399
  function offerDisplayTokens(offer) {
3354
- const swaps = offer.tokens.filter((token) => token.role === "swap");
3400
+ const swaps = offer.tokens.filter(
3401
+ (token) => token.role === "swap" || token.role === "vault"
3402
+ );
3355
3403
  const distributions = offer.tokens.filter(
3356
3404
  (token) => token.role === "distribution"
3357
3405
  );
@@ -3893,6 +3941,146 @@ var OAuthSession = {
3893
3941
  }
3894
3942
  };
3895
3943
 
3944
+ // src/universal/types/providers/centrifuge/centrifuge.ts
3945
+ var CentrifugeVaultQuote = {
3946
+ fromDto: (dto) => {
3947
+ const spendDecimals = AssetDecimals(dto.spend_input_decimals);
3948
+ const shareDecimals = AssetDecimals(dto.share_decimals);
3949
+ return {
3950
+ chain: EthereumChain(dto.chain),
3951
+ symbol: AssetSymbol(dto.symbol),
3952
+ spendInputAmount: blockchainAmountFromRawOrThrow({
3953
+ label: "spend_input_amount",
3954
+ raw: dto.spend_input_amount,
3955
+ decimals: spendDecimals
3956
+ }),
3957
+ estimatedShares: blockchainAmountFromRawOrThrow({
3958
+ label: "estimated_shares",
3959
+ raw: dto.estimated_shares,
3960
+ decimals: shareDecimals
3961
+ }),
3962
+ indicativePrice: decimalOrNull(dto.indicative_price),
3963
+ minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
3964
+ label: "minimum_input_amount",
3965
+ raw: dto.minimum_input_amount,
3966
+ decimals: spendDecimals
3967
+ }),
3968
+ orderability: parseOrderability(
3969
+ dto.can_order,
3970
+ dto.reasons,
3971
+ "CentrifugeVaultQuote"
3972
+ )
3973
+ };
3974
+ }
3975
+ };
3976
+ var CentrifugeVaultStatus = {
3977
+ fromDto: (dto) => ({
3978
+ chain: EthereumChain(dto.chain),
3979
+ symbol: AssetSymbol(dto.symbol),
3980
+ vaultAddress: EvmContractAddress(dto.vault_address),
3981
+ linked: dto.linked,
3982
+ permissioned: dto.permissioned,
3983
+ membershipValidUntil: dateOrNull(
3984
+ dto.membership_valid_until,
3985
+ "CentrifugeVaultStatus.membership_valid_until"
3986
+ ),
3987
+ halted: dto.halted,
3988
+ priceUpdatedAt: dateOrNull(
3989
+ dto.price_updated_at,
3990
+ "CentrifugeVaultStatus.price_updated_at"
3991
+ ),
3992
+ orderability: parseOrderability(
3993
+ dto.can_order,
3994
+ dto.reasons,
3995
+ "CentrifugeVaultStatus"
3996
+ ),
3997
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
3998
+ })
3999
+ };
4000
+ var CentrifugeVaultBuyTransaction = {
4001
+ fromDto: (dto) => {
4002
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
4003
+ label: "spend_input_amount",
4004
+ raw: dto.spend_input_amount,
4005
+ decimals: AssetDecimals(dto.spend_input_decimals)
4006
+ });
4007
+ if (spendInputAmount.raw <= 0n) {
4008
+ throw new ValidationError(
4009
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
4010
+ );
4011
+ }
4012
+ return {
4013
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
4014
+ spendInputAmount,
4015
+ estimatedShares: blockchainAmountFromRawOrThrow({
4016
+ label: "estimated_shares",
4017
+ raw: dto.estimated_shares,
4018
+ decimals: AssetDecimals(dto.share_decimals)
4019
+ })
4020
+ };
4021
+ }
4022
+ };
4023
+ var CentrifugeVaultClaimTransaction = {
4024
+ fromDto: (dto) => ({
4025
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
4026
+ claimableShares: blockchainAmountFromRawOrThrow({
4027
+ label: "claimable_shares",
4028
+ raw: dto.claimable_shares,
4029
+ decimals: AssetDecimals(dto.share_decimals)
4030
+ })
4031
+ })
4032
+ };
4033
+ var CentrifugeVaultPosition = {
4034
+ fromDto: (dto) => {
4035
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
4036
+ const shareDecimals = AssetDecimals(dto.share_decimals);
4037
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
4038
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
4039
+ return {
4040
+ chain: EthereumChain(dto.chain),
4041
+ symbol: AssetSymbol(dto.symbol),
4042
+ walletAddress: EvmWalletAddress(dto.wallet_address),
4043
+ status: dto.status,
4044
+ requested: asset("requested", dto.requested),
4045
+ pending: asset("pending", dto.pending),
4046
+ filledAssets: asset("filled_assets", dto.filled_assets),
4047
+ earnedShares: shares("earned_shares", dto.earned_shares),
4048
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
4049
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
4050
+ shareBalance: shares("share_balance", dto.share_balance),
4051
+ averagePrice: decimalOrNull(dto.average_price),
4052
+ frozen: dto.frozen,
4053
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
4054
+ };
4055
+ }
4056
+ };
4057
+ function parseOrderability(canOrder, reasons, model) {
4058
+ const [first, ...rest] = reasons;
4059
+ if (canOrder) {
4060
+ if (first !== void 0) {
4061
+ throw new ValidationError(
4062
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
4063
+ );
4064
+ }
4065
+ return { type: "orderable" };
4066
+ }
4067
+ if (first === void 0) {
4068
+ throw new ValidationError(
4069
+ `${model}.reasons: expected at least one when can_order is false`
4070
+ );
4071
+ }
4072
+ return { type: "blocked", reasons: [first, ...rest] };
4073
+ }
4074
+ function parseTransactionCore(dto, model) {
4075
+ return {
4076
+ tx: {
4077
+ to: EvmContractAddress(dto.to),
4078
+ data: HexEncodedTransactionData(dto.data)
4079
+ },
4080
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
4081
+ };
4082
+ }
4083
+
3896
4084
  // src/universal/types/time.ts
3897
4085
  var MAX_EPOCH_MILLIS = 864e13;
3898
4086
  var EpochMillis = {
@@ -3964,6 +4152,11 @@ var User = {
3964
4152
  Blockchain,
3965
4153
  BlockchainAmount,
3966
4154
  Bps,
4155
+ CentrifugeVaultBuyTransaction,
4156
+ CentrifugeVaultClaimTransaction,
4157
+ CentrifugeVaultPosition,
4158
+ CentrifugeVaultQuote,
4159
+ CentrifugeVaultStatus,
3967
4160
  Chain,
3968
4161
  ClientCredentialsOAuth,
3969
4162
  ClientId,
@@ -4010,6 +4203,7 @@ var User = {
4010
4203
  NotImplementedError,
4011
4204
  OAuthRefreshToken,
4012
4205
  OAuthSession,
4206
+ ONDO_NOT_TRADABLE_CODE,
4013
4207
  ONDO_POLL_INTERVAL_MS,
4014
4208
  ONDO_QUOTE_MAX_TTL_MS,
4015
4209
  ONDO_SETTLEMENT_ASSET,
@@ -4026,6 +4220,7 @@ var User = {
4026
4220
  OfferSlug,
4027
4221
  OfferSwapContract,
4028
4222
  OfferToken,
4223
+ OfferVaultContract,
4029
4224
  OffersNamespaceImpl,
4030
4225
  OndoBuyTransaction,
4031
4226
  OndoNamespaceImpl,
@@ -4110,6 +4305,7 @@ var User = {
4110
4305
  isChain,
4111
4306
  isExpired,
4112
4307
  isOfferType,
4308
+ isOndoNotTradableError,
4113
4309
  isSwapAvailable,
4114
4310
  offerDisplayTokens,
4115
4311
  ondoQuoteOfferDeadline,