@coinlist-co/react 0.12.2-rc.31c2f50 → 0.12.2-rc.5f2ca48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4IZ2F732.js → chunk-6NCNF5GF.js} +2 -2
- package/dist/{chunk-UJYSXXJF.js → chunk-VUIDJYHY.js} +6 -156
- package/dist/chunk-VUIDJYHY.js.map +1 -0
- package/dist/{chunk-NBO5E2RO.js → chunk-XCRU3YE2.js} +599 -409
- package/dist/chunk-XCRU3YE2.js.map +1 -0
- package/dist/client/index.cjs +458 -111
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +184 -5
- package/dist/client/index.d.ts +184 -5
- package/dist/client/index.js +222 -9
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +151 -26
- 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-DvgN98Q9.d.ts → time-CTuVDTx6.d.ts} +1 -1
- package/dist/{time-CFocgYyl.d.cts → time-Dv1dejVB.d.cts} +1 -1
- package/dist/{token-registry-snapshot-Cc_eA5zM.d.cts → token-registry-snapshot-CX5YiSHp.d.cts} +1 -1
- package/dist/{token-registry-snapshot-BsAfBL_b.d.ts → token-registry-snapshot-CzJd2VYU.d.ts} +1 -1
- package/dist/{tokens-namespace-D_XSpiS-.d.cts → tokens-namespace-CcvHrw-k.d.cts} +361 -2
- package/dist/{tokens-namespace-D_XSpiS-.d.ts → tokens-namespace-CcvHrw-k.d.ts} +361 -2
- package/dist/universal/index.cjs +528 -472
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +18 -321
- package/dist/universal/index.d.ts +18 -321
- package/dist/universal/index.js +11 -7
- package/package.json +1 -1
- package/dist/chunk-NBO5E2RO.js.map +0 -1
- package/dist/chunk-UJYSXXJF.js.map +0 -1
- /package/dist/{chunk-4IZ2F732.js.map → chunk-6NCNF5GF.js.map} +0 -0
package/dist/universal/index.cjs
CHANGED
|
@@ -32,6 +32,8 @@ __export(universal_exports, {
|
|
|
32
32
|
Blockchain: () => Blockchain,
|
|
33
33
|
BlockchainAmount: () => BlockchainAmount,
|
|
34
34
|
Bps: () => Bps,
|
|
35
|
+
CENTRIFUGE_POLL_INTERVAL_MS: () => CENTRIFUGE_POLL_INTERVAL_MS,
|
|
36
|
+
CentrifugeNamespaceImpl: () => CentrifugeNamespaceImpl,
|
|
35
37
|
CentrifugeVaultBuyTransaction: () => CentrifugeVaultBuyTransaction,
|
|
36
38
|
CentrifugeVaultClaimTransaction: () => CentrifugeVaultClaimTransaction,
|
|
37
39
|
CentrifugeVaultPosition: () => CentrifugeVaultPosition,
|
|
@@ -462,49 +464,8 @@ async function generatePKCEParams(config) {
|
|
|
462
464
|
};
|
|
463
465
|
}
|
|
464
466
|
|
|
465
|
-
// src/universal/
|
|
466
|
-
var
|
|
467
|
-
var PaginatedResponse = {
|
|
468
|
-
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
469
|
-
/**
|
|
470
|
-
* For a mapper that decides the page as a whole - one that drops items it
|
|
471
|
-
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
472
|
-
* cursors are the wire's either way: dropping an item changes what the
|
|
473
|
-
* page holds, not where the next page starts.
|
|
474
|
-
*/
|
|
475
|
-
fromDtoPage: (dto, pageMapper) => ({
|
|
476
|
-
data: pageMapper(dto.data),
|
|
477
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
478
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
479
|
-
})
|
|
480
|
-
};
|
|
481
|
-
var PaginationParams = {
|
|
482
|
-
toQueryParams: (params) => {
|
|
483
|
-
const queryParams = {};
|
|
484
|
-
if (params.after) {
|
|
485
|
-
queryParams.starting_after = params.after;
|
|
486
|
-
}
|
|
487
|
-
if (params.before) {
|
|
488
|
-
queryParams.starting_before = params.before;
|
|
489
|
-
}
|
|
490
|
-
if (params.limit) {
|
|
491
|
-
queryParams.limit = params.limit;
|
|
492
|
-
}
|
|
493
|
-
return queryParams;
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
// src/universal/types/asset.ts
|
|
498
|
-
var AssetId = (value) => value;
|
|
499
|
-
var AssetCode = (value) => value;
|
|
500
|
-
var Asset = {
|
|
501
|
-
fromDto: (dto) => ({
|
|
502
|
-
id: AssetId(dto.id),
|
|
503
|
-
code: AssetCode(dto.code),
|
|
504
|
-
name: dto.name,
|
|
505
|
-
fractionalDigits: dto.fractional_digits
|
|
506
|
-
})
|
|
507
|
-
};
|
|
467
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
468
|
+
var import_viem = require("viem");
|
|
508
469
|
|
|
509
470
|
// src/universal/types/errors.ts
|
|
510
471
|
var NotImplementedError = class extends Error {
|
|
@@ -635,6 +596,65 @@ var StablecoinSymbol = (value) => value;
|
|
|
635
596
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
636
597
|
var Bps = (value) => value;
|
|
637
598
|
|
|
599
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
600
|
+
function blockchainAmountFromRawOrThrow({
|
|
601
|
+
label,
|
|
602
|
+
raw,
|
|
603
|
+
decimals
|
|
604
|
+
}) {
|
|
605
|
+
const trimmed = raw.trim();
|
|
606
|
+
if (trimmed === "") {
|
|
607
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
608
|
+
}
|
|
609
|
+
let value;
|
|
610
|
+
try {
|
|
611
|
+
value = BigInt(trimmed);
|
|
612
|
+
} catch {
|
|
613
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
614
|
+
}
|
|
615
|
+
try {
|
|
616
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
617
|
+
} catch {
|
|
618
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
function parseBlockchainAmount(amount, decimals) {
|
|
622
|
+
const trimmed = amount.trim();
|
|
623
|
+
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
624
|
+
if (trimmed.startsWith("-")) {
|
|
625
|
+
return { valid: false, reason: { type: "negative" } };
|
|
626
|
+
}
|
|
627
|
+
if (/[eE]/.test(trimmed)) {
|
|
628
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
629
|
+
}
|
|
630
|
+
if (trimmed === ".") {
|
|
631
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
632
|
+
}
|
|
633
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
634
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
635
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
636
|
+
}
|
|
637
|
+
const [, fraction = ""] = normalised.split(".");
|
|
638
|
+
if (fraction.length > decimals) {
|
|
639
|
+
return {
|
|
640
|
+
valid: false,
|
|
641
|
+
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
try {
|
|
645
|
+
const raw = (0, import_viem.parseUnits)(normalised, decimals);
|
|
646
|
+
if (raw > MAX_UINT_256) {
|
|
647
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
648
|
+
}
|
|
649
|
+
return {
|
|
650
|
+
valid: true,
|
|
651
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
652
|
+
};
|
|
653
|
+
} catch {
|
|
654
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
638
658
|
// src/universal/core/shared/utils/wire.ts
|
|
639
659
|
function unknownTypeError(dto, model) {
|
|
640
660
|
const type = dto.type;
|
|
@@ -658,22 +678,430 @@ function requiredDate(value, field) {
|
|
|
658
678
|
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
659
679
|
);
|
|
660
680
|
}
|
|
661
|
-
return date;
|
|
662
|
-
}
|
|
663
|
-
function dateOrNull(value, field) {
|
|
664
|
-
return value === null ? null : requiredDate(value, field);
|
|
665
|
-
}
|
|
666
|
-
function decimalOrNull(value) {
|
|
667
|
-
return value === null ? null : DecimalString(value);
|
|
668
|
-
}
|
|
669
|
-
function requiredArray(value, field) {
|
|
670
|
-
if (!Array.isArray(value)) {
|
|
671
|
-
throw new ValidationError(
|
|
672
|
-
`${field}: expected an array, got ${typeof value}`
|
|
673
|
-
);
|
|
681
|
+
return date;
|
|
682
|
+
}
|
|
683
|
+
function dateOrNull(value, field) {
|
|
684
|
+
return value === null ? null : requiredDate(value, field);
|
|
685
|
+
}
|
|
686
|
+
function decimalOrNull(value) {
|
|
687
|
+
return value === null ? null : DecimalString(value);
|
|
688
|
+
}
|
|
689
|
+
function requiredArray(value, field) {
|
|
690
|
+
if (!Array.isArray(value)) {
|
|
691
|
+
throw new ValidationError(
|
|
692
|
+
`${field}: expected an array, got ${typeof value}`
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
return value;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
699
|
+
var CentrifugeVaultQuote = {
|
|
700
|
+
fromDto: (dto) => {
|
|
701
|
+
const spendDecimals = AssetDecimals(dto.spend_input_decimals);
|
|
702
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
703
|
+
return {
|
|
704
|
+
chain: EthereumChain(dto.chain),
|
|
705
|
+
symbol: AssetSymbol(dto.symbol),
|
|
706
|
+
spendInputAmount: blockchainAmountFromRawOrThrow({
|
|
707
|
+
label: "spend_input_amount",
|
|
708
|
+
raw: dto.spend_input_amount,
|
|
709
|
+
decimals: spendDecimals
|
|
710
|
+
}),
|
|
711
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
712
|
+
label: "estimated_shares",
|
|
713
|
+
raw: dto.estimated_shares,
|
|
714
|
+
decimals: shareDecimals
|
|
715
|
+
}),
|
|
716
|
+
indicativePrice: decimalOrNull(dto.indicative_price),
|
|
717
|
+
minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
|
|
718
|
+
label: "minimum_input_amount",
|
|
719
|
+
raw: dto.minimum_input_amount,
|
|
720
|
+
decimals: spendDecimals
|
|
721
|
+
}),
|
|
722
|
+
orderability: parseOrderability(
|
|
723
|
+
dto.can_order,
|
|
724
|
+
dto.reasons,
|
|
725
|
+
"CentrifugeVaultQuote"
|
|
726
|
+
)
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
var CentrifugeVaultStatus = {
|
|
731
|
+
fromDto: (dto) => ({
|
|
732
|
+
chain: EthereumChain(dto.chain),
|
|
733
|
+
symbol: AssetSymbol(dto.symbol),
|
|
734
|
+
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
735
|
+
linked: dto.linked,
|
|
736
|
+
permissioned: dto.permissioned,
|
|
737
|
+
membershipValidUntil: dateOrNull(
|
|
738
|
+
dto.membership_valid_until,
|
|
739
|
+
"CentrifugeVaultStatus.membership_valid_until"
|
|
740
|
+
),
|
|
741
|
+
halted: dto.halted,
|
|
742
|
+
priceUpdatedAt: dateOrNull(
|
|
743
|
+
dto.price_updated_at,
|
|
744
|
+
"CentrifugeVaultStatus.price_updated_at"
|
|
745
|
+
),
|
|
746
|
+
orderability: parseOrderability(
|
|
747
|
+
dto.can_order,
|
|
748
|
+
dto.reasons,
|
|
749
|
+
"CentrifugeVaultStatus"
|
|
750
|
+
),
|
|
751
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
752
|
+
})
|
|
753
|
+
};
|
|
754
|
+
var CentrifugeVaultBuyTransaction = {
|
|
755
|
+
fromDto: (dto) => {
|
|
756
|
+
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
757
|
+
label: "spend_input_amount",
|
|
758
|
+
raw: dto.spend_input_amount,
|
|
759
|
+
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
760
|
+
});
|
|
761
|
+
if (spendInputAmount.raw <= 0n) {
|
|
762
|
+
throw new ValidationError(
|
|
763
|
+
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
return {
|
|
767
|
+
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
768
|
+
spendInputAmount,
|
|
769
|
+
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
770
|
+
label: "estimated_shares",
|
|
771
|
+
raw: dto.estimated_shares,
|
|
772
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
773
|
+
})
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
var CentrifugeVaultClaimTransaction = {
|
|
778
|
+
fromDto: (dto) => ({
|
|
779
|
+
...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
|
|
780
|
+
claimableShares: blockchainAmountFromRawOrThrow({
|
|
781
|
+
label: "claimable_shares",
|
|
782
|
+
raw: dto.claimable_shares,
|
|
783
|
+
decimals: AssetDecimals(dto.share_decimals)
|
|
784
|
+
})
|
|
785
|
+
})
|
|
786
|
+
};
|
|
787
|
+
var CentrifugeVaultPosition = {
|
|
788
|
+
fromDto: (dto) => {
|
|
789
|
+
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
790
|
+
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
791
|
+
const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
|
|
792
|
+
const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
|
|
793
|
+
return {
|
|
794
|
+
chain: EthereumChain(dto.chain),
|
|
795
|
+
symbol: AssetSymbol(dto.symbol),
|
|
796
|
+
walletAddress: EvmWalletAddress(dto.wallet_address),
|
|
797
|
+
status: dto.status,
|
|
798
|
+
requested: asset("requested", dto.requested),
|
|
799
|
+
pending: asset("pending", dto.pending),
|
|
800
|
+
filledAssets: asset("filled_assets", dto.filled_assets),
|
|
801
|
+
earnedShares: shares("earned_shares", dto.earned_shares),
|
|
802
|
+
claimedShares: shares("claimed_shares", dto.claimed_shares),
|
|
803
|
+
claimableShares: shares("claimable_shares", dto.claimable_shares),
|
|
804
|
+
shareBalance: shares("share_balance", dto.share_balance),
|
|
805
|
+
averagePrice: decimalOrNull(dto.average_price),
|
|
806
|
+
frozen: dto.frozen,
|
|
807
|
+
asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
function parseOrderability(canOrder, reasons, model) {
|
|
812
|
+
const [first, ...rest] = reasons;
|
|
813
|
+
if (canOrder) {
|
|
814
|
+
if (first !== void 0) {
|
|
815
|
+
throw new ValidationError(
|
|
816
|
+
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
return { type: "orderable" };
|
|
820
|
+
}
|
|
821
|
+
if (first === void 0) {
|
|
822
|
+
throw new ValidationError(
|
|
823
|
+
`${model}.reasons: expected at least one when can_order is false`
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
return { type: "blocked", reasons: [first, ...rest] };
|
|
827
|
+
}
|
|
828
|
+
function parseTransactionCore(dto, model) {
|
|
829
|
+
return {
|
|
830
|
+
tx: {
|
|
831
|
+
to: EvmContractAddress(dto.to),
|
|
832
|
+
data: HexEncodedTransactionData(dto.data)
|
|
833
|
+
},
|
|
834
|
+
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
839
|
+
async function getCentrifugeVaultQuote(api, params) {
|
|
840
|
+
const dto = await api.send({
|
|
841
|
+
method: "GET",
|
|
842
|
+
url: "/v1/centrifuge/vault/quote",
|
|
843
|
+
queryParams: {
|
|
844
|
+
symbol: params.symbol,
|
|
845
|
+
chain: params.chain,
|
|
846
|
+
amount: params.amount.raw.toString()
|
|
847
|
+
},
|
|
848
|
+
attributes: Attributes.protected()
|
|
849
|
+
});
|
|
850
|
+
return CentrifugeVaultQuote.fromDto(dto);
|
|
851
|
+
}
|
|
852
|
+
async function getCentrifugeVaultStatus(api, params) {
|
|
853
|
+
const dto = await api.send({
|
|
854
|
+
method: "GET",
|
|
855
|
+
url: "/v1/centrifuge/vault/status",
|
|
856
|
+
queryParams: {
|
|
857
|
+
symbol: params.symbol,
|
|
858
|
+
chain: params.chain
|
|
859
|
+
},
|
|
860
|
+
attributes: Attributes.protected()
|
|
861
|
+
});
|
|
862
|
+
return CentrifugeVaultStatus.fromDto(dto);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// src/universal/core/shared/observability/log-cause.ts
|
|
866
|
+
var import_viem2 = require("viem");
|
|
867
|
+
function classifyLogCause(error) {
|
|
868
|
+
if (error instanceof HttpError) {
|
|
869
|
+
return httpCause(error);
|
|
870
|
+
}
|
|
871
|
+
if (error instanceof ValidationError) {
|
|
872
|
+
return { type: "validation", message: error.message };
|
|
873
|
+
}
|
|
874
|
+
if (error instanceof InvariantError) {
|
|
875
|
+
return { type: "invariant", message: error.message };
|
|
876
|
+
}
|
|
877
|
+
if (error instanceof MathError) {
|
|
878
|
+
return { type: "math", message: error.message };
|
|
879
|
+
}
|
|
880
|
+
if (error instanceof NotAuthenticatedError) {
|
|
881
|
+
return { type: "not-authenticated" };
|
|
882
|
+
}
|
|
883
|
+
if (error instanceof NotImplementedError) {
|
|
884
|
+
return { type: "not-implemented" };
|
|
885
|
+
}
|
|
886
|
+
if (error instanceof import_viem2.BaseError) {
|
|
887
|
+
const http = error.walk((e) => e instanceof HttpError);
|
|
888
|
+
if (http instanceof HttpError) {
|
|
889
|
+
return httpCause(http);
|
|
890
|
+
}
|
|
891
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
892
|
+
}
|
|
893
|
+
return { type: "generic-error", name: errorName(error) };
|
|
894
|
+
}
|
|
895
|
+
function rpcFailureReason(error) {
|
|
896
|
+
if (error.walk((e) => e instanceof import_viem2.ContractFunctionRevertedError)) {
|
|
897
|
+
return "reverted";
|
|
898
|
+
}
|
|
899
|
+
if (error.walk((e) => e instanceof import_viem2.RpcError)) {
|
|
900
|
+
return "node-rejected";
|
|
901
|
+
}
|
|
902
|
+
if (error.walk(
|
|
903
|
+
(e) => e instanceof import_viem2.HttpRequestError || e instanceof import_viem2.WebSocketRequestError || e instanceof import_viem2.SocketClosedError || e instanceof import_viem2.TimeoutError
|
|
904
|
+
)) {
|
|
905
|
+
return "transport";
|
|
906
|
+
}
|
|
907
|
+
if (error instanceof import_viem2.ContractFunctionExecutionError) {
|
|
908
|
+
return "malformed-response";
|
|
909
|
+
}
|
|
910
|
+
return "unknown";
|
|
911
|
+
}
|
|
912
|
+
function describeErrorUnredacted(error) {
|
|
913
|
+
if (error instanceof HttpError) {
|
|
914
|
+
return describeHttpErrorRedacted(error);
|
|
915
|
+
}
|
|
916
|
+
if (error instanceof Error) {
|
|
917
|
+
return `${error.name}: ${error.message}`;
|
|
918
|
+
}
|
|
919
|
+
return `thrown non-error: ${stringifyUnredacted(error)}`;
|
|
920
|
+
}
|
|
921
|
+
function stringifyUnredacted(value) {
|
|
922
|
+
if (value === void 0) return "";
|
|
923
|
+
try {
|
|
924
|
+
return JSON.stringify(
|
|
925
|
+
value,
|
|
926
|
+
(_key, item) => typeof item === "bigint" ? `${item}` : item
|
|
927
|
+
) ?? String(value);
|
|
928
|
+
} catch (_) {
|
|
929
|
+
return "<unserializable>";
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
function describeHttpErrorRedacted(error) {
|
|
933
|
+
const code = apiErrorCode(error);
|
|
934
|
+
const status = error.response.status;
|
|
935
|
+
return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
|
|
936
|
+
}
|
|
937
|
+
function errorName(error) {
|
|
938
|
+
return error instanceof Error ? error.name : `non-error ${typeof error}`;
|
|
939
|
+
}
|
|
940
|
+
function httpCause(error) {
|
|
941
|
+
return {
|
|
942
|
+
type: "http",
|
|
943
|
+
requestId: error.requestId,
|
|
944
|
+
status: error.response.status,
|
|
945
|
+
code: apiErrorCode(error),
|
|
946
|
+
eventId: apiErrorEventId(error)
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
function apiErrorEventId(error) {
|
|
950
|
+
const body = error.response.body;
|
|
951
|
+
if (typeof body !== "object" || body === null) return null;
|
|
952
|
+
const eventId = body.event_id;
|
|
953
|
+
return typeof eventId === "string" ? eventId : null;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// src/universal/core/shared/observability/internal-logger.ts
|
|
957
|
+
function internalLogger(logger, scope) {
|
|
958
|
+
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
959
|
+
}
|
|
960
|
+
var LEVEL_RANK = {
|
|
961
|
+
none: 0,
|
|
962
|
+
error: 1,
|
|
963
|
+
warn: 2,
|
|
964
|
+
info: 3,
|
|
965
|
+
debug: 4
|
|
966
|
+
};
|
|
967
|
+
function scopedLogger(logger, scope, bindings) {
|
|
968
|
+
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
969
|
+
const safe = (event) => ({
|
|
970
|
+
msg: event.msg,
|
|
971
|
+
scope,
|
|
972
|
+
bindings,
|
|
973
|
+
fields: event.fields ?? {},
|
|
974
|
+
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
975
|
+
});
|
|
976
|
+
const unredacted = (event) => ({
|
|
977
|
+
msg: event.msg,
|
|
978
|
+
scope,
|
|
979
|
+
bindings,
|
|
980
|
+
fields: event.fields ?? {}
|
|
981
|
+
});
|
|
982
|
+
const self = {
|
|
983
|
+
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
984
|
+
debug: (event) => {
|
|
985
|
+
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
986
|
+
},
|
|
987
|
+
info: (event) => {
|
|
988
|
+
if (admits("info")) logger.info(() => safe(event()));
|
|
989
|
+
},
|
|
990
|
+
warn: (event) => {
|
|
991
|
+
if (admits("warn")) logger.warn(() => safe(event()));
|
|
992
|
+
},
|
|
993
|
+
error: (event) => {
|
|
994
|
+
if (admits("error")) logger.error(() => safe(event()));
|
|
995
|
+
},
|
|
996
|
+
failure: (event, error) => {
|
|
997
|
+
if (admits("debug"))
|
|
998
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
999
|
+
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
1000
|
+
},
|
|
1001
|
+
warning: (event, error) => {
|
|
1002
|
+
if (admits("debug"))
|
|
1003
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1004
|
+
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
1005
|
+
},
|
|
1006
|
+
wrap: async (op, params, run) => {
|
|
1007
|
+
const opLog = self.child({ op });
|
|
1008
|
+
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
1009
|
+
try {
|
|
1010
|
+
return await run();
|
|
1011
|
+
} catch (error) {
|
|
1012
|
+
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
1013
|
+
throw error;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
return self;
|
|
1018
|
+
}
|
|
1019
|
+
function verbatim(event, error) {
|
|
1020
|
+
return {
|
|
1021
|
+
msg: event.msg,
|
|
1022
|
+
fields: { ...event.fields, error: describeErrorUnredacted(error) }
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
function classified(event, error) {
|
|
1026
|
+
return { ...event, cause: event.cause ?? classifyLogCause(error) };
|
|
1027
|
+
}
|
|
1028
|
+
var noopInternalLogger = {
|
|
1029
|
+
child: () => noopInternalLogger,
|
|
1030
|
+
debug: () => void 0,
|
|
1031
|
+
info: () => void 0,
|
|
1032
|
+
warn: () => void 0,
|
|
1033
|
+
error: () => void 0,
|
|
1034
|
+
failure: () => void 0,
|
|
1035
|
+
warning: () => void 0,
|
|
1036
|
+
wrap: (_op, _params, run) => run()
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
// src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
|
|
1040
|
+
var CentrifugeNamespaceImpl = class {
|
|
1041
|
+
constructor(ctx) {
|
|
1042
|
+
this.ctx = ctx;
|
|
1043
|
+
this.log = internalLogger(ctx.logger, "CENTRIFUGE");
|
|
1044
|
+
}
|
|
1045
|
+
async getQuote(params) {
|
|
1046
|
+
return this.log.wrap("getQuote", params, async () => {
|
|
1047
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1048
|
+
return getCentrifugeVaultQuote(this.ctx.api, params);
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
async getVaultStatus(params) {
|
|
1052
|
+
return this.log.wrap("getVaultStatus", params, async () => {
|
|
1053
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1054
|
+
return getCentrifugeVaultStatus(this.ctx.api, params);
|
|
1055
|
+
});
|
|
674
1056
|
}
|
|
675
|
-
|
|
676
|
-
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
// src/universal/core/checkout/centrifuge/constants.ts
|
|
1060
|
+
var CENTRIFUGE_POLL_INTERVAL_MS = 15e3;
|
|
1061
|
+
|
|
1062
|
+
// src/universal/types/pagination.ts
|
|
1063
|
+
var Cursor = (value) => value;
|
|
1064
|
+
var PaginatedResponse = {
|
|
1065
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1066
|
+
/**
|
|
1067
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1068
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1069
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1070
|
+
* page holds, not where the next page starts.
|
|
1071
|
+
*/
|
|
1072
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1073
|
+
data: pageMapper(dto.data),
|
|
1074
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1075
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1076
|
+
})
|
|
1077
|
+
};
|
|
1078
|
+
var PaginationParams = {
|
|
1079
|
+
toQueryParams: (params) => {
|
|
1080
|
+
const queryParams = {};
|
|
1081
|
+
if (params.after) {
|
|
1082
|
+
queryParams.starting_after = params.after;
|
|
1083
|
+
}
|
|
1084
|
+
if (params.before) {
|
|
1085
|
+
queryParams.starting_before = params.before;
|
|
1086
|
+
}
|
|
1087
|
+
if (params.limit) {
|
|
1088
|
+
queryParams.limit = params.limit;
|
|
1089
|
+
}
|
|
1090
|
+
return queryParams;
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
// src/universal/types/asset.ts
|
|
1095
|
+
var AssetId = (value) => value;
|
|
1096
|
+
var AssetCode = (value) => value;
|
|
1097
|
+
var Asset = {
|
|
1098
|
+
fromDto: (dto) => ({
|
|
1099
|
+
id: AssetId(dto.id),
|
|
1100
|
+
code: AssetCode(dto.code),
|
|
1101
|
+
name: dto.name,
|
|
1102
|
+
fractionalDigits: dto.fractional_digits
|
|
1103
|
+
})
|
|
1104
|
+
};
|
|
677
1105
|
|
|
678
1106
|
// src/universal/types/offer.ts
|
|
679
1107
|
var OfferId = (value) => value;
|
|
@@ -946,221 +1374,47 @@ var CreateParticipationParams = {
|
|
|
946
1374
|
toDto: (params) => ({
|
|
947
1375
|
offer_id: params.offerId,
|
|
948
1376
|
offer_option_id: params.offerOptionId,
|
|
949
|
-
chain: params.chain,
|
|
950
|
-
wallet_address: params.walletAddress,
|
|
951
|
-
amount: params.amount,
|
|
952
|
-
asset_id: params.assetId,
|
|
953
|
-
approval_transaction_hash: params.approvalTransactionHash
|
|
954
|
-
})
|
|
955
|
-
};
|
|
956
|
-
|
|
957
|
-
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
958
|
-
async function fetchParticipations(api, offerId) {
|
|
959
|
-
return fetchAllPages(
|
|
960
|
-
(params) => fetchParticipationsPage(api, params),
|
|
961
|
-
{ offerId }
|
|
962
|
-
);
|
|
963
|
-
}
|
|
964
|
-
async function fetchParticipationsPage(api, params) {
|
|
965
|
-
const pageDto = await api.send({
|
|
966
|
-
method: "GET",
|
|
967
|
-
url: "/v1/participations",
|
|
968
|
-
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
969
|
-
attributes: Attributes.protected()
|
|
970
|
-
});
|
|
971
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
972
|
-
}
|
|
973
|
-
async function fetchParticipation(api, id) {
|
|
974
|
-
const dto = await api.send({
|
|
975
|
-
method: "GET",
|
|
976
|
-
url: `/v1/participations/${id}`,
|
|
977
|
-
attributes: Attributes.protected()
|
|
978
|
-
});
|
|
979
|
-
return Participation.fromDto(dto);
|
|
980
|
-
}
|
|
981
|
-
async function createParticipation(api, params) {
|
|
982
|
-
const dto = await api.send({
|
|
983
|
-
method: "POST",
|
|
984
|
-
url: "/v1/participations",
|
|
985
|
-
body: CreateParticipationParams.toDto(params),
|
|
986
|
-
attributes: Attributes.protected()
|
|
987
|
-
});
|
|
988
|
-
return Participation.fromDto(dto);
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
// src/universal/core/shared/observability/log-cause.ts
|
|
992
|
-
var import_viem = require("viem");
|
|
993
|
-
function classifyLogCause(error) {
|
|
994
|
-
if (error instanceof HttpError) {
|
|
995
|
-
return httpCause(error);
|
|
996
|
-
}
|
|
997
|
-
if (error instanceof ValidationError) {
|
|
998
|
-
return { type: "validation", message: error.message };
|
|
999
|
-
}
|
|
1000
|
-
if (error instanceof InvariantError) {
|
|
1001
|
-
return { type: "invariant", message: error.message };
|
|
1002
|
-
}
|
|
1003
|
-
if (error instanceof MathError) {
|
|
1004
|
-
return { type: "math", message: error.message };
|
|
1005
|
-
}
|
|
1006
|
-
if (error instanceof NotAuthenticatedError) {
|
|
1007
|
-
return { type: "not-authenticated" };
|
|
1008
|
-
}
|
|
1009
|
-
if (error instanceof NotImplementedError) {
|
|
1010
|
-
return { type: "not-implemented" };
|
|
1011
|
-
}
|
|
1012
|
-
if (error instanceof import_viem.BaseError) {
|
|
1013
|
-
const http = error.walk((e) => e instanceof HttpError);
|
|
1014
|
-
if (http instanceof HttpError) {
|
|
1015
|
-
return httpCause(http);
|
|
1016
|
-
}
|
|
1017
|
-
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
1018
|
-
}
|
|
1019
|
-
return { type: "generic-error", name: errorName(error) };
|
|
1020
|
-
}
|
|
1021
|
-
function rpcFailureReason(error) {
|
|
1022
|
-
if (error.walk((e) => e instanceof import_viem.ContractFunctionRevertedError)) {
|
|
1023
|
-
return "reverted";
|
|
1024
|
-
}
|
|
1025
|
-
if (error.walk((e) => e instanceof import_viem.RpcError)) {
|
|
1026
|
-
return "node-rejected";
|
|
1027
|
-
}
|
|
1028
|
-
if (error.walk(
|
|
1029
|
-
(e) => e instanceof import_viem.HttpRequestError || e instanceof import_viem.WebSocketRequestError || e instanceof import_viem.SocketClosedError || e instanceof import_viem.TimeoutError
|
|
1030
|
-
)) {
|
|
1031
|
-
return "transport";
|
|
1032
|
-
}
|
|
1033
|
-
if (error instanceof import_viem.ContractFunctionExecutionError) {
|
|
1034
|
-
return "malformed-response";
|
|
1035
|
-
}
|
|
1036
|
-
return "unknown";
|
|
1037
|
-
}
|
|
1038
|
-
function describeErrorUnredacted(error) {
|
|
1039
|
-
if (error instanceof HttpError) {
|
|
1040
|
-
return describeHttpErrorRedacted(error);
|
|
1041
|
-
}
|
|
1042
|
-
if (error instanceof Error) {
|
|
1043
|
-
return `${error.name}: ${error.message}`;
|
|
1044
|
-
}
|
|
1045
|
-
return `thrown non-error: ${stringifyUnredacted(error)}`;
|
|
1046
|
-
}
|
|
1047
|
-
function stringifyUnredacted(value) {
|
|
1048
|
-
if (value === void 0) return "";
|
|
1049
|
-
try {
|
|
1050
|
-
return JSON.stringify(
|
|
1051
|
-
value,
|
|
1052
|
-
(_key, item) => typeof item === "bigint" ? `${item}` : item
|
|
1053
|
-
) ?? String(value);
|
|
1054
|
-
} catch (_) {
|
|
1055
|
-
return "<unserializable>";
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
function describeHttpErrorRedacted(error) {
|
|
1059
|
-
const code = apiErrorCode(error);
|
|
1060
|
-
const status = error.response.status;
|
|
1061
|
-
return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
|
|
1062
|
-
}
|
|
1063
|
-
function errorName(error) {
|
|
1064
|
-
return error instanceof Error ? error.name : `non-error ${typeof error}`;
|
|
1065
|
-
}
|
|
1066
|
-
function httpCause(error) {
|
|
1067
|
-
return {
|
|
1068
|
-
type: "http",
|
|
1069
|
-
requestId: error.requestId,
|
|
1070
|
-
status: error.response.status,
|
|
1071
|
-
code: apiErrorCode(error),
|
|
1072
|
-
eventId: apiErrorEventId(error)
|
|
1073
|
-
};
|
|
1074
|
-
}
|
|
1075
|
-
function apiErrorEventId(error) {
|
|
1076
|
-
const body = error.response.body;
|
|
1077
|
-
if (typeof body !== "object" || body === null) return null;
|
|
1078
|
-
const eventId = body.event_id;
|
|
1079
|
-
return typeof eventId === "string" ? eventId : null;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
// src/universal/core/shared/observability/internal-logger.ts
|
|
1083
|
-
function internalLogger(logger, scope) {
|
|
1084
|
-
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
1085
|
-
}
|
|
1086
|
-
var LEVEL_RANK = {
|
|
1087
|
-
none: 0,
|
|
1088
|
-
error: 1,
|
|
1089
|
-
warn: 2,
|
|
1090
|
-
info: 3,
|
|
1091
|
-
debug: 4
|
|
1092
|
-
};
|
|
1093
|
-
function scopedLogger(logger, scope, bindings) {
|
|
1094
|
-
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
1095
|
-
const safe = (event) => ({
|
|
1096
|
-
msg: event.msg,
|
|
1097
|
-
scope,
|
|
1098
|
-
bindings,
|
|
1099
|
-
fields: event.fields ?? {},
|
|
1100
|
-
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
1101
|
-
});
|
|
1102
|
-
const unredacted = (event) => ({
|
|
1103
|
-
msg: event.msg,
|
|
1104
|
-
scope,
|
|
1105
|
-
bindings,
|
|
1106
|
-
fields: event.fields ?? {}
|
|
1107
|
-
});
|
|
1108
|
-
const self = {
|
|
1109
|
-
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
1110
|
-
debug: (event) => {
|
|
1111
|
-
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
1112
|
-
},
|
|
1113
|
-
info: (event) => {
|
|
1114
|
-
if (admits("info")) logger.info(() => safe(event()));
|
|
1115
|
-
},
|
|
1116
|
-
warn: (event) => {
|
|
1117
|
-
if (admits("warn")) logger.warn(() => safe(event()));
|
|
1118
|
-
},
|
|
1119
|
-
error: (event) => {
|
|
1120
|
-
if (admits("error")) logger.error(() => safe(event()));
|
|
1121
|
-
},
|
|
1122
|
-
failure: (event, error) => {
|
|
1123
|
-
if (admits("debug"))
|
|
1124
|
-
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1125
|
-
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
1126
|
-
},
|
|
1127
|
-
warning: (event, error) => {
|
|
1128
|
-
if (admits("debug"))
|
|
1129
|
-
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
1130
|
-
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
1131
|
-
},
|
|
1132
|
-
wrap: async (op, params, run) => {
|
|
1133
|
-
const opLog = self.child({ op });
|
|
1134
|
-
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
1135
|
-
try {
|
|
1136
|
-
return await run();
|
|
1137
|
-
} catch (error) {
|
|
1138
|
-
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
1139
|
-
throw error;
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
return self;
|
|
1377
|
+
chain: params.chain,
|
|
1378
|
+
wallet_address: params.walletAddress,
|
|
1379
|
+
amount: params.amount,
|
|
1380
|
+
asset_id: params.assetId,
|
|
1381
|
+
approval_transaction_hash: params.approvalTransactionHash
|
|
1382
|
+
})
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
1386
|
+
async function fetchParticipations(api, offerId) {
|
|
1387
|
+
return fetchAllPages(
|
|
1388
|
+
(params) => fetchParticipationsPage(api, params),
|
|
1389
|
+
{ offerId }
|
|
1390
|
+
);
|
|
1144
1391
|
}
|
|
1145
|
-
function
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1392
|
+
async function fetchParticipationsPage(api, params) {
|
|
1393
|
+
const pageDto = await api.send({
|
|
1394
|
+
method: "GET",
|
|
1395
|
+
url: "/v1/participations",
|
|
1396
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
1397
|
+
attributes: Attributes.protected()
|
|
1398
|
+
});
|
|
1399
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
1150
1400
|
}
|
|
1151
|
-
function
|
|
1152
|
-
|
|
1401
|
+
async function fetchParticipation(api, id) {
|
|
1402
|
+
const dto = await api.send({
|
|
1403
|
+
method: "GET",
|
|
1404
|
+
url: `/v1/participations/${id}`,
|
|
1405
|
+
attributes: Attributes.protected()
|
|
1406
|
+
});
|
|
1407
|
+
return Participation.fromDto(dto);
|
|
1408
|
+
}
|
|
1409
|
+
async function createParticipation(api, params) {
|
|
1410
|
+
const dto = await api.send({
|
|
1411
|
+
method: "POST",
|
|
1412
|
+
url: "/v1/participations",
|
|
1413
|
+
body: CreateParticipationParams.toDto(params),
|
|
1414
|
+
attributes: Attributes.protected()
|
|
1415
|
+
});
|
|
1416
|
+
return Participation.fromDto(dto);
|
|
1153
1417
|
}
|
|
1154
|
-
var noopInternalLogger = {
|
|
1155
|
-
child: () => noopInternalLogger,
|
|
1156
|
-
debug: () => void 0,
|
|
1157
|
-
info: () => void 0,
|
|
1158
|
-
warn: () => void 0,
|
|
1159
|
-
error: () => void 0,
|
|
1160
|
-
failure: () => void 0,
|
|
1161
|
-
warning: () => void 0,
|
|
1162
|
-
wrap: (_op, _params, run) => run()
|
|
1163
|
-
};
|
|
1164
1418
|
|
|
1165
1419
|
// src/universal/core/checkout/coin-list/token-sale-namespace.ts
|
|
1166
1420
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
@@ -1317,7 +1571,7 @@ function isOndoNotTradableError(error) {
|
|
|
1317
1571
|
}
|
|
1318
1572
|
|
|
1319
1573
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
1320
|
-
var
|
|
1574
|
+
var import_viem3 = require("viem");
|
|
1321
1575
|
|
|
1322
1576
|
// src/universal/types/blockchain/ui.ts
|
|
1323
1577
|
var FormattedAmountUi = (value) => value;
|
|
@@ -1388,7 +1642,7 @@ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
|
1388
1642
|
};
|
|
1389
1643
|
}
|
|
1390
1644
|
function formatRawAmount(amount) {
|
|
1391
|
-
return (0,
|
|
1645
|
+
return (0, import_viem3.formatUnits)(amount.raw, amount.decimals);
|
|
1392
1646
|
}
|
|
1393
1647
|
function formatCompactAmount(amount, locale) {
|
|
1394
1648
|
const value = Number(formatRawAmount(amount));
|
|
@@ -1492,66 +1746,6 @@ function explorerBaseUrl(chain) {
|
|
|
1492
1746
|
}
|
|
1493
1747
|
}
|
|
1494
1748
|
|
|
1495
|
-
// src/universal/core/shared/blockchain/math.ts
|
|
1496
|
-
var import_viem3 = require("viem");
|
|
1497
|
-
function blockchainAmountFromRawOrThrow({
|
|
1498
|
-
label,
|
|
1499
|
-
raw,
|
|
1500
|
-
decimals
|
|
1501
|
-
}) {
|
|
1502
|
-
const trimmed = raw.trim();
|
|
1503
|
-
if (trimmed === "") {
|
|
1504
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1505
|
-
}
|
|
1506
|
-
let value;
|
|
1507
|
-
try {
|
|
1508
|
-
value = BigInt(trimmed);
|
|
1509
|
-
} catch {
|
|
1510
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1511
|
-
}
|
|
1512
|
-
try {
|
|
1513
|
-
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
1514
|
-
} catch {
|
|
1515
|
-
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
function parseBlockchainAmount(amount, decimals) {
|
|
1519
|
-
const trimmed = amount.trim();
|
|
1520
|
-
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
1521
|
-
if (trimmed.startsWith("-")) {
|
|
1522
|
-
return { valid: false, reason: { type: "negative" } };
|
|
1523
|
-
}
|
|
1524
|
-
if (/[eE]/.test(trimmed)) {
|
|
1525
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1526
|
-
}
|
|
1527
|
-
if (trimmed === ".") {
|
|
1528
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1529
|
-
}
|
|
1530
|
-
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1531
|
-
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1532
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1533
|
-
}
|
|
1534
|
-
const [, fraction = ""] = normalised.split(".");
|
|
1535
|
-
if (fraction.length > decimals) {
|
|
1536
|
-
return {
|
|
1537
|
-
valid: false,
|
|
1538
|
-
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
try {
|
|
1542
|
-
const raw = (0, import_viem3.parseUnits)(normalised, decimals);
|
|
1543
|
-
if (raw > MAX_UINT_256) {
|
|
1544
|
-
return { valid: false, reason: { type: "overflow" } };
|
|
1545
|
-
}
|
|
1546
|
-
return {
|
|
1547
|
-
valid: true,
|
|
1548
|
-
amount: BlockchainAmount({ raw, decimals })
|
|
1549
|
-
};
|
|
1550
|
-
} catch {
|
|
1551
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
1749
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1556
1750
|
var OndoTradingStatus = {
|
|
1557
1751
|
fromDto: (dto) => {
|
|
@@ -3941,146 +4135,6 @@ var OAuthSession = {
|
|
|
3941
4135
|
}
|
|
3942
4136
|
};
|
|
3943
4137
|
|
|
3944
|
-
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
3945
|
-
var CentrifugeVaultQuote = {
|
|
3946
|
-
fromDto: (dto) => {
|
|
3947
|
-
const spendDecimals = AssetDecimals(dto.spend_input_decimals);
|
|
3948
|
-
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
3949
|
-
return {
|
|
3950
|
-
chain: EthereumChain(dto.chain),
|
|
3951
|
-
symbol: AssetSymbol(dto.symbol),
|
|
3952
|
-
spendInputAmount: blockchainAmountFromRawOrThrow({
|
|
3953
|
-
label: "spend_input_amount",
|
|
3954
|
-
raw: dto.spend_input_amount,
|
|
3955
|
-
decimals: spendDecimals
|
|
3956
|
-
}),
|
|
3957
|
-
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
3958
|
-
label: "estimated_shares",
|
|
3959
|
-
raw: dto.estimated_shares,
|
|
3960
|
-
decimals: shareDecimals
|
|
3961
|
-
}),
|
|
3962
|
-
indicativePrice: decimalOrNull(dto.indicative_price),
|
|
3963
|
-
minimumInputAmount: dto.minimum_input_amount === null ? null : blockchainAmountFromRawOrThrow({
|
|
3964
|
-
label: "minimum_input_amount",
|
|
3965
|
-
raw: dto.minimum_input_amount,
|
|
3966
|
-
decimals: spendDecimals
|
|
3967
|
-
}),
|
|
3968
|
-
orderability: parseOrderability(
|
|
3969
|
-
dto.can_order,
|
|
3970
|
-
dto.reasons,
|
|
3971
|
-
"CentrifugeVaultQuote"
|
|
3972
|
-
)
|
|
3973
|
-
};
|
|
3974
|
-
}
|
|
3975
|
-
};
|
|
3976
|
-
var CentrifugeVaultStatus = {
|
|
3977
|
-
fromDto: (dto) => ({
|
|
3978
|
-
chain: EthereumChain(dto.chain),
|
|
3979
|
-
symbol: AssetSymbol(dto.symbol),
|
|
3980
|
-
vaultAddress: EvmContractAddress(dto.vault_address),
|
|
3981
|
-
linked: dto.linked,
|
|
3982
|
-
permissioned: dto.permissioned,
|
|
3983
|
-
membershipValidUntil: dateOrNull(
|
|
3984
|
-
dto.membership_valid_until,
|
|
3985
|
-
"CentrifugeVaultStatus.membership_valid_until"
|
|
3986
|
-
),
|
|
3987
|
-
halted: dto.halted,
|
|
3988
|
-
priceUpdatedAt: dateOrNull(
|
|
3989
|
-
dto.price_updated_at,
|
|
3990
|
-
"CentrifugeVaultStatus.price_updated_at"
|
|
3991
|
-
),
|
|
3992
|
-
orderability: parseOrderability(
|
|
3993
|
-
dto.can_order,
|
|
3994
|
-
dto.reasons,
|
|
3995
|
-
"CentrifugeVaultStatus"
|
|
3996
|
-
),
|
|
3997
|
-
asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
|
|
3998
|
-
})
|
|
3999
|
-
};
|
|
4000
|
-
var CentrifugeVaultBuyTransaction = {
|
|
4001
|
-
fromDto: (dto) => {
|
|
4002
|
-
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
4003
|
-
label: "spend_input_amount",
|
|
4004
|
-
raw: dto.spend_input_amount,
|
|
4005
|
-
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
4006
|
-
});
|
|
4007
|
-
if (spendInputAmount.raw <= 0n) {
|
|
4008
|
-
throw new ValidationError(
|
|
4009
|
-
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
4010
|
-
);
|
|
4011
|
-
}
|
|
4012
|
-
return {
|
|
4013
|
-
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
4014
|
-
spendInputAmount,
|
|
4015
|
-
estimatedShares: blockchainAmountFromRawOrThrow({
|
|
4016
|
-
label: "estimated_shares",
|
|
4017
|
-
raw: dto.estimated_shares,
|
|
4018
|
-
decimals: AssetDecimals(dto.share_decimals)
|
|
4019
|
-
})
|
|
4020
|
-
};
|
|
4021
|
-
}
|
|
4022
|
-
};
|
|
4023
|
-
var CentrifugeVaultClaimTransaction = {
|
|
4024
|
-
fromDto: (dto) => ({
|
|
4025
|
-
...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
|
|
4026
|
-
claimableShares: blockchainAmountFromRawOrThrow({
|
|
4027
|
-
label: "claimable_shares",
|
|
4028
|
-
raw: dto.claimable_shares,
|
|
4029
|
-
decimals: AssetDecimals(dto.share_decimals)
|
|
4030
|
-
})
|
|
4031
|
-
})
|
|
4032
|
-
};
|
|
4033
|
-
var CentrifugeVaultPosition = {
|
|
4034
|
-
fromDto: (dto) => {
|
|
4035
|
-
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
4036
|
-
const shareDecimals = AssetDecimals(dto.share_decimals);
|
|
4037
|
-
const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
|
|
4038
|
-
const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
|
|
4039
|
-
return {
|
|
4040
|
-
chain: EthereumChain(dto.chain),
|
|
4041
|
-
symbol: AssetSymbol(dto.symbol),
|
|
4042
|
-
walletAddress: EvmWalletAddress(dto.wallet_address),
|
|
4043
|
-
status: dto.status,
|
|
4044
|
-
requested: asset("requested", dto.requested),
|
|
4045
|
-
pending: asset("pending", dto.pending),
|
|
4046
|
-
filledAssets: asset("filled_assets", dto.filled_assets),
|
|
4047
|
-
earnedShares: shares("earned_shares", dto.earned_shares),
|
|
4048
|
-
claimedShares: shares("claimed_shares", dto.claimed_shares),
|
|
4049
|
-
claimableShares: shares("claimable_shares", dto.claimable_shares),
|
|
4050
|
-
shareBalance: shares("share_balance", dto.share_balance),
|
|
4051
|
-
averagePrice: decimalOrNull(dto.average_price),
|
|
4052
|
-
frozen: dto.frozen,
|
|
4053
|
-
asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
|
|
4054
|
-
};
|
|
4055
|
-
}
|
|
4056
|
-
};
|
|
4057
|
-
function parseOrderability(canOrder, reasons, model) {
|
|
4058
|
-
const [first, ...rest] = reasons;
|
|
4059
|
-
if (canOrder) {
|
|
4060
|
-
if (first !== void 0) {
|
|
4061
|
-
throw new ValidationError(
|
|
4062
|
-
`${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
|
|
4063
|
-
);
|
|
4064
|
-
}
|
|
4065
|
-
return { type: "orderable" };
|
|
4066
|
-
}
|
|
4067
|
-
if (first === void 0) {
|
|
4068
|
-
throw new ValidationError(
|
|
4069
|
-
`${model}.reasons: expected at least one when can_order is false`
|
|
4070
|
-
);
|
|
4071
|
-
}
|
|
4072
|
-
return { type: "blocked", reasons: [first, ...rest] };
|
|
4073
|
-
}
|
|
4074
|
-
function parseTransactionCore(dto, model) {
|
|
4075
|
-
return {
|
|
4076
|
-
tx: {
|
|
4077
|
-
to: EvmContractAddress(dto.to),
|
|
4078
|
-
data: HexEncodedTransactionData(dto.data)
|
|
4079
|
-
},
|
|
4080
|
-
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
4081
|
-
};
|
|
4082
|
-
}
|
|
4083
|
-
|
|
4084
4138
|
// src/universal/types/time.ts
|
|
4085
4139
|
var MAX_EPOCH_MILLIS = 864e13;
|
|
4086
4140
|
var EpochMillis = {
|
|
@@ -4152,6 +4206,8 @@ var User = {
|
|
|
4152
4206
|
Blockchain,
|
|
4153
4207
|
BlockchainAmount,
|
|
4154
4208
|
Bps,
|
|
4209
|
+
CENTRIFUGE_POLL_INTERVAL_MS,
|
|
4210
|
+
CentrifugeNamespaceImpl,
|
|
4155
4211
|
CentrifugeVaultBuyTransaction,
|
|
4156
4212
|
CentrifugeVaultClaimTransaction,
|
|
4157
4213
|
CentrifugeVaultPosition,
|