@coinlist-co/react 0.12.2-rc.e1f6c82 → 0.12.2-rc.eea3be6
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-GIE4UWB3.js → chunk-335G7ZM5.js} +228 -193
- package/dist/chunk-335G7ZM5.js.map +1 -0
- package/dist/{chunk-EKLUJZ7T.js → chunk-IUAGXUJY.js} +2 -2
- package/dist/{chunk-PIOQA6HW.js → chunk-WBB6P6ZI.js} +111 -101
- package/dist/chunk-WBB6P6ZI.js.map +1 -0
- package/dist/client/index.d.ts +1490 -1211
- package/dist/client/index.js +9818 -9967
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{time-Bbqlt2x7.d.ts → time-qZW4aYYp.d.ts} +34 -17
- package/dist/{token-registry-snapshot-DttZXGvY.d.ts → token-registry-snapshot-CMrhSBun.d.ts} +19 -21
- package/dist/universal/index.d.ts +45 -33
- package/dist/universal/index.js +10 -6
- package/package.json +1 -1
- package/dist/chunk-GIE4UWB3.js.map +0 -1
- package/dist/chunk-PIOQA6HW.js.map +0 -1
- /package/dist/{chunk-EKLUJZ7T.js.map → chunk-IUAGXUJY.js.map} +0 -0
|
@@ -291,6 +291,75 @@ function isExpired({
|
|
|
291
291
|
return now >= expiresAt - buffer;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
// src/universal/types/blockchain/ui.ts
|
|
295
|
+
var FormattedAmountUi = (value) => value;
|
|
296
|
+
var FormattedPercentUi = (value) => value;
|
|
297
|
+
var TxExplorerUrl = (value) => value;
|
|
298
|
+
var ShortenedWalletAddress = (value) => value;
|
|
299
|
+
var FormattedAmountAssetUi = (value) => value;
|
|
300
|
+
var AssetIconUrl = (value) => value;
|
|
301
|
+
|
|
302
|
+
// src/universal/core/shared/blockchain/chain.ts
|
|
303
|
+
import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
|
|
304
|
+
var VIEM_CHAINS = {
|
|
305
|
+
ethereum_mainnet: mainnet,
|
|
306
|
+
ethereum_sepolia: sepolia,
|
|
307
|
+
base_mainnet: base,
|
|
308
|
+
base_sepolia: baseSepolia
|
|
309
|
+
};
|
|
310
|
+
function viemChain(chain) {
|
|
311
|
+
return VIEM_CHAINS[chain];
|
|
312
|
+
}
|
|
313
|
+
function getChainId(chain) {
|
|
314
|
+
return VIEM_CHAINS[chain].id;
|
|
315
|
+
}
|
|
316
|
+
function chainFromId(chainId) {
|
|
317
|
+
const chains = Object.keys(VIEM_CHAINS);
|
|
318
|
+
const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
|
|
319
|
+
if (!chain) {
|
|
320
|
+
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
321
|
+
}
|
|
322
|
+
return chain;
|
|
323
|
+
}
|
|
324
|
+
function contractOn(contracts, chain) {
|
|
325
|
+
return contracts.find((contract) => contract.chain === chain)?.address ?? null;
|
|
326
|
+
}
|
|
327
|
+
function getNetworkName(chain) {
|
|
328
|
+
switch (chain) {
|
|
329
|
+
case "ethereum_mainnet":
|
|
330
|
+
return "Ethereum";
|
|
331
|
+
case "ethereum_sepolia":
|
|
332
|
+
return "Ethereum Sepolia";
|
|
333
|
+
case "base_mainnet":
|
|
334
|
+
return "Base";
|
|
335
|
+
case "base_sepolia":
|
|
336
|
+
return "Base Sepolia";
|
|
337
|
+
default: {
|
|
338
|
+
const _exhaustive = chain;
|
|
339
|
+
return _exhaustive;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function txExplorerUrl(chain, txHash) {
|
|
344
|
+
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
345
|
+
}
|
|
346
|
+
function explorerBaseUrl(chain) {
|
|
347
|
+
switch (chain) {
|
|
348
|
+
case "ethereum_mainnet":
|
|
349
|
+
return "https://etherscan.io";
|
|
350
|
+
case "ethereum_sepolia":
|
|
351
|
+
return "https://sepolia.etherscan.io";
|
|
352
|
+
case "base_mainnet":
|
|
353
|
+
return "https://basescan.org";
|
|
354
|
+
case "base_sepolia":
|
|
355
|
+
return "https://sepolia-explorer.base.org";
|
|
356
|
+
default: {
|
|
357
|
+
const _exhaustive = chain;
|
|
358
|
+
return _exhaustive;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
294
363
|
// src/universal/types/blockchain/core.ts
|
|
295
364
|
var ETHEREUM_CHAINS = {
|
|
296
365
|
ethereum_mainnet: true,
|
|
@@ -421,6 +490,36 @@ function blockchainAmountFromRawOrThrow({
|
|
|
421
490
|
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
422
491
|
}
|
|
423
492
|
}
|
|
493
|
+
function positiveAmountFromRawOrThrow({
|
|
494
|
+
label,
|
|
495
|
+
raw,
|
|
496
|
+
decimals,
|
|
497
|
+
reason
|
|
498
|
+
}) {
|
|
499
|
+
const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
|
|
500
|
+
if (amount.raw === 0n) {
|
|
501
|
+
throw new ValidationError(
|
|
502
|
+
`${label}: must be greater than zero ("${raw}") - ${reason}`
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
return amount;
|
|
506
|
+
}
|
|
507
|
+
function pricePerShare({
|
|
508
|
+
usd,
|
|
509
|
+
shares
|
|
510
|
+
}) {
|
|
511
|
+
const price = BlockchainAmount.div(usd, shares);
|
|
512
|
+
return BlockchainAmount({
|
|
513
|
+
raw: assertPriceFits(price.raw),
|
|
514
|
+
decimals: price.decimals
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function assertPriceFits(raw) {
|
|
518
|
+
if (raw > MAX_UINT_256) {
|
|
519
|
+
throw new MathError(`Price per share: out of uint256 bounds (${raw})`);
|
|
520
|
+
}
|
|
521
|
+
return raw;
|
|
522
|
+
}
|
|
424
523
|
function parseBlockchainAmount(amount, decimals) {
|
|
425
524
|
const trimmed = amount.trim();
|
|
426
525
|
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
@@ -534,10 +633,13 @@ function requiredDate(value, field) {
|
|
|
534
633
|
return date;
|
|
535
634
|
}
|
|
536
635
|
function dateOrNull(value, field) {
|
|
537
|
-
return value
|
|
636
|
+
return mapNullish(value, (date) => requiredDate(date, field));
|
|
538
637
|
}
|
|
539
638
|
function decimalOrNull(value) {
|
|
540
|
-
return value
|
|
639
|
+
return mapNullish(value, DecimalString);
|
|
640
|
+
}
|
|
641
|
+
function mapNullish(value, parse) {
|
|
642
|
+
return value === null || value === void 0 ? null : parse(value);
|
|
541
643
|
}
|
|
542
644
|
function requiredArray(value, field) {
|
|
543
645
|
if (!Array.isArray(value)) {
|
|
@@ -547,6 +649,12 @@ function requiredArray(value, field) {
|
|
|
547
649
|
}
|
|
548
650
|
return value;
|
|
549
651
|
}
|
|
652
|
+
function txFromWire(wire) {
|
|
653
|
+
return {
|
|
654
|
+
to: EvmContractAddress(wire.to),
|
|
655
|
+
data: HexEncodedTransactionData(wire.data)
|
|
656
|
+
};
|
|
657
|
+
}
|
|
550
658
|
|
|
551
659
|
// src/universal/types/providers/centrifuge/centrifuge.ts
|
|
552
660
|
var CentrifugeVaultStatus = {
|
|
@@ -575,19 +683,16 @@ var CentrifugeVaultStatus = {
|
|
|
575
683
|
};
|
|
576
684
|
var CentrifugeVaultBuyTransaction = {
|
|
577
685
|
fromDto: (dto) => {
|
|
578
|
-
const spendInputAmount = blockchainAmountFromRawOrThrow({
|
|
579
|
-
label: "spend_input_amount",
|
|
580
|
-
raw: dto.spend_input_amount,
|
|
581
|
-
decimals: AssetDecimals(dto.spend_input_decimals)
|
|
582
|
-
});
|
|
583
|
-
if (spendInputAmount.raw <= 0n) {
|
|
584
|
-
throw new ValidationError(
|
|
585
|
-
`spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
686
|
return {
|
|
589
687
|
...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
|
|
590
|
-
spendInputAmount
|
|
688
|
+
spendInputAmount: positiveAmountFromRawOrThrow({
|
|
689
|
+
label: "spend_input_amount",
|
|
690
|
+
raw: dto.spend_input_amount,
|
|
691
|
+
decimals: AssetDecimals(dto.spend_input_decimals),
|
|
692
|
+
// Frontline refuses an `amount` of zero, so a zero here is a changed
|
|
693
|
+
// encoding, not a small deposit - and not calldata worth signing.
|
|
694
|
+
reason: "a deposit of nothing is not a request"
|
|
695
|
+
})
|
|
591
696
|
};
|
|
592
697
|
}
|
|
593
698
|
};
|
|
@@ -671,14 +776,25 @@ function parseOrderability(canOrder, reasons, model) {
|
|
|
671
776
|
}
|
|
672
777
|
function parseTransactionCore(dto, model) {
|
|
673
778
|
return {
|
|
674
|
-
tx:
|
|
675
|
-
to: EvmContractAddress(dto.to),
|
|
676
|
-
data: HexEncodedTransactionData(dto.data)
|
|
677
|
-
},
|
|
779
|
+
tx: txFromWire(dto),
|
|
678
780
|
expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
|
|
679
781
|
};
|
|
680
782
|
}
|
|
681
783
|
|
|
784
|
+
// src/universal/api/frontline/providers/shared/spend-scale.ts
|
|
785
|
+
function assertSpendScaleAgrees({
|
|
786
|
+
published,
|
|
787
|
+
sized,
|
|
788
|
+
trade,
|
|
789
|
+
note
|
|
790
|
+
}) {
|
|
791
|
+
if (published === sized.decimals) return;
|
|
792
|
+
const because = note === void 0 ? "" : ` - ${note}`;
|
|
793
|
+
throw new ValidationError(
|
|
794
|
+
`spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
|
|
682
798
|
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
683
799
|
async function getCentrifugeVaultStatus(api, params) {
|
|
684
800
|
const dto = await api.send({
|
|
@@ -702,11 +818,11 @@ async function buildCentrifugeVaultBuy(api, params) {
|
|
|
702
818
|
},
|
|
703
819
|
attributes: Attributes.protected()
|
|
704
820
|
});
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
}
|
|
821
|
+
assertSpendScaleAgrees({
|
|
822
|
+
published: dto.spend_input_decimals,
|
|
823
|
+
sized: params.amount,
|
|
824
|
+
trade: "deposit"
|
|
825
|
+
});
|
|
710
826
|
return CentrifugeVaultBuyTransaction.fromDto(dto);
|
|
711
827
|
}
|
|
712
828
|
async function createCentrifugeVaultClaim(api, params) {
|
|
@@ -735,7 +851,7 @@ function walletFields(params) {
|
|
|
735
851
|
};
|
|
736
852
|
}
|
|
737
853
|
|
|
738
|
-
// src/universal/core/checkout/centrifuge/blockchain/abi.ts
|
|
854
|
+
// src/universal/core/providers/checkout/centrifuge/blockchain/abi.ts
|
|
739
855
|
var CENTRIFUGE_PROXY_ABI = [
|
|
740
856
|
{
|
|
741
857
|
type: "function",
|
|
@@ -998,7 +1114,7 @@ var noopInternalLogger = {
|
|
|
998
1114
|
wrap: (_op, _params, run) => run()
|
|
999
1115
|
};
|
|
1000
1116
|
|
|
1001
|
-
// src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
|
|
1117
|
+
// src/universal/core/providers/checkout/centrifuge/centrifuge-namespace.ts
|
|
1002
1118
|
var CentrifugeNamespaceImpl = class {
|
|
1003
1119
|
constructor(ctx) {
|
|
1004
1120
|
this.ctx = ctx;
|
|
@@ -1044,14 +1160,6 @@ var CentrifugeNamespaceImpl = class {
|
|
|
1044
1160
|
}
|
|
1045
1161
|
};
|
|
1046
1162
|
|
|
1047
|
-
// src/universal/types/blockchain/ui.ts
|
|
1048
|
-
var FormattedAmountUi = (value) => value;
|
|
1049
|
-
var FormattedPercentUi = (value) => value;
|
|
1050
|
-
var TxExplorerUrl = (value) => value;
|
|
1051
|
-
var ShortenedWalletAddress = (value) => value;
|
|
1052
|
-
var FormattedAmountAssetUi = (value) => value;
|
|
1053
|
-
var AssetIconUrl = (value) => value;
|
|
1054
|
-
|
|
1055
1163
|
// src/universal/core/shared/blockchain/formatters.ts
|
|
1056
1164
|
import { formatUnits } from "viem";
|
|
1057
1165
|
function shortenAddress(address) {
|
|
@@ -1160,6 +1268,38 @@ function formattedUsdPrice(amount, locale) {
|
|
|
1160
1268
|
);
|
|
1161
1269
|
}
|
|
1162
1270
|
|
|
1271
|
+
// src/universal/types/pagination.ts
|
|
1272
|
+
var Cursor = (value) => value;
|
|
1273
|
+
var PaginatedResponse = {
|
|
1274
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1275
|
+
/**
|
|
1276
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1277
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1278
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1279
|
+
* page holds, not where the next page starts.
|
|
1280
|
+
*/
|
|
1281
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
1282
|
+
data: pageMapper(dto.data),
|
|
1283
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1284
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1285
|
+
})
|
|
1286
|
+
};
|
|
1287
|
+
var PaginationParams = {
|
|
1288
|
+
toQueryParams: (params) => {
|
|
1289
|
+
const queryParams = {};
|
|
1290
|
+
if (params.after) {
|
|
1291
|
+
queryParams.starting_after = params.after;
|
|
1292
|
+
}
|
|
1293
|
+
if (params.before) {
|
|
1294
|
+
queryParams.starting_before = params.before;
|
|
1295
|
+
}
|
|
1296
|
+
if (params.limit) {
|
|
1297
|
+
queryParams.limit = params.limit;
|
|
1298
|
+
}
|
|
1299
|
+
return queryParams;
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1163
1303
|
// src/universal/types/asset.ts
|
|
1164
1304
|
var AssetId = (value) => value;
|
|
1165
1305
|
var AssetCode = (value) => value;
|
|
@@ -1311,6 +1451,17 @@ var OfferVaultContract = {
|
|
|
1311
1451
|
*/
|
|
1312
1452
|
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
|
|
1313
1453
|
};
|
|
1454
|
+
var OfferFundingContract = {
|
|
1455
|
+
fromDto: (dto) => ({
|
|
1456
|
+
chain: Chain(dto.chain),
|
|
1457
|
+
address: EvmContractAddress(dto.address)
|
|
1458
|
+
}),
|
|
1459
|
+
/**
|
|
1460
|
+
* Drops every contract on a chain this SDK does not name, as
|
|
1461
|
+
* {@link OfferVaultContract.listFromDto} does.
|
|
1462
|
+
*/
|
|
1463
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferFundingContract.fromDto)
|
|
1464
|
+
};
|
|
1314
1465
|
var OfferDetail = {
|
|
1315
1466
|
fromDto: (dto) => {
|
|
1316
1467
|
const fundingAssets = requiredArray(
|
|
@@ -1352,7 +1503,15 @@ var OfferDetail = {
|
|
|
1352
1503
|
...base2,
|
|
1353
1504
|
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
1354
1505
|
type: dto.type,
|
|
1355
|
-
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
1506
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url"),
|
|
1507
|
+
// `[]` is fine and a missing key is not, as for `swap_contracts`:
|
|
1508
|
+
// this is the spender a participation's approval names.
|
|
1509
|
+
fundingContracts: OfferFundingContract.listFromDto(
|
|
1510
|
+
requiredArray(
|
|
1511
|
+
dto.funding_contracts,
|
|
1512
|
+
"OfferDetail.funding_contracts"
|
|
1513
|
+
)
|
|
1514
|
+
)
|
|
1356
1515
|
};
|
|
1357
1516
|
case "superstate::swap":
|
|
1358
1517
|
return {
|
|
@@ -1428,42 +1587,8 @@ var Milestone = {
|
|
|
1428
1587
|
})
|
|
1429
1588
|
};
|
|
1430
1589
|
|
|
1431
|
-
// src/universal/types/pagination.ts
|
|
1432
|
-
var Cursor = (value) => value;
|
|
1433
|
-
var PaginatedResponse = {
|
|
1434
|
-
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
1435
|
-
/**
|
|
1436
|
-
* For a mapper that decides the page as a whole - one that drops items it
|
|
1437
|
-
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1438
|
-
* cursors are the wire's either way: dropping an item changes what the
|
|
1439
|
-
* page holds, not where the next page starts.
|
|
1440
|
-
*/
|
|
1441
|
-
fromDtoPage: (dto, pageMapper) => ({
|
|
1442
|
-
data: pageMapper(dto.data),
|
|
1443
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
1444
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
1445
|
-
})
|
|
1446
|
-
};
|
|
1447
|
-
var PaginationParams = {
|
|
1448
|
-
toQueryParams: (params) => {
|
|
1449
|
-
const queryParams = {};
|
|
1450
|
-
if (params.after) {
|
|
1451
|
-
queryParams.starting_after = params.after;
|
|
1452
|
-
}
|
|
1453
|
-
if (params.before) {
|
|
1454
|
-
queryParams.starting_before = params.before;
|
|
1455
|
-
}
|
|
1456
|
-
if (params.limit) {
|
|
1457
|
-
queryParams.limit = params.limit;
|
|
1458
|
-
}
|
|
1459
|
-
return queryParams;
|
|
1460
|
-
}
|
|
1461
|
-
};
|
|
1462
|
-
|
|
1463
1590
|
// src/universal/types/providers/coin-list/token-sale.ts
|
|
1464
1591
|
var ParticipationId = (value) => value;
|
|
1465
|
-
var Blockchain = (value) => value;
|
|
1466
|
-
var WalletAddress = (value) => value;
|
|
1467
1592
|
var ParticipationsPaginationParams = {
|
|
1468
1593
|
toQueryParams: (params) => {
|
|
1469
1594
|
const queryParams = PaginationParams.toQueryParams(params);
|
|
@@ -1487,10 +1612,10 @@ var Participation = {
|
|
|
1487
1612
|
amount: dto.amount,
|
|
1488
1613
|
displayAmount: dto.amount_string,
|
|
1489
1614
|
asset: Asset.fromDto(dto.asset),
|
|
1490
|
-
chain:
|
|
1615
|
+
chain: isChain(dto.chain) ? dto.chain : null,
|
|
1491
1616
|
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
1492
1617
|
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
1493
|
-
walletAddress: walletAddress ?
|
|
1618
|
+
walletAddress: walletAddress ? EvmWalletAddress(walletAddress) : null
|
|
1494
1619
|
};
|
|
1495
1620
|
}
|
|
1496
1621
|
};
|
|
@@ -1557,7 +1682,7 @@ async function createParticipation(api, params) {
|
|
|
1557
1682
|
return Participation.fromDto(dto);
|
|
1558
1683
|
}
|
|
1559
1684
|
|
|
1560
|
-
// src/universal/core/checkout/coin-list/token-sale-namespace.ts
|
|
1685
|
+
// src/universal/core/providers/checkout/coin-list/token-sale-namespace.ts
|
|
1561
1686
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
1562
1687
|
constructor(ctx) {
|
|
1563
1688
|
this.ctx = ctx;
|
|
@@ -1589,64 +1714,6 @@ var CoinListTokenSaleNamespaceImpl = class {
|
|
|
1589
1714
|
}
|
|
1590
1715
|
};
|
|
1591
1716
|
|
|
1592
|
-
// src/universal/core/shared/blockchain/chain.ts
|
|
1593
|
-
import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
|
|
1594
|
-
var VIEM_CHAINS = {
|
|
1595
|
-
ethereum_mainnet: mainnet,
|
|
1596
|
-
ethereum_sepolia: sepolia,
|
|
1597
|
-
base_mainnet: base,
|
|
1598
|
-
base_sepolia: baseSepolia
|
|
1599
|
-
};
|
|
1600
|
-
function viemChain(chain) {
|
|
1601
|
-
return VIEM_CHAINS[chain];
|
|
1602
|
-
}
|
|
1603
|
-
function getChainId(chain) {
|
|
1604
|
-
return VIEM_CHAINS[chain].id;
|
|
1605
|
-
}
|
|
1606
|
-
function chainFromId(chainId) {
|
|
1607
|
-
const chains = Object.keys(VIEM_CHAINS);
|
|
1608
|
-
const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
|
|
1609
|
-
if (!chain) {
|
|
1610
|
-
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
1611
|
-
}
|
|
1612
|
-
return chain;
|
|
1613
|
-
}
|
|
1614
|
-
function getNetworkName(chain) {
|
|
1615
|
-
switch (chain) {
|
|
1616
|
-
case "ethereum_mainnet":
|
|
1617
|
-
return "Ethereum";
|
|
1618
|
-
case "ethereum_sepolia":
|
|
1619
|
-
return "Ethereum Sepolia";
|
|
1620
|
-
case "base_mainnet":
|
|
1621
|
-
return "Base";
|
|
1622
|
-
case "base_sepolia":
|
|
1623
|
-
return "Base Sepolia";
|
|
1624
|
-
default: {
|
|
1625
|
-
const _exhaustive = chain;
|
|
1626
|
-
return _exhaustive;
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
function txExplorerUrl(chain, txHash) {
|
|
1631
|
-
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
1632
|
-
}
|
|
1633
|
-
function explorerBaseUrl(chain) {
|
|
1634
|
-
switch (chain) {
|
|
1635
|
-
case "ethereum_mainnet":
|
|
1636
|
-
return "https://etherscan.io";
|
|
1637
|
-
case "ethereum_sepolia":
|
|
1638
|
-
return "https://sepolia.etherscan.io";
|
|
1639
|
-
case "base_mainnet":
|
|
1640
|
-
return "https://basescan.org";
|
|
1641
|
-
case "base_sepolia":
|
|
1642
|
-
return "https://sepolia-explorer.base.org";
|
|
1643
|
-
default: {
|
|
1644
|
-
const _exhaustive = chain;
|
|
1645
|
-
return _exhaustive;
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
1717
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1651
1718
|
var OndoTradingStatus = {
|
|
1652
1719
|
fromDto: (dto) => {
|
|
@@ -1701,7 +1768,7 @@ var OndoBuyTransaction = {
|
|
|
1701
1768
|
raw: dto.notional_value,
|
|
1702
1769
|
decimals: spendDecimals
|
|
1703
1770
|
}),
|
|
1704
|
-
receiveOutputAmount:
|
|
1771
|
+
receiveOutputAmount: positiveAmountFromRawOrThrow({
|
|
1705
1772
|
label: "receive_output_amount",
|
|
1706
1773
|
raw: dto.receive_output_amount,
|
|
1707
1774
|
decimals: outputDecimals,
|
|
@@ -1720,7 +1787,7 @@ var OndoSellTransaction = {
|
|
|
1720
1787
|
fromDto: (dto) => {
|
|
1721
1788
|
const spendDecimals = AssetDecimals(dto.spend_input_decimals);
|
|
1722
1789
|
const outputDecimals = AssetDecimals(dto.receive_output_decimals);
|
|
1723
|
-
const expectedQuantity =
|
|
1790
|
+
const expectedQuantity = positiveAmountFromRawOrThrow({
|
|
1724
1791
|
label: "expected_quantity",
|
|
1725
1792
|
raw: dto.expected_quantity,
|
|
1726
1793
|
decimals: outputDecimals,
|
|
@@ -1754,12 +1821,12 @@ var OndoSellTransaction = {
|
|
|
1754
1821
|
};
|
|
1755
1822
|
function parseSwapCore(dto, spendDecimals) {
|
|
1756
1823
|
return {
|
|
1757
|
-
tx:
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
expiresAt:
|
|
1762
|
-
spendInputAmount:
|
|
1824
|
+
tx: txFromWire(dto),
|
|
1825
|
+
// A transaction whose expiry cannot be read is not safely fillable - the
|
|
1826
|
+
// deadline is encoded in the calldata either way, so broadcasting against
|
|
1827
|
+
// an unknown one only spends gas on a revert.
|
|
1828
|
+
expiresAt: requiredDate(dto.expires_at, "expires_at"),
|
|
1829
|
+
spendInputAmount: positiveAmountFromRawOrThrow({
|
|
1763
1830
|
label: "spend_input_amount",
|
|
1764
1831
|
raw: dto.spend_input_amount,
|
|
1765
1832
|
decimals: spendDecimals,
|
|
@@ -1777,7 +1844,7 @@ function parseSwapCore(dto, spendDecimals) {
|
|
|
1777
1844
|
};
|
|
1778
1845
|
}
|
|
1779
1846
|
function parseMinimumQuantity(raw, decimals, expectedQuantity) {
|
|
1780
|
-
const amount =
|
|
1847
|
+
const amount = positiveAmountFromRawOrThrow({
|
|
1781
1848
|
label: "minimum_quantity",
|
|
1782
1849
|
raw,
|
|
1783
1850
|
decimals,
|
|
@@ -1790,27 +1857,6 @@ function parseMinimumQuantity(raw, decimals, expectedQuantity) {
|
|
|
1790
1857
|
}
|
|
1791
1858
|
return amount;
|
|
1792
1859
|
}
|
|
1793
|
-
function parsePositiveAmount({
|
|
1794
|
-
label,
|
|
1795
|
-
raw,
|
|
1796
|
-
decimals,
|
|
1797
|
-
reason
|
|
1798
|
-
}) {
|
|
1799
|
-
const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
|
|
1800
|
-
if (amount.raw <= 0n) {
|
|
1801
|
-
throw new ValidationError(
|
|
1802
|
-
`${label}: must be greater than zero ("${raw}") - ${reason}`
|
|
1803
|
-
);
|
|
1804
|
-
}
|
|
1805
|
-
return amount;
|
|
1806
|
-
}
|
|
1807
|
-
function parseExpiresAt(value) {
|
|
1808
|
-
const date = new Date(value);
|
|
1809
|
-
if (Number.isNaN(date.getTime())) {
|
|
1810
|
-
throw new ValidationError(`expires_at: not a date ("${value}")`);
|
|
1811
|
-
}
|
|
1812
|
-
return date;
|
|
1813
|
-
}
|
|
1814
1860
|
|
|
1815
1861
|
// src/universal/api/frontline/providers/ondo/ondo.ts
|
|
1816
1862
|
async function getOndoTradingStatus(api, params) {
|
|
@@ -1876,18 +1922,6 @@ function swapBody(params) {
|
|
|
1876
1922
|
amount: params.amount.raw.toString()
|
|
1877
1923
|
};
|
|
1878
1924
|
}
|
|
1879
|
-
function assertSpendScaleAgrees({
|
|
1880
|
-
published,
|
|
1881
|
-
sized,
|
|
1882
|
-
trade,
|
|
1883
|
-
note
|
|
1884
|
-
}) {
|
|
1885
|
-
if (published === sized.decimals) return;
|
|
1886
|
-
const because = note === void 0 ? "" : ` - ${note}`;
|
|
1887
|
-
throw new ValidationError(
|
|
1888
|
-
`spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
|
|
1889
|
-
);
|
|
1890
|
-
}
|
|
1891
1925
|
function sizeParam(params) {
|
|
1892
1926
|
const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
|
|
1893
1927
|
const notionalValue = "notionalValue" in params ? params.notionalValue : void 0;
|
|
@@ -1907,7 +1941,7 @@ function sizeParam(params) {
|
|
|
1907
1941
|
return { notional_value: notionalValue };
|
|
1908
1942
|
}
|
|
1909
1943
|
|
|
1910
|
-
// src/universal/core/checkout/ondo/ondo-namespace.ts
|
|
1944
|
+
// src/universal/core/providers/checkout/ondo/ondo-namespace.ts
|
|
1911
1945
|
var OndoNamespaceImpl = class {
|
|
1912
1946
|
constructor(ctx) {
|
|
1913
1947
|
this.ctx = ctx;
|
|
@@ -1983,8 +2017,7 @@ var AllowWalletResponse = {
|
|
|
1983
2017
|
case "broadcast_transaction":
|
|
1984
2018
|
return {
|
|
1985
2019
|
action: "broadcast_transaction",
|
|
1986
|
-
|
|
1987
|
-
data: HexEncodedTransactionData(dto.data)
|
|
2020
|
+
tx: txFromWire(dto)
|
|
1988
2021
|
};
|
|
1989
2022
|
case "none":
|
|
1990
2023
|
return {
|
|
@@ -1999,7 +2032,7 @@ var AllowWalletResponse = {
|
|
|
1999
2032
|
}
|
|
2000
2033
|
};
|
|
2001
2034
|
|
|
2002
|
-
// src/universal/core/checkout/superstate/blockchain/quote.ts
|
|
2035
|
+
// src/universal/core/providers/checkout/superstate/blockchain/quote.ts
|
|
2003
2036
|
var SwapQuote = {
|
|
2004
2037
|
/**
|
|
2005
2038
|
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
@@ -2034,7 +2067,7 @@ async function allowWallet(api, params) {
|
|
|
2034
2067
|
return AllowWalletResponse.fromDto(dto);
|
|
2035
2068
|
}
|
|
2036
2069
|
|
|
2037
|
-
// src/universal/core/checkout/superstate/blockchain/abi.ts
|
|
2070
|
+
// src/universal/core/providers/checkout/superstate/blockchain/abi.ts
|
|
2038
2071
|
var SUPERSTATE_SWAP_ABI = [
|
|
2039
2072
|
{
|
|
2040
2073
|
type: "function",
|
|
@@ -3055,7 +3088,7 @@ async function getSwapOutputToken(clients, params) {
|
|
|
3055
3088
|
};
|
|
3056
3089
|
}
|
|
3057
3090
|
|
|
3058
|
-
// src/universal/core/checkout/superstate/swap-namespace.ts
|
|
3091
|
+
// src/universal/core/providers/checkout/superstate/swap-namespace.ts
|
|
3059
3092
|
var SuperstateSwapNamespaceImpl = class {
|
|
3060
3093
|
constructor(ctx) {
|
|
3061
3094
|
this.ctx = ctx;
|
|
@@ -3914,6 +3947,18 @@ export {
|
|
|
3914
3947
|
Seconds,
|
|
3915
3948
|
isExpired,
|
|
3916
3949
|
ERC20_ABI,
|
|
3950
|
+
FormattedAmountUi,
|
|
3951
|
+
FormattedPercentUi,
|
|
3952
|
+
TxExplorerUrl,
|
|
3953
|
+
ShortenedWalletAddress,
|
|
3954
|
+
FormattedAmountAssetUi,
|
|
3955
|
+
AssetIconUrl,
|
|
3956
|
+
viemChain,
|
|
3957
|
+
getChainId,
|
|
3958
|
+
chainFromId,
|
|
3959
|
+
contractOn,
|
|
3960
|
+
getNetworkName,
|
|
3961
|
+
txExplorerUrl,
|
|
3917
3962
|
ETHEREUM_CHAINS,
|
|
3918
3963
|
EthereumChain,
|
|
3919
3964
|
SOLANA_CHAINS,
|
|
@@ -3936,6 +3981,8 @@ export {
|
|
|
3936
3981
|
KnownAssetSymbol,
|
|
3937
3982
|
Bps,
|
|
3938
3983
|
blockchainAmountFromRawOrThrow,
|
|
3984
|
+
positiveAmountFromRawOrThrow,
|
|
3985
|
+
pricePerShare,
|
|
3939
3986
|
parseBlockchainAmount,
|
|
3940
3987
|
CentrifugeVaultStatus,
|
|
3941
3988
|
CentrifugeVaultBuyTransaction,
|
|
@@ -3948,12 +3995,6 @@ export {
|
|
|
3948
3995
|
CentrifugeVaultLegId,
|
|
3949
3996
|
CentrifugeVaultClaimProceedsTransaction,
|
|
3950
3997
|
CentrifugeNamespaceImpl,
|
|
3951
|
-
FormattedAmountUi,
|
|
3952
|
-
FormattedPercentUi,
|
|
3953
|
-
TxExplorerUrl,
|
|
3954
|
-
ShortenedWalletAddress,
|
|
3955
|
-
FormattedAmountAssetUi,
|
|
3956
|
-
AssetIconUrl,
|
|
3957
3998
|
shortenAddress,
|
|
3958
3999
|
formatAmount,
|
|
3959
4000
|
formatRawAmount,
|
|
@@ -3964,6 +4005,9 @@ export {
|
|
|
3964
4005
|
NA_AMOUNT_ASSET_UI,
|
|
3965
4006
|
formatShareAmount,
|
|
3966
4007
|
formattedUsdPrice,
|
|
4008
|
+
Cursor,
|
|
4009
|
+
PaginatedResponse,
|
|
4010
|
+
PaginationParams,
|
|
3967
4011
|
AssetId,
|
|
3968
4012
|
AssetCode,
|
|
3969
4013
|
Asset,
|
|
@@ -3980,27 +4024,18 @@ export {
|
|
|
3980
4024
|
OfferOptionSlug,
|
|
3981
4025
|
OfferSwapContract,
|
|
3982
4026
|
OfferVaultContract,
|
|
4027
|
+
OfferFundingContract,
|
|
3983
4028
|
OfferDetail,
|
|
3984
4029
|
OfferOption,
|
|
3985
4030
|
FaqItem,
|
|
3986
4031
|
Link,
|
|
3987
4032
|
TermItem,
|
|
3988
4033
|
Milestone,
|
|
3989
|
-
Cursor,
|
|
3990
|
-
PaginatedResponse,
|
|
3991
|
-
PaginationParams,
|
|
3992
4034
|
ParticipationId,
|
|
3993
|
-
Blockchain,
|
|
3994
|
-
WalletAddress,
|
|
3995
4035
|
ParticipationsPaginationParams,
|
|
3996
4036
|
Participation,
|
|
3997
4037
|
CreateParticipationParams,
|
|
3998
4038
|
CoinListTokenSaleNamespaceImpl,
|
|
3999
|
-
viemChain,
|
|
4000
|
-
getChainId,
|
|
4001
|
-
chainFromId,
|
|
4002
|
-
getNetworkName,
|
|
4003
|
-
txExplorerUrl,
|
|
4004
4039
|
OndoTradingStatus,
|
|
4005
4040
|
OndoQuote,
|
|
4006
4041
|
OndoBuyTransaction,
|
|
@@ -4039,4 +4074,4 @@ export {
|
|
|
4039
4074
|
TokenMetadata,
|
|
4040
4075
|
TokensNamespaceImpl
|
|
4041
4076
|
};
|
|
4042
|
-
//# sourceMappingURL=chunk-
|
|
4077
|
+
//# sourceMappingURL=chunk-335G7ZM5.js.map
|