@coinlist-co/react 0.12.2-rc.abd9d38 → 0.12.2-rc.bc20f5b
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.
- package/README.md +10 -0
- package/dist/{chunk-45LAPB7U.js → chunk-3WW5FLT7.js} +2 -2
- package/dist/{chunk-HDJEDOS4.js → chunk-C6GF7MDF.js} +759 -412
- package/dist/chunk-C6GF7MDF.js.map +1 -0
- package/dist/{chunk-M7WDZZPX.js → chunk-IZJ4JSSC.js} +69 -4
- package/dist/chunk-IZJ4JSSC.js.map +1 -0
- package/dist/client/index.cjs +11305 -7943
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +1545 -10
- package/dist/client/index.d.ts +1545 -10
- package/dist/client/index.js +7725 -4781
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +347 -62
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +6 -2
- package/dist/server/index.d.ts +6 -2
- package/dist/server/index.js +4 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{tokens-namespace-DrwRi0AQ.d.cts → time-CVZpAkGY.d.cts} +815 -192
- package/dist/{tokens-namespace-DrwRi0AQ.d.ts → time-CVZpAkGY.d.ts} +815 -192
- package/dist/{token-registry-snapshot-C-Qs3Lgs.d.ts → token-registry-snapshot-BkwA8KmD.d.ts} +74 -8
- package/dist/{token-registry-snapshot-CpzLmsc2.d.cts → token-registry-snapshot-bR14QehS.d.cts} +74 -8
- package/dist/universal/index.cjs +812 -385
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +54 -6
- package/dist/universal/index.d.ts +54 -6
- package/dist/universal/index.js +30 -2
- package/package.json +1 -1
- package/dist/chunk-HDJEDOS4.js.map +0 -1
- package/dist/chunk-M7WDZZPX.js.map +0 -1
- package/dist/time-BOCS1TbH.d.cts +0 -50
- package/dist/time-C7mhO5_a.d.ts +0 -50
- /package/dist/{chunk-45LAPB7U.js.map → chunk-3WW5FLT7.js.map} +0 -0
|
@@ -391,66 +391,6 @@ var ERC20_ABI = [
|
|
|
391
391
|
}
|
|
392
392
|
];
|
|
393
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
394
|
// src/universal/types/blockchain/core.ts
|
|
455
395
|
var ETHEREUM_CHAINS = {
|
|
456
396
|
ethereum_mainnet: true,
|
|
@@ -548,6 +488,66 @@ var StablecoinSymbol = (value) => value;
|
|
|
548
488
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
549
489
|
var Bps = (value) => value;
|
|
550
490
|
|
|
491
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
492
|
+
import { parseUnits } from "viem";
|
|
493
|
+
function blockchainAmountFromRawOrThrow({
|
|
494
|
+
label,
|
|
495
|
+
raw,
|
|
496
|
+
decimals
|
|
497
|
+
}) {
|
|
498
|
+
const trimmed = raw.trim();
|
|
499
|
+
if (trimmed === "") {
|
|
500
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
501
|
+
}
|
|
502
|
+
let value;
|
|
503
|
+
try {
|
|
504
|
+
value = BigInt(trimmed);
|
|
505
|
+
} catch {
|
|
506
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
510
|
+
} catch {
|
|
511
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function parseBlockchainAmount(amount, decimals) {
|
|
515
|
+
const trimmed = amount.trim();
|
|
516
|
+
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
517
|
+
if (trimmed.startsWith("-")) {
|
|
518
|
+
return { valid: false, reason: { type: "negative" } };
|
|
519
|
+
}
|
|
520
|
+
if (/[eE]/.test(trimmed)) {
|
|
521
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
522
|
+
}
|
|
523
|
+
if (trimmed === ".") {
|
|
524
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
525
|
+
}
|
|
526
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
527
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
528
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
529
|
+
}
|
|
530
|
+
const [, fraction = ""] = normalised.split(".");
|
|
531
|
+
if (fraction.length > decimals) {
|
|
532
|
+
return {
|
|
533
|
+
valid: false,
|
|
534
|
+
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
try {
|
|
538
|
+
const raw = parseUnits(normalised, decimals);
|
|
539
|
+
if (raw > MAX_UINT_256) {
|
|
540
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
541
|
+
}
|
|
542
|
+
return {
|
|
543
|
+
valid: true,
|
|
544
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
545
|
+
};
|
|
546
|
+
} catch {
|
|
547
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
551
|
// src/universal/core/shared/utils/crypto.ts
|
|
552
552
|
async function sha256(data) {
|
|
553
553
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
@@ -596,41 +596,570 @@ function notBlankStringOrNull(value) {
|
|
|
596
596
|
} else {
|
|
597
597
|
return null;
|
|
598
598
|
}
|
|
599
|
-
}
|
|
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
|
-
);
|
|
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
|
-
);
|
|
599
|
+
}
|
|
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
|
+
);
|
|
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);
|
|
631
|
+
}
|
|
632
|
+
function requiredArray(value, field) {
|
|
633
|
+
if (!Array.isArray(value)) {
|
|
634
|
+
throw new ValidationError(
|
|
635
|
+
`${field}: expected an array, got ${typeof value}`
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
return value;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
642
|
+
var CentrifugeVaultStatus = {
|
|
643
|
+
fromDto: (dto) => ({
|
|
644
|
+
chain: EthereumChain(dto.chain),
|
|
645
|
+
symbol: AssetSymbol(dto.symbol),
|
|
646
|
+
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
647
|
+
linked: dto.linked,
|
|
648
|
+
permissioned: dto.permissioned,
|
|
649
|
+
membershipValidUntil: dateOrNull(
|
|
650
|
+
dto.membership_valid_until,
|
|
651
|
+
"CentrifugeVaultStatus.membership_valid_until"
|
|
652
|
+
),
|
|
653
|
+
halted: dto.halted,
|
|
654
|
+
priceUpdatedAt: dateOrNull(
|
|
655
|
+
dto.price_updated_at,
|
|
656
|
+
"CentrifugeVaultStatus.price_updated_at"
|
|
657
|
+
),
|
|
658
|
+
orderability: parseOrderability(
|
|
659
|
+
dto.can_order,
|
|
660
|
+
dto.reasons,
|
|
661
|
+
"CentrifugeVaultStatus"
|
|
662
|
+
),
|
|
663
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
664
|
+
})
|
|
665
|
+
};
|
|
666
|
+
var CentrifugeVaultBuyTransaction = {
|
|
667
|
+
fromDto: (dto) => {
|
|
668
|
+
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
669
|
+
label: "spend_input_amount",
|
|
670
|
+
raw: dto.spend_input_amount,
|
|
671
|
+
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
672
|
+
});
|
|
673
|
+
if (spendInputAmount.raw <= 0n) {
|
|
674
|
+
throw new ValidationError(
|
|
675
|
+
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
680
|
+
spendInputAmount
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var CentrifugeVaultClaimTransaction = {
|
|
685
|
+
fromDto: (dto) => ({
|
|
686
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
|
|
687
|
+
claimableShares: blockchainAmountFromRawOrThrow({
|
|
688
|
+
label: "claimable_shares",
|
|
689
|
+
raw: dto.claimable_shares,
|
|
690
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
691
|
+
})
|
|
692
|
+
})
|
|
693
|
+
};
|
|
694
|
+
var CentrifugeVaultPosition = {
|
|
695
|
+
fromDto: (dto) => {
|
|
696
|
+
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
697
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
698
|
+
const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
|
|
699
|
+
const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
|
|
700
|
+
return {
|
|
701
|
+
chain: EthereumChain(dto.chain),
|
|
702
|
+
symbol: AssetSymbol(dto.symbol),
|
|
703
|
+
walletAddress: EvmWalletAddress(dto.wallet_address),
|
|
704
|
+
status: dto.status,
|
|
705
|
+
requested: asset("requested", dto.requested),
|
|
706
|
+
pending: asset("pending", dto.pending),
|
|
707
|
+
filledAssets: asset("filled_assets", dto.filled_assets),
|
|
708
|
+
earnedShares: shares("earned_shares", dto.earned_shares),
|
|
709
|
+
claimedShares: shares("claimed_shares", dto.claimed_shares),
|
|
710
|
+
claimableShares: shares("claimable_shares", dto.claimable_shares),
|
|
711
|
+
shareBalance: shares("share_balance", dto.share_balance),
|
|
712
|
+
averagePrice: decimalOrNull(dto.average_price),
|
|
713
|
+
frozen: dto.frozen,
|
|
714
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
var CentrifugeVaultRedeemPosition = {
|
|
719
|
+
fromDto: (dto) => ({
|
|
720
|
+
chain: EthereumChain(dto.chain),
|
|
721
|
+
symbol: AssetSymbol(dto.symbol),
|
|
722
|
+
walletAddress: EvmWalletAddress(dto.wallet_address),
|
|
723
|
+
status: dto.status,
|
|
724
|
+
pending: blockchainAmountFromRawOrThrow({
|
|
725
|
+
label: "pending",
|
|
726
|
+
raw: dto.pending,
|
|
727
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
728
|
+
}),
|
|
729
|
+
claimableAssets: blockchainAmountFromRawOrThrow({
|
|
730
|
+
label: "claimable_assets",
|
|
731
|
+
raw: dto.claimable_assets,
|
|
732
|
+
decimals: AssetDecimals(dto.asset_decimals)
|
|
733
|
+
}),
|
|
734
|
+
frozen: dto.frozen,
|
|
735
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
|
|
736
|
+
})
|
|
737
|
+
};
|
|
738
|
+
var CentrifugeVaultLeg = {
|
|
739
|
+
/**
|
|
740
|
+
* What a claim on the leg would collect: shares for `invest`, the funding
|
|
741
|
+
* token for `redeem`.
|
|
742
|
+
*/
|
|
743
|
+
claimable: (leg) => {
|
|
744
|
+
switch (leg.direction) {
|
|
745
|
+
case "invest":
|
|
746
|
+
return leg.position.claimableShares;
|
|
747
|
+
case "redeem":
|
|
748
|
+
return leg.position.claimableAssets;
|
|
749
|
+
default: {
|
|
750
|
+
const exhaustive = leg;
|
|
751
|
+
return exhaustive;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
/** Whether the leg has anything queued or anything ready to claim. */
|
|
756
|
+
isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
|
|
757
|
+
};
|
|
758
|
+
var CentrifugeVaultLegId = {
|
|
759
|
+
/** Addresses compare case-insensitively: frontline echoes them lower case. */
|
|
760
|
+
of: (leg) => [
|
|
761
|
+
leg.direction,
|
|
762
|
+
leg.position.chain,
|
|
763
|
+
leg.position.walletAddress.toLowerCase()
|
|
764
|
+
].join(":")
|
|
765
|
+
};
|
|
766
|
+
var CentrifugeVaultClaimProceedsTransaction = {
|
|
767
|
+
fromDto: (dto) => ({
|
|
768
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
|
|
769
|
+
claimableAssets: blockchainAmountFromRawOrThrow({
|
|
770
|
+
label: "claimable_assets",
|
|
771
|
+
raw: dto.claimable_assets,
|
|
772
|
+
decimals: AssetDecimals(dto.asset_decimals)
|
|
773
|
+
})
|
|
774
|
+
})
|
|
775
|
+
};
|
|
776
|
+
function parseOrderability(canOrder, reasons, model) {
|
|
777
|
+
const [first, ...rest] = reasons;
|
|
778
|
+
if (canOrder) {
|
|
779
|
+
if (first !== void 0) {
|
|
780
|
+
throw new ValidationError(
|
|
781
|
+
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
return { type: "orderable" };
|
|
785
|
+
}
|
|
786
|
+
if (first === void 0) {
|
|
787
|
+
throw new ValidationError(
|
|
788
|
+
`${model}.reasons: expected at least one when can_order is false`
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
return { type: "blocked", reasons: [first, ...rest] };
|
|
792
|
+
}
|
|
793
|
+
function parseTransactionCore(dto, model) {
|
|
794
|
+
return {
|
|
795
|
+
tx: {
|
|
796
|
+
to: EvmContractAddress(dto.to),
|
|
797
|
+
data: HexEncodedTransactionData(dto.data)
|
|
798
|
+
},
|
|
799
|
+
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
804
|
+
async function getCentrifugeVaultStatus(api, params) {
|
|
805
|
+
const dto = await api.send({
|
|
806
|
+
method: "GET",
|
|
807
|
+
url: "/v1/centrifuge/vault/status",
|
|
808
|
+
queryParams: {
|
|
809
|
+
symbol: params.symbol,
|
|
810
|
+
chain: params.chain
|
|
811
|
+
},
|
|
812
|
+
attributes: Attributes.protected()
|
|
813
|
+
});
|
|
814
|
+
return CentrifugeVaultStatus.fromDto(dto);
|
|
815
|
+
}
|
|
816
|
+
async function buildCentrifugeVaultBuy(api, params) {
|
|
817
|
+
const dto = await api.send({
|
|
818
|
+
method: "POST",
|
|
819
|
+
url: "/v1/centrifuge/vault/invest",
|
|
820
|
+
body: {
|
|
821
|
+
...walletFields(params),
|
|
822
|
+
amount: params.amount.raw.toString()
|
|
823
|
+
},
|
|
824
|
+
attributes: Attributes.protected()
|
|
825
|
+
});
|
|
826
|
+
if (dto.spend_input_decimals !== params.amount.decimals) {
|
|
827
|
+
throw new ValidationError(
|
|
828
|
+
`spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
return CentrifugeVaultBuyTransaction.fromDto(dto);
|
|
832
|
+
}
|
|
833
|
+
async function getCentrifugeVaultPosition(api, params) {
|
|
834
|
+
const dto = await api.send({
|
|
835
|
+
method: "GET",
|
|
836
|
+
url: "/v1/centrifuge/vault/position",
|
|
837
|
+
queryParams: walletFields(params),
|
|
838
|
+
attributes: Attributes.protected()
|
|
839
|
+
});
|
|
840
|
+
return CentrifugeVaultPosition.fromDto(dto);
|
|
841
|
+
}
|
|
842
|
+
async function getCentrifugeVaultRedeemPosition(api, params) {
|
|
843
|
+
const dto = await api.send({
|
|
844
|
+
method: "GET",
|
|
845
|
+
url: "/v1/centrifuge/vault/redeem-position",
|
|
846
|
+
queryParams: walletFields(params),
|
|
847
|
+
attributes: Attributes.protected()
|
|
848
|
+
});
|
|
849
|
+
return CentrifugeVaultRedeemPosition.fromDto(dto);
|
|
850
|
+
}
|
|
851
|
+
async function createCentrifugeVaultClaim(api, params) {
|
|
852
|
+
const dto = await api.send({
|
|
853
|
+
method: "POST",
|
|
854
|
+
url: "/v1/centrifuge/vault/claim",
|
|
855
|
+
body: walletFields(params),
|
|
856
|
+
attributes: Attributes.protected()
|
|
857
|
+
});
|
|
858
|
+
return CentrifugeVaultClaimTransaction.fromDto(dto);
|
|
859
|
+
}
|
|
860
|
+
async function createCentrifugeVaultClaimProceeds(api, params) {
|
|
861
|
+
const dto = await api.send({
|
|
862
|
+
method: "POST",
|
|
863
|
+
url: "/v1/centrifuge/vault/claim-proceeds",
|
|
864
|
+
body: walletFields(params),
|
|
865
|
+
attributes: Attributes.protected()
|
|
866
|
+
});
|
|
867
|
+
return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
|
|
868
|
+
}
|
|
869
|
+
function walletFields(params) {
|
|
870
|
+
return {
|
|
871
|
+
symbol: params.symbol,
|
|
872
|
+
chain: params.chain,
|
|
873
|
+
wallet_address: params.walletAddress
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// src/universal/core/shared/observability/log-cause.ts
|
|
878
|
+
import {
|
|
879
|
+
BaseError,
|
|
880
|
+
ContractFunctionExecutionError,
|
|
881
|
+
ContractFunctionRevertedError,
|
|
882
|
+
HttpRequestError,
|
|
883
|
+
RpcError,
|
|
884
|
+
SocketClosedError,
|
|
885
|
+
TimeoutError,
|
|
886
|
+
WebSocketRequestError
|
|
887
|
+
} from "viem";
|
|
888
|
+
function classifyLogCause(error) {
|
|
889
|
+
if (error instanceof HttpError) {
|
|
890
|
+
return httpCause(error);
|
|
891
|
+
}
|
|
892
|
+
if (error instanceof ValidationError) {
|
|
893
|
+
return { type: "validation", message: error.message };
|
|
894
|
+
}
|
|
895
|
+
if (error instanceof InvariantError) {
|
|
896
|
+
return { type: "invariant", message: error.message };
|
|
897
|
+
}
|
|
898
|
+
if (error instanceof MathError) {
|
|
899
|
+
return { type: "math", message: error.message };
|
|
900
|
+
}
|
|
901
|
+
if (error instanceof NotAuthenticatedError) {
|
|
902
|
+
return { type: "not-authenticated" };
|
|
903
|
+
}
|
|
904
|
+
if (error instanceof NotImplementedError) {
|
|
905
|
+
return { type: "not-implemented" };
|
|
906
|
+
}
|
|
907
|
+
if (error instanceof BaseError) {
|
|
908
|
+
const http = error.walk((e) => e instanceof HttpError);
|
|
909
|
+
if (http instanceof HttpError) {
|
|
910
|
+
return httpCause(http);
|
|
911
|
+
}
|
|
912
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
913
|
+
}
|
|
914
|
+
return { type: "generic-error", name: errorName(error) };
|
|
915
|
+
}
|
|
916
|
+
function rpcFailureReason(error) {
|
|
917
|
+
if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
|
|
918
|
+
return "reverted";
|
|
919
|
+
}
|
|
920
|
+
if (error.walk((e) => e instanceof RpcError)) {
|
|
921
|
+
return "node-rejected";
|
|
922
|
+
}
|
|
923
|
+
if (error.walk(
|
|
924
|
+
(e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
|
|
925
|
+
)) {
|
|
926
|
+
return "transport";
|
|
927
|
+
}
|
|
928
|
+
if (error instanceof ContractFunctionExecutionError) {
|
|
929
|
+
return "malformed-response";
|
|
930
|
+
}
|
|
931
|
+
return "unknown";
|
|
932
|
+
}
|
|
933
|
+
function describeErrorUnredacted(error) {
|
|
934
|
+
if (error instanceof HttpError) {
|
|
935
|
+
return describeHttpErrorRedacted(error);
|
|
936
|
+
}
|
|
937
|
+
if (error instanceof Error) {
|
|
938
|
+
return `${error.name}: ${error.message}`;
|
|
939
|
+
}
|
|
940
|
+
return `thrown non-error: ${stringifyUnredacted(error)}`;
|
|
941
|
+
}
|
|
942
|
+
function stringifyUnredacted(value) {
|
|
943
|
+
if (value === void 0) return "";
|
|
944
|
+
try {
|
|
945
|
+
return JSON.stringify(
|
|
946
|
+
value,
|
|
947
|
+
(_key, item) => typeof item === "bigint" ? `${item}` : item
|
|
948
|
+
) ?? String(value);
|
|
949
|
+
} catch (_) {
|
|
950
|
+
return "<unserializable>";
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function describeHttpErrorRedacted(error) {
|
|
954
|
+
const code = apiErrorCode(error);
|
|
955
|
+
const status = error.response.status;
|
|
956
|
+
return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
|
|
957
|
+
}
|
|
958
|
+
function errorName(error) {
|
|
959
|
+
return error instanceof Error ? error.name : `non-error ${typeof error}`;
|
|
960
|
+
}
|
|
961
|
+
function httpCause(error) {
|
|
962
|
+
return {
|
|
963
|
+
type: "http",
|
|
964
|
+
requestId: error.requestId,
|
|
965
|
+
status: error.response.status,
|
|
966
|
+
code: apiErrorCode(error),
|
|
967
|
+
eventId: apiErrorEventId(error)
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
function apiErrorEventId(error) {
|
|
971
|
+
const body = error.response.body;
|
|
972
|
+
if (typeof body !== "object" || body === null) return null;
|
|
973
|
+
const eventId = body.event_id;
|
|
974
|
+
return typeof eventId === "string" ? eventId : null;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// src/universal/core/shared/observability/internal-logger.ts
|
|
978
|
+
function internalLogger(logger, scope) {
|
|
979
|
+
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
980
|
+
}
|
|
981
|
+
var LEVEL_RANK = {
|
|
982
|
+
none: 0,
|
|
983
|
+
error: 1,
|
|
984
|
+
warn: 2,
|
|
985
|
+
info: 3,
|
|
986
|
+
debug: 4
|
|
987
|
+
};
|
|
988
|
+
function scopedLogger(logger, scope, bindings) {
|
|
989
|
+
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
990
|
+
const safe = (event) => ({
|
|
991
|
+
msg: event.msg,
|
|
992
|
+
scope,
|
|
993
|
+
bindings,
|
|
994
|
+
fields: event.fields ?? {},
|
|
995
|
+
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
996
|
+
});
|
|
997
|
+
const unredacted = (event) => ({
|
|
998
|
+
msg: event.msg,
|
|
999
|
+
scope,
|
|
1000
|
+
bindings,
|
|
1001
|
+
fields: event.fields ?? {}
|
|
1002
|
+
});
|
|
1003
|
+
const self = {
|
|
1004
|
+
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
1005
|
+
debug: (event) => {
|
|
1006
|
+
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
1007
|
+
},
|
|
1008
|
+
info: (event) => {
|
|
1009
|
+
if (admits("info")) logger.info(() => safe(event()));
|
|
1010
|
+
},
|
|
1011
|
+
warn: (event) => {
|
|
1012
|
+
if (admits("warn")) logger.warn(() => safe(event()));
|
|
1013
|
+
},
|
|
1014
|
+
error: (event) => {
|
|
1015
|
+
if (admits("error")) logger.error(() => safe(event()));
|
|
1016
|
+
},
|
|
1017
|
+
failure: (event, error) => {
|
|
1018
|
+
if (admits("debug"))
|
|
1019
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1020
|
+
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
1021
|
+
},
|
|
1022
|
+
warning: (event, error) => {
|
|
1023
|
+
if (admits("debug"))
|
|
1024
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1025
|
+
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
1026
|
+
},
|
|
1027
|
+
wrap: async (op, params, run) => {
|
|
1028
|
+
const opLog = self.child({ op });
|
|
1029
|
+
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
1030
|
+
try {
|
|
1031
|
+
return await run();
|
|
1032
|
+
} catch (error) {
|
|
1033
|
+
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
1034
|
+
throw error;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
return self;
|
|
1039
|
+
}
|
|
1040
|
+
function verbatim(event, error) {
|
|
1041
|
+
return {
|
|
1042
|
+
msg: event.msg,
|
|
1043
|
+
fields: { ...event.fields, error: describeErrorUnredacted(error) }
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function classified(event, error) {
|
|
1047
|
+
return { ...event, cause: event.cause ?? classifyLogCause(error) };
|
|
1048
|
+
}
|
|
1049
|
+
var noopInternalLogger = {
|
|
1050
|
+
child: () => noopInternalLogger,
|
|
1051
|
+
debug: () => void 0,
|
|
1052
|
+
info: () => void 0,
|
|
1053
|
+
warn: () => void 0,
|
|
1054
|
+
error: () => void 0,
|
|
1055
|
+
failure: () => void 0,
|
|
1056
|
+
warning: () => void 0,
|
|
1057
|
+
wrap: (_op, _params, run) => run()
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
// src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
|
|
1061
|
+
var CentrifugeNamespaceImpl = class {
|
|
1062
|
+
constructor(ctx) {
|
|
1063
|
+
this.ctx = ctx;
|
|
1064
|
+
this.log = internalLogger(ctx.logger, "CENTRIFUGE");
|
|
1065
|
+
}
|
|
1066
|
+
async getVaultStatus(params) {
|
|
1067
|
+
return this.log.wrap("getVaultStatus", params, async () => {
|
|
1068
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1069
|
+
return getCentrifugeVaultStatus(this.ctx.api, params);
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
async getPosition(params) {
|
|
1073
|
+
return this.log.wrap("getPosition", params, async () => {
|
|
1074
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1075
|
+
return getCentrifugeVaultPosition(this.ctx.api, params);
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
async getRedeemPosition(params) {
|
|
1079
|
+
return this.log.wrap("getRedeemPosition", params, async () => {
|
|
1080
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1081
|
+
return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
async createClaim(params) {
|
|
1085
|
+
return this.log.wrap("createClaim", params, async () => {
|
|
1086
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1087
|
+
return createCentrifugeVaultClaim(this.ctx.api, params);
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
async createClaimProceeds(params) {
|
|
1091
|
+
return this.log.wrap("createClaimProceeds", params, async () => {
|
|
1092
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1093
|
+
return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
|
|
1094
|
+
});
|
|
614
1095
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
throw new ValidationError(
|
|
621
|
-
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
622
|
-
);
|
|
1096
|
+
async buildBuyTransaction(params) {
|
|
1097
|
+
return this.log.wrap("buildBuyTransaction", params, async () => {
|
|
1098
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1099
|
+
return buildCentrifugeVaultBuy(this.ctx.api, params);
|
|
1100
|
+
});
|
|
623
1101
|
}
|
|
624
|
-
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
// src/universal/api/pagination.ts
|
|
1105
|
+
async function fetchAllPages(fetchPage, baseParams) {
|
|
1106
|
+
const items = [];
|
|
1107
|
+
let cursor = null;
|
|
1108
|
+
do {
|
|
1109
|
+
const params = {
|
|
1110
|
+
...baseParams ?? {},
|
|
1111
|
+
after: cursor ?? void 0
|
|
1112
|
+
};
|
|
1113
|
+
const page = await fetchPage(params);
|
|
1114
|
+
items.push(...page.data);
|
|
1115
|
+
cursor = page.startingAfter;
|
|
1116
|
+
} while (cursor);
|
|
1117
|
+
return items;
|
|
625
1118
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1119
|
+
|
|
1120
|
+
// src/universal/types/pagination.ts
|
|
1121
|
+
var Cursor = (value) => value;
|
|
1122
|
+
var PaginatedResponse = {
|
|
1123
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1124
|
+
/**
|
|
1125
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1126
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1127
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1128
|
+
* page holds, not where the next page starts.
|
|
1129
|
+
*/
|
|
1130
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1131
|
+
data: pageMapper(dto.data),
|
|
1132
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1133
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1134
|
+
})
|
|
1135
|
+
};
|
|
1136
|
+
var PaginationParams = {
|
|
1137
|
+
toQueryParams: (params) => {
|
|
1138
|
+
const queryParams = {};
|
|
1139
|
+
if (params.after) {
|
|
1140
|
+
queryParams.starting_after = params.after;
|
|
1141
|
+
}
|
|
1142
|
+
if (params.before) {
|
|
1143
|
+
queryParams.starting_before = params.before;
|
|
1144
|
+
}
|
|
1145
|
+
if (params.limit) {
|
|
1146
|
+
queryParams.limit = params.limit;
|
|
1147
|
+
}
|
|
1148
|
+
return queryParams;
|
|
631
1149
|
}
|
|
632
|
-
|
|
633
|
-
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
// src/universal/types/asset.ts
|
|
1153
|
+
var AssetId = (value) => value;
|
|
1154
|
+
var AssetCode = (value) => value;
|
|
1155
|
+
var Asset = {
|
|
1156
|
+
fromDto: (dto) => ({
|
|
1157
|
+
id: AssetId(dto.id),
|
|
1158
|
+
code: AssetCode(dto.code),
|
|
1159
|
+
name: dto.name,
|
|
1160
|
+
fractionalDigits: dto.fractional_digits
|
|
1161
|
+
})
|
|
1162
|
+
};
|
|
634
1163
|
|
|
635
1164
|
// src/universal/types/offer.ts
|
|
636
1165
|
var OfferId = (value) => value;
|
|
@@ -638,7 +1167,8 @@ var OfferSlug = (value) => value;
|
|
|
638
1167
|
var OFFER_TYPES = {
|
|
639
1168
|
"coinlist::token_sale": true,
|
|
640
1169
|
"superstate::swap": true,
|
|
641
|
-
"ondo::swap": true
|
|
1170
|
+
"ondo::swap": true,
|
|
1171
|
+
"centrifuge::vault": true
|
|
642
1172
|
};
|
|
643
1173
|
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
644
1174
|
var OfferEditorial = {
|
|
@@ -680,6 +1210,7 @@ var Offer = {
|
|
|
680
1210
|
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
681
1211
|
// is 1970 for one variant and a date for the others.
|
|
682
1212
|
case "ondo::swap":
|
|
1213
|
+
case "centrifuge::vault":
|
|
683
1214
|
return {
|
|
684
1215
|
...base2,
|
|
685
1216
|
type: dto.type,
|
|
@@ -724,6 +1255,30 @@ var Ticker = (value) => value;
|
|
|
724
1255
|
var Isin = (value) => value;
|
|
725
1256
|
|
|
726
1257
|
// src/universal/types/offer-detail.ts
|
|
1258
|
+
var AsyncOfferDetail = {
|
|
1259
|
+
/**
|
|
1260
|
+
* Narrows an offer fetched generically, e.g. on an offer page, to one with
|
|
1261
|
+
* something to claim.
|
|
1262
|
+
*
|
|
1263
|
+
* An exhaustive `switch` rather than a list of async types, so a new offer
|
|
1264
|
+
* type is a compile error here until someone decides whether it settles
|
|
1265
|
+
* later.
|
|
1266
|
+
*/
|
|
1267
|
+
is: (offer) => {
|
|
1268
|
+
switch (offer.type) {
|
|
1269
|
+
case "centrifuge::vault":
|
|
1270
|
+
return true;
|
|
1271
|
+
case "ondo::swap":
|
|
1272
|
+
case "superstate::swap":
|
|
1273
|
+
case "coinlist::token_sale":
|
|
1274
|
+
return false;
|
|
1275
|
+
default: {
|
|
1276
|
+
const exhaustive = offer;
|
|
1277
|
+
return exhaustive;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
727
1282
|
var OfferOptionId = (value) => value;
|
|
728
1283
|
var OfferOptionSlug = (value) => value;
|
|
729
1284
|
var OfferSwapContract = {
|
|
@@ -732,6 +1287,19 @@ var OfferSwapContract = {
|
|
|
732
1287
|
address: EvmContractAddress(dto.address)
|
|
733
1288
|
})
|
|
734
1289
|
};
|
|
1290
|
+
var OfferVaultContract = {
|
|
1291
|
+
fromDto: (dto) => ({
|
|
1292
|
+
chain: Chain(dto.chain),
|
|
1293
|
+
address: EvmContractAddress(dto.address)
|
|
1294
|
+
}),
|
|
1295
|
+
/**
|
|
1296
|
+
* Drops every proxy on a chain this SDK does not name, as
|
|
1297
|
+
* `OfferToken.listFromDto` does: frontline publishes the full offer-token
|
|
1298
|
+
* chain list, which runs ahead of {@link Chain}, and one unmodelled chain
|
|
1299
|
+
* should not throw away the proxies the SDK can use.
|
|
1300
|
+
*/
|
|
1301
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
|
|
1302
|
+
};
|
|
735
1303
|
var OfferDetail = {
|
|
736
1304
|
fromDto: (dto) => {
|
|
737
1305
|
const fundingAssets = requiredArray(
|
|
@@ -794,6 +1362,18 @@ var OfferDetail = {
|
|
|
794
1362
|
"OfferDetail.swap_contracts"
|
|
795
1363
|
).map(OfferSwapContract.fromDto)
|
|
796
1364
|
};
|
|
1365
|
+
// No editorial, as for Ondo. `[]` is fine and a missing key is not, for
|
|
1366
|
+
// the same reason as `swap_contracts`: this is the spender a user
|
|
1367
|
+
// approves.
|
|
1368
|
+
case "centrifuge::vault":
|
|
1369
|
+
return {
|
|
1370
|
+
...base2,
|
|
1371
|
+
type: dto.type,
|
|
1372
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
1373
|
+
vaultContracts: OfferVaultContract.listFromDto(
|
|
1374
|
+
requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
|
|
1375
|
+
)
|
|
1376
|
+
};
|
|
797
1377
|
default:
|
|
798
1378
|
return unknownTypeError(dto, "OfferDetail");
|
|
799
1379
|
}
|
|
@@ -843,263 +1423,80 @@ var Blockchain = (value) => value;
|
|
|
843
1423
|
var WalletAddress = (value) => value;
|
|
844
1424
|
var ParticipationsPaginationParams = {
|
|
845
1425
|
toQueryParams: (params) => {
|
|
846
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
847
|
-
if (params.offerId) {
|
|
848
|
-
queryParams["filters[0][field]"] = "offer_id";
|
|
849
|
-
queryParams["filters[0][op]"] = "==";
|
|
850
|
-
queryParams["filters[0][value]"] = params.offerId;
|
|
851
|
-
}
|
|
852
|
-
return queryParams;
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
var Participation = {
|
|
856
|
-
/** Maps API DTO shape into the SDK participation domain model. */
|
|
857
|
-
fromDto: (dto) => {
|
|
858
|
-
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
859
|
-
return {
|
|
860
|
-
id: ParticipationId(dto.id),
|
|
861
|
-
offerId: OfferId(dto.offer_id),
|
|
862
|
-
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
863
|
-
status: dto.status,
|
|
864
|
-
amount: dto.amount,
|
|
865
|
-
displayAmount: dto.amount_string,
|
|
866
|
-
asset: Asset.fromDto(dto.asset),
|
|
867
|
-
chain: Blockchain(dto.chain),
|
|
868
|
-
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
869
|
-
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
870
|
-
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
var CreateParticipationParams = {
|
|
875
|
-
/** Maps participation creation params into API DTO payload. */
|
|
876
|
-
toDto: (params) => ({
|
|
877
|
-
offer_id: params.offerId,
|
|
878
|
-
offer_option_id: params.offerOptionId,
|
|
879
|
-
chain: params.chain,
|
|
880
|
-
wallet_address: params.walletAddress,
|
|
881
|
-
amount: params.amount,
|
|
882
|
-
asset_id: params.assetId,
|
|
883
|
-
approval_transaction_hash: params.approvalTransactionHash
|
|
884
|
-
})
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
888
|
-
async function fetchParticipations(api, offerId) {
|
|
889
|
-
return fetchAllPages(
|
|
890
|
-
(params) => fetchParticipationsPage(api, params),
|
|
891
|
-
{ offerId }
|
|
892
|
-
);
|
|
893
|
-
}
|
|
894
|
-
async function fetchParticipationsPage(api, params) {
|
|
895
|
-
const pageDto = await api.send({
|
|
896
|
-
method: "GET",
|
|
897
|
-
url: "/v1/participations",
|
|
898
|
-
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
899
|
-
attributes: Attributes.protected()
|
|
900
|
-
});
|
|
901
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
902
|
-
}
|
|
903
|
-
async function fetchParticipation(api, id) {
|
|
904
|
-
const dto = await api.send({
|
|
905
|
-
method: "GET",
|
|
906
|
-
url: `/v1/participations/${id}`,
|
|
907
|
-
attributes: Attributes.protected()
|
|
908
|
-
});
|
|
909
|
-
return Participation.fromDto(dto);
|
|
910
|
-
}
|
|
911
|
-
async function createParticipation(api, params) {
|
|
912
|
-
const dto = await api.send({
|
|
913
|
-
method: "POST",
|
|
914
|
-
url: "/v1/participations",
|
|
915
|
-
body: CreateParticipationParams.toDto(params),
|
|
916
|
-
attributes: Attributes.protected()
|
|
917
|
-
});
|
|
918
|
-
return Participation.fromDto(dto);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
// src/universal/core/shared/observability/log-cause.ts
|
|
922
|
-
import {
|
|
923
|
-
BaseError,
|
|
924
|
-
ContractFunctionExecutionError,
|
|
925
|
-
ContractFunctionRevertedError,
|
|
926
|
-
HttpRequestError,
|
|
927
|
-
RpcError,
|
|
928
|
-
SocketClosedError,
|
|
929
|
-
TimeoutError,
|
|
930
|
-
WebSocketRequestError
|
|
931
|
-
} from "viem";
|
|
932
|
-
function classifyLogCause(error) {
|
|
933
|
-
if (error instanceof HttpError) {
|
|
934
|
-
return httpCause(error);
|
|
935
|
-
}
|
|
936
|
-
if (error instanceof ValidationError) {
|
|
937
|
-
return { type: "validation", message: error.message };
|
|
938
|
-
}
|
|
939
|
-
if (error instanceof InvariantError) {
|
|
940
|
-
return { type: "invariant", message: error.message };
|
|
941
|
-
}
|
|
942
|
-
if (error instanceof MathError) {
|
|
943
|
-
return { type: "math", message: error.message };
|
|
944
|
-
}
|
|
945
|
-
if (error instanceof NotAuthenticatedError) {
|
|
946
|
-
return { type: "not-authenticated" };
|
|
947
|
-
}
|
|
948
|
-
if (error instanceof NotImplementedError) {
|
|
949
|
-
return { type: "not-implemented" };
|
|
950
|
-
}
|
|
951
|
-
if (error instanceof BaseError) {
|
|
952
|
-
const http = error.walk((e) => e instanceof HttpError);
|
|
953
|
-
if (http instanceof HttpError) {
|
|
954
|
-
return httpCause(http);
|
|
955
|
-
}
|
|
956
|
-
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
957
|
-
}
|
|
958
|
-
return { type: "generic-error", name: errorName(error) };
|
|
959
|
-
}
|
|
960
|
-
function rpcFailureReason(error) {
|
|
961
|
-
if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
|
|
962
|
-
return "reverted";
|
|
963
|
-
}
|
|
964
|
-
if (error.walk((e) => e instanceof RpcError)) {
|
|
965
|
-
return "node-rejected";
|
|
966
|
-
}
|
|
967
|
-
if (error.walk(
|
|
968
|
-
(e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
|
|
969
|
-
)) {
|
|
970
|
-
return "transport";
|
|
971
|
-
}
|
|
972
|
-
if (error instanceof ContractFunctionExecutionError) {
|
|
973
|
-
return "malformed-response";
|
|
974
|
-
}
|
|
975
|
-
return "unknown";
|
|
976
|
-
}
|
|
977
|
-
function describeErrorUnredacted(error) {
|
|
978
|
-
if (error instanceof HttpError) {
|
|
979
|
-
return describeHttpErrorRedacted(error);
|
|
980
|
-
}
|
|
981
|
-
if (error instanceof Error) {
|
|
982
|
-
return `${error.name}: ${error.message}`;
|
|
1426
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
1427
|
+
if (params.offerId) {
|
|
1428
|
+
queryParams["filters[0][field]"] = "offer_id";
|
|
1429
|
+
queryParams["filters[0][op]"] = "==";
|
|
1430
|
+
queryParams["filters[0][value]"] = params.offerId;
|
|
1431
|
+
}
|
|
1432
|
+
return queryParams;
|
|
983
1433
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
return
|
|
990
|
-
|
|
991
|
-
(
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1434
|
+
};
|
|
1435
|
+
var Participation = {
|
|
1436
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
1437
|
+
fromDto: (dto) => {
|
|
1438
|
+
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
1439
|
+
return {
|
|
1440
|
+
id: ParticipationId(dto.id),
|
|
1441
|
+
offerId: OfferId(dto.offer_id),
|
|
1442
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
1443
|
+
status: dto.status,
|
|
1444
|
+
amount: dto.amount,
|
|
1445
|
+
displayAmount: dto.amount_string,
|
|
1446
|
+
asset: Asset.fromDto(dto.asset),
|
|
1447
|
+
chain: Blockchain(dto.chain),
|
|
1448
|
+
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
1449
|
+
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
1450
|
+
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
1451
|
+
};
|
|
995
1452
|
}
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
status: error.response.status,
|
|
1010
|
-
code: apiErrorCode(error),
|
|
1011
|
-
eventId: apiErrorEventId(error)
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
function apiErrorEventId(error) {
|
|
1015
|
-
const body = error.response.body;
|
|
1016
|
-
if (typeof body !== "object" || body === null) return null;
|
|
1017
|
-
const eventId = body.event_id;
|
|
1018
|
-
return typeof eventId === "string" ? eventId : null;
|
|
1019
|
-
}
|
|
1453
|
+
};
|
|
1454
|
+
var CreateParticipationParams = {
|
|
1455
|
+
/** Maps participation creation params into API DTO payload. */
|
|
1456
|
+
toDto: (params) => ({
|
|
1457
|
+
offer_id: params.offerId,
|
|
1458
|
+
offer_option_id: params.offerOptionId,
|
|
1459
|
+
chain: params.chain,
|
|
1460
|
+
wallet_address: params.walletAddress,
|
|
1461
|
+
amount: params.amount,
|
|
1462
|
+
asset_id: params.assetId,
|
|
1463
|
+
approval_transaction_hash: params.approvalTransactionHash
|
|
1464
|
+
})
|
|
1465
|
+
};
|
|
1020
1466
|
|
|
1021
|
-
// src/universal/
|
|
1022
|
-
function
|
|
1023
|
-
return
|
|
1467
|
+
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
1468
|
+
async function fetchParticipations(api, offerId) {
|
|
1469
|
+
return fetchAllPages(
|
|
1470
|
+
(params) => fetchParticipationsPage(api, params),
|
|
1471
|
+
{ offerId }
|
|
1472
|
+
);
|
|
1024
1473
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
};
|
|
1032
|
-
function scopedLogger(logger, scope, bindings) {
|
|
1033
|
-
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
1034
|
-
const safe = (event) => ({
|
|
1035
|
-
msg: event.msg,
|
|
1036
|
-
scope,
|
|
1037
|
-
bindings,
|
|
1038
|
-
fields: event.fields ?? {},
|
|
1039
|
-
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
1040
|
-
});
|
|
1041
|
-
const unredacted = (event) => ({
|
|
1042
|
-
msg: event.msg,
|
|
1043
|
-
scope,
|
|
1044
|
-
bindings,
|
|
1045
|
-
fields: event.fields ?? {}
|
|
1474
|
+
async function fetchParticipationsPage(api, params) {
|
|
1475
|
+
const pageDto = await api.send({
|
|
1476
|
+
method: "GET",
|
|
1477
|
+
url: "/v1/participations",
|
|
1478
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
1479
|
+
attributes: Attributes.protected()
|
|
1046
1480
|
});
|
|
1047
|
-
|
|
1048
|
-
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
1049
|
-
debug: (event) => {
|
|
1050
|
-
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
1051
|
-
},
|
|
1052
|
-
info: (event) => {
|
|
1053
|
-
if (admits("info")) logger.info(() => safe(event()));
|
|
1054
|
-
},
|
|
1055
|
-
warn: (event) => {
|
|
1056
|
-
if (admits("warn")) logger.warn(() => safe(event()));
|
|
1057
|
-
},
|
|
1058
|
-
error: (event) => {
|
|
1059
|
-
if (admits("error")) logger.error(() => safe(event()));
|
|
1060
|
-
},
|
|
1061
|
-
failure: (event, error) => {
|
|
1062
|
-
if (admits("debug"))
|
|
1063
|
-
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1064
|
-
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
1065
|
-
},
|
|
1066
|
-
warning: (event, error) => {
|
|
1067
|
-
if (admits("debug"))
|
|
1068
|
-
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1069
|
-
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
1070
|
-
},
|
|
1071
|
-
wrap: async (op, params, run) => {
|
|
1072
|
-
const opLog = self.child({ op });
|
|
1073
|
-
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
1074
|
-
try {
|
|
1075
|
-
return await run();
|
|
1076
|
-
} catch (error) {
|
|
1077
|
-
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
1078
|
-
throw error;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
return self;
|
|
1481
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
1083
1482
|
}
|
|
1084
|
-
function
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1483
|
+
async function fetchParticipation(api, id) {
|
|
1484
|
+
const dto = await api.send({
|
|
1485
|
+
method: "GET",
|
|
1486
|
+
url: `/v1/participations/${id}`,
|
|
1487
|
+
attributes: Attributes.protected()
|
|
1488
|
+
});
|
|
1489
|
+
return Participation.fromDto(dto);
|
|
1089
1490
|
}
|
|
1090
|
-
function
|
|
1091
|
-
|
|
1491
|
+
async function createParticipation(api, params) {
|
|
1492
|
+
const dto = await api.send({
|
|
1493
|
+
method: "POST",
|
|
1494
|
+
url: "/v1/participations",
|
|
1495
|
+
body: CreateParticipationParams.toDto(params),
|
|
1496
|
+
attributes: Attributes.protected()
|
|
1497
|
+
});
|
|
1498
|
+
return Participation.fromDto(dto);
|
|
1092
1499
|
}
|
|
1093
|
-
var noopInternalLogger = {
|
|
1094
|
-
child: () => noopInternalLogger,
|
|
1095
|
-
debug: () => void 0,
|
|
1096
|
-
info: () => void 0,
|
|
1097
|
-
warn: () => void 0,
|
|
1098
|
-
error: () => void 0,
|
|
1099
|
-
failure: () => void 0,
|
|
1100
|
-
warning: () => void 0,
|
|
1101
|
-
wrap: (_op, _params, run) => run()
|
|
1102
|
-
};
|
|
1103
1500
|
|
|
1104
1501
|
// src/universal/core/checkout/coin-list/token-sale-namespace.ts
|
|
1105
1502
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
@@ -1307,66 +1704,6 @@ function explorerBaseUrl(chain) {
|
|
|
1307
1704
|
}
|
|
1308
1705
|
}
|
|
1309
1706
|
|
|
1310
|
-
// src/universal/core/shared/blockchain/math.ts
|
|
1311
|
-
import { parseUnits } from "viem";
|
|
1312
|
-
function blockchainAmountFromRawOrThrow({
|
|
1313
|
-
label,
|
|
1314
|
-
raw,
|
|
1315
|
-
decimals
|
|
1316
|
-
}) {
|
|
1317
|
-
const trimmed = raw.trim();
|
|
1318
|
-
if (trimmed === "") {
|
|
1319
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1320
|
-
}
|
|
1321
|
-
let value;
|
|
1322
|
-
try {
|
|
1323
|
-
value = BigInt(trimmed);
|
|
1324
|
-
} catch {
|
|
1325
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1326
|
-
}
|
|
1327
|
-
try {
|
|
1328
|
-
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
1329
|
-
} catch {
|
|
1330
|
-
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
function parseBlockchainAmount(amount, decimals) {
|
|
1334
|
-
const trimmed = amount.trim();
|
|
1335
|
-
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
1336
|
-
if (trimmed.startsWith("-")) {
|
|
1337
|
-
return { valid: false, reason: { type: "negative" } };
|
|
1338
|
-
}
|
|
1339
|
-
if (/[eE]/.test(trimmed)) {
|
|
1340
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1341
|
-
}
|
|
1342
|
-
if (trimmed === ".") {
|
|
1343
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1344
|
-
}
|
|
1345
|
-
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1346
|
-
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1347
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1348
|
-
}
|
|
1349
|
-
const [, fraction = ""] = normalised.split(".");
|
|
1350
|
-
if (fraction.length > decimals) {
|
|
1351
|
-
return {
|
|
1352
|
-
valid: false,
|
|
1353
|
-
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
1354
|
-
};
|
|
1355
|
-
}
|
|
1356
|
-
try {
|
|
1357
|
-
const raw = parseUnits(normalised, decimals);
|
|
1358
|
-
if (raw > MAX_UINT_256) {
|
|
1359
|
-
return { valid: false, reason: { type: "overflow" } };
|
|
1360
|
-
}
|
|
1361
|
-
return {
|
|
1362
|
-
valid: true,
|
|
1363
|
-
amount: BlockchainAmount({ raw, decimals })
|
|
1364
|
-
};
|
|
1365
|
-
} catch {
|
|
1366
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
1707
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1371
1708
|
var OndoTradingStatus = {
|
|
1372
1709
|
fromDto: (dto) => {
|
|
@@ -1382,7 +1719,6 @@ var OndoTradingStatus = {
|
|
|
1382
1719
|
};
|
|
1383
1720
|
}
|
|
1384
1721
|
};
|
|
1385
|
-
var decimalOrNull = (value) => value === null ? null : DecimalString(value);
|
|
1386
1722
|
var OndoQuote = {
|
|
1387
1723
|
fromDto: (dto) => {
|
|
1388
1724
|
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
@@ -3516,13 +3852,6 @@ export {
|
|
|
3516
3852
|
Seconds,
|
|
3517
3853
|
isExpired,
|
|
3518
3854
|
ERC20_ABI,
|
|
3519
|
-
fetchAllPages,
|
|
3520
|
-
Cursor,
|
|
3521
|
-
PaginatedResponse,
|
|
3522
|
-
PaginationParams,
|
|
3523
|
-
AssetId,
|
|
3524
|
-
AssetCode,
|
|
3525
|
-
Asset,
|
|
3526
3855
|
ETHEREUM_CHAINS,
|
|
3527
3856
|
EthereumChain,
|
|
3528
3857
|
SOLANA_CHAINS,
|
|
@@ -3544,6 +3873,24 @@ export {
|
|
|
3544
3873
|
StablecoinSymbol,
|
|
3545
3874
|
KnownAssetSymbol,
|
|
3546
3875
|
Bps,
|
|
3876
|
+
blockchainAmountFromRawOrThrow,
|
|
3877
|
+
parseBlockchainAmount,
|
|
3878
|
+
CentrifugeVaultStatus,
|
|
3879
|
+
CentrifugeVaultBuyTransaction,
|
|
3880
|
+
CentrifugeVaultClaimTransaction,
|
|
3881
|
+
CentrifugeVaultPosition,
|
|
3882
|
+
CentrifugeVaultRedeemPosition,
|
|
3883
|
+
CentrifugeVaultLeg,
|
|
3884
|
+
CentrifugeVaultLegId,
|
|
3885
|
+
CentrifugeVaultClaimProceedsTransaction,
|
|
3886
|
+
CentrifugeNamespaceImpl,
|
|
3887
|
+
fetchAllPages,
|
|
3888
|
+
Cursor,
|
|
3889
|
+
PaginatedResponse,
|
|
3890
|
+
PaginationParams,
|
|
3891
|
+
AssetId,
|
|
3892
|
+
AssetCode,
|
|
3893
|
+
Asset,
|
|
3547
3894
|
OfferId,
|
|
3548
3895
|
OfferSlug,
|
|
3549
3896
|
isOfferType,
|
|
@@ -3552,9 +3899,11 @@ export {
|
|
|
3552
3899
|
OfferToken,
|
|
3553
3900
|
Ticker,
|
|
3554
3901
|
Isin,
|
|
3902
|
+
AsyncOfferDetail,
|
|
3555
3903
|
OfferOptionId,
|
|
3556
3904
|
OfferOptionSlug,
|
|
3557
3905
|
OfferSwapContract,
|
|
3906
|
+
OfferVaultContract,
|
|
3558
3907
|
OfferDetail,
|
|
3559
3908
|
OfferOption,
|
|
3560
3909
|
FaqItem,
|
|
@@ -3589,8 +3938,6 @@ export {
|
|
|
3589
3938
|
chainFromId,
|
|
3590
3939
|
getNetworkName,
|
|
3591
3940
|
txExplorerUrl,
|
|
3592
|
-
blockchainAmountFromRawOrThrow,
|
|
3593
|
-
parseBlockchainAmount,
|
|
3594
3941
|
OndoTradingStatus,
|
|
3595
3942
|
OndoQuote,
|
|
3596
3943
|
OndoBuyTransaction,
|
|
@@ -3631,4 +3978,4 @@ export {
|
|
|
3631
3978
|
OAuthRefreshToken,
|
|
3632
3979
|
OAuthSession
|
|
3633
3980
|
};
|
|
3634
|
-
//# sourceMappingURL=chunk-
|
|
3981
|
+
//# sourceMappingURL=chunk-C6GF7MDF.js.map
|