@coinlist-co/react 0.12.2-rc.31c2f50 → 0.12.2-rc.3de3751

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.
Files changed (36) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-NBO5E2RO.js → chunk-HMLWCXAP.js} +1329 -945
  3. package/dist/chunk-HMLWCXAP.js.map +1 -0
  4. package/dist/{chunk-4IZ2F732.js → chunk-L7SVKXXW.js} +10 -10
  5. package/dist/chunk-L7SVKXXW.js.map +1 -0
  6. package/dist/chunk-MJ6YXZWH.js +22 -0
  7. package/dist/chunk-MJ6YXZWH.js.map +1 -0
  8. package/dist/{chunk-UJYSXXJF.js → chunk-RLOYYAMO.js} +193 -364
  9. package/dist/chunk-RLOYYAMO.js.map +1 -0
  10. package/dist/client/index.d.ts +3302 -4561
  11. package/dist/client/index.js +9396 -7549
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/server/index.d.ts +7 -33
  14. package/dist/server/index.js +8 -4
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/{tokens-namespace-D_XSpiS-.d.ts → time-DkU7jivQ.d.ts} +2179 -2906
  17. package/dist/{token-registry-snapshot-BsAfBL_b.d.ts → token-registry-snapshot-D0OWXMe4.d.ts} +62 -34
  18. package/dist/universal/index.d.ts +84 -1337
  19. package/dist/universal/index.js +39 -47
  20. package/package.json +18 -14
  21. package/dist/chunk-4IZ2F732.js.map +0 -1
  22. package/dist/chunk-NBO5E2RO.js.map +0 -1
  23. package/dist/chunk-UJYSXXJF.js.map +0 -1
  24. package/dist/client/index.cjs +0 -17133
  25. package/dist/client/index.cjs.map +0 -1
  26. package/dist/client/index.d.cts +0 -6671
  27. package/dist/server/index.cjs +0 -4269
  28. package/dist/server/index.cjs.map +0 -1
  29. package/dist/server/index.d.cts +0 -378
  30. package/dist/time-CFocgYyl.d.cts +0 -50
  31. package/dist/time-DvgN98Q9.d.ts +0 -50
  32. package/dist/token-registry-snapshot-Cc_eA5zM.d.cts +0 -181
  33. package/dist/tokens-namespace-D_XSpiS-.d.cts +0 -3436
  34. package/dist/universal/index.cjs +0 -4321
  35. package/dist/universal/index.cjs.map +0 -1
  36. package/dist/universal/index.d.cts +0 -1629
@@ -291,165 +291,74 @@ 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
- }
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;
409
301
 
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
- })
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
425
309
  };
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;
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;
434
340
  }
435
- if (params.limit) {
436
- queryParams.limit = params.limit;
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;
437
359
  }
438
- return queryParams;
439
360
  }
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
- };
361
+ }
453
362
 
454
363
  // src/universal/types/blockchain/core.ts
455
364
  var ETHEREUM_CHAINS = {
@@ -513,8 +422,18 @@ var BlockchainAmount = Object.assign(
513
422
  {
514
423
  add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
515
424
  sub: (a, b) => combineAmounts(a, b, (x, y) => x - y),
516
- mul: multiplyAmounts,
517
- div: divideAmounts
425
+ /**
426
+ * `a * b`, in `a`'s decimals - a price times a quantity. Multiplies before
427
+ * it rescales, then truncates towards zero. The exact inverse of `div`.
428
+ */
429
+ mul: (a, b) => multiplyAmounts(a, b),
430
+ /**
431
+ * `a / b`, in `a`'s decimals - a price, a ratio. Rescales before it
432
+ * divides, then truncates towards zero.
433
+ *
434
+ * @throws MathError when `b` is zero.
435
+ */
436
+ div: (a, b) => divideAmounts(a, b)
518
437
  }
519
438
  );
520
439
  function multiplyAmounts(a, b) {
@@ -548,30 +467,120 @@ var StablecoinSymbol = (value) => value;
548
467
  var KnownAssetSymbol = StablecoinSymbol;
549
468
  var Bps = (value) => value;
550
469
 
551
- // src/universal/core/shared/utils/crypto.ts
552
- async function sha256(data) {
553
- const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
554
- const buffer = bytes.buffer.slice(
555
- bytes.byteOffset,
556
- bytes.byteOffset + bytes.byteLength
557
- );
558
- return crypto.subtle.digest("SHA-256", buffer);
559
- }
560
- function arrayBufferToBase64Url(buffer, padding = true) {
561
- const bytes = new Uint8Array(buffer);
562
- let binary = "";
563
- for (let i = 0; i < bytes.length; i++) {
564
- binary += String.fromCharCode(bytes[i]);
470
+ // src/universal/core/shared/blockchain/math.ts
471
+ import { parseUnits } from "viem";
472
+ function blockchainAmountFromRawOrThrow({
473
+ label,
474
+ raw,
475
+ decimals
476
+ }) {
477
+ const trimmed = raw.trim();
478
+ if (trimmed === "") {
479
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
565
480
  }
566
- let base64 = btoa(binary);
567
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
568
- if (!padding) {
569
- base64 = base64.replace(/=+$/, "");
481
+ let value;
482
+ try {
483
+ value = BigInt(trimmed);
484
+ } catch {
485
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
486
+ }
487
+ try {
488
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
489
+ } catch {
490
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
570
491
  }
571
- return base64;
572
492
  }
573
- function generateSecureRandomBase64Url(byteLength) {
574
- const bytes = new Uint8Array(byteLength);
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
+ }
523
+ function parseBlockchainAmount(amount, decimals) {
524
+ const trimmed = amount.trim();
525
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
526
+ if (trimmed.startsWith("-")) {
527
+ return { valid: false, reason: { type: "negative" } };
528
+ }
529
+ if (/[eE]/.test(trimmed)) {
530
+ return { valid: false, reason: { type: "invalid-format" } };
531
+ }
532
+ if (trimmed === ".") {
533
+ return { valid: false, reason: { type: "invalid-format" } };
534
+ }
535
+ const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
536
+ if (!/^\d+(\.\d+)?$/.test(normalised)) {
537
+ return { valid: false, reason: { type: "invalid-format" } };
538
+ }
539
+ const [, fraction = ""] = normalised.split(".");
540
+ if (fraction.length > decimals) {
541
+ return {
542
+ valid: false,
543
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
544
+ };
545
+ }
546
+ try {
547
+ const raw = parseUnits(normalised, decimals);
548
+ if (raw > MAX_UINT_256) {
549
+ return { valid: false, reason: { type: "overflow" } };
550
+ }
551
+ return {
552
+ valid: true,
553
+ amount: BlockchainAmount({ raw, decimals })
554
+ };
555
+ } catch {
556
+ return { valid: false, reason: { type: "invalid-format" } };
557
+ }
558
+ }
559
+
560
+ // src/universal/core/shared/utils/crypto.ts
561
+ async function sha256(data) {
562
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
563
+ const buffer = bytes.buffer.slice(
564
+ bytes.byteOffset,
565
+ bytes.byteOffset + bytes.byteLength
566
+ );
567
+ return crypto.subtle.digest("SHA-256", buffer);
568
+ }
569
+ function arrayBufferToBase64Url(buffer, padding = true) {
570
+ const bytes = new Uint8Array(buffer);
571
+ let binary = "";
572
+ for (let i = 0; i < bytes.length; i++) {
573
+ binary += String.fromCharCode(bytes[i]);
574
+ }
575
+ let base64 = btoa(binary);
576
+ base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
577
+ if (!padding) {
578
+ base64 = base64.replace(/=+$/, "");
579
+ }
580
+ return base64;
581
+ }
582
+ function generateSecureRandomBase64Url(byteLength) {
583
+ const bytes = new Uint8Array(byteLength);
575
584
  crypto.getRandomValues(bytes);
576
585
  const buffer = bytes.buffer;
577
586
  return arrayBufferToBase64Url(buffer, false);
@@ -637,318 +646,286 @@ function requiredArray(value, field) {
637
646
  }
638
647
  return value;
639
648
  }
649
+ function txFromWire(wire) {
650
+ return {
651
+ to: EvmContractAddress(wire.to),
652
+ data: HexEncodedTransactionData(wire.data)
653
+ };
654
+ }
640
655
 
641
- // src/universal/types/offer.ts
642
- var OfferId = (value) => value;
643
- var OfferSlug = (value) => value;
644
- var OFFER_TYPES = {
645
- "coinlist::token_sale": true,
646
- "superstate::swap": true,
647
- "ondo::swap": true,
648
- "centrifuge::vault": true
649
- };
650
- var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
651
- var OfferEditorial = {
652
- /**
653
- * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
654
- * the same three checks name the payload that failed them.
655
- */
656
- fromDto: (dto, model) => ({
657
- tagline: requiredString(dto.tagline, `${model}.tagline`),
658
- bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
659
- startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
656
+ // src/universal/types/providers/centrifuge/centrifuge.ts
657
+ var CentrifugeVaultStatus = {
658
+ fromDto: (dto) => ({
659
+ chain: EthereumChain(dto.chain),
660
+ symbol: AssetSymbol(dto.symbol),
661
+ vaultAddress: EvmContractAddress(dto.vault_address),
662
+ linked: dto.linked,
663
+ permissioned: dto.permissioned,
664
+ membershipValidUntil: dateOrNull(
665
+ dto.membership_valid_until,
666
+ "CentrifugeVaultStatus.membership_valid_until"
667
+ ),
668
+ halted: dto.halted,
669
+ priceUpdatedAt: dateOrNull(
670
+ dto.price_updated_at,
671
+ "CentrifugeVaultStatus.price_updated_at"
672
+ ),
673
+ orderability: parseOrderability(
674
+ dto.can_order,
675
+ dto.reasons,
676
+ "CentrifugeVaultStatus"
677
+ ),
678
+ asOf: requiredDate(dto.as_of, "CentrifugeVaultStatus.as_of")
660
679
  })
661
680
  };
662
- var Offer = {
681
+ var CentrifugeVaultBuyTransaction = {
663
682
  fromDto: (dto) => {
664
- const tokens = requiredArray(dto.tokens, "Offer.tokens");
665
- const base2 = {
666
- id: OfferId(dto.id),
667
- slug: OfferSlug(dto.slug),
668
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
669
- tokens: OfferToken.listFromDto(tokens)
683
+ return {
684
+ ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
685
+ spendInputAmount: positiveAmountFromRawOrThrow({
686
+ label: "spend_input_amount",
687
+ raw: dto.spend_input_amount,
688
+ decimals: AssetDecimals(dto.spend_input_decimals),
689
+ // Frontline refuses an `amount` of zero, so a zero here is a changed
690
+ // encoding, not a small deposit - and not calldata worth signing.
691
+ reason: "a deposit of nothing is not a request"
692
+ })
670
693
  };
671
- switch (dto.type) {
672
- case "coinlist::token_sale":
673
- return {
674
- ...base2,
675
- ...OfferEditorial.fromDto(dto, "Offer"),
676
- type: dto.type,
677
- logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
678
- };
679
- case "superstate::swap":
680
- return {
681
- ...base2,
682
- ...OfferEditorial.fromDto(dto, "Offer"),
683
- type: dto.type,
684
- logoUrl: notBlankStringOrNull(dto.logo_url)
685
- };
686
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
687
- // on the wire: copying them would hand every consumer a `startsAt` that
688
- // is 1970 for one variant and a date for the others.
689
- case "ondo::swap":
690
- case "centrifuge::vault":
691
- return {
692
- ...base2,
693
- type: dto.type,
694
- logoUrl: notBlankStringOrNull(dto.logo_url)
695
- };
696
- default:
697
- return unknownTypeError(dto, "Offer");
698
- }
699
- },
700
- /**
701
- * Maps a page of offers, dropping every offer whose `type` this SDK does not
702
- * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
703
- * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
704
- * reject the whole page, so one offer of an unknown type would blank the
705
- * grid for every offer beside it. A single offer fetched by id still
706
- * throws, because there is nothing beside it to keep.
707
- */
708
- listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
709
- };
710
- var OfferToken = {
711
- fromDto: (dto) => ({
712
- role: dto.role,
713
- chain: Chain(dto.chain),
714
- address: EvmContractAddress(dto.address)
715
- }),
716
- /**
717
- * Maps an offer's token list, dropping every token on a chain this SDK does
718
- * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
719
- * plain `.map` would throw out of `Offer.fromDto` and, through
720
- * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
721
- * one Base token blanked production's offers list. Dropping costs that
722
- * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
723
- * so nobody could have looked it up anyway.
724
- *
725
- * Same shape as `TokenMetadata.fromRegistryDto`.
726
- */
727
- listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
694
+ }
728
695
  };
729
-
730
- // src/universal/types/trading.ts
731
- var Ticker = (value) => value;
732
- var Isin = (value) => value;
733
-
734
- // src/universal/types/offer-detail.ts
735
- var OfferOptionId = (value) => value;
736
- var OfferOptionSlug = (value) => value;
737
- var OfferSwapContract = {
696
+ var CentrifugeVaultClaimTransaction = {
738
697
  fromDto: (dto) => ({
739
- chain: Chain(dto.chain),
740
- address: EvmContractAddress(dto.address)
698
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimTransaction"),
699
+ claimableShares: blockchainAmountFromRawOrThrow({
700
+ label: "claimable_shares",
701
+ raw: dto.claimable_shares,
702
+ decimals: AssetDecimals(dto.share_decimals)
703
+ })
741
704
  })
742
705
  };
743
- var OfferVaultContract = {
706
+ var CentrifugeAssets = (amount) => amount;
707
+ var CentrifugeShares = (amount) => amount;
708
+ var CentrifugeDepositPosition = {
709
+ fromContract: (raw, context) => {
710
+ const assets = (label, value) => CentrifugeAssets(contractAmount(label, value, context.assetDecimals));
711
+ return {
712
+ chain: context.chain,
713
+ proxy: context.proxy,
714
+ walletAddress: context.walletAddress,
715
+ pending: assets("pendingDepositRequest", raw.pendingDepositRequest),
716
+ claimable: assets("claimableDepositRequest", raw.claimableDepositRequest)
717
+ };
718
+ }
719
+ };
720
+ var CentrifugeRedeemPosition = {
721
+ fromContract: (raw, context) => {
722
+ const shares = (label, value) => CentrifugeShares(contractAmount(label, value, context.shareDecimals));
723
+ return {
724
+ chain: context.chain,
725
+ proxy: context.proxy,
726
+ walletAddress: context.walletAddress,
727
+ pending: shares("pendingRedeemRequest", raw.pendingRedeemRequest),
728
+ claimable: shares("claimableRedeemRequest", raw.claimableRedeemRequest)
729
+ };
730
+ }
731
+ };
732
+ var CentrifugeVaultLeg = {
733
+ /** Whether the leg has anything queued or anything ready to claim. */
734
+ isActive: (leg) => leg.position.pending.raw > 0n || leg.position.claimable.raw > 0n
735
+ };
736
+ function contractAmount(label, value, decimals) {
737
+ return BlockchainAmount({ raw: parseUint256(value, label), decimals });
738
+ }
739
+ var CentrifugeVaultLegId = {
740
+ /** Addresses compare case-insensitively: a host may pass either case. */
741
+ of: (leg) => [
742
+ leg.direction,
743
+ leg.position.chain,
744
+ leg.position.walletAddress.toLowerCase()
745
+ ].join(":")
746
+ };
747
+ var CentrifugeVaultClaimProceedsTransaction = {
744
748
  fromDto: (dto) => ({
745
- chain: Chain(dto.chain),
746
- address: EvmContractAddress(dto.address)
747
- }),
748
- /**
749
- * Drops every proxy on a chain this SDK does not name, as
750
- * `OfferToken.listFromDto` does: frontline publishes the full offer-token
751
- * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
752
- * should not throw away the proxies the SDK can use.
753
- */
754
- listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
749
+ ...parseTransactionCore(dto, "CentrifugeVaultClaimProceedsTransaction"),
750
+ claimableAssets: blockchainAmountFromRawOrThrow({
751
+ label: "claimable_assets",
752
+ raw: dto.claimable_assets,
753
+ decimals: AssetDecimals(dto.asset_decimals)
754
+ })
755
+ })
755
756
  };
756
- var OfferDetail = {
757
- fromDto: (dto) => {
758
- const fundingAssets = requiredArray(
759
- dto.funding_assets,
760
- "OfferDetail.funding_assets"
757
+ function parseOrderability(canOrder, reasons, model) {
758
+ const [first, ...rest] = reasons;
759
+ if (canOrder) {
760
+ if (first !== void 0) {
761
+ throw new ValidationError(
762
+ `${model}.reasons: expected none when can_order is true, got ${JSON.stringify(reasons)}`
763
+ );
764
+ }
765
+ return { type: "orderable" };
766
+ }
767
+ if (first === void 0) {
768
+ throw new ValidationError(
769
+ `${model}.reasons: expected at least one when can_order is false`
761
770
  );
762
- const options = requiredArray(dto.options, "OfferDetail.options");
763
- const terms = requiredArray(dto.terms, "OfferDetail.terms");
764
- const links = requiredArray(dto.links, "OfferDetail.links");
765
- const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
766
- const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
767
- const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
768
- const isin = notBlankStringOrNull(dto.isin);
769
- const ticker = notBlankStringOrNull(dto.ticker);
770
- const base2 = {
771
- id: OfferId(dto.id),
772
- slug: OfferSlug(dto.slug),
773
- name: dto.name,
774
- asset: Asset.fromDto(dto.asset),
775
- fundingAssets: fundingAssets.map(Asset.fromDto),
776
- tokens: OfferToken.listFromDto(tokens),
777
- about: notBlankStringOrNull(dto.about),
778
- category: dto.category,
779
- issuer: notBlankStringOrNull(dto.issuer),
780
- isin: isin === null ? null : Isin(isin),
781
- ticker: ticker === null ? null : Ticker(ticker),
782
- instrumentType: notBlankStringOrNull(dto.instrument_type),
783
- listingVenue: notBlankStringOrNull(dto.listing_venue),
784
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
785
- faqs: faqs.map(FaqItem.fromDto),
786
- links: links.map(Link.fromDto),
787
- milestones: milestones.map(Milestone.fromDto),
788
- options: options.map(OfferOption.fromDto),
789
- terms: terms.map(TermItem.fromDto)
790
- };
791
- switch (dto.type) {
792
- case "coinlist::token_sale":
793
- return {
794
- ...base2,
795
- ...OfferEditorial.fromDto(dto, "OfferDetail"),
796
- type: dto.type,
797
- logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
798
- };
799
- case "superstate::swap":
800
- return {
801
- ...base2,
802
- ...OfferEditorial.fromDto(dto, "OfferDetail"),
803
- type: dto.type,
804
- logoUrl: notBlankStringOrNull(dto.logo_url)
805
- };
806
- // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
807
- // on the wire, as in `Offer.fromDto`.
808
- case "ondo::swap":
809
- return {
810
- ...base2,
811
- type: dto.type,
812
- logoUrl: notBlankStringOrNull(dto.logo_url),
813
- swapContracts: requiredArray(
814
- dto.swap_contracts,
815
- "OfferDetail.swap_contracts"
816
- ).map(OfferSwapContract.fromDto)
817
- };
818
- // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
819
- // the same reason as `swap_contracts`: this is the spender a user
820
- // approves.
821
- case "centrifuge::vault":
822
- return {
823
- ...base2,
824
- type: dto.type,
825
- logoUrl: notBlankStringOrNull(dto.logo_url),
826
- vaultContracts: OfferVaultContract.listFromDto(
827
- requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
828
- )
829
- };
830
- default:
831
- return unknownTypeError(dto, "OfferDetail");
832
- }
833
- }
834
- };
835
- var OfferOption = {
836
- fromDto: (dto) => ({
837
- id: OfferOptionId(dto.id),
838
- slug: OfferOptionSlug(dto.slug),
839
- bidIncrement: dto.bid_increment,
840
- floorPriceUsd: dto.floor_price_usd,
841
- minimumPurchaseUsd: dto.minimum_purchase_usd,
842
- priceUsd: dto.price_usd,
843
- saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
844
- totalTokenSupply: dto.total_token_supply
845
- })
846
- };
847
- var FaqItem = {
848
- fromDto: (dto) => ({
849
- question: notBlankStringOrNull(dto.question),
850
- answer: notBlankStringOrNull(dto.answer)
851
- })
852
- };
853
- var Link = {
854
- fromDto: (dto) => ({
855
- label: notBlankStringOrNull(dto.label),
856
- url: notBlankStringOrNull(dto.url)
857
- })
858
- };
859
- var TermItem = {
860
- fromDto: (dto) => ({
861
- key: notBlankStringOrNull(dto.key),
862
- value: notBlankStringOrNull(dto.value)
863
- })
864
- };
865
- var Milestone = {
866
- fromDto: (dto) => ({
867
- name: notBlankStringOrNull(dto.name),
868
- schedule: notBlankStringOrNull(dto.schedule),
869
- status: dto.status
870
- })
871
- };
872
-
873
- // src/universal/types/providers/coin-list/token-sale.ts
874
- var ParticipationId = (value) => value;
875
- var Blockchain = (value) => value;
876
- var WalletAddress = (value) => value;
877
- var ParticipationsPaginationParams = {
878
- toQueryParams: (params) => {
879
- const queryParams = PaginationParams.toQueryParams(params);
880
- if (params.offerId) {
881
- queryParams["filters[0][field]"] = "offer_id";
882
- queryParams["filters[0][op]"] = "==";
883
- queryParams["filters[0][value]"] = params.offerId;
884
- }
885
- return queryParams;
886
- }
887
- };
888
- var Participation = {
889
- /** Maps API DTO shape into the SDK participation domain model. */
890
- fromDto: (dto) => {
891
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
892
- return {
893
- id: ParticipationId(dto.id),
894
- offerId: OfferId(dto.offer_id),
895
- offerOptionId: OfferOptionId(dto.offer_option_id),
896
- status: dto.status,
897
- amount: dto.amount,
898
- displayAmount: dto.amount_string,
899
- asset: Asset.fromDto(dto.asset),
900
- chain: Blockchain(dto.chain),
901
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
902
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
903
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
904
- };
905
771
  }
906
- };
907
- var CreateParticipationParams = {
908
- /** Maps participation creation params into API DTO payload. */
909
- toDto: (params) => ({
910
- offer_id: params.offerId,
911
- offer_option_id: params.offerOptionId,
912
- chain: params.chain,
913
- wallet_address: params.walletAddress,
914
- amount: params.amount,
915
- asset_id: params.assetId,
916
- approval_transaction_hash: params.approvalTransactionHash
917
- })
918
- };
772
+ return { type: "blocked", reasons: [first, ...rest] };
773
+ }
774
+ function parseTransactionCore(dto, model) {
775
+ return {
776
+ tx: txFromWire(dto),
777
+ expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
778
+ };
779
+ }
919
780
 
920
- // src/universal/api/frontline/providers/coin-list/token-sale.ts
921
- async function fetchParticipations(api, offerId) {
922
- return fetchAllPages(
923
- (params) => fetchParticipationsPage(api, params),
924
- { offerId }
781
+ // src/universal/api/frontline/providers/shared/spend-scale.ts
782
+ function assertSpendScaleAgrees({
783
+ published,
784
+ sized,
785
+ trade,
786
+ note
787
+ }) {
788
+ if (published === sized.decimals) return;
789
+ const because = note === void 0 ? "" : ` - ${note}`;
790
+ throw new ValidationError(
791
+ `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
925
792
  );
926
793
  }
927
- async function fetchParticipationsPage(api, params) {
928
- const pageDto = await api.send({
794
+
795
+ // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
796
+ async function getCentrifugeVaultStatus(api, params) {
797
+ const dto = await api.send({
929
798
  method: "GET",
930
- url: "/v1/participations",
931
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
799
+ url: "/v1/centrifuge/vault/status",
800
+ queryParams: {
801
+ symbol: params.symbol,
802
+ chain: params.chain
803
+ },
932
804
  attributes: Attributes.protected()
933
805
  });
934
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
806
+ return CentrifugeVaultStatus.fromDto(dto);
935
807
  }
936
- async function fetchParticipation(api, id) {
808
+ async function buildCentrifugeVaultBuy(api, params) {
937
809
  const dto = await api.send({
938
- method: "GET",
939
- url: `/v1/participations/${id}`,
810
+ method: "POST",
811
+ url: "/v1/centrifuge/vault/invest",
812
+ body: {
813
+ ...walletFields(params),
814
+ amount: params.amount.raw.toString()
815
+ },
940
816
  attributes: Attributes.protected()
941
817
  });
942
- return Participation.fromDto(dto);
818
+ assertSpendScaleAgrees({
819
+ published: dto.spend_input_decimals,
820
+ sized: params.amount,
821
+ trade: "deposit"
822
+ });
823
+ return CentrifugeVaultBuyTransaction.fromDto(dto);
943
824
  }
944
- async function createParticipation(api, params) {
825
+ async function createCentrifugeVaultClaim(api, params) {
945
826
  const dto = await api.send({
946
827
  method: "POST",
947
- url: "/v1/participations",
948
- body: CreateParticipationParams.toDto(params),
828
+ url: "/v1/centrifuge/vault/claim",
829
+ body: walletFields(params),
949
830
  attributes: Attributes.protected()
950
831
  });
951
- return Participation.fromDto(dto);
832
+ return CentrifugeVaultClaimTransaction.fromDto(dto);
833
+ }
834
+ async function createCentrifugeVaultClaimProceeds(api, params) {
835
+ const dto = await api.send({
836
+ method: "POST",
837
+ url: "/v1/centrifuge/vault/claim-proceeds",
838
+ body: walletFields(params),
839
+ attributes: Attributes.protected()
840
+ });
841
+ return CentrifugeVaultClaimProceedsTransaction.fromDto(dto);
842
+ }
843
+ function walletFields(params) {
844
+ return {
845
+ symbol: params.symbol,
846
+ chain: params.chain,
847
+ wallet_address: params.walletAddress
848
+ };
849
+ }
850
+
851
+ // src/universal/core/providers/checkout/centrifuge/blockchain/abi.ts
852
+ var CENTRIFUGE_PROXY_ABI = [
853
+ {
854
+ type: "function",
855
+ name: "pendingDepositRequest",
856
+ inputs: [{ name: "investor", type: "address" }],
857
+ outputs: [{ name: "", type: "uint256" }],
858
+ stateMutability: "view"
859
+ },
860
+ {
861
+ type: "function",
862
+ name: "claimableDepositRequest",
863
+ inputs: [{ name: "investor", type: "address" }],
864
+ outputs: [{ name: "", type: "uint256" }],
865
+ stateMutability: "view"
866
+ },
867
+ {
868
+ type: "function",
869
+ name: "pendingRedeemRequest",
870
+ inputs: [{ name: "investor", type: "address" }],
871
+ outputs: [{ name: "", type: "uint256" }],
872
+ stateMutability: "view"
873
+ },
874
+ {
875
+ type: "function",
876
+ name: "claimableRedeemRequest",
877
+ inputs: [{ name: "investor", type: "address" }],
878
+ outputs: [{ name: "", type: "uint256" }],
879
+ stateMutability: "view"
880
+ }
881
+ ];
882
+
883
+ // src/universal/api/rpc/providers/centrifuge/position.ts
884
+ async function readCentrifugeDepositPosition(clients, params) {
885
+ const client = clients(params.vault.chain);
886
+ const proxy = proxyOf(params);
887
+ const wallet = params.walletAddress;
888
+ const [pendingDepositRequest, claimableDepositRequest] = await client.multicall({
889
+ allowFailure: false,
890
+ contracts: [
891
+ { ...proxy, functionName: "pendingDepositRequest", args: [wallet] },
892
+ { ...proxy, functionName: "claimableDepositRequest", args: [wallet] }
893
+ ]
894
+ });
895
+ return CentrifugeDepositPosition.fromContract(
896
+ { pendingDepositRequest, claimableDepositRequest },
897
+ contextOf(params)
898
+ );
899
+ }
900
+ async function readCentrifugeRedeemPosition(clients, params) {
901
+ const client = clients(params.vault.chain);
902
+ const proxy = proxyOf(params);
903
+ const wallet = params.walletAddress;
904
+ const [pendingRedeemRequest, claimableRedeemRequest] = await client.multicall(
905
+ {
906
+ allowFailure: false,
907
+ contracts: [
908
+ { ...proxy, functionName: "pendingRedeemRequest", args: [wallet] },
909
+ { ...proxy, functionName: "claimableRedeemRequest", args: [wallet] }
910
+ ]
911
+ }
912
+ );
913
+ return CentrifugeRedeemPosition.fromContract(
914
+ { pendingRedeemRequest, claimableRedeemRequest },
915
+ contextOf(params)
916
+ );
917
+ }
918
+ function proxyOf(params) {
919
+ return { address: params.vault.proxy, abi: CENTRIFUGE_PROXY_ABI };
920
+ }
921
+ function contextOf(params) {
922
+ return {
923
+ chain: params.vault.chain,
924
+ proxy: params.vault.proxy,
925
+ walletAddress: params.walletAddress,
926
+ assetDecimals: params.vault.funding.decimals,
927
+ shareDecimals: params.vault.share.decimals
928
+ };
952
929
  }
953
930
 
954
931
  // src/universal/core/shared/observability/log-cause.ts
@@ -1134,46 +1111,52 @@ var noopInternalLogger = {
1134
1111
  wrap: (_op, _params, run) => run()
1135
1112
  };
1136
1113
 
1137
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1138
- var CoinListTokenSaleNamespaceImpl = class {
1114
+ // src/universal/core/providers/checkout/centrifuge/centrifuge-namespace.ts
1115
+ var CentrifugeNamespaceImpl = class {
1139
1116
  constructor(ctx) {
1140
1117
  this.ctx = ctx;
1141
- this.log = internalLogger(ctx.logger, "TOKEN_SALE");
1118
+ this.log = internalLogger(ctx.logger, "CENTRIFUGE");
1142
1119
  }
1143
- async list(offerId) {
1144
- return this.log.wrap("list", offerId, async () => {
1120
+ async getVaultStatus(params) {
1121
+ return this.log.wrap("getVaultStatus", params, async () => {
1145
1122
  await this.ctx.ensureUserAuthenticated();
1146
- return fetchParticipations(this.ctx.api, offerId);
1123
+ return getCentrifugeVaultStatus(this.ctx.api, params);
1147
1124
  });
1148
1125
  }
1149
- async listPage(params) {
1150
- return this.log.wrap("listPage", params, async () => {
1126
+ async readDepositPosition(params) {
1127
+ return this.log.wrap(
1128
+ "readDepositPosition",
1129
+ params,
1130
+ () => readCentrifugeDepositPosition(this.ctx.rpc, params)
1131
+ );
1132
+ }
1133
+ async readRedeemPosition(params) {
1134
+ return this.log.wrap(
1135
+ "readRedeemPosition",
1136
+ params,
1137
+ () => readCentrifugeRedeemPosition(this.ctx.rpc, params)
1138
+ );
1139
+ }
1140
+ async createClaim(params) {
1141
+ return this.log.wrap("createClaim", params, async () => {
1151
1142
  await this.ctx.ensureUserAuthenticated();
1152
- return fetchParticipationsPage(this.ctx.api, params);
1143
+ return createCentrifugeVaultClaim(this.ctx.api, params);
1153
1144
  });
1154
1145
  }
1155
- async get(id) {
1156
- return this.log.wrap("get", id, async () => {
1146
+ async createClaimProceeds(params) {
1147
+ return this.log.wrap("createClaimProceeds", params, async () => {
1157
1148
  await this.ctx.ensureUserAuthenticated();
1158
- return fetchParticipation(this.ctx.api, id);
1149
+ return createCentrifugeVaultClaimProceeds(this.ctx.api, params);
1159
1150
  });
1160
1151
  }
1161
- async createParticipation(params) {
1162
- return this.log.wrap("createParticipation", params, async () => {
1152
+ async buildBuyTransaction(params) {
1153
+ return this.log.wrap("buildBuyTransaction", params, async () => {
1163
1154
  await this.ctx.ensureUserAuthenticated();
1164
- return createParticipation(this.ctx.api, params);
1155
+ return buildCentrifugeVaultBuy(this.ctx.api, params);
1165
1156
  });
1166
1157
  }
1167
1158
  };
1168
1159
 
1169
- // src/universal/types/blockchain/ui.ts
1170
- var FormattedAmountUi = (value) => value;
1171
- var FormattedPercentUi = (value) => value;
1172
- var TxExplorerUrl = (value) => value;
1173
- var ShortenedWalletAddress = (value) => value;
1174
- var FormattedAmountAssetUi = (value) => value;
1175
- var AssetIconUrl = (value) => value;
1176
-
1177
1160
  // src/universal/core/shared/blockchain/formatters.ts
1178
1161
  import { formatUnits } from "viem";
1179
1162
  function shortenAddress(address) {
@@ -1282,123 +1265,432 @@ function formattedUsdPrice(amount, locale) {
1282
1265
  );
1283
1266
  }
1284
1267
 
1285
- // src/universal/core/shared/blockchain/chain.ts
1286
- import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
1287
- var VIEM_CHAINS = {
1288
- ethereum_mainnet: mainnet,
1289
- ethereum_sepolia: sepolia,
1290
- base_mainnet: base,
1291
- base_sepolia: baseSepolia
1268
+ // src/universal/types/pagination.ts
1269
+ var Cursor = (value) => value;
1270
+ var PaginatedResponse = {
1271
+ fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
1272
+ /**
1273
+ * For a mapper that decides the page as a whole - one that drops items it
1274
+ * cannot map, such as `Offer.listFromDto` - rather than item by item. The
1275
+ * cursors are the wire's either way: dropping an item changes what the
1276
+ * page holds, not where the next page starts.
1277
+ */
1278
+ fromDtoPage: (dto, pageMapper) => ({
1279
+ data: pageMapper(dto.data),
1280
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
1281
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
1282
+ })
1292
1283
  };
1293
- function viemChain(chain) {
1294
- return VIEM_CHAINS[chain];
1295
- }
1296
- function getChainId(chain) {
1297
- return VIEM_CHAINS[chain].id;
1298
- }
1299
- function chainFromId(chainId) {
1300
- const chains = Object.keys(VIEM_CHAINS);
1301
- const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
1302
- if (!chain) {
1303
- throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
1284
+ var PaginationParams = {
1285
+ toQueryParams: (params) => {
1286
+ const queryParams = {};
1287
+ if (params.after) {
1288
+ queryParams.starting_after = params.after;
1289
+ }
1290
+ if (params.before) {
1291
+ queryParams.starting_before = params.before;
1292
+ }
1293
+ if (params.limit) {
1294
+ queryParams.limit = params.limit;
1295
+ }
1296
+ return queryParams;
1304
1297
  }
1305
- return chain;
1306
- }
1307
- function getNetworkName(chain) {
1308
- switch (chain) {
1309
- case "ethereum_mainnet":
1310
- return "Ethereum";
1311
- case "ethereum_sepolia":
1312
- return "Ethereum Sepolia";
1313
- case "base_mainnet":
1314
- return "Base";
1315
- case "base_sepolia":
1316
- return "Base Sepolia";
1317
- default: {
1318
- const _exhaustive = chain;
1319
- return _exhaustive;
1298
+ };
1299
+
1300
+ // src/universal/types/asset.ts
1301
+ var AssetId = (value) => value;
1302
+ var AssetCode = (value) => value;
1303
+ var Asset = {
1304
+ fromDto: (dto) => ({
1305
+ id: AssetId(dto.id),
1306
+ code: AssetCode(dto.code),
1307
+ name: dto.name,
1308
+ fractionalDigits: dto.fractional_digits
1309
+ })
1310
+ };
1311
+
1312
+ // src/universal/types/offer.ts
1313
+ var OfferId = (value) => value;
1314
+ var OfferSlug = (value) => value;
1315
+ var OFFER_TYPES = {
1316
+ "coinlist::token_sale": true,
1317
+ "superstate::swap": true,
1318
+ "ondo::swap": true,
1319
+ "centrifuge::vault": true
1320
+ };
1321
+ var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
1322
+ var OfferEditorial = {
1323
+ /**
1324
+ * `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
1325
+ * the same three checks name the payload that failed them.
1326
+ */
1327
+ fromDto: (dto, model) => ({
1328
+ tagline: requiredString(dto.tagline, `${model}.tagline`),
1329
+ bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
1330
+ startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
1331
+ })
1332
+ };
1333
+ var Offer = {
1334
+ fromDto: (dto) => {
1335
+ const tokens = requiredArray(dto.tokens, "Offer.tokens");
1336
+ const base2 = {
1337
+ id: OfferId(dto.id),
1338
+ slug: OfferSlug(dto.slug),
1339
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1340
+ tokens: OfferToken.listFromDto(tokens)
1341
+ };
1342
+ switch (dto.type) {
1343
+ case "coinlist::token_sale":
1344
+ return {
1345
+ ...base2,
1346
+ ...OfferEditorial.fromDto(dto, "Offer"),
1347
+ type: dto.type,
1348
+ logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
1349
+ };
1350
+ case "superstate::swap":
1351
+ return {
1352
+ ...base2,
1353
+ ...OfferEditorial.fromDto(dto, "Offer"),
1354
+ type: dto.type,
1355
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1356
+ };
1357
+ // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
1358
+ // on the wire: copying them would hand every consumer a `startsAt` that
1359
+ // is 1970 for one variant and a date for the others.
1360
+ case "ondo::swap":
1361
+ case "centrifuge::vault":
1362
+ return {
1363
+ ...base2,
1364
+ type: dto.type,
1365
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1366
+ };
1367
+ default:
1368
+ return unknownTypeError(dto, "Offer");
1369
+ }
1370
+ },
1371
+ /**
1372
+ * Maps a page of offers, dropping every offer whose `type` this SDK does not
1373
+ * name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
1374
+ * would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
1375
+ * reject the whole page, so one offer of an unknown type would blank the
1376
+ * grid for every offer beside it. A single offer fetched by id still
1377
+ * throws, because there is nothing beside it to keep.
1378
+ */
1379
+ listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
1380
+ };
1381
+ var OfferToken = {
1382
+ fromDto: (dto) => ({
1383
+ role: dto.role,
1384
+ chain: Chain(dto.chain),
1385
+ address: EvmContractAddress(dto.address)
1386
+ }),
1387
+ /**
1388
+ * Maps an offer's token list, dropping every token on a chain this SDK does
1389
+ * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
1390
+ * plain `.map` would throw out of `Offer.fromDto` and, through
1391
+ * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
1392
+ * one Base token blanked production's offers list. Dropping costs that
1393
+ * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
1394
+ * so nobody could have looked it up anyway.
1395
+ *
1396
+ * Same shape as `TokenMetadata.fromRegistryDto`.
1397
+ */
1398
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
1399
+ };
1400
+
1401
+ // src/universal/types/trading.ts
1402
+ var Ticker = (value) => value;
1403
+ var Isin = (value) => value;
1404
+
1405
+ // src/universal/types/offer-detail.ts
1406
+ var AsyncOfferDetail = {
1407
+ /**
1408
+ * Narrows an offer fetched generically, e.g. on an offer page, to one with
1409
+ * something to claim.
1410
+ *
1411
+ * An exhaustive `switch` rather than a list of async types, so a new offer
1412
+ * type is a compile error here until someone decides whether it settles
1413
+ * later.
1414
+ */
1415
+ is: (offer) => {
1416
+ switch (offer.type) {
1417
+ case "centrifuge::vault":
1418
+ return true;
1419
+ case "ondo::swap":
1420
+ case "superstate::swap":
1421
+ case "coinlist::token_sale":
1422
+ return false;
1423
+ default: {
1424
+ const exhaustive = offer;
1425
+ return exhaustive;
1426
+ }
1320
1427
  }
1321
1428
  }
1322
- }
1323
- function txExplorerUrl(chain, txHash) {
1324
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
1325
- }
1326
- function explorerBaseUrl(chain) {
1327
- switch (chain) {
1328
- case "ethereum_mainnet":
1329
- return "https://etherscan.io";
1330
- case "ethereum_sepolia":
1331
- return "https://sepolia.etherscan.io";
1332
- case "base_mainnet":
1333
- return "https://basescan.org";
1334
- case "base_sepolia":
1335
- return "https://sepolia-explorer.base.org";
1336
- default: {
1337
- const _exhaustive = chain;
1338
- return _exhaustive;
1429
+ };
1430
+ var OfferOptionId = (value) => value;
1431
+ var OfferOptionSlug = (value) => value;
1432
+ var OfferSwapContract = {
1433
+ fromDto: (dto) => ({
1434
+ chain: Chain(dto.chain),
1435
+ address: EvmContractAddress(dto.address)
1436
+ })
1437
+ };
1438
+ var OfferVaultContract = {
1439
+ fromDto: (dto) => ({
1440
+ chain: Chain(dto.chain),
1441
+ address: EvmContractAddress(dto.address)
1442
+ }),
1443
+ /**
1444
+ * Drops every proxy on a chain this SDK does not name, as
1445
+ * `OfferToken.listFromDto` does: frontline publishes the full offer-token
1446
+ * chain list, which runs ahead of {@link Chain}, and one unmodelled chain
1447
+ * should not throw away the proxies the SDK can use.
1448
+ */
1449
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1450
+ };
1451
+ var OfferDetail = {
1452
+ fromDto: (dto) => {
1453
+ const fundingAssets = requiredArray(
1454
+ dto.funding_assets,
1455
+ "OfferDetail.funding_assets"
1456
+ );
1457
+ const options = requiredArray(dto.options, "OfferDetail.options");
1458
+ const terms = requiredArray(dto.terms, "OfferDetail.terms");
1459
+ const links = requiredArray(dto.links, "OfferDetail.links");
1460
+ const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
1461
+ const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
1462
+ const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
1463
+ const isin = notBlankStringOrNull(dto.isin);
1464
+ const ticker = notBlankStringOrNull(dto.ticker);
1465
+ const base2 = {
1466
+ id: OfferId(dto.id),
1467
+ slug: OfferSlug(dto.slug),
1468
+ name: dto.name,
1469
+ asset: Asset.fromDto(dto.asset),
1470
+ fundingAssets: fundingAssets.map(Asset.fromDto),
1471
+ tokens: OfferToken.listFromDto(tokens),
1472
+ about: notBlankStringOrNull(dto.about),
1473
+ category: dto.category,
1474
+ issuer: notBlankStringOrNull(dto.issuer),
1475
+ isin: isin === null ? null : Isin(isin),
1476
+ ticker: ticker === null ? null : Ticker(ticker),
1477
+ instrumentType: notBlankStringOrNull(dto.instrument_type),
1478
+ listingVenue: notBlankStringOrNull(dto.listing_venue),
1479
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1480
+ faqs: faqs.map(FaqItem.fromDto),
1481
+ links: links.map(Link.fromDto),
1482
+ milestones: milestones.map(Milestone.fromDto),
1483
+ options: options.map(OfferOption.fromDto),
1484
+ terms: terms.map(TermItem.fromDto)
1485
+ };
1486
+ switch (dto.type) {
1487
+ case "coinlist::token_sale":
1488
+ return {
1489
+ ...base2,
1490
+ ...OfferEditorial.fromDto(dto, "OfferDetail"),
1491
+ type: dto.type,
1492
+ logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
1493
+ };
1494
+ case "superstate::swap":
1495
+ return {
1496
+ ...base2,
1497
+ ...OfferEditorial.fromDto(dto, "OfferDetail"),
1498
+ type: dto.type,
1499
+ logoUrl: notBlankStringOrNull(dto.logo_url)
1500
+ };
1501
+ // `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
1502
+ // on the wire, as in `Offer.fromDto`.
1503
+ case "ondo::swap":
1504
+ return {
1505
+ ...base2,
1506
+ type: dto.type,
1507
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1508
+ swapContracts: requiredArray(
1509
+ dto.swap_contracts,
1510
+ "OfferDetail.swap_contracts"
1511
+ ).map(OfferSwapContract.fromDto)
1512
+ };
1513
+ // No editorial, as for Ondo. `[]` is fine and a missing key is not, for
1514
+ // the same reason as `swap_contracts`: this is the spender a user
1515
+ // approves.
1516
+ case "centrifuge::vault":
1517
+ return {
1518
+ ...base2,
1519
+ type: dto.type,
1520
+ logoUrl: notBlankStringOrNull(dto.logo_url),
1521
+ vaultContracts: OfferVaultContract.listFromDto(
1522
+ requiredArray(dto.vault_contracts, "OfferDetail.vault_contracts")
1523
+ )
1524
+ };
1525
+ default:
1526
+ return unknownTypeError(dto, "OfferDetail");
1339
1527
  }
1340
1528
  }
1341
- }
1529
+ };
1530
+ var OfferOption = {
1531
+ fromDto: (dto) => ({
1532
+ id: OfferOptionId(dto.id),
1533
+ slug: OfferOptionSlug(dto.slug),
1534
+ bidIncrement: dto.bid_increment,
1535
+ floorPriceUsd: dto.floor_price_usd,
1536
+ minimumPurchaseUsd: dto.minimum_purchase_usd,
1537
+ priceUsd: dto.price_usd,
1538
+ saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
1539
+ totalTokenSupply: dto.total_token_supply
1540
+ })
1541
+ };
1542
+ var FaqItem = {
1543
+ fromDto: (dto) => ({
1544
+ question: notBlankStringOrNull(dto.question),
1545
+ answer: notBlankStringOrNull(dto.answer)
1546
+ })
1547
+ };
1548
+ var Link = {
1549
+ fromDto: (dto) => ({
1550
+ label: notBlankStringOrNull(dto.label),
1551
+ url: notBlankStringOrNull(dto.url)
1552
+ })
1553
+ };
1554
+ var TermItem = {
1555
+ fromDto: (dto) => ({
1556
+ key: notBlankStringOrNull(dto.key),
1557
+ value: notBlankStringOrNull(dto.value)
1558
+ })
1559
+ };
1560
+ var Milestone = {
1561
+ fromDto: (dto) => ({
1562
+ name: notBlankStringOrNull(dto.name),
1563
+ schedule: notBlankStringOrNull(dto.schedule),
1564
+ status: dto.status
1565
+ })
1566
+ };
1342
1567
 
1343
- // src/universal/core/shared/blockchain/math.ts
1344
- import { parseUnits } from "viem";
1345
- function blockchainAmountFromRawOrThrow({
1346
- label,
1347
- raw,
1348
- decimals
1349
- }) {
1350
- const trimmed = raw.trim();
1351
- if (trimmed === "") {
1352
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1353
- }
1354
- let value;
1355
- try {
1356
- value = BigInt(trimmed);
1357
- } catch {
1358
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1568
+ // src/universal/types/providers/coin-list/token-sale.ts
1569
+ var ParticipationId = (value) => value;
1570
+ var ParticipationsPaginationParams = {
1571
+ toQueryParams: (params) => {
1572
+ const queryParams = PaginationParams.toQueryParams(params);
1573
+ if (params.offerId) {
1574
+ queryParams["filters[0][field]"] = "offer_id";
1575
+ queryParams["filters[0][op]"] = "==";
1576
+ queryParams["filters[0][value]"] = params.offerId;
1577
+ }
1578
+ return queryParams;
1359
1579
  }
1360
- try {
1361
- return BlockchainAmount({ raw: assertUint256(value), decimals });
1362
- } catch {
1363
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1580
+ };
1581
+ var Participation = {
1582
+ /** Maps API DTO shape into the SDK participation domain model. */
1583
+ fromDto: (dto) => {
1584
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
1585
+ return {
1586
+ id: ParticipationId(dto.id),
1587
+ offerId: OfferId(dto.offer_id),
1588
+ offerOptionId: OfferOptionId(dto.offer_option_id),
1589
+ status: dto.status,
1590
+ amount: dto.amount,
1591
+ displayAmount: dto.amount_string,
1592
+ asset: Asset.fromDto(dto.asset),
1593
+ chain: isChain(dto.chain) ? dto.chain : null,
1594
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1595
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1596
+ walletAddress: walletAddress ? EvmWalletAddress(walletAddress) : null
1597
+ };
1364
1598
  }
1599
+ };
1600
+ var CreateParticipationParams = {
1601
+ /** Maps participation creation params into API DTO payload. */
1602
+ toDto: (params) => ({
1603
+ offer_id: params.offerId,
1604
+ offer_option_id: params.offerOptionId,
1605
+ chain: params.chain,
1606
+ wallet_address: params.walletAddress,
1607
+ amount: params.amount,
1608
+ asset_id: params.assetId,
1609
+ approval_transaction_hash: params.approvalTransactionHash
1610
+ })
1611
+ };
1612
+
1613
+ // src/universal/api/pagination.ts
1614
+ async function fetchAllPages(fetchPage, baseParams) {
1615
+ const items = [];
1616
+ let cursor = null;
1617
+ do {
1618
+ const params = {
1619
+ ...baseParams ?? {},
1620
+ after: cursor ?? void 0
1621
+ };
1622
+ const page = await fetchPage(params);
1623
+ items.push(...page.data);
1624
+ cursor = page.startingAfter;
1625
+ } while (cursor);
1626
+ return items;
1365
1627
  }
1366
- function parseBlockchainAmount(amount, decimals) {
1367
- const trimmed = amount.trim();
1368
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1369
- if (trimmed.startsWith("-")) {
1370
- return { valid: false, reason: { type: "negative" } };
1371
- }
1372
- if (/[eE]/.test(trimmed)) {
1373
- return { valid: false, reason: { type: "invalid-format" } };
1628
+
1629
+ // src/universal/api/frontline/providers/coin-list/token-sale.ts
1630
+ async function fetchParticipations(api, offerId) {
1631
+ return fetchAllPages(
1632
+ (params) => fetchParticipationsPage(api, params),
1633
+ { offerId }
1634
+ );
1635
+ }
1636
+ async function fetchParticipationsPage(api, params) {
1637
+ const pageDto = await api.send({
1638
+ method: "GET",
1639
+ url: "/v1/participations",
1640
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
1641
+ attributes: Attributes.protected()
1642
+ });
1643
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1644
+ }
1645
+ async function fetchParticipation(api, id) {
1646
+ const dto = await api.send({
1647
+ method: "GET",
1648
+ url: `/v1/participations/${id}`,
1649
+ attributes: Attributes.protected()
1650
+ });
1651
+ return Participation.fromDto(dto);
1652
+ }
1653
+ async function createParticipation(api, params) {
1654
+ const dto = await api.send({
1655
+ method: "POST",
1656
+ url: "/v1/participations",
1657
+ body: CreateParticipationParams.toDto(params),
1658
+ attributes: Attributes.protected()
1659
+ });
1660
+ return Participation.fromDto(dto);
1661
+ }
1662
+
1663
+ // src/universal/core/providers/checkout/coin-list/token-sale-namespace.ts
1664
+ var CoinListTokenSaleNamespaceImpl = class {
1665
+ constructor(ctx) {
1666
+ this.ctx = ctx;
1667
+ this.log = internalLogger(ctx.logger, "TOKEN_SALE");
1374
1668
  }
1375
- if (trimmed === ".") {
1376
- return { valid: false, reason: { type: "invalid-format" } };
1669
+ async list(offerId) {
1670
+ return this.log.wrap("list", offerId, async () => {
1671
+ await this.ctx.ensureUserAuthenticated();
1672
+ return fetchParticipations(this.ctx.api, offerId);
1673
+ });
1377
1674
  }
1378
- const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
1379
- if (!/^\d+(\.\d+)?$/.test(normalised)) {
1380
- return { valid: false, reason: { type: "invalid-format" } };
1675
+ async listPage(params) {
1676
+ return this.log.wrap("listPage", params, async () => {
1677
+ await this.ctx.ensureUserAuthenticated();
1678
+ return fetchParticipationsPage(this.ctx.api, params);
1679
+ });
1381
1680
  }
1382
- const [, fraction = ""] = normalised.split(".");
1383
- if (fraction.length > decimals) {
1384
- return {
1385
- valid: false,
1386
- reason: { type: "too-many-decimals", maxDecimals: decimals }
1387
- };
1681
+ async get(id) {
1682
+ return this.log.wrap("get", id, async () => {
1683
+ await this.ctx.ensureUserAuthenticated();
1684
+ return fetchParticipation(this.ctx.api, id);
1685
+ });
1388
1686
  }
1389
- try {
1390
- const raw = parseUnits(normalised, decimals);
1391
- if (raw > MAX_UINT_256) {
1392
- return { valid: false, reason: { type: "overflow" } };
1393
- }
1394
- return {
1395
- valid: true,
1396
- amount: BlockchainAmount({ raw, decimals })
1397
- };
1398
- } catch {
1399
- return { valid: false, reason: { type: "invalid-format" } };
1687
+ async createParticipation(params) {
1688
+ return this.log.wrap("createParticipation", params, async () => {
1689
+ await this.ctx.ensureUserAuthenticated();
1690
+ return createParticipation(this.ctx.api, params);
1691
+ });
1400
1692
  }
1401
- }
1693
+ };
1402
1694
 
1403
1695
  // src/universal/types/providers/ondo/ondo.ts
1404
1696
  var OndoTradingStatus = {
@@ -1454,7 +1746,7 @@ var OndoBuyTransaction = {
1454
1746
  raw: dto.notional_value,
1455
1747
  decimals: spendDecimals
1456
1748
  }),
1457
- receiveOutputAmount: parsePositiveAmount({
1749
+ receiveOutputAmount: positiveAmountFromRawOrThrow({
1458
1750
  label: "receive_output_amount",
1459
1751
  raw: dto.receive_output_amount,
1460
1752
  decimals: outputDecimals,
@@ -1473,7 +1765,7 @@ var OndoSellTransaction = {
1473
1765
  fromDto: (dto) => {
1474
1766
  const spendDecimals = AssetDecimals(dto.spend_input_decimals);
1475
1767
  const outputDecimals = AssetDecimals(dto.receive_output_decimals);
1476
- const expectedQuantity = parsePositiveAmount({
1768
+ const expectedQuantity = positiveAmountFromRawOrThrow({
1477
1769
  label: "expected_quantity",
1478
1770
  raw: dto.expected_quantity,
1479
1771
  decimals: outputDecimals,
@@ -1507,12 +1799,12 @@ var OndoSellTransaction = {
1507
1799
  };
1508
1800
  function parseSwapCore(dto, spendDecimals) {
1509
1801
  return {
1510
- tx: {
1511
- to: EvmContractAddress(dto.to),
1512
- data: HexEncodedTransactionData(dto.data)
1513
- },
1514
- expiresAt: parseExpiresAt(dto.expires_at),
1515
- spendInputAmount: parsePositiveAmount({
1802
+ tx: txFromWire(dto),
1803
+ // A transaction whose expiry cannot be read is not safely fillable - the
1804
+ // deadline is encoded in the calldata either way, so broadcasting against
1805
+ // an unknown one only spends gas on a revert.
1806
+ expiresAt: requiredDate(dto.expires_at, "expires_at"),
1807
+ spendInputAmount: positiveAmountFromRawOrThrow({
1516
1808
  label: "spend_input_amount",
1517
1809
  raw: dto.spend_input_amount,
1518
1810
  decimals: spendDecimals,
@@ -1530,7 +1822,7 @@ function parseSwapCore(dto, spendDecimals) {
1530
1822
  };
1531
1823
  }
1532
1824
  function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1533
- const amount = parsePositiveAmount({
1825
+ const amount = positiveAmountFromRawOrThrow({
1534
1826
  label: "minimum_quantity",
1535
1827
  raw,
1536
1828
  decimals,
@@ -1543,27 +1835,6 @@ function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1543
1835
  }
1544
1836
  return amount;
1545
1837
  }
1546
- function parsePositiveAmount({
1547
- label,
1548
- raw,
1549
- decimals,
1550
- reason
1551
- }) {
1552
- const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
1553
- if (amount.raw <= 0n) {
1554
- throw new ValidationError(
1555
- `${label}: must be greater than zero ("${raw}") - ${reason}`
1556
- );
1557
- }
1558
- return amount;
1559
- }
1560
- function parseExpiresAt(value) {
1561
- const date = new Date(value);
1562
- if (Number.isNaN(date.getTime())) {
1563
- throw new ValidationError(`expires_at: not a date ("${value}")`);
1564
- }
1565
- return date;
1566
- }
1567
1838
 
1568
1839
  // src/universal/api/frontline/providers/ondo/ondo.ts
1569
1840
  async function getOndoTradingStatus(api, params) {
@@ -1629,18 +1900,6 @@ function swapBody(params) {
1629
1900
  amount: params.amount.raw.toString()
1630
1901
  };
1631
1902
  }
1632
- function assertSpendScaleAgrees({
1633
- published,
1634
- sized,
1635
- trade,
1636
- note
1637
- }) {
1638
- if (published === sized.decimals) return;
1639
- const because = note === void 0 ? "" : ` - ${note}`;
1640
- throw new ValidationError(
1641
- `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
1642
- );
1643
- }
1644
1903
  function sizeParam(params) {
1645
1904
  const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
1646
1905
  const notionalValue = "notionalValue" in params ? params.notionalValue : void 0;
@@ -1660,7 +1919,7 @@ function sizeParam(params) {
1660
1919
  return { notional_value: notionalValue };
1661
1920
  }
1662
1921
 
1663
- // src/universal/core/checkout/ondo/ondo-namespace.ts
1922
+ // src/universal/core/providers/checkout/ondo/ondo-namespace.ts
1664
1923
  var OndoNamespaceImpl = class {
1665
1924
  constructor(ctx) {
1666
1925
  this.ctx = ctx;
@@ -1692,7 +1951,101 @@ var OndoNamespaceImpl = class {
1692
1951
  }
1693
1952
  };
1694
1953
 
1695
- // src/universal/core/checkout/superstate/blockchain/abi.ts
1954
+ // src/universal/types/providers/superstate/swap.ts
1955
+ var SwapPreview = {
1956
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
1957
+ fromContract: (preview) => ({
1958
+ inputAmount: parseUint256(preview.input, "SwapPreview.input"),
1959
+ fee: parseUint256(preview.fee, "SwapPreview.fee"),
1960
+ outputAmount: parseUint256(preview.output, "SwapPreview.output")
1961
+ })
1962
+ };
1963
+ var PauseFlags = (value) => value;
1964
+ var SwapStatus = {
1965
+ /**
1966
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
1967
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
1968
+ *
1969
+ * `flags` is carried onto the `paused` arm only. On the other two the
1970
+ * contract sets it to a self-identifying marker rather than to information -
1971
+ * so repeating it would invite a caller to read meaning into a constant.
1972
+ *
1973
+ * @throws ValidationError on a `state` outside the enum. A contract that has
1974
+ * grown a fourth state is one the SDK does not model, and guessing `active`
1975
+ * would let a halted swap read as a live one.
1976
+ */
1977
+ fromContract: (status) => {
1978
+ switch (status.state) {
1979
+ case 0:
1980
+ return { state: "active" };
1981
+ case 1:
1982
+ return { state: "paused", pausedLevels: PauseFlags(status.flags) };
1983
+ case 2:
1984
+ return { state: "stopped" };
1985
+ default:
1986
+ throw new ValidationError(
1987
+ `SwapStatus.state: unknown contract state (${status.state})`
1988
+ );
1989
+ }
1990
+ }
1991
+ };
1992
+ var AllowWalletResponse = {
1993
+ fromDto: (dto) => {
1994
+ switch (dto.action) {
1995
+ case "broadcast_transaction":
1996
+ return {
1997
+ action: "broadcast_transaction",
1998
+ tx: txFromWire(dto)
1999
+ };
2000
+ case "none":
2001
+ return {
2002
+ action: "none",
2003
+ alreadyAllowed: dto.already_allowed
2004
+ };
2005
+ default: {
2006
+ const _exhaustive = dto;
2007
+ return _exhaustive;
2008
+ }
2009
+ }
2010
+ }
2011
+ };
2012
+
2013
+ // src/universal/core/providers/checkout/superstate/blockchain/quote.ts
2014
+ var SwapQuote = {
2015
+ /**
2016
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
2017
+ * input and fee are denominated in the input token; the output in the output
2018
+ * token.
2019
+ */
2020
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
2021
+ inputTokenAmount: BlockchainAmount({
2022
+ raw: preview.inputAmount,
2023
+ decimals: inputDecimals
2024
+ }),
2025
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
2026
+ outputTokenAmount: BlockchainAmount({
2027
+ raw: preview.outputAmount,
2028
+ decimals: outputDecimals
2029
+ })
2030
+ })
2031
+ };
2032
+
2033
+ // src/universal/api/frontline/providers/superstate/swap.ts
2034
+ async function allowWallet(api, params) {
2035
+ const dto = await api.send({
2036
+ method: "POST",
2037
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2038
+ body: {
2039
+ wallet_address: params.walletAddress,
2040
+ chain: params.chain,
2041
+ signature: params.signature
2042
+ },
2043
+ attributes: Attributes.protected()
2044
+ });
2045
+ return AllowWalletResponse.fromDto(dto);
2046
+ }
2047
+
2048
+ // src/universal/core/providers/checkout/superstate/blockchain/abi.ts
1696
2049
  var SUPERSTATE_SWAP_ABI = [
1697
2050
  {
1698
2051
  type: "function",
@@ -2545,100 +2898,125 @@ var SUPERSTATE_SWAP_ABI = [
2545
2898
  type: "error",
2546
2899
  name: "SwapFailed",
2547
2900
  inputs: [
2548
- {
2549
- name: "user",
2550
- type: "address",
2551
- internalType: "address"
2552
- },
2553
- {
2554
- name: "token",
2555
- type: "address",
2556
- internalType: "address"
2557
- }
2558
- ]
2901
+ {
2902
+ name: "user",
2903
+ type: "address",
2904
+ internalType: "address"
2905
+ },
2906
+ {
2907
+ name: "token",
2908
+ type: "address",
2909
+ internalType: "address"
2910
+ }
2911
+ ]
2912
+ },
2913
+ {
2914
+ type: "error",
2915
+ name: "Unauthorized",
2916
+ inputs: []
2917
+ }
2918
+ ];
2919
+
2920
+ // src/universal/core/shared/blockchain/erc20/abi.ts
2921
+ var ERC20_ABI = [
2922
+ {
2923
+ type: "function",
2924
+ name: "allowance",
2925
+ inputs: [
2926
+ { name: "owner", type: "address" },
2927
+ { name: "spender", type: "address" }
2928
+ ],
2929
+ outputs: [{ name: "", type: "uint256" }],
2930
+ stateMutability: "view"
2931
+ },
2932
+ {
2933
+ type: "function",
2934
+ name: "approve",
2935
+ inputs: [
2936
+ { name: "spender", type: "address" },
2937
+ { name: "amount", type: "uint256" }
2938
+ ],
2939
+ outputs: [{ name: "", type: "bool" }],
2940
+ stateMutability: "nonpayable"
2941
+ },
2942
+ {
2943
+ type: "function",
2944
+ name: "balanceOf",
2945
+ inputs: [{ name: "account", type: "address" }],
2946
+ outputs: [{ name: "", type: "uint256" }],
2947
+ stateMutability: "view"
2948
+ },
2949
+ {
2950
+ type: "function",
2951
+ name: "decimals",
2952
+ inputs: [],
2953
+ outputs: [{ name: "", type: "uint8" }],
2954
+ stateMutability: "view"
2955
+ },
2956
+ {
2957
+ type: "function",
2958
+ name: "name",
2959
+ inputs: [],
2960
+ outputs: [{ name: "", type: "string" }],
2961
+ stateMutability: "view"
2962
+ },
2963
+ {
2964
+ type: "function",
2965
+ name: "symbol",
2966
+ inputs: [],
2967
+ outputs: [{ name: "", type: "string" }],
2968
+ stateMutability: "view"
2969
+ },
2970
+ {
2971
+ type: "function",
2972
+ name: "totalSupply",
2973
+ inputs: [],
2974
+ outputs: [{ name: "", type: "uint256" }],
2975
+ stateMutability: "view"
2976
+ },
2977
+ {
2978
+ type: "function",
2979
+ name: "transfer",
2980
+ inputs: [
2981
+ { name: "recipient", type: "address" },
2982
+ { name: "amount", type: "uint256" }
2983
+ ],
2984
+ outputs: [{ name: "", type: "bool" }],
2985
+ stateMutability: "nonpayable"
2986
+ },
2987
+ {
2988
+ type: "function",
2989
+ name: "transferFrom",
2990
+ inputs: [
2991
+ { name: "sender", type: "address" },
2992
+ { name: "recipient", type: "address" },
2993
+ { name: "amount", type: "uint256" }
2994
+ ],
2995
+ outputs: [{ name: "", type: "bool" }],
2996
+ stateMutability: "nonpayable"
2997
+ },
2998
+ {
2999
+ type: "event",
3000
+ name: "Approval",
3001
+ inputs: [
3002
+ { name: "owner", type: "address", indexed: true },
3003
+ { name: "spender", type: "address", indexed: true },
3004
+ { name: "value", type: "uint256", indexed: false }
3005
+ ],
3006
+ anonymous: false
2559
3007
  },
2560
3008
  {
2561
- type: "error",
2562
- name: "Unauthorized",
2563
- inputs: []
3009
+ type: "event",
3010
+ name: "Transfer",
3011
+ inputs: [
3012
+ { name: "from", type: "address", indexed: true },
3013
+ { name: "to", type: "address", indexed: true },
3014
+ { name: "value", type: "uint256", indexed: false }
3015
+ ],
3016
+ anonymous: false
2564
3017
  }
2565
3018
  ];
2566
3019
 
2567
- // src/universal/types/providers/superstate/swap.ts
2568
- var SwapPreview = {
2569
- /** Maps the contract's `Preview { input, fee, output }` struct. */
2570
- fromContract: (preview) => ({
2571
- inputAmount: parseUint256(preview.input, "SwapPreview.input"),
2572
- fee: parseUint256(preview.fee, "SwapPreview.fee"),
2573
- outputAmount: parseUint256(preview.output, "SwapPreview.output")
2574
- })
2575
- };
2576
- var PauseFlags = (value) => value;
2577
- var SwapStatus = {
2578
- /**
2579
- * Maps the contract's `Status { uint32 flags; State state }` struct, where
2580
- * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2581
- *
2582
- * `flags` is carried onto the `paused` arm only. On the other two the
2583
- * contract sets it to a self-identifying marker rather than to information -
2584
- * so repeating it would invite a caller to read meaning into a constant.
2585
- *
2586
- * @throws ValidationError on a `state` outside the enum. A contract that has
2587
- * grown a fourth state is one the SDK does not model, and guessing `active`
2588
- * would let a halted swap read as a live one.
2589
- */
2590
- fromContract: (status) => {
2591
- switch (status.state) {
2592
- case 0:
2593
- return { state: "active" };
2594
- case 1:
2595
- return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2596
- case 2:
2597
- return { state: "stopped" };
2598
- default:
2599
- throw new ValidationError(
2600
- `SwapStatus.state: unknown contract state (${status.state})`
2601
- );
2602
- }
2603
- }
2604
- };
2605
- var AllowWalletResponse = {
2606
- fromDto: (dto) => {
2607
- switch (dto.action) {
2608
- case "broadcast_transaction":
2609
- return {
2610
- action: "broadcast_transaction",
2611
- to: EvmContractAddress(dto.to),
2612
- data: HexEncodedTransactionData(dto.data)
2613
- };
2614
- case "none":
2615
- return {
2616
- action: "none",
2617
- alreadyAllowed: dto.already_allowed
2618
- };
2619
- default: {
2620
- const _exhaustive = dto;
2621
- return _exhaustive;
2622
- }
2623
- }
2624
- }
2625
- };
2626
-
2627
- // src/universal/api/frontline/providers/superstate/swap.ts
2628
- async function allowWallet(api, params) {
2629
- const dto = await api.send({
2630
- method: "POST",
2631
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2632
- body: {
2633
- wallet_address: params.walletAddress,
2634
- chain: params.chain,
2635
- signature: params.signature
2636
- },
2637
- attributes: Attributes.protected()
2638
- });
2639
- return AllowWalletResponse.fromDto(dto);
2640
- }
2641
-
2642
3020
  // src/universal/api/rpc/providers/superstate/swap.ts
2643
3021
  async function getSwapAuthorization(clients, params) {
2644
3022
  return clients(params.chain).readContract({
@@ -2688,7 +3066,7 @@ async function getSwapOutputToken(clients, params) {
2688
3066
  };
2689
3067
  }
2690
3068
 
2691
- // src/universal/core/checkout/superstate/swap-namespace.ts
3069
+ // src/universal/core/providers/checkout/superstate/swap-namespace.ts
2692
3070
  var SuperstateSwapNamespaceImpl = class {
2693
3071
  constructor(ctx) {
2694
3072
  this.ctx = ctx;
@@ -2708,6 +3086,20 @@ var SuperstateSwapNamespaceImpl = class {
2708
3086
  async () => getSwapPreview(this.ctx.rpc, params)
2709
3087
  );
2710
3088
  }
3089
+ async getQuote(params) {
3090
+ return this.log.wrap("getQuote", params, async () => {
3091
+ const { amount, outputTokenDecimals, ...ref } = params;
3092
+ const preview = await getSwapPreview(this.ctx.rpc, {
3093
+ ...ref,
3094
+ amount: amount.raw
3095
+ });
3096
+ return SwapQuote.fromPreview(
3097
+ preview,
3098
+ amount.decimals,
3099
+ outputTokenDecimals
3100
+ );
3101
+ });
3102
+ }
2711
3103
  async getStatus(params) {
2712
3104
  return this.log.wrap(
2713
3105
  "getStatus",
@@ -2866,40 +3258,181 @@ var RequirementsNamespaceImpl = class {
2866
3258
  await this.ctx.ensureUserAuthenticated();
2867
3259
  return fetchOfferRequirements(
2868
3260
  this.ctx.api,
2869
- offerId,
2870
- void 0
3261
+ offerId,
3262
+ void 0
3263
+ );
3264
+ });
3265
+ }
3266
+ async statuses(offerId) {
3267
+ return this.log.wrap("statuses", offerId, async () => {
3268
+ await this.ctx.ensureUserAuthenticated();
3269
+ return fetchRequirementStatuses(this.ctx.api, offerId);
3270
+ });
3271
+ }
3272
+ async createKycToken(params) {
3273
+ return this.log.wrap("createKycToken", params, async () => {
3274
+ await this.ctx.ensureUserAuthenticated();
3275
+ return createKycToken(
3276
+ this.ctx.api,
3277
+ params?.levelName,
3278
+ params?.reset
3279
+ );
3280
+ });
3281
+ }
3282
+ async getPii() {
3283
+ return this.log.wrap("getPii", void 0, async () => {
3284
+ await this.ctx.ensureUserAuthenticated();
3285
+ return fetchPii(this.ctx.api);
3286
+ });
3287
+ }
3288
+ async submitDocument(params) {
3289
+ return this.log.wrap("submitDocument", params, async () => {
3290
+ await this.ctx.ensureUserAuthenticated();
3291
+ return submitDocument(
3292
+ this.ctx.api,
3293
+ params.documentType,
3294
+ params.fields
3295
+ );
3296
+ });
3297
+ }
3298
+ };
3299
+
3300
+ // src/universal/types/offer-option-address.ts
3301
+ var OfferOptionAddressId = (value) => value;
3302
+ var OfferOptionAddress = {
3303
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
3304
+ fromDto: (dto) => ({
3305
+ id: OfferOptionAddressId(dto.id),
3306
+ offerOptionId: OfferOptionId(dto.offer_option_id),
3307
+ address: EvmWalletAddress(dto.address),
3308
+ protocol: dto.protocol,
3309
+ createdAt: new Date(dto.created_at)
3310
+ })
3311
+ };
3312
+ var ConnectExternalWalletParams = {
3313
+ /** Maps connect-wallet params into the API DTO payload. */
3314
+ toDto: (params) => ({
3315
+ offer_option_id: params.offerOptionId,
3316
+ wallet_address: params.walletAddress,
3317
+ chain: params.chain,
3318
+ signature: params.signature
3319
+ })
3320
+ };
3321
+
3322
+ // src/universal/types/wallet-ownership-challenge.ts
3323
+ var WalletOwnershipChallenge = {
3324
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3325
+ fromDto: (dto) => ({
3326
+ message: dto.message,
3327
+ expiresAt: new Date(dto.expires_at)
3328
+ })
3329
+ };
3330
+ var CreateWalletOwnershipChallengeParams = {
3331
+ /**
3332
+ * Maps challenge-request params into the API DTO payload. The discriminated
3333
+ * union guarantees SIWE fields are present exactly when `challengeType` is
3334
+ * `siwe`, so the mapping narrows on the discriminant.
3335
+ */
3336
+ toDto: (params) => {
3337
+ switch (params.challengeType) {
3338
+ case "plain":
3339
+ return {
3340
+ wallet_address: params.walletAddress,
3341
+ chain: params.chain,
3342
+ challenge_type: "plain"
3343
+ };
3344
+ case "siwe":
3345
+ return {
3346
+ wallet_address: params.walletAddress,
3347
+ chain: params.chain,
3348
+ challenge_type: "siwe",
3349
+ domain: params.domain,
3350
+ uri: params.uri,
3351
+ statement: params.statement
3352
+ };
3353
+ default: {
3354
+ const _exhaustive = params;
3355
+ return _exhaustive;
3356
+ }
3357
+ }
3358
+ }
3359
+ };
3360
+
3361
+ // src/universal/api/frontline/wallet-connect.ts
3362
+ async function createWalletOwnershipChallenge(api, params) {
3363
+ const dto = await api.send({
3364
+ method: "POST",
3365
+ url: "/v1/wallet-ownership",
3366
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
3367
+ attributes: Attributes.protected()
3368
+ });
3369
+ return WalletOwnershipChallenge.fromDto(dto);
3370
+ }
3371
+ async function connectExternalWallet(api, params) {
3372
+ const dto = await api.send({
3373
+ method: "POST",
3374
+ url: `/v1/offers/${params.offerId}/addresses`,
3375
+ body: ConnectExternalWalletParams.toDto(params),
3376
+ attributes: Attributes.protected()
3377
+ });
3378
+ return OfferOptionAddress.fromDto(dto);
3379
+ }
3380
+ async function listOptionAddresses(api, offerId, offerOptionId) {
3381
+ const { data } = await api.send({
3382
+ method: "GET",
3383
+ url: `/v1/offers/${offerId}/addresses`,
3384
+ queryParams: { offer_option_id: offerOptionId },
3385
+ attributes: Attributes.protected()
3386
+ });
3387
+ return data.map(OfferOptionAddress.fromDto);
3388
+ }
3389
+ async function removeOptionAddress(api, offerId, addressId) {
3390
+ const dto = await api.send({
3391
+ method: "DELETE",
3392
+ url: `/v1/offers/${offerId}/addresses/${addressId}`,
3393
+ attributes: Attributes.protected()
3394
+ });
3395
+ return OfferOptionAddress.fromDto(dto);
3396
+ }
3397
+
3398
+ // src/universal/core/wallets/wallets-namespace.ts
3399
+ var WalletsNamespaceImpl = class {
3400
+ constructor(ctx) {
3401
+ this.ctx = ctx;
3402
+ this.log = internalLogger(ctx.logger, "WALLETS");
3403
+ }
3404
+ async createOwnershipChallenge(params) {
3405
+ return this.log.wrap("createOwnershipChallenge", params, async () => {
3406
+ await this.ctx.ensureUserAuthenticated();
3407
+ return createWalletOwnershipChallenge(
3408
+ this.ctx.api,
3409
+ params
2871
3410
  );
2872
3411
  });
2873
3412
  }
2874
- async statuses(offerId) {
2875
- return this.log.wrap("statuses", offerId, async () => {
3413
+ async connectExternal(params) {
3414
+ return this.log.wrap("connectExternal", params, async () => {
2876
3415
  await this.ctx.ensureUserAuthenticated();
2877
- return fetchRequirementStatuses(this.ctx.api, offerId);
3416
+ return connectExternalWallet(this.ctx.api, params);
2878
3417
  });
2879
3418
  }
2880
- async createKycToken(params) {
2881
- return this.log.wrap("createKycToken", params, async () => {
3419
+ async list(params) {
3420
+ return this.log.wrap("list", params, async () => {
2882
3421
  await this.ctx.ensureUserAuthenticated();
2883
- return createKycToken(
3422
+ return listOptionAddresses(
2884
3423
  this.ctx.api,
2885
- params?.levelName,
2886
- params?.reset
3424
+ params.offerId,
3425
+ params.offerOptionId
2887
3426
  );
2888
3427
  });
2889
3428
  }
2890
- async getPii() {
2891
- return this.log.wrap("getPii", void 0, async () => {
2892
- await this.ctx.ensureUserAuthenticated();
2893
- return fetchPii(this.ctx.api);
2894
- });
2895
- }
2896
- async submitDocument(params) {
2897
- return this.log.wrap("submitDocument", params, async () => {
3429
+ async remove(params) {
3430
+ return this.log.wrap("remove", params, async () => {
2898
3431
  await this.ctx.ensureUserAuthenticated();
2899
- return submitDocument(
3432
+ return removeOptionAddress(
2900
3433
  this.ctx.api,
2901
- params.documentType,
2902
- params.fields
3434
+ params.offerId,
3435
+ params.addressId
2903
3436
  );
2904
3437
  });
2905
3438
  }
@@ -3327,163 +3860,6 @@ var TokensNamespaceImpl = class {
3327
3860
  }
3328
3861
  };
3329
3862
 
3330
- // src/universal/types/offer-option-address.ts
3331
- var OfferOptionAddressId = (value) => value;
3332
- var OfferOptionAddress = {
3333
- /** Maps the API DTO into the SDK offer-option-address domain model. */
3334
- fromDto: (dto) => ({
3335
- id: OfferOptionAddressId(dto.id),
3336
- offerOptionId: OfferOptionId(dto.offer_option_id),
3337
- address: EvmWalletAddress(dto.address),
3338
- protocol: dto.protocol,
3339
- createdAt: new Date(dto.created_at)
3340
- })
3341
- };
3342
- var ConnectExternalWalletParams = {
3343
- /** Maps connect-wallet params into the API DTO payload. */
3344
- toDto: (params) => ({
3345
- offer_option_id: params.offerOptionId,
3346
- wallet_address: params.walletAddress,
3347
- chain: params.chain,
3348
- signature: params.signature
3349
- })
3350
- };
3351
-
3352
- // src/universal/types/wallet-ownership-challenge.ts
3353
- var WalletOwnershipChallenge = {
3354
- /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3355
- fromDto: (dto) => ({
3356
- message: dto.message,
3357
- expiresAt: new Date(dto.expires_at)
3358
- })
3359
- };
3360
- var CreateWalletOwnershipChallengeParams = {
3361
- /**
3362
- * Maps challenge-request params into the API DTO payload. The discriminated
3363
- * union guarantees SIWE fields are present exactly when `challengeType` is
3364
- * `siwe`, so the mapping narrows on the discriminant.
3365
- */
3366
- toDto: (params) => {
3367
- switch (params.challengeType) {
3368
- case "plain":
3369
- return {
3370
- wallet_address: params.walletAddress,
3371
- chain: params.chain,
3372
- challenge_type: "plain"
3373
- };
3374
- case "siwe":
3375
- return {
3376
- wallet_address: params.walletAddress,
3377
- chain: params.chain,
3378
- challenge_type: "siwe",
3379
- domain: params.domain,
3380
- uri: params.uri,
3381
- statement: params.statement
3382
- };
3383
- default: {
3384
- const _exhaustive = params;
3385
- return _exhaustive;
3386
- }
3387
- }
3388
- }
3389
- };
3390
-
3391
- // src/universal/api/frontline/wallet-connect.ts
3392
- async function createWalletOwnershipChallenge(api, params) {
3393
- const dto = await api.send({
3394
- method: "POST",
3395
- url: "/v1/wallet-ownership",
3396
- body: CreateWalletOwnershipChallengeParams.toDto(params),
3397
- attributes: Attributes.protected()
3398
- });
3399
- return WalletOwnershipChallenge.fromDto(dto);
3400
- }
3401
- async function connectExternalWallet(api, params) {
3402
- const dto = await api.send({
3403
- method: "POST",
3404
- url: `/v1/offers/${params.offerId}/addresses`,
3405
- body: ConnectExternalWalletParams.toDto(params),
3406
- attributes: Attributes.protected()
3407
- });
3408
- return OfferOptionAddress.fromDto(dto);
3409
- }
3410
- async function listOptionAddresses(api, offerId, offerOptionId) {
3411
- const { data } = await api.send({
3412
- method: "GET",
3413
- url: `/v1/offers/${offerId}/addresses`,
3414
- queryParams: { offer_option_id: offerOptionId },
3415
- attributes: Attributes.protected()
3416
- });
3417
- return data.map(OfferOptionAddress.fromDto);
3418
- }
3419
- async function removeOptionAddress(api, offerId, addressId) {
3420
- const dto = await api.send({
3421
- method: "DELETE",
3422
- url: `/v1/offers/${offerId}/addresses/${addressId}`,
3423
- attributes: Attributes.protected()
3424
- });
3425
- return OfferOptionAddress.fromDto(dto);
3426
- }
3427
-
3428
- // src/universal/core/wallets/wallets-namespace.ts
3429
- var WalletsNamespaceImpl = class {
3430
- constructor(ctx) {
3431
- this.ctx = ctx;
3432
- this.log = internalLogger(ctx.logger, "WALLETS");
3433
- }
3434
- async createOwnershipChallenge(params) {
3435
- return this.log.wrap("createOwnershipChallenge", params, async () => {
3436
- await this.ctx.ensureUserAuthenticated();
3437
- return createWalletOwnershipChallenge(
3438
- this.ctx.api,
3439
- params
3440
- );
3441
- });
3442
- }
3443
- async connectExternal(params) {
3444
- return this.log.wrap("connectExternal", params, async () => {
3445
- await this.ctx.ensureUserAuthenticated();
3446
- return connectExternalWallet(this.ctx.api, params);
3447
- });
3448
- }
3449
- async list(params) {
3450
- return this.log.wrap("list", params, async () => {
3451
- await this.ctx.ensureUserAuthenticated();
3452
- return listOptionAddresses(
3453
- this.ctx.api,
3454
- params.offerId,
3455
- params.offerOptionId
3456
- );
3457
- });
3458
- }
3459
- async remove(params) {
3460
- return this.log.wrap("remove", params, async () => {
3461
- await this.ctx.ensureUserAuthenticated();
3462
- return removeOptionAddress(
3463
- this.ctx.api,
3464
- params.offerId,
3465
- params.addressId
3466
- );
3467
- });
3468
- }
3469
- };
3470
-
3471
- // src/universal/types/oauth-session.ts
3472
- var ClientCredentialsOAuth = (value) => value;
3473
- var OAuthRefreshToken = (value) => value;
3474
- var OAuthSession = {
3475
- fromDto: (dto) => {
3476
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
3477
- return {
3478
- accessToken: {
3479
- value: dto.access_token,
3480
- expiresAt
3481
- },
3482
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
3483
- };
3484
- }
3485
- };
3486
-
3487
3863
  // src/universal/api/frontline/offers.ts
3488
3864
  async function fetchOffers(api, clientCreds) {
3489
3865
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
@@ -3540,6 +3916,7 @@ export {
3540
3916
  ValidationError,
3541
3917
  InvariantError,
3542
3918
  MathError,
3919
+ classifyLogCause,
3543
3920
  describeErrorUnredacted,
3544
3921
  internalLogger,
3545
3922
  HttpClient,
@@ -3548,13 +3925,18 @@ export {
3548
3925
  Seconds,
3549
3926
  isExpired,
3550
3927
  ERC20_ABI,
3551
- fetchAllPages,
3552
- Cursor,
3553
- PaginatedResponse,
3554
- PaginationParams,
3555
- AssetId,
3556
- AssetCode,
3557
- Asset,
3928
+ FormattedAmountUi,
3929
+ FormattedPercentUi,
3930
+ TxExplorerUrl,
3931
+ ShortenedWalletAddress,
3932
+ FormattedAmountAssetUi,
3933
+ AssetIconUrl,
3934
+ viemChain,
3935
+ getChainId,
3936
+ chainFromId,
3937
+ contractOn,
3938
+ getNetworkName,
3939
+ txExplorerUrl,
3558
3940
  ETHEREUM_CHAINS,
3559
3941
  EthereumChain,
3560
3942
  SOLANA_CHAINS,
@@ -3576,9 +3958,37 @@ export {
3576
3958
  StablecoinSymbol,
3577
3959
  KnownAssetSymbol,
3578
3960
  Bps,
3579
- requiredDate,
3580
- dateOrNull,
3581
- decimalOrNull,
3961
+ blockchainAmountFromRawOrThrow,
3962
+ positiveAmountFromRawOrThrow,
3963
+ pricePerShare,
3964
+ parseBlockchainAmount,
3965
+ CentrifugeVaultStatus,
3966
+ CentrifugeVaultBuyTransaction,
3967
+ CentrifugeVaultClaimTransaction,
3968
+ CentrifugeAssets,
3969
+ CentrifugeShares,
3970
+ CentrifugeDepositPosition,
3971
+ CentrifugeRedeemPosition,
3972
+ CentrifugeVaultLeg,
3973
+ CentrifugeVaultLegId,
3974
+ CentrifugeVaultClaimProceedsTransaction,
3975
+ CentrifugeNamespaceImpl,
3976
+ shortenAddress,
3977
+ formatAmount,
3978
+ formatRawAmount,
3979
+ formatCompactAmount,
3980
+ formatBpsAsPercent,
3981
+ usdAmount,
3982
+ assetAmount,
3983
+ NA_AMOUNT_ASSET_UI,
3984
+ formatShareAmount,
3985
+ formattedUsdPrice,
3986
+ Cursor,
3987
+ PaginatedResponse,
3988
+ PaginationParams,
3989
+ AssetId,
3990
+ AssetCode,
3991
+ Asset,
3582
3992
  OfferId,
3583
3993
  OfferSlug,
3584
3994
  isOfferType,
@@ -3587,6 +3997,7 @@ export {
3587
3997
  OfferToken,
3588
3998
  Ticker,
3589
3999
  Isin,
4000
+ AsyncOfferDetail,
3590
4001
  OfferOptionId,
3591
4002
  OfferOptionSlug,
3592
4003
  OfferSwapContract,
@@ -3598,35 +4009,10 @@ export {
3598
4009
  TermItem,
3599
4010
  Milestone,
3600
4011
  ParticipationId,
3601
- Blockchain,
3602
- WalletAddress,
3603
4012
  ParticipationsPaginationParams,
3604
4013
  Participation,
3605
4014
  CreateParticipationParams,
3606
4015
  CoinListTokenSaleNamespaceImpl,
3607
- FormattedAmountUi,
3608
- FormattedPercentUi,
3609
- TxExplorerUrl,
3610
- ShortenedWalletAddress,
3611
- FormattedAmountAssetUi,
3612
- AssetIconUrl,
3613
- shortenAddress,
3614
- formatAmount,
3615
- formatRawAmount,
3616
- formatCompactAmount,
3617
- formatBpsAsPercent,
3618
- usdAmount,
3619
- assetAmount,
3620
- NA_AMOUNT_ASSET_UI,
3621
- formatShareAmount,
3622
- formattedUsdPrice,
3623
- viemChain,
3624
- getChainId,
3625
- chainFromId,
3626
- getNetworkName,
3627
- txExplorerUrl,
3628
- blockchainAmountFromRawOrThrow,
3629
- parseBlockchainAmount,
3630
4016
  OndoTradingStatus,
3631
4017
  OndoQuote,
3632
4018
  OndoBuyTransaction,
@@ -3637,10 +4023,8 @@ export {
3637
4023
  PauseFlags,
3638
4024
  SwapStatus,
3639
4025
  AllowWalletResponse,
4026
+ SwapQuote,
3640
4027
  SuperstateSwapNamespaceImpl,
3641
- fetchOffers,
3642
- fetchOffersPage,
3643
- fetchOfferDetails,
3644
4028
  DocumentSubmission,
3645
4029
  KycToken,
3646
4030
  Iso2CountryCode,
@@ -3652,19 +4036,19 @@ export {
3652
4036
  RequirementStatusInfo,
3653
4037
  fetchOfferRequirements,
3654
4038
  RequirementsNamespaceImpl,
3655
- Erc20NamespaceImpl,
3656
- TokenLogoUrl,
3657
- TokenLogo,
3658
- TokenMetadata,
3659
- TokensNamespaceImpl,
3660
4039
  OfferOptionAddressId,
3661
4040
  OfferOptionAddress,
3662
4041
  ConnectExternalWalletParams,
3663
4042
  WalletOwnershipChallenge,
3664
4043
  CreateWalletOwnershipChallengeParams,
3665
4044
  WalletsNamespaceImpl,
3666
- ClientCredentialsOAuth,
3667
- OAuthRefreshToken,
3668
- OAuthSession
4045
+ fetchOffers,
4046
+ fetchOffersPage,
4047
+ fetchOfferDetails,
4048
+ Erc20NamespaceImpl,
4049
+ TokenLogoUrl,
4050
+ TokenLogo,
4051
+ TokenMetadata,
4052
+ TokensNamespaceImpl
3669
4053
  };
3670
- //# sourceMappingURL=chunk-NBO5E2RO.js.map
4054
+ //# sourceMappingURL=chunk-HMLWCXAP.js.map