@coinlist-co/react 0.12.2-rc.0fda52c → 0.12.2-rc.5f2ca48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-STAHYDLY.js → chunk-6NCNF5GF.js} +2 -2
- package/dist/{chunk-KRA6EM2L.js → chunk-VUIDJYHY.js} +18 -3
- package/dist/chunk-VUIDJYHY.js.map +1 -0
- package/dist/{chunk-BNMF2HMW.js → chunk-XCRU3YE2.js} +628 -402
- package/dist/chunk-XCRU3YE2.js.map +1 -0
- package/dist/client/index.cjs +605 -160
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +271 -29
- package/dist/client/index.d.ts +271 -29
- package/dist/client/index.js +294 -21
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +216 -62
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +10 -2
- package/dist/server/index.d.ts +10 -2
- package/dist/server/index.js +4 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{time-B5YOQxuh.d.ts → time-CTuVDTx6.d.ts} +1 -1
- package/dist/{time-BY3apBpc.d.cts → time-Dv1dejVB.d.cts} +1 -1
- package/dist/{token-registry-snapshot-DyjrA32p.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +9 -7
- package/dist/{token-registry-snapshot-C1NxdBmF.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +9 -7
- package/dist/{tokens-namespace-BJfFeowE.d.cts → tokens-namespace-CcvHrw-k.d.cts} +462 -20
- package/dist/{tokens-namespace-BJfFeowE.d.ts → tokens-namespace-CcvHrw-k.d.ts} +462 -20
- package/dist/universal/index.cjs +568 -316
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +38 -6
- package/dist/universal/index.d.ts +38 -6
- package/dist/universal/index.js +22 -2
- package/package.json +1 -1
- package/dist/chunk-BNMF2HMW.js.map +0 -1
- package/dist/chunk-KRA6EM2L.js.map +0 -1
- /package/dist/{chunk-STAHYDLY.js.map → chunk-6NCNF5GF.js.map} +0 -0
|
@@ -407,50 +407,6 @@ async function fetchAllPages(fetchPage, baseParams) {
|
|
|
407
407
|
return items;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
// src/universal/types/pagination.ts
|
|
411
|
-
var Cursor = (value) => value;
|
|
412
|
-
var PaginatedResponse = {
|
|
413
|
-
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
414
|
-
/**
|
|
415
|
-
* For a mapper that decides the page as a whole - one that drops items it
|
|
416
|
-
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
417
|
-
* cursors are the wire's either way: dropping an item changes what the
|
|
418
|
-
* page holds, not where the next page starts.
|
|
419
|
-
*/
|
|
420
|
-
fromDtoPage: (dto, pageMapper) => ({
|
|
421
|
-
data: pageMapper(dto.data),
|
|
422
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
423
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
424
|
-
})
|
|
425
|
-
};
|
|
426
|
-
var PaginationParams = {
|
|
427
|
-
toQueryParams: (params) => {
|
|
428
|
-
const queryParams = {};
|
|
429
|
-
if (params.after) {
|
|
430
|
-
queryParams.starting_after = params.after;
|
|
431
|
-
}
|
|
432
|
-
if (params.before) {
|
|
433
|
-
queryParams.starting_before = params.before;
|
|
434
|
-
}
|
|
435
|
-
if (params.limit) {
|
|
436
|
-
queryParams.limit = params.limit;
|
|
437
|
-
}
|
|
438
|
-
return queryParams;
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
// src/universal/types/asset.ts
|
|
443
|
-
var AssetId = (value) => value;
|
|
444
|
-
var AssetCode = (value) => value;
|
|
445
|
-
var Asset = {
|
|
446
|
-
fromDto: (dto) => ({
|
|
447
|
-
id: AssetId(dto.id),
|
|
448
|
-
code: AssetCode(dto.code),
|
|
449
|
-
name: dto.name,
|
|
450
|
-
fractionalDigits: dto.fractional_digits
|
|
451
|
-
})
|
|
452
|
-
};
|
|
453
|
-
|
|
454
410
|
// src/universal/types/blockchain/core.ts
|
|
455
411
|
var ETHEREUM_CHAINS = {
|
|
456
412
|
ethereum_mainnet: true,
|
|
@@ -548,6 +504,66 @@ var StablecoinSymbol = (value) => value;
|
|
|
548
504
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
549
505
|
var Bps = (value) => value;
|
|
550
506
|
|
|
507
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
508
|
+
import { parseUnits } from "viem";
|
|
509
|
+
function blockchainAmountFromRawOrThrow({
|
|
510
|
+
label,
|
|
511
|
+
raw,
|
|
512
|
+
decimals
|
|
513
|
+
}) {
|
|
514
|
+
const trimmed = raw.trim();
|
|
515
|
+
if (trimmed === "") {
|
|
516
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
517
|
+
}
|
|
518
|
+
let value;
|
|
519
|
+
try {
|
|
520
|
+
value = BigInt(trimmed);
|
|
521
|
+
} catch {
|
|
522
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
523
|
+
}
|
|
524
|
+
try {
|
|
525
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
526
|
+
} catch {
|
|
527
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function parseBlockchainAmount(amount, decimals) {
|
|
531
|
+
const trimmed = amount.trim();
|
|
532
|
+
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
533
|
+
if (trimmed.startsWith("-")) {
|
|
534
|
+
return { valid: false, reason: { type: "negative" } };
|
|
535
|
+
}
|
|
536
|
+
if (/[eE]/.test(trimmed)) {
|
|
537
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
538
|
+
}
|
|
539
|
+
if (trimmed === ".") {
|
|
540
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
541
|
+
}
|
|
542
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
543
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
544
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
545
|
+
}
|
|
546
|
+
const [, fraction = ""] = normalised.split(".");
|
|
547
|
+
if (fraction.length > decimals) {
|
|
548
|
+
return {
|
|
549
|
+
valid: false,
|
|
550
|
+
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
try {
|
|
554
|
+
const raw = parseUnits(normalised, decimals);
|
|
555
|
+
if (raw > MAX_UINT_256) {
|
|
556
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
557
|
+
}
|
|
558
|
+
return {
|
|
559
|
+
valid: true,
|
|
560
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
561
|
+
};
|
|
562
|
+
} catch {
|
|
563
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
551
567
|
// src/universal/core/shared/utils/crypto.ts
|
|
552
568
|
async function sha256(data) {
|
|
553
569
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
@@ -590,47 +606,467 @@ function getUUIDv4() {
|
|
|
590
606
|
}
|
|
591
607
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
592
608
|
}
|
|
593
|
-
function notBlankStringOrNull(value) {
|
|
594
|
-
if (value?.trim()) {
|
|
595
|
-
return value;
|
|
596
|
-
} else {
|
|
597
|
-
return null;
|
|
598
|
-
}
|
|
609
|
+
function notBlankStringOrNull(value) {
|
|
610
|
+
if (value?.trim()) {
|
|
611
|
+
return value;
|
|
612
|
+
} else {
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/universal/core/shared/utils/wire.ts
|
|
618
|
+
function unknownTypeError(dto, model) {
|
|
619
|
+
const type = dto.type;
|
|
620
|
+
throw new ValidationError(
|
|
621
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
function requiredString(value, field) {
|
|
625
|
+
const text = notBlankStringOrNull(value);
|
|
626
|
+
if (text === null) {
|
|
627
|
+
throw new ValidationError(
|
|
628
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
return text;
|
|
632
|
+
}
|
|
633
|
+
function requiredDate(value, field) {
|
|
634
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
635
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
636
|
+
throw new ValidationError(
|
|
637
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
return date;
|
|
641
|
+
}
|
|
642
|
+
function dateOrNull(value, field) {
|
|
643
|
+
return value === null ? null : requiredDate(value, field);
|
|
644
|
+
}
|
|
645
|
+
function decimalOrNull(value) {
|
|
646
|
+
return value === null ? null : DecimalString(value);
|
|
647
|
+
}
|
|
648
|
+
function requiredArray(value, field) {
|
|
649
|
+
if (!Array.isArray(value)) {
|
|
650
|
+
throw new ValidationError(
|
|
651
|
+
`${field}: expected an array, got ${typeof value}`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
return value;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
658
|
+
var CentrifugeVaultQuote = {
|
|
659
|
+
fromDto: (dto) => {
|
|
660
|
+
const spendDecimals = AssetDecimals(dto.spend_input_decimals);
|
|
661
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
662
|
+
return {
|
|
663
|
+
chain: EthereumChain(dto.chain),
|
|
664
|
+
symbol: AssetSymbol(dto.symbol),
|
|
665
|
+
spendInputAmount: blockchainAmountFromRawOrThrow({
|
|
666
|
+
label: "spend_input_amount",
|
|
667
|
+
raw: dto.spend_input_amount,
|
|
668
|
+
decimals: spendDecimals
|
|
669
|
+
}),
|
|
670
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
671
|
+
label: "estimated_shares",
|
|
672
|
+
raw: dto.estimated_shares,
|
|
673
|
+
decimals: shareDecimals
|
|
674
|
+
}),
|
|
675
|
+
indicativePrice: decimalOrNull(dto.indicative_price),
|
|
676
|
+
minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
|
|
677
|
+
label: "minimum_input_amount",
|
|
678
|
+
raw: dto.minimum_input_amount,
|
|
679
|
+
decimals: spendDecimals
|
|
680
|
+
}),
|
|
681
|
+
orderability: parseOrderability(
|
|
682
|
+
dto.can_order,
|
|
683
|
+
dto.reasons,
|
|
684
|
+
"CentrifugeVaultQuote"
|
|
685
|
+
)
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
var CentrifugeVaultStatus = {
|
|
690
|
+
fromDto: (dto) => ({
|
|
691
|
+
chain: EthereumChain(dto.chain),
|
|
692
|
+
symbol: AssetSymbol(dto.symbol),
|
|
693
|
+
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
694
|
+
linked: dto.linked,
|
|
695
|
+
permissioned: dto.permissioned,
|
|
696
|
+
membershipValidUntil: dateOrNull(
|
|
697
|
+
dto.membership_valid_until,
|
|
698
|
+
"CentrifugeVaultStatus.membership_valid_until"
|
|
699
|
+
),
|
|
700
|
+
halted: dto.halted,
|
|
701
|
+
priceUpdatedAt: dateOrNull(
|
|
702
|
+
dto.price_updated_at,
|
|
703
|
+
"CentrifugeVaultStatus.price_updated_at"
|
|
704
|
+
),
|
|
705
|
+
orderability: parseOrderability(
|
|
706
|
+
dto.can_order,
|
|
707
|
+
dto.reasons,
|
|
708
|
+
"CentrifugeVaultStatus"
|
|
709
|
+
),
|
|
710
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
711
|
+
})
|
|
712
|
+
};
|
|
713
|
+
var CentrifugeVaultBuyTransaction = {
|
|
714
|
+
fromDto: (dto) => {
|
|
715
|
+
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
716
|
+
label: "spend_input_amount",
|
|
717
|
+
raw: dto.spend_input_amount,
|
|
718
|
+
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
719
|
+
});
|
|
720
|
+
if (spendInputAmount.raw <= 0n) {
|
|
721
|
+
throw new ValidationError(
|
|
722
|
+
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
return {
|
|
726
|
+
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
727
|
+
spendInputAmount,
|
|
728
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
729
|
+
label: "estimated_shares",
|
|
730
|
+
raw: dto.estimated_shares,
|
|
731
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
732
|
+
})
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
var CentrifugeVaultClaimTransaction = {
|
|
737
|
+
fromDto: (dto) => ({
|
|
738
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
|
|
739
|
+
claimableShares: blockchainAmountFromRawOrThrow({
|
|
740
|
+
label: "claimable_shares",
|
|
741
|
+
raw: dto.claimable_shares,
|
|
742
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
743
|
+
})
|
|
744
|
+
})
|
|
745
|
+
};
|
|
746
|
+
var CentrifugeVaultPosition = {
|
|
747
|
+
fromDto: (dto) => {
|
|
748
|
+
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
749
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
750
|
+
const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
|
|
751
|
+
const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
|
|
752
|
+
return {
|
|
753
|
+
chain: EthereumChain(dto.chain),
|
|
754
|
+
symbol: AssetSymbol(dto.symbol),
|
|
755
|
+
walletAddress: EvmWalletAddress(dto.wallet_address),
|
|
756
|
+
status: dto.status,
|
|
757
|
+
requested: asset("requested", dto.requested),
|
|
758
|
+
pending: asset("pending", dto.pending),
|
|
759
|
+
filledAssets: asset("filled_assets", dto.filled_assets),
|
|
760
|
+
earnedShares: shares("earned_shares", dto.earned_shares),
|
|
761
|
+
claimedShares: shares("claimed_shares", dto.claimed_shares),
|
|
762
|
+
claimableShares: shares("claimable_shares", dto.claimable_shares),
|
|
763
|
+
shareBalance: shares("share_balance", dto.share_balance),
|
|
764
|
+
averagePrice: decimalOrNull(dto.average_price),
|
|
765
|
+
frozen: dto.frozen,
|
|
766
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
function parseOrderability(canOrder, reasons, model) {
|
|
771
|
+
const [first, ...rest] = reasons;
|
|
772
|
+
if (canOrder) {
|
|
773
|
+
if (first !== void 0) {
|
|
774
|
+
throw new ValidationError(
|
|
775
|
+
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
return { type: "orderable" };
|
|
779
|
+
}
|
|
780
|
+
if (first === void 0) {
|
|
781
|
+
throw new ValidationError(
|
|
782
|
+
`${model}.reasons: expected at least one when can_order is false`
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
return { type: "blocked", reasons: [first, ...rest] };
|
|
786
|
+
}
|
|
787
|
+
function parseTransactionCore(dto, model) {
|
|
788
|
+
return {
|
|
789
|
+
tx: {
|
|
790
|
+
to: EvmContractAddress(dto.to),
|
|
791
|
+
data: HexEncodedTransactionData(dto.data)
|
|
792
|
+
},
|
|
793
|
+
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
798
|
+
async function getCentrifugeVaultQuote(api, params) {
|
|
799
|
+
const dto = await api.send({
|
|
800
|
+
method: "GET",
|
|
801
|
+
url: "/v1/centrifuge/vault/quote",
|
|
802
|
+
queryParams: {
|
|
803
|
+
symbol: params.symbol,
|
|
804
|
+
chain: params.chain,
|
|
805
|
+
amount: params.amount.raw.toString()
|
|
806
|
+
},
|
|
807
|
+
attributes: Attributes.protected()
|
|
808
|
+
});
|
|
809
|
+
return CentrifugeVaultQuote.fromDto(dto);
|
|
810
|
+
}
|
|
811
|
+
async function getCentrifugeVaultStatus(api, params) {
|
|
812
|
+
const dto = await api.send({
|
|
813
|
+
method: "GET",
|
|
814
|
+
url: "/v1/centrifuge/vault/status",
|
|
815
|
+
queryParams: {
|
|
816
|
+
symbol: params.symbol,
|
|
817
|
+
chain: params.chain
|
|
818
|
+
},
|
|
819
|
+
attributes: Attributes.protected()
|
|
820
|
+
});
|
|
821
|
+
return CentrifugeVaultStatus.fromDto(dto);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
// src/universal/core/shared/observability/log-cause.ts
|
|
825
|
+
import {
|
|
826
|
+
BaseError,
|
|
827
|
+
ContractFunctionExecutionError,
|
|
828
|
+
ContractFunctionRevertedError,
|
|
829
|
+
HttpRequestError,
|
|
830
|
+
RpcError,
|
|
831
|
+
SocketClosedError,
|
|
832
|
+
TimeoutError,
|
|
833
|
+
WebSocketRequestError
|
|
834
|
+
} from "viem";
|
|
835
|
+
function classifyLogCause(error) {
|
|
836
|
+
if (error instanceof HttpError) {
|
|
837
|
+
return httpCause(error);
|
|
838
|
+
}
|
|
839
|
+
if (error instanceof ValidationError) {
|
|
840
|
+
return { type: "validation", message: error.message };
|
|
841
|
+
}
|
|
842
|
+
if (error instanceof InvariantError) {
|
|
843
|
+
return { type: "invariant", message: error.message };
|
|
844
|
+
}
|
|
845
|
+
if (error instanceof MathError) {
|
|
846
|
+
return { type: "math", message: error.message };
|
|
847
|
+
}
|
|
848
|
+
if (error instanceof NotAuthenticatedError) {
|
|
849
|
+
return { type: "not-authenticated" };
|
|
850
|
+
}
|
|
851
|
+
if (error instanceof NotImplementedError) {
|
|
852
|
+
return { type: "not-implemented" };
|
|
853
|
+
}
|
|
854
|
+
if (error instanceof BaseError) {
|
|
855
|
+
const http = error.walk((e) => e instanceof HttpError);
|
|
856
|
+
if (http instanceof HttpError) {
|
|
857
|
+
return httpCause(http);
|
|
858
|
+
}
|
|
859
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
860
|
+
}
|
|
861
|
+
return { type: "generic-error", name: errorName(error) };
|
|
862
|
+
}
|
|
863
|
+
function rpcFailureReason(error) {
|
|
864
|
+
if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
|
|
865
|
+
return "reverted";
|
|
866
|
+
}
|
|
867
|
+
if (error.walk((e) => e instanceof RpcError)) {
|
|
868
|
+
return "node-rejected";
|
|
869
|
+
}
|
|
870
|
+
if (error.walk(
|
|
871
|
+
(e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
|
|
872
|
+
)) {
|
|
873
|
+
return "transport";
|
|
874
|
+
}
|
|
875
|
+
if (error instanceof ContractFunctionExecutionError) {
|
|
876
|
+
return "malformed-response";
|
|
877
|
+
}
|
|
878
|
+
return "unknown";
|
|
879
|
+
}
|
|
880
|
+
function describeErrorUnredacted(error) {
|
|
881
|
+
if (error instanceof HttpError) {
|
|
882
|
+
return describeHttpErrorRedacted(error);
|
|
883
|
+
}
|
|
884
|
+
if (error instanceof Error) {
|
|
885
|
+
return `${error.name}: ${error.message}`;
|
|
886
|
+
}
|
|
887
|
+
return `thrown non-error: ${stringifyUnredacted(error)}`;
|
|
888
|
+
}
|
|
889
|
+
function stringifyUnredacted(value) {
|
|
890
|
+
if (value === void 0) return "";
|
|
891
|
+
try {
|
|
892
|
+
return JSON.stringify(
|
|
893
|
+
value,
|
|
894
|
+
(_key, item) => typeof item === "bigint" ? `${item}` : item
|
|
895
|
+
) ?? String(value);
|
|
896
|
+
} catch (_) {
|
|
897
|
+
return "<unserializable>";
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function describeHttpErrorRedacted(error) {
|
|
901
|
+
const code = apiErrorCode(error);
|
|
902
|
+
const status = error.response.status;
|
|
903
|
+
return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
|
|
904
|
+
}
|
|
905
|
+
function errorName(error) {
|
|
906
|
+
return error instanceof Error ? error.name : `non-error ${typeof error}`;
|
|
907
|
+
}
|
|
908
|
+
function httpCause(error) {
|
|
909
|
+
return {
|
|
910
|
+
type: "http",
|
|
911
|
+
requestId: error.requestId,
|
|
912
|
+
status: error.response.status,
|
|
913
|
+
code: apiErrorCode(error),
|
|
914
|
+
eventId: apiErrorEventId(error)
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function apiErrorEventId(error) {
|
|
918
|
+
const body = error.response.body;
|
|
919
|
+
if (typeof body !== "object" || body === null) return null;
|
|
920
|
+
const eventId = body.event_id;
|
|
921
|
+
return typeof eventId === "string" ? eventId : null;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// src/universal/core/shared/observability/internal-logger.ts
|
|
925
|
+
function internalLogger(logger, scope) {
|
|
926
|
+
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
927
|
+
}
|
|
928
|
+
var LEVEL_RANK = {
|
|
929
|
+
none: 0,
|
|
930
|
+
error: 1,
|
|
931
|
+
warn: 2,
|
|
932
|
+
info: 3,
|
|
933
|
+
debug: 4
|
|
934
|
+
};
|
|
935
|
+
function scopedLogger(logger, scope, bindings) {
|
|
936
|
+
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
937
|
+
const safe = (event) => ({
|
|
938
|
+
msg: event.msg,
|
|
939
|
+
scope,
|
|
940
|
+
bindings,
|
|
941
|
+
fields: event.fields ?? {},
|
|
942
|
+
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
943
|
+
});
|
|
944
|
+
const unredacted = (event) => ({
|
|
945
|
+
msg: event.msg,
|
|
946
|
+
scope,
|
|
947
|
+
bindings,
|
|
948
|
+
fields: event.fields ?? {}
|
|
949
|
+
});
|
|
950
|
+
const self = {
|
|
951
|
+
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
952
|
+
debug: (event) => {
|
|
953
|
+
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
954
|
+
},
|
|
955
|
+
info: (event) => {
|
|
956
|
+
if (admits("info")) logger.info(() => safe(event()));
|
|
957
|
+
},
|
|
958
|
+
warn: (event) => {
|
|
959
|
+
if (admits("warn")) logger.warn(() => safe(event()));
|
|
960
|
+
},
|
|
961
|
+
error: (event) => {
|
|
962
|
+
if (admits("error")) logger.error(() => safe(event()));
|
|
963
|
+
},
|
|
964
|
+
failure: (event, error) => {
|
|
965
|
+
if (admits("debug"))
|
|
966
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
967
|
+
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
968
|
+
},
|
|
969
|
+
warning: (event, error) => {
|
|
970
|
+
if (admits("debug"))
|
|
971
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
972
|
+
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
973
|
+
},
|
|
974
|
+
wrap: async (op, params, run) => {
|
|
975
|
+
const opLog = self.child({ op });
|
|
976
|
+
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
977
|
+
try {
|
|
978
|
+
return await run();
|
|
979
|
+
} catch (error) {
|
|
980
|
+
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
981
|
+
throw error;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
return self;
|
|
986
|
+
}
|
|
987
|
+
function verbatim(event, error) {
|
|
988
|
+
return {
|
|
989
|
+
msg: event.msg,
|
|
990
|
+
fields: { ...event.fields, error: describeErrorUnredacted(error) }
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
function classified(event, error) {
|
|
994
|
+
return { ...event, cause: event.cause ?? classifyLogCause(error) };
|
|
599
995
|
}
|
|
996
|
+
var noopInternalLogger = {
|
|
997
|
+
child: () => noopInternalLogger,
|
|
998
|
+
debug: () => void 0,
|
|
999
|
+
info: () => void 0,
|
|
1000
|
+
warn: () => void 0,
|
|
1001
|
+
error: () => void 0,
|
|
1002
|
+
failure: () => void 0,
|
|
1003
|
+
warning: () => void 0,
|
|
1004
|
+
wrap: (_op, _params, run) => run()
|
|
1005
|
+
};
|
|
600
1006
|
|
|
601
|
-
// src/universal/core/
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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
|
-
);
|
|
1007
|
+
// src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
|
|
1008
|
+
var CentrifugeNamespaceImpl = class {
|
|
1009
|
+
constructor(ctx) {
|
|
1010
|
+
this.ctx = ctx;
|
|
1011
|
+
this.log = internalLogger(ctx.logger, "CENTRIFUGE");
|
|
614
1012
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
throw new ValidationError(
|
|
621
|
-
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
622
|
-
);
|
|
1013
|
+
async getQuote(params) {
|
|
1014
|
+
return this.log.wrap("getQuote", params, async () => {
|
|
1015
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1016
|
+
return getCentrifugeVaultQuote(this.ctx.api, params);
|
|
1017
|
+
});
|
|
623
1018
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
`${field}: expected an array, got ${typeof value}`
|
|
630
|
-
);
|
|
1019
|
+
async getVaultStatus(params) {
|
|
1020
|
+
return this.log.wrap("getVaultStatus", params, async () => {
|
|
1021
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1022
|
+
return getCentrifugeVaultStatus(this.ctx.api, params);
|
|
1023
|
+
});
|
|
631
1024
|
}
|
|
632
|
-
|
|
633
|
-
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
// src/universal/types/pagination.ts
|
|
1028
|
+
var Cursor = (value) => value;
|
|
1029
|
+
var PaginatedResponse = {
|
|
1030
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1031
|
+
/**
|
|
1032
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1033
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1034
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1035
|
+
* page holds, not where the next page starts.
|
|
1036
|
+
*/
|
|
1037
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1038
|
+
data: pageMapper(dto.data),
|
|
1039
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1040
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1041
|
+
})
|
|
1042
|
+
};
|
|
1043
|
+
var PaginationParams = {
|
|
1044
|
+
toQueryParams: (params) => {
|
|
1045
|
+
const queryParams = {};
|
|
1046
|
+
if (params.after) {
|
|
1047
|
+
queryParams.starting_after = params.after;
|
|
1048
|
+
}
|
|
1049
|
+
if (params.before) {
|
|
1050
|
+
queryParams.starting_before = params.before;
|
|
1051
|
+
}
|
|
1052
|
+
if (params.limit) {
|
|
1053
|
+
queryParams.limit = params.limit;
|
|
1054
|
+
}
|
|
1055
|
+
return queryParams;
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
// src/universal/types/asset.ts
|
|
1060
|
+
var AssetId = (value) => value;
|
|
1061
|
+
var AssetCode = (value) => value;
|
|
1062
|
+
var Asset = {
|
|
1063
|
+
fromDto: (dto) => ({
|
|
1064
|
+
id: AssetId(dto.id),
|
|
1065
|
+
code: AssetCode(dto.code),
|
|
1066
|
+
name: dto.name,
|
|
1067
|
+
fractionalDigits: dto.fractional_digits
|
|
1068
|
+
})
|
|
1069
|
+
};
|
|
634
1070
|
|
|
635
1071
|
// src/universal/types/offer.ts
|
|
636
1072
|
var OfferId = (value) => value;
|
|
@@ -638,7 +1074,8 @@ var OfferSlug = (value) => value;
|
|
|
638
1074
|
var OFFER_TYPES = {
|
|
639
1075
|
"coinlist::token_sale": true,
|
|
640
1076
|
"superstate::swap": true,
|
|
641
|
-
"ondo::swap": true
|
|
1077
|
+
"ondo::swap": true,
|
|
1078
|
+
"centrifuge::vault": true
|
|
642
1079
|
};
|
|
643
1080
|
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
644
1081
|
var OfferEditorial = {
|
|
@@ -680,6 +1117,7 @@ var Offer = {
|
|
|
680
1117
|
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
681
1118
|
// is 1970 for one variant and a date for the others.
|
|
682
1119
|
case "ondo::swap":
|
|
1120
|
+
case "centrifuge::vault":
|
|
683
1121
|
return {
|
|
684
1122
|
...base2,
|
|
685
1123
|
type: dto.type,
|
|
@@ -732,6 +1170,19 @@ var OfferSwapContract = {
|
|
|
732
1170
|
address: EvmContractAddress(dto.address)
|
|
733
1171
|
})
|
|
734
1172
|
};
|
|
1173
|
+
var OfferVaultContract = {
|
|
1174
|
+
fromDto: (dto) => ({
|
|
1175
|
+
chain: Chain(dto.chain),
|
|
1176
|
+
address: EvmContractAddress(dto.address)
|
|
1177
|
+
}),
|
|
1178
|
+
/**
|
|
1179
|
+
* Drops every proxy on a chain this SDK does not name, as
|
|
1180
|
+
* `OfferToken.listFromDto` does: frontline publishes the full offer-token
|
|
1181
|
+
* chain list, which runs ahead of {@link Chain}, and one unmodelled chain
|
|
1182
|
+
* should not throw away the proxies the SDK can use.
|
|
1183
|
+
*/
|
|
1184
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
|
|
1185
|
+
};
|
|
735
1186
|
var OfferDetail = {
|
|
736
1187
|
fromDto: (dto) => {
|
|
737
1188
|
const fundingAssets = requiredArray(
|
|
@@ -794,6 +1245,18 @@ var OfferDetail = {
|
|
|
794
1245
|
"OfferDetail.swap_contracts"
|
|
795
1246
|
).map(OfferSwapContract.fromDto)
|
|
796
1247
|
};
|
|
1248
|
+
// No editorial, as for Ondo. `[]` is fine and a missing key is not, for
|
|
1249
|
+
// the same reason as `swap_contracts`: this is the spender a user
|
|
1250
|
+
// approves.
|
|
1251
|
+
case "centrifuge::vault":
|
|
1252
|
+
return {
|
|
1253
|
+
...base2,
|
|
1254
|
+
type: dto.type,
|
|
1255
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
1256
|
+
vaultContracts: OfferVaultContract.listFromDto(
|
|
1257
|
+
requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
|
|
1258
|
+
)
|
|
1259
|
+
};
|
|
797
1260
|
default:
|
|
798
1261
|
return unknownTypeError(dto, "OfferDetail");
|
|
799
1262
|
}
|
|
@@ -841,265 +1304,82 @@ var Milestone = {
|
|
|
841
1304
|
var ParticipationId = (value) => value;
|
|
842
1305
|
var Blockchain = (value) => value;
|
|
843
1306
|
var WalletAddress = (value) => value;
|
|
844
|
-
var ParticipationsPaginationParams = {
|
|
845
|
-
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}`;
|
|
1307
|
+
var ParticipationsPaginationParams = {
|
|
1308
|
+
toQueryParams: (params) => {
|
|
1309
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
1310
|
+
if (params.offerId) {
|
|
1311
|
+
queryParams["filters[0][field]"] = "offer_id";
|
|
1312
|
+
queryParams["filters[0][op]"] = "==";
|
|
1313
|
+
queryParams["filters[0][value]"] = params.offerId;
|
|
1314
|
+
}
|
|
1315
|
+
return queryParams;
|
|
983
1316
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
return
|
|
990
|
-
|
|
991
|
-
(
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1317
|
+
};
|
|
1318
|
+
var Participation = {
|
|
1319
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
1320
|
+
fromDto: (dto) => {
|
|
1321
|
+
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
1322
|
+
return {
|
|
1323
|
+
id: ParticipationId(dto.id),
|
|
1324
|
+
offerId: OfferId(dto.offer_id),
|
|
1325
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
1326
|
+
status: dto.status,
|
|
1327
|
+
amount: dto.amount,
|
|
1328
|
+
displayAmount: dto.amount_string,
|
|
1329
|
+
asset: Asset.fromDto(dto.asset),
|
|
1330
|
+
chain: Blockchain(dto.chain),
|
|
1331
|
+
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
1332
|
+
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
1333
|
+
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
1334
|
+
};
|
|
995
1335
|
}
|
|
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
|
-
}
|
|
1336
|
+
};
|
|
1337
|
+
var CreateParticipationParams = {
|
|
1338
|
+
/** Maps participation creation params into API DTO payload. */
|
|
1339
|
+
toDto: (params) => ({
|
|
1340
|
+
offer_id: params.offerId,
|
|
1341
|
+
offer_option_id: params.offerOptionId,
|
|
1342
|
+
chain: params.chain,
|
|
1343
|
+
wallet_address: params.walletAddress,
|
|
1344
|
+
amount: params.amount,
|
|
1345
|
+
asset_id: params.assetId,
|
|
1346
|
+
approval_transaction_hash: params.approvalTransactionHash
|
|
1347
|
+
})
|
|
1348
|
+
};
|
|
1020
1349
|
|
|
1021
|
-
// src/universal/
|
|
1022
|
-
function
|
|
1023
|
-
return
|
|
1350
|
+
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
1351
|
+
async function fetchParticipations(api, offerId) {
|
|
1352
|
+
return fetchAllPages(
|
|
1353
|
+
(params) => fetchParticipationsPage(api, params),
|
|
1354
|
+
{ offerId }
|
|
1355
|
+
);
|
|
1024
1356
|
}
|
|
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 ?? {}
|
|
1357
|
+
async function fetchParticipationsPage(api, params) {
|
|
1358
|
+
const pageDto = await api.send({
|
|
1359
|
+
method: "GET",
|
|
1360
|
+
url: "/v1/participations",
|
|
1361
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
1362
|
+
attributes: Attributes.protected()
|
|
1046
1363
|
});
|
|
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;
|
|
1364
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
1083
1365
|
}
|
|
1084
|
-
function
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1366
|
+
async function fetchParticipation(api, id) {
|
|
1367
|
+
const dto = await api.send({
|
|
1368
|
+
method: "GET",
|
|
1369
|
+
url: `/v1/participations/${id}`,
|
|
1370
|
+
attributes: Attributes.protected()
|
|
1371
|
+
});
|
|
1372
|
+
return Participation.fromDto(dto);
|
|
1089
1373
|
}
|
|
1090
|
-
function
|
|
1091
|
-
|
|
1374
|
+
async function createParticipation(api, params) {
|
|
1375
|
+
const dto = await api.send({
|
|
1376
|
+
method: "POST",
|
|
1377
|
+
url: "/v1/participations",
|
|
1378
|
+
body: CreateParticipationParams.toDto(params),
|
|
1379
|
+
attributes: Attributes.protected()
|
|
1380
|
+
});
|
|
1381
|
+
return Participation.fromDto(dto);
|
|
1092
1382
|
}
|
|
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
1383
|
|
|
1104
1384
|
// src/universal/core/checkout/coin-list/token-sale-namespace.ts
|
|
1105
1385
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
@@ -1307,66 +1587,6 @@ function explorerBaseUrl(chain) {
|
|
|
1307
1587
|
}
|
|
1308
1588
|
}
|
|
1309
1589
|
|
|
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
1590
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1371
1591
|
var OndoTradingStatus = {
|
|
1372
1592
|
fromDto: (dto) => {
|
|
@@ -1382,7 +1602,6 @@ var OndoTradingStatus = {
|
|
|
1382
1602
|
};
|
|
1383
1603
|
}
|
|
1384
1604
|
};
|
|
1385
|
-
var decimalOrNull = (value) => value === null ? null : DecimalString(value);
|
|
1386
1605
|
var OndoQuote = {
|
|
1387
1606
|
fromDto: (dto) => {
|
|
1388
1607
|
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
@@ -3517,12 +3736,6 @@ export {
|
|
|
3517
3736
|
isExpired,
|
|
3518
3737
|
ERC20_ABI,
|
|
3519
3738
|
fetchAllPages,
|
|
3520
|
-
Cursor,
|
|
3521
|
-
PaginatedResponse,
|
|
3522
|
-
PaginationParams,
|
|
3523
|
-
AssetId,
|
|
3524
|
-
AssetCode,
|
|
3525
|
-
Asset,
|
|
3526
3739
|
ETHEREUM_CHAINS,
|
|
3527
3740
|
EthereumChain,
|
|
3528
3741
|
SOLANA_CHAINS,
|
|
@@ -3544,6 +3757,20 @@ export {
|
|
|
3544
3757
|
StablecoinSymbol,
|
|
3545
3758
|
KnownAssetSymbol,
|
|
3546
3759
|
Bps,
|
|
3760
|
+
blockchainAmountFromRawOrThrow,
|
|
3761
|
+
parseBlockchainAmount,
|
|
3762
|
+
CentrifugeVaultQuote,
|
|
3763
|
+
CentrifugeVaultStatus,
|
|
3764
|
+
CentrifugeVaultBuyTransaction,
|
|
3765
|
+
CentrifugeVaultClaimTransaction,
|
|
3766
|
+
CentrifugeVaultPosition,
|
|
3767
|
+
CentrifugeNamespaceImpl,
|
|
3768
|
+
Cursor,
|
|
3769
|
+
PaginatedResponse,
|
|
3770
|
+
PaginationParams,
|
|
3771
|
+
AssetId,
|
|
3772
|
+
AssetCode,
|
|
3773
|
+
Asset,
|
|
3547
3774
|
OfferId,
|
|
3548
3775
|
OfferSlug,
|
|
3549
3776
|
isOfferType,
|
|
@@ -3555,6 +3782,7 @@ export {
|
|
|
3555
3782
|
OfferOptionId,
|
|
3556
3783
|
OfferOptionSlug,
|
|
3557
3784
|
OfferSwapContract,
|
|
3785
|
+
OfferVaultContract,
|
|
3558
3786
|
OfferDetail,
|
|
3559
3787
|
OfferOption,
|
|
3560
3788
|
FaqItem,
|
|
@@ -3589,8 +3817,6 @@ export {
|
|
|
3589
3817
|
chainFromId,
|
|
3590
3818
|
getNetworkName,
|
|
3591
3819
|
txExplorerUrl,
|
|
3592
|
-
blockchainAmountFromRawOrThrow,
|
|
3593
|
-
parseBlockchainAmount,
|
|
3594
3820
|
OndoTradingStatus,
|
|
3595
3821
|
OndoQuote,
|
|
3596
3822
|
OndoBuyTransaction,
|
|
@@ -3631,4 +3857,4 @@ export {
|
|
|
3631
3857
|
OAuthRefreshToken,
|
|
3632
3858
|
OAuthSession
|
|
3633
3859
|
};
|
|
3634
|
-
//# sourceMappingURL=chunk-
|
|
3860
|
+
//# sourceMappingURL=chunk-XCRU3YE2.js.map
|