@coinlist-co/react 0.12.2-rc.a59b344 → 0.12.2-rc.aa91ce3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-UJYSXXJF.js → chunk-3OTYQADF.js} +62 -153
  2. package/dist/chunk-3OTYQADF.js.map +1 -0
  3. package/dist/{chunk-NBO5E2RO.js → chunk-IAY3F42Q.js} +863 -519
  4. package/dist/chunk-IAY3F42Q.js.map +1 -0
  5. package/dist/{chunk-4IZ2F732.js → chunk-QRVIBG6H.js} +2 -2
  6. package/dist/client/index.cjs +6031 -4024
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +758 -6
  9. package/dist/client/index.d.ts +758 -6
  10. package/dist/client/index.js +2449 -821
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +291 -26
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +9 -2
  15. package/dist/server/index.d.ts +9 -2
  16. package/dist/server/index.js +4 -2
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/{tokens-namespace-D_XSpiS-.d.cts → time-DyjvzWso.d.cts} +634 -41
  19. package/dist/{tokens-namespace-D_XSpiS-.d.ts → time-DyjvzWso.d.ts} +634 -41
  20. package/dist/{token-registry-snapshot-BsAfBL_b.d.ts → token-registry-snapshot-Bldj1r5X.d.ts} +66 -2
  21. package/dist/{token-registry-snapshot-Cc_eA5zM.d.cts → token-registry-snapshot-CbNCYP_5.d.cts} +66 -2
  22. package/dist/universal/index.cjs +736 -461
  23. package/dist/universal/index.cjs.map +1 -1
  24. package/dist/universal/index.d.cts +59 -321
  25. package/dist/universal/index.d.ts +59 -321
  26. package/dist/universal/index.js +25 -7
  27. package/package.json +1 -1
  28. package/dist/chunk-NBO5E2RO.js.map +0 -1
  29. package/dist/chunk-UJYSXXJF.js.map +0 -1
  30. package/dist/time-CFocgYyl.d.cts +0 -50
  31. package/dist/time-DvgN98Q9.d.ts +0 -50
  32. /package/dist/{chunk-4IZ2F732.js.map → chunk-QRVIBG6H.js.map} +0 -0
@@ -291,166 +291,6 @@ function isExpired({
291
291
  return now >= expiresAt - buffer;
292
292
  }
293
293
 
294
- // src/universal/core/shared/blockchain/erc20/abi.ts
295
- var ERC20_ABI = [
296
- {
297
- type: "function",
298
- name: "allowance",
299
- inputs: [
300
- { name: "owner", type: "address" },
301
- { name: "spender", type: "address" }
302
- ],
303
- outputs: [{ name: "", type: "uint256" }],
304
- stateMutability: "view"
305
- },
306
- {
307
- type: "function",
308
- name: "approve",
309
- inputs: [
310
- { name: "spender", type: "address" },
311
- { name: "amount", type: "uint256" }
312
- ],
313
- outputs: [{ name: "", type: "bool" }],
314
- stateMutability: "nonpayable"
315
- },
316
- {
317
- type: "function",
318
- name: "balanceOf",
319
- inputs: [{ name: "account", type: "address" }],
320
- outputs: [{ name: "", type: "uint256" }],
321
- stateMutability: "view"
322
- },
323
- {
324
- type: "function",
325
- name: "decimals",
326
- inputs: [],
327
- outputs: [{ name: "", type: "uint8" }],
328
- stateMutability: "view"
329
- },
330
- {
331
- type: "function",
332
- name: "name",
333
- inputs: [],
334
- outputs: [{ name: "", type: "string" }],
335
- stateMutability: "view"
336
- },
337
- {
338
- type: "function",
339
- name: "symbol",
340
- inputs: [],
341
- outputs: [{ name: "", type: "string" }],
342
- stateMutability: "view"
343
- },
344
- {
345
- type: "function",
346
- name: "totalSupply",
347
- inputs: [],
348
- outputs: [{ name: "", type: "uint256" }],
349
- stateMutability: "view"
350
- },
351
- {
352
- type: "function",
353
- name: "transfer",
354
- inputs: [
355
- { name: "recipient", type: "address" },
356
- { name: "amount", type: "uint256" }
357
- ],
358
- outputs: [{ name: "", type: "bool" }],
359
- stateMutability: "nonpayable"
360
- },
361
- {
362
- type: "function",
363
- name: "transferFrom",
364
- inputs: [
365
- { name: "sender", type: "address" },
366
- { name: "recipient", type: "address" },
367
- { name: "amount", type: "uint256" }
368
- ],
369
- outputs: [{ name: "", type: "bool" }],
370
- stateMutability: "nonpayable"
371
- },
372
- {
373
- type: "event",
374
- name: "Approval",
375
- inputs: [
376
- { name: "owner", type: "address", indexed: true },
377
- { name: "spender", type: "address", indexed: true },
378
- { name: "value", type: "uint256", indexed: false }
379
- ],
380
- anonymous: false
381
- },
382
- {
383
- type: "event",
384
- name: "Transfer",
385
- inputs: [
386
- { name: "from", type: "address", indexed: true },
387
- { name: "to", type: "address", indexed: true },
388
- { name: "value", type: "uint256", indexed: false }
389
- ],
390
- anonymous: false
391
- }
392
- ];
393
-
394
- // src/universal/api/pagination.ts
395
- async function fetchAllPages(fetchPage, baseParams) {
396
- const items = [];
397
- let cursor = null;
398
- do {
399
- const params = {
400
- ...baseParams ?? {},
401
- after: cursor ?? void 0
402
- };
403
- const page = await fetchPage(params);
404
- items.push(...page.data);
405
- cursor = page.startingAfter;
406
- } while (cursor);
407
- return items;
408
- }
409
-
410
- // src/universal/types/pagination.ts
411
- var Cursor = (value) => value;
412
- var PaginatedResponse = {
413
- fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
414
- /**
415
- * For a mapper that decides the page as a whole - one that drops items it
416
- * cannot map, such as `Offer.listFromDto` - rather than item by item. The
417
- * cursors are the wire's either way: dropping an item changes what the
418
- * page holds, not where the next page starts.
419
- */
420
- fromDtoPage: (dto, pageMapper) => ({
421
- data: pageMapper(dto.data),
422
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
423
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
424
- })
425
- };
426
- var PaginationParams = {
427
- toQueryParams: (params) => {
428
- const queryParams = {};
429
- if (params.after) {
430
- queryParams.starting_after = params.after;
431
- }
432
- if (params.before) {
433
- queryParams.starting_before = params.before;
434
- }
435
- if (params.limit) {
436
- queryParams.limit = params.limit;
437
- }
438
- return queryParams;
439
- }
440
- };
441
-
442
- // src/universal/types/asset.ts
443
- var AssetId = (value) => value;
444
- var AssetCode = (value) => value;
445
- var Asset = {
446
- fromDto: (dto) => ({
447
- id: AssetId(dto.id),
448
- code: AssetCode(dto.code),
449
- name: dto.name,
450
- fractionalDigits: dto.fractional_digits
451
- })
452
- };
453
-
454
294
  // src/universal/types/blockchain/core.ts
455
295
  var ETHEREUM_CHAINS = {
456
296
  ethereum_mainnet: true,
@@ -548,6 +388,66 @@ var StablecoinSymbol = (value) => value;
548
388
  var KnownAssetSymbol = StablecoinSymbol;
549
389
  var Bps = (value) => value;
550
390
 
391
+ // src/universal/core/shared/blockchain/math.ts
392
+ import { parseUnits } from "viem";
393
+ function blockchainAmountFromRawOrThrow({
394
+ label,
395
+ raw,
396
+ decimals
397
+ }) {
398
+ const trimmed = raw.trim();
399
+ if (trimmed === "") {
400
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
401
+ }
402
+ let value;
403
+ try {
404
+ value = BigInt(trimmed);
405
+ } catch {
406
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
407
+ }
408
+ try {
409
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
410
+ } catch {
411
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
412
+ }
413
+ }
414
+ function parseBlockchainAmount(amount, decimals) {
415
+ const trimmed = amount.trim();
416
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
417
+ if (trimmed.startsWith("-")) {
418
+ return { valid: false, reason: { type: "negative" } };
419
+ }
420
+ if (/[eE]/.test(trimmed)) {
421
+ return { valid: false, reason: { type: "invalid-format" } };
422
+ }
423
+ if (trimmed === ".") {
424
+ return { valid: false, reason: { type: "invalid-format" } };
425
+ }
426
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
427
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
428
+ return { valid: false, reason: { type: "invalid-format" } };
429
+ }
430
+ const [, fraction = ""] = normalised.split(".");
431
+ if (fraction.length > decimals) {
432
+ return {
433
+ valid: false,
434
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
435
+ };
436
+ }
437
+ try {
438
+ const raw = parseUnits(normalised, decimals);
439
+ if (raw > MAX_UINT_256) {
440
+ return { valid: false, reason: { type: "overflow" } };
441
+ }
442
+ return {
443
+ valid: true,
444
+ amount: BlockchainAmount({ raw, decimals })
445
+ };
446
+ } catch {
447
+ return { valid: false, reason: { type: "invalid-format" } };
448
+ }
449
+ }
450
+
551
451
  // src/universal/core/shared/utils/crypto.ts
552
452
  async function sha256(data) {
553
453
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
@@ -596,47 +496,702 @@ function notBlankStringOrNull(value) {
596
496
  } else {
597
497
  return null;
598
498
  }
599
- }
499
+ }
500
+
501
+ // src/universal/core/shared/utils/wire.ts
502
+ function unknownTypeError(dto, model) {
503
+ const type = dto.type;
504
+ throw new ValidationError(
505
+ `${model}.type: unknown type ${JSON.stringify(type)}`
506
+ );
507
+ }
508
+ function requiredString(value, field) {
509
+ const text = notBlankStringOrNull(value);
510
+ if (text === null) {
511
+ throw new ValidationError(
512
+ `${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
513
+ );
514
+ }
515
+ return text;
516
+ }
517
+ function requiredDate(value, field) {
518
+ const date = typeof value === "string" ? new Date(value) : null;
519
+ if (date === null || Number.isNaN(date.getTime())) {
520
+ throw new ValidationError(
521
+ `${field}: expected a date, got ${JSON.stringify(value)}`
522
+ );
523
+ }
524
+ return date;
525
+ }
526
+ function dateOrNull(value, field) {
527
+ return value === null ? null : requiredDate(value, field);
528
+ }
529
+ function decimalOrNull(value) {
530
+ return value === null ? null : DecimalString(value);
531
+ }
532
+ function requiredArray(value, field) {
533
+ if (!Array.isArray(value)) {
534
+ throw new ValidationError(
535
+ `${field}: expected an array, got ${typeof value}`
536
+ );
537
+ }
538
+ return value;
539
+ }
540
+
541
+ // src/universal/types/providers/centrifuge/centrifuge.ts
542
+ var CentrifugeVaultQuote = {
543
+ fromDto: (dto) => {
544
+ const spendDecimals = AssetDecimals(dto.spend_input_decimals);
545
+ const shareDecimals = AssetDecimals(dto.share_decimals);
546
+ return {
547
+ chain: EthereumChain(dto.chain),
548
+ symbol: AssetSymbol(dto.symbol),
549
+ spendInputAmount: blockchainAmountFromRawOrThrow({
550
+ label: "spend_input_amount",
551
+ raw: dto.spend_input_amount,
552
+ decimals: spendDecimals
553
+ }),
554
+ estimatedShares: blockchainAmountFromRawOrThrow({
555
+ label: "estimated_shares",
556
+ raw: dto.estimated_shares,
557
+ decimals: shareDecimals
558
+ }),
559
+ indicativePrice: decimalOrNull(dto.indicative_price),
560
+ minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
561
+ label: "minimum_input_amount",
562
+ raw: dto.minimum_input_amount,
563
+ decimals: spendDecimals
564
+ }),
565
+ orderability: parseOrderability(
566
+ dto.can_order,
567
+ dto.reasons,
568
+ "CentrifugeVaultQuote"
569
+ )
570
+ };
571
+ }
572
+ };
573
+ var CentrifugeVaultStatus = {
574
+ fromDto: (dto) => ({
575
+ chain: EthereumChain(dto.chain),
576
+ symbol: AssetSymbol(dto.symbol),
577
+ vaultAddress: EvmContractAddress(dto.vault_address),
578
+ linked: dto.linked,
579
+ permissioned: dto.permissioned,
580
+ membershipValidUntil: dateOrNull(
581
+ dto.membership_valid_until,
582
+ "CentrifugeVaultStatus.membership_valid_until"
583
+ ),
584
+ halted: dto.halted,
585
+ priceUpdatedAt: dateOrNull(
586
+ dto.price_updated_at,
587
+ "CentrifugeVaultStatus.price_updated_at"
588
+ ),
589
+ orderability: parseOrderability(
590
+ dto.can_order,
591
+ dto.reasons,
592
+ "CentrifugeVaultStatus"
593
+ ),
594
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
595
+ })
596
+ };
597
+ var CentrifugeVaultBuyTransaction = {
598
+ fromDto: (dto) => {
599
+ const spendInputAmount = blockchainAmountFromRawOrThrow({
600
+ label: "spend_input_amount",
601
+ raw: dto.spend_input_amount,
602
+ decimals: AssetDecimals(dto.spend_input_decimals)
603
+ });
604
+ if (spendInputAmount.raw <= 0n) {
605
+ throw new ValidationError(
606
+ `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
607
+ );
608
+ }
609
+ return {
610
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
611
+ spendInputAmount,
612
+ estimatedShares: blockchainAmountFromRawOrThrow({
613
+ label: "estimated_shares",
614
+ raw: dto.estimated_shares,
615
+ decimals: AssetDecimals(dto.share_decimals)
616
+ })
617
+ };
618
+ }
619
+ };
620
+ var CentrifugeVaultClaimTransaction = {
621
+ fromDto: (dto) => ({
622
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
623
+ claimableShares: blockchainAmountFromRawOrThrow({
624
+ label: "claimable_shares",
625
+ raw: dto.claimable_shares,
626
+ decimals: AssetDecimals(dto.share_decimals)
627
+ })
628
+ })
629
+ };
630
+ var CentrifugeVaultPosition = {
631
+ fromDto: (dto) => {
632
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
633
+ const shareDecimals = AssetDecimals(dto.share_decimals);
634
+ const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
635
+ const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
636
+ return {
637
+ chain: EthereumChain(dto.chain),
638
+ symbol: AssetSymbol(dto.symbol),
639
+ walletAddress: EvmWalletAddress(dto.wallet_address),
640
+ status: dto.status,
641
+ requested: asset("requested", dto.requested),
642
+ pending: asset("pending", dto.pending),
643
+ filledAssets: asset("filled_assets", dto.filled_assets),
644
+ earnedShares: shares("earned_shares", dto.earned_shares),
645
+ claimedShares: shares("claimed_shares", dto.claimed_shares),
646
+ claimableShares: shares("claimable_shares", dto.claimable_shares),
647
+ shareBalance: shares("share_balance", dto.share_balance),
648
+ averagePrice: decimalOrNull(dto.average_price),
649
+ frozen: dto.frozen,
650
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
651
+ };
652
+ }
653
+ };
654
+ var CentrifugeVaultRedeemPosition = {
655
+ fromDto: (dto) => ({
656
+ chain: EthereumChain(dto.chain),
657
+ symbol: AssetSymbol(dto.symbol),
658
+ walletAddress: EvmWalletAddress(dto.wallet_address),
659
+ status: dto.status,
660
+ pending: blockchainAmountFromRawOrThrow({
661
+ label: "pending",
662
+ raw: dto.pending,
663
+ decimals: AssetDecimals(dto.share_decimals)
664
+ }),
665
+ claimableAssets: blockchainAmountFromRawOrThrow({
666
+ label: "claimable_assets",
667
+ raw: dto.claimable_assets,
668
+ decimals: AssetDecimals(dto.asset_decimals)
669
+ }),
670
+ frozen: dto.frozen,
671
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
672
+ })
673
+ };
674
+ var CentrifugeVaultLeg = {
675
+ /**
676
+ * What a claim on the leg would collect: shares for `invest`, the funding
677
+ * token for `redeem`.
678
+ */
679
+ claimable: (leg) => {
680
+ switch (leg.direction) {
681
+ case "invest":
682
+ return leg.position.claimableShares;
683
+ case "redeem":
684
+ return leg.position.claimableAssets;
685
+ default: {
686
+ const exhaustive = leg;
687
+ return exhaustive;
688
+ }
689
+ }
690
+ },
691
+ /** Whether the leg has anything queued or anything ready to claim. */
692
+ isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
693
+ };
694
+ var CentrifugeVaultLegId = {
695
+ /** Addresses compare case-insensitively: frontline echoes them lower case. */
696
+ of: (leg) => [
697
+ leg.direction,
698
+ leg.position.chain,
699
+ leg.position.walletAddress.toLowerCase()
700
+ ].join(":")
701
+ };
702
+ var CentrifugeVaultClaimProceedsTransaction = {
703
+ fromDto: (dto) => ({
704
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
705
+ claimableAssets: blockchainAmountFromRawOrThrow({
706
+ label: "claimable_assets",
707
+ raw: dto.claimable_assets,
708
+ decimals: AssetDecimals(dto.asset_decimals)
709
+ })
710
+ })
711
+ };
712
+ function parseOrderability(canOrder, reasons, model) {
713
+ const [first, ...rest] = reasons;
714
+ if (canOrder) {
715
+ if (first !== void 0) {
716
+ throw new ValidationError(
717
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
718
+ );
719
+ }
720
+ return { type: "orderable" };
721
+ }
722
+ if (first === void 0) {
723
+ throw new ValidationError(
724
+ `${model}.reasons: expected at least one when can_order is false`
725
+ );
726
+ }
727
+ return { type: "blocked", reasons: [first, ...rest] };
728
+ }
729
+ function parseTransactionCore(dto, model) {
730
+ return {
731
+ tx: {
732
+ to: EvmContractAddress(dto.to),
733
+ data: HexEncodedTransactionData(dto.data)
734
+ },
735
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
736
+ };
737
+ }
738
+
739
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
740
+ async function getCentrifugeVaultQuote(api, params) {
741
+ const dto = await api.send({
742
+ method: "GET",
743
+ url: "/v1/centrifuge/vault/quote",
744
+ queryParams: {
745
+ symbol: params.symbol,
746
+ chain: params.chain,
747
+ amount: params.amount.raw.toString()
748
+ },
749
+ attributes: Attributes.protected()
750
+ });
751
+ return CentrifugeVaultQuote.fromDto(dto);
752
+ }
753
+ async function getCentrifugeVaultStatus(api, params) {
754
+ const dto = await api.send({
755
+ method: "GET",
756
+ url: "/v1/centrifuge/vault/status",
757
+ queryParams: {
758
+ symbol: params.symbol,
759
+ chain: params.chain
760
+ },
761
+ attributes: Attributes.protected()
762
+ });
763
+ return CentrifugeVaultStatus.fromDto(dto);
764
+ }
765
+ async function getCentrifugeVaultPosition(api, params) {
766
+ const dto = await api.send({
767
+ method: "GET",
768
+ url: "/v1/centrifuge/vault/position",
769
+ queryParams: walletFields(params),
770
+ attributes: Attributes.protected()
771
+ });
772
+ return CentrifugeVaultPosition.fromDto(dto);
773
+ }
774
+ async function getCentrifugeVaultRedeemPosition(api, params) {
775
+ const dto = await api.send({
776
+ method: "GET",
777
+ url: "/v1/centrifuge/vault/redeem-position",
778
+ queryParams: walletFields(params),
779
+ attributes: Attributes.protected()
780
+ });
781
+ return CentrifugeVaultRedeemPosition.fromDto(dto);
782
+ }
783
+ async function createCentrifugeVaultClaim(api, params) {
784
+ const dto = await api.send({
785
+ method: "POST",
786
+ url: "/v1/centrifuge/vault/claim",
787
+ body: walletFields(params),
788
+ attributes: Attributes.protected()
789
+ });
790
+ return CentrifugeVaultClaimTransaction.fromDto(dto);
791
+ }
792
+ async function createCentrifugeVaultClaimProceeds(api, params) {
793
+ const dto = await api.send({
794
+ method: "POST",
795
+ url: "/v1/centrifuge/vault/claim-proceeds",
796
+ body: walletFields(params),
797
+ attributes: Attributes.protected()
798
+ });
799
+ return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
800
+ }
801
+ function walletFields(params) {
802
+ return {
803
+ symbol: params.symbol,
804
+ chain: params.chain,
805
+ wallet_address: params.walletAddress
806
+ };
807
+ }
808
+
809
+ // src/universal/core/shared/observability/log-cause.ts
810
+ import {
811
+ BaseError,
812
+ ContractFunctionExecutionError,
813
+ ContractFunctionRevertedError,
814
+ HttpRequestError,
815
+ RpcError,
816
+ SocketClosedError,
817
+ TimeoutError,
818
+ WebSocketRequestError
819
+ } from "viem";
820
+ function classifyLogCause(error) {
821
+ if (error instanceof HttpError) {
822
+ return httpCause(error);
823
+ }
824
+ if (error instanceof ValidationError) {
825
+ return { type: "validation", message: error.message };
826
+ }
827
+ if (error instanceof InvariantError) {
828
+ return { type: "invariant", message: error.message };
829
+ }
830
+ if (error instanceof MathError) {
831
+ return { type: "math", message: error.message };
832
+ }
833
+ if (error instanceof NotAuthenticatedError) {
834
+ return { type: "not-authenticated" };
835
+ }
836
+ if (error instanceof NotImplementedError) {
837
+ return { type: "not-implemented" };
838
+ }
839
+ if (error instanceof BaseError) {
840
+ const http = error.walk((e) => e instanceof HttpError);
841
+ if (http instanceof HttpError) {
842
+ return httpCause(http);
843
+ }
844
+ return { type: "rpc", reason: rpcFailureReason(error) };
845
+ }
846
+ return { type: "generic-error", name: errorName(error) };
847
+ }
848
+ function rpcFailureReason(error) {
849
+ if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
850
+ return "reverted";
851
+ }
852
+ if (error.walk((e) => e instanceof RpcError)) {
853
+ return "node-rejected";
854
+ }
855
+ if (error.walk(
856
+ (e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
857
+ )) {
858
+ return "transport";
859
+ }
860
+ if (error instanceof ContractFunctionExecutionError) {
861
+ return "malformed-response";
862
+ }
863
+ return "unknown";
864
+ }
865
+ function describeErrorUnredacted(error) {
866
+ if (error instanceof HttpError) {
867
+ return describeHttpErrorRedacted(error);
868
+ }
869
+ if (error instanceof Error) {
870
+ return `${error.name}: ${error.message}`;
871
+ }
872
+ return `thrown non-error: ${stringifyUnredacted(error)}`;
873
+ }
874
+ function stringifyUnredacted(value) {
875
+ if (value === void 0) return "";
876
+ try {
877
+ return JSON.stringify(
878
+ value,
879
+ (_key, item) => typeof item === "bigint" ? `${item}` : item
880
+ ) ?? String(value);
881
+ } catch (_) {
882
+ return "<unserializable>";
883
+ }
884
+ }
885
+ function describeHttpErrorRedacted(error) {
886
+ const code = apiErrorCode(error);
887
+ const status = error.response.status;
888
+ return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
889
+ }
890
+ function errorName(error) {
891
+ return error instanceof Error ? error.name : `non-error ${typeof error}`;
892
+ }
893
+ function httpCause(error) {
894
+ return {
895
+ type: "http",
896
+ requestId: error.requestId,
897
+ status: error.response.status,
898
+ code: apiErrorCode(error),
899
+ eventId: apiErrorEventId(error)
900
+ };
901
+ }
902
+ function apiErrorEventId(error) {
903
+ const body = error.response.body;
904
+ if (typeof body !== "object" || body === null) return null;
905
+ const eventId = body.event_id;
906
+ return typeof eventId === "string" ? eventId : null;
907
+ }
908
+
909
+ // src/universal/core/shared/observability/internal-logger.ts
910
+ function internalLogger(logger, scope) {
911
+ return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
912
+ }
913
+ var LEVEL_RANK = {
914
+ none: 0,
915
+ error: 1,
916
+ warn: 2,
917
+ info: 3,
918
+ debug: 4
919
+ };
920
+ function scopedLogger(logger, scope, bindings) {
921
+ const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
922
+ const safe = (event) => ({
923
+ msg: event.msg,
924
+ scope,
925
+ bindings,
926
+ fields: event.fields ?? {},
927
+ ...event.cause === void 0 ? {} : { cause: event.cause }
928
+ });
929
+ const unredacted = (event) => ({
930
+ msg: event.msg,
931
+ scope,
932
+ bindings,
933
+ fields: event.fields ?? {}
934
+ });
935
+ const self = {
936
+ child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
937
+ debug: (event) => {
938
+ if (admits("debug")) logger.debug(() => unredacted(event()));
939
+ },
940
+ info: (event) => {
941
+ if (admits("info")) logger.info(() => safe(event()));
942
+ },
943
+ warn: (event) => {
944
+ if (admits("warn")) logger.warn(() => safe(event()));
945
+ },
946
+ error: (event) => {
947
+ if (admits("error")) logger.error(() => safe(event()));
948
+ },
949
+ failure: (event, error) => {
950
+ if (admits("debug"))
951
+ logger.debug(() => unredacted(verbatim(event(), error)));
952
+ if (admits("error")) logger.error(() => safe(classified(event(), error)));
953
+ },
954
+ warning: (event, error) => {
955
+ if (admits("debug"))
956
+ logger.debug(() => unredacted(verbatim(event(), error)));
957
+ if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
958
+ },
959
+ wrap: async (op, params, run) => {
960
+ const opLog = self.child({ op });
961
+ opLog.debug(() => ({ msg: "call", fields: { params } }));
962
+ try {
963
+ return await run();
964
+ } catch (error) {
965
+ opLog.failure(() => ({ msg: "call failed" }), error);
966
+ throw error;
967
+ }
968
+ }
969
+ };
970
+ return self;
971
+ }
972
+ function verbatim(event, error) {
973
+ return {
974
+ msg: event.msg,
975
+ fields: { ...event.fields, error: describeErrorUnredacted(error) }
976
+ };
977
+ }
978
+ function classified(event, error) {
979
+ return { ...event, cause: event.cause ?? classifyLogCause(error) };
980
+ }
981
+ var noopInternalLogger = {
982
+ child: () => noopInternalLogger,
983
+ debug: () => void 0,
984
+ info: () => void 0,
985
+ warn: () => void 0,
986
+ error: () => void 0,
987
+ failure: () => void 0,
988
+ warning: () => void 0,
989
+ wrap: (_op, _params, run) => run()
990
+ };
991
+
992
+ // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
993
+ var CentrifugeNamespaceImpl = class {
994
+ constructor(ctx) {
995
+ this.ctx = ctx;
996
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
997
+ }
998
+ async getQuote(params) {
999
+ return this.log.wrap("getQuote", params, async () => {
1000
+ await this.ctx.ensureUserAuthenticated();
1001
+ return getCentrifugeVaultQuote(this.ctx.api, params);
1002
+ });
1003
+ }
1004
+ async getVaultStatus(params) {
1005
+ return this.log.wrap("getVaultStatus", params, async () => {
1006
+ await this.ctx.ensureUserAuthenticated();
1007
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1008
+ });
1009
+ }
1010
+ async getPosition(params) {
1011
+ return this.log.wrap("getPosition", params, async () => {
1012
+ await this.ctx.ensureUserAuthenticated();
1013
+ return getCentrifugeVaultPosition(this.ctx.api, params);
1014
+ });
1015
+ }
1016
+ async getRedeemPosition(params) {
1017
+ return this.log.wrap("getRedeemPosition", params, async () => {
1018
+ await this.ctx.ensureUserAuthenticated();
1019
+ return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
1020
+ });
1021
+ }
1022
+ async createClaim(params) {
1023
+ return this.log.wrap("createClaim", params, async () => {
1024
+ await this.ctx.ensureUserAuthenticated();
1025
+ return createCentrifugeVaultClaim(this.ctx.api, params);
1026
+ });
1027
+ }
1028
+ async createClaimProceeds(params) {
1029
+ return this.log.wrap("createClaimProceeds", params, async () => {
1030
+ await this.ctx.ensureUserAuthenticated();
1031
+ return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
1032
+ });
1033
+ }
1034
+ };
1035
+
1036
+ // src/universal/core/shared/blockchain/erc20/abi.ts
1037
+ var ERC20_ABI = [
1038
+ {
1039
+ type: "function",
1040
+ name: "allowance",
1041
+ inputs: [
1042
+ { name: "owner", type: "address" },
1043
+ { name: "spender", type: "address" }
1044
+ ],
1045
+ outputs: [{ name: "", type: "uint256" }],
1046
+ stateMutability: "view"
1047
+ },
1048
+ {
1049
+ type: "function",
1050
+ name: "approve",
1051
+ inputs: [
1052
+ { name: "spender", type: "address" },
1053
+ { name: "amount", type: "uint256" }
1054
+ ],
1055
+ outputs: [{ name: "", type: "bool" }],
1056
+ stateMutability: "nonpayable"
1057
+ },
1058
+ {
1059
+ type: "function",
1060
+ name: "balanceOf",
1061
+ inputs: [{ name: "account", type: "address" }],
1062
+ outputs: [{ name: "", type: "uint256" }],
1063
+ stateMutability: "view"
1064
+ },
1065
+ {
1066
+ type: "function",
1067
+ name: "decimals",
1068
+ inputs: [],
1069
+ outputs: [{ name: "", type: "uint8" }],
1070
+ stateMutability: "view"
1071
+ },
1072
+ {
1073
+ type: "function",
1074
+ name: "name",
1075
+ inputs: [],
1076
+ outputs: [{ name: "", type: "string" }],
1077
+ stateMutability: "view"
1078
+ },
1079
+ {
1080
+ type: "function",
1081
+ name: "symbol",
1082
+ inputs: [],
1083
+ outputs: [{ name: "", type: "string" }],
1084
+ stateMutability: "view"
1085
+ },
1086
+ {
1087
+ type: "function",
1088
+ name: "totalSupply",
1089
+ inputs: [],
1090
+ outputs: [{ name: "", type: "uint256" }],
1091
+ stateMutability: "view"
1092
+ },
1093
+ {
1094
+ type: "function",
1095
+ name: "transfer",
1096
+ inputs: [
1097
+ { name: "recipient", type: "address" },
1098
+ { name: "amount", type: "uint256" }
1099
+ ],
1100
+ outputs: [{ name: "", type: "bool" }],
1101
+ stateMutability: "nonpayable"
1102
+ },
1103
+ {
1104
+ type: "function",
1105
+ name: "transferFrom",
1106
+ inputs: [
1107
+ { name: "sender", type: "address" },
1108
+ { name: "recipient", type: "address" },
1109
+ { name: "amount", type: "uint256" }
1110
+ ],
1111
+ outputs: [{ name: "", type: "bool" }],
1112
+ stateMutability: "nonpayable"
1113
+ },
1114
+ {
1115
+ type: "event",
1116
+ name: "Approval",
1117
+ inputs: [
1118
+ { name: "owner", type: "address", indexed: true },
1119
+ { name: "spender", type: "address", indexed: true },
1120
+ { name: "value", type: "uint256", indexed: false }
1121
+ ],
1122
+ anonymous: false
1123
+ },
1124
+ {
1125
+ type: "event",
1126
+ name: "Transfer",
1127
+ inputs: [
1128
+ { name: "from", type: "address", indexed: true },
1129
+ { name: "to", type: "address", indexed: true },
1130
+ { name: "value", type: "uint256", indexed: false }
1131
+ ],
1132
+ anonymous: false
1133
+ }
1134
+ ];
600
1135
 
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
- );
607
- }
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
- );
614
- }
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
- );
623
- }
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);
1136
+ // src/universal/api/pagination.ts
1137
+ async function fetchAllPages(fetchPage, baseParams) {
1138
+ const items = [];
1139
+ let cursor = null;
1140
+ do {
1141
+ const params = {
1142
+ ...baseParams ?? {},
1143
+ after: cursor ?? void 0
1144
+ };
1145
+ const page = await fetchPage(params);
1146
+ items.push(...page.data);
1147
+ cursor = page.startingAfter;
1148
+ } while (cursor);
1149
+ return items;
631
1150
  }
632
- function requiredArray(value, field) {
633
- if (!Array.isArray(value)) {
634
- throw new ValidationError(
635
- `${field}: expected an array, got ${typeof value}`
636
- );
1151
+
1152
+ // src/universal/types/pagination.ts
1153
+ var Cursor = (value) => value;
1154
+ var PaginatedResponse = {
1155
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1156
+ /**
1157
+ * For a mapper that decides the page as a whole - one that drops items it
1158
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1159
+ * cursors are the wire's either way: dropping an item changes what the
1160
+ * page holds, not where the next page starts.
1161
+ */
1162
+ fromDtoPage: (dto, pageMapper) => ({
1163
+ data: pageMapper(dto.data),
1164
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1165
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1166
+ })
1167
+ };
1168
+ var PaginationParams = {
1169
+ toQueryParams: (params) => {
1170
+ const queryParams = {};
1171
+ if (params.after) {
1172
+ queryParams.starting_after = params.after;
1173
+ }
1174
+ if (params.before) {
1175
+ queryParams.starting_before = params.before;
1176
+ }
1177
+ if (params.limit) {
1178
+ queryParams.limit = params.limit;
1179
+ }
1180
+ return queryParams;
637
1181
  }
638
- return value;
639
- }
1182
+ };
1183
+
1184
+ // src/universal/types/asset.ts
1185
+ var AssetId = (value) => value;
1186
+ var AssetCode = (value) => value;
1187
+ var Asset = {
1188
+ fromDto: (dto) => ({
1189
+ id: AssetId(dto.id),
1190
+ code: AssetCode(dto.code),
1191
+ name: dto.name,
1192
+ fractionalDigits: dto.fractional_digits
1193
+ })
1194
+ };
640
1195
 
641
1196
  // src/universal/types/offer.ts
642
1197
  var OfferId = (value) => value;
@@ -732,6 +1287,30 @@ var Ticker = (value) => value;
732
1287
  var Isin = (value) => value;
733
1288
 
734
1289
  // src/universal/types/offer-detail.ts
1290
+ var AsyncOfferDetail = {
1291
+ /**
1292
+ * Narrows an offer fetched generically, e.g. on an offer page, to one with
1293
+ * something to claim.
1294
+ *
1295
+ * An exhaustive `switch` rather than a list of async types, so a new offer
1296
+ * type is a compile error here until someone decides whether it settles
1297
+ * later.
1298
+ */
1299
+ is: (offer) => {
1300
+ switch (offer.type) {
1301
+ case "centrifuge::vault":
1302
+ return true;
1303
+ case "ondo::swap":
1304
+ case "superstate::swap":
1305
+ case "coinlist::token_sale":
1306
+ return false;
1307
+ default: {
1308
+ const exhaustive = offer;
1309
+ return exhaustive;
1310
+ }
1311
+ }
1312
+ }
1313
+ };
735
1314
  var OfferOptionId = (value) => value;
736
1315
  var OfferOptionSlug = (value) => value;
737
1316
  var OfferSwapContract = {
@@ -878,261 +1457,78 @@ var ParticipationsPaginationParams = {
878
1457
  toQueryParams: (params) => {
879
1458
  const queryParams = PaginationParams.toQueryParams(params);
880
1459
  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}`;
1460
+ queryParams["filters[0][field]"] = "offer_id";
1461
+ queryParams["filters[0][op]"] = "==";
1462
+ queryParams["filters[0][value]"] = params.offerId;
1463
+ }
1464
+ return queryParams;
1016
1465
  }
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>";
1466
+ };
1467
+ var Participation = {
1468
+ /** Maps API DTO shape into the SDK participation domain model. */
1469
+ fromDto: (dto) => {
1470
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
1471
+ return {
1472
+ id: ParticipationId(dto.id),
1473
+ offerId: OfferId(dto.offer_id),
1474
+ offerOptionId: OfferOptionId(dto.offer_option_id),
1475
+ status: dto.status,
1476
+ amount: dto.amount,
1477
+ displayAmount: dto.amount_string,
1478
+ asset: Asset.fromDto(dto.asset),
1479
+ chain: Blockchain(dto.chain),
1480
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1481
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1482
+ walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1483
+ };
1028
1484
  }
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
- }
1485
+ };
1486
+ var CreateParticipationParams = {
1487
+ /** Maps participation creation params into API DTO payload. */
1488
+ toDto: (params) => ({
1489
+ offer_id: params.offerId,
1490
+ offer_option_id: params.offerOptionId,
1491
+ chain: params.chain,
1492
+ wallet_address: params.walletAddress,
1493
+ amount: params.amount,
1494
+ asset_id: params.assetId,
1495
+ approval_transaction_hash: params.approvalTransactionHash
1496
+ })
1497
+ };
1053
1498
 
1054
- // src/universal/core/shared/observability/internal-logger.ts
1055
- function internalLogger(logger, scope) {
1056
- return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
1499
+ // src/universal/api/frontline/providers/coin-list/token-sale.ts
1500
+ async function fetchParticipations(api, offerId) {
1501
+ return fetchAllPages(
1502
+ (params) => fetchParticipationsPage(api, params),
1503
+ { offerId }
1504
+ );
1057
1505
  }
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 ?? {}
1506
+ async function fetchParticipationsPage(api, params) {
1507
+ const pageDto = await api.send({
1508
+ method: "GET",
1509
+ url: "/v1/participations",
1510
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
1511
+ attributes: Attributes.protected()
1079
1512
  });
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;
1513
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1116
1514
  }
1117
- function verbatim(event, error) {
1118
- return {
1119
- msg: event.msg,
1120
- fields: { ...event.fields, error: describeErrorUnredacted(error) }
1121
- };
1515
+ async function fetchParticipation(api, id) {
1516
+ const dto = await api.send({
1517
+ method: "GET",
1518
+ url: `/v1/participations/${id}`,
1519
+ attributes: Attributes.protected()
1520
+ });
1521
+ return Participation.fromDto(dto);
1122
1522
  }
1123
- function classified(event, error) {
1124
- return { ...event, cause: event.cause ?? classifyLogCause(error) };
1523
+ async function createParticipation(api, params) {
1524
+ const dto = await api.send({
1525
+ method: "POST",
1526
+ url: "/v1/participations",
1527
+ body: CreateParticipationParams.toDto(params),
1528
+ attributes: Attributes.protected()
1529
+ });
1530
+ return Participation.fromDto(dto);
1125
1531
  }
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
1532
 
1137
1533
  // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1138
1534
  var CoinListTokenSaleNamespaceImpl = class {
@@ -1340,66 +1736,6 @@ function explorerBaseUrl(chain) {
1340
1736
  }
1341
1737
  }
1342
1738
 
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
1739
  // src/universal/types/providers/ondo/ondo.ts
1404
1740
  var OndoTradingStatus = {
1405
1741
  fromDto: (dto) => {
@@ -3547,14 +3883,6 @@ export {
3547
3883
  Millis,
3548
3884
  Seconds,
3549
3885
  isExpired,
3550
- ERC20_ABI,
3551
- fetchAllPages,
3552
- Cursor,
3553
- PaginatedResponse,
3554
- PaginationParams,
3555
- AssetId,
3556
- AssetCode,
3557
- Asset,
3558
3886
  ETHEREUM_CHAINS,
3559
3887
  EthereumChain,
3560
3888
  SOLANA_CHAINS,
@@ -3576,9 +3904,26 @@ export {
3576
3904
  StablecoinSymbol,
3577
3905
  KnownAssetSymbol,
3578
3906
  Bps,
3579
- requiredDate,
3580
- dateOrNull,
3581
- decimalOrNull,
3907
+ blockchainAmountFromRawOrThrow,
3908
+ parseBlockchainAmount,
3909
+ CentrifugeVaultQuote,
3910
+ CentrifugeVaultStatus,
3911
+ CentrifugeVaultBuyTransaction,
3912
+ CentrifugeVaultClaimTransaction,
3913
+ CentrifugeVaultPosition,
3914
+ CentrifugeVaultRedeemPosition,
3915
+ CentrifugeVaultLeg,
3916
+ CentrifugeVaultLegId,
3917
+ CentrifugeVaultClaimProceedsTransaction,
3918
+ CentrifugeNamespaceImpl,
3919
+ ERC20_ABI,
3920
+ fetchAllPages,
3921
+ Cursor,
3922
+ PaginatedResponse,
3923
+ PaginationParams,
3924
+ AssetId,
3925
+ AssetCode,
3926
+ Asset,
3582
3927
  OfferId,
3583
3928
  OfferSlug,
3584
3929
  isOfferType,
@@ -3587,6 +3932,7 @@ export {
3587
3932
  OfferToken,
3588
3933
  Ticker,
3589
3934
  Isin,
3935
+ AsyncOfferDetail,
3590
3936
  OfferOptionId,
3591
3937
  OfferOptionSlug,
3592
3938
  OfferSwapContract,
@@ -3625,8 +3971,6 @@ export {
3625
3971
  chainFromId,
3626
3972
  getNetworkName,
3627
3973
  txExplorerUrl,
3628
- blockchainAmountFromRawOrThrow,
3629
- parseBlockchainAmount,
3630
3974
  OndoTradingStatus,
3631
3975
  OndoQuote,
3632
3976
  OndoBuyTransaction,
@@ -3667,4 +4011,4 @@ export {
3667
4011
  OAuthRefreshToken,
3668
4012
  OAuthSession
3669
4013
  };
3670
- //# sourceMappingURL=chunk-NBO5E2RO.js.map
4014
+ //# sourceMappingURL=chunk-IAY3F42Q.js.map