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