@coinlist-co/react 0.12.1-rc.14ac67e → 0.12.1-rc.73e7e17

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 (33) hide show
  1. package/dist/{chunk-SOMNMOBU.js → chunk-3ZZCK4IT.js} +9 -9
  2. package/dist/chunk-3ZZCK4IT.js.map +1 -0
  3. package/dist/{chunk-3ATIDGVR.js → chunk-D42IQHQZ.js} +661 -638
  4. package/dist/chunk-D42IQHQZ.js.map +1 -0
  5. package/dist/{chunk-2XBPKC4C.js → chunk-ZUVVNZJJ.js} +126 -126
  6. package/dist/chunk-ZUVVNZJJ.js.map +1 -0
  7. package/dist/client/index.cjs +1560 -1405
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +375 -237
  10. package/dist/client/index.d.ts +375 -237
  11. package/dist/client/index.js +850 -723
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-DVCh4jUp.d.ts → collections-CMoojQ9M.d.ts} +1 -1
  14. package/dist/{collections-DNbBE6Pk.d.cts → collections-koI4cjYa.d.cts} +1 -1
  15. package/dist/{config-DFYAM0GD.d.cts → config-BmK0t-XO.d.cts} +100 -17
  16. package/dist/{config-DFYAM0GD.d.ts → config-BmK0t-XO.d.ts} +100 -17
  17. package/dist/server/index.cjs +259 -238
  18. package/dist/server/index.cjs.map +1 -1
  19. package/dist/server/index.d.cts +4 -4
  20. package/dist/server/index.d.ts +4 -4
  21. package/dist/server/index.js +3 -3
  22. package/dist/server/index.js.map +1 -1
  23. package/dist/{shared → universal}/index.cjs +870 -843
  24. package/dist/universal/index.cjs.map +1 -0
  25. package/dist/{shared → universal}/index.d.cts +557 -557
  26. package/dist/{shared → universal}/index.d.ts +557 -557
  27. package/dist/{shared → universal}/index.js +6 -2
  28. package/package.json +6 -5
  29. package/dist/chunk-2XBPKC4C.js.map +0 -1
  30. package/dist/chunk-3ATIDGVR.js.map +0 -1
  31. package/dist/chunk-SOMNMOBU.js.map +0 -1
  32. package/dist/shared/index.cjs.map +0 -1
  33. /package/dist/{shared → universal}/index.js.map +0 -0
@@ -1,4 +1,4 @@
1
- // src/shared/api/http-attributes.ts
1
+ // src/universal/api/http-attributes.ts
2
2
  var empty = {};
3
3
  var concat = (left, right) => ({
4
4
  ...left,
@@ -53,7 +53,7 @@ var Attributes = {
53
53
  getRequestId
54
54
  };
55
55
 
56
- // src/shared/api/http.ts
56
+ // src/universal/api/http.ts
57
57
  var HttpError = class extends Error {
58
58
  constructor(response) {
59
59
  super(`Request failed with ${response.status} status`);
@@ -177,7 +177,7 @@ var Request = {
177
177
  concatAttributes
178
178
  };
179
179
 
180
- // src/shared/types/errors.ts
180
+ // src/universal/types/errors.ts
181
181
  var NotImplementedError = class extends Error {
182
182
  constructor(message = "Not implemented yet") {
183
183
  super(message);
@@ -209,7 +209,7 @@ var MathError = class extends Error {
209
209
  }
210
210
  };
211
211
 
212
- // src/shared/api/pagination.ts
212
+ // src/universal/api/pagination.ts
213
213
  async function fetchAllPages(fetchPage, baseParams) {
214
214
  const items = [];
215
215
  let cursor = null;
@@ -225,7 +225,44 @@ async function fetchAllPages(fetchPage, baseParams) {
225
225
  return items;
226
226
  }
227
227
 
228
- // src/shared/types/blockchain/core.ts
228
+ // src/universal/types/pagination.ts
229
+ var Cursor = (value) => value;
230
+ var PaginatedResponse = {
231
+ fromDto: (dto, itemMapper) => ({
232
+ data: dto.data.map(itemMapper),
233
+ startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
234
+ startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
235
+ })
236
+ };
237
+ var PaginationParams = {
238
+ toQueryParams: (params) => {
239
+ const queryParams = {};
240
+ if (params.after) {
241
+ queryParams.starting_after = params.after;
242
+ }
243
+ if (params.before) {
244
+ queryParams.starting_before = params.before;
245
+ }
246
+ if (params.limit) {
247
+ queryParams.limit = params.limit;
248
+ }
249
+ return queryParams;
250
+ }
251
+ };
252
+
253
+ // src/universal/types/asset.ts
254
+ var AssetId = (value) => value;
255
+ var AssetCode = (value) => value;
256
+ var Asset = {
257
+ fromDto: (dto) => ({
258
+ id: AssetId(dto.id),
259
+ code: AssetCode(dto.code),
260
+ name: dto.name,
261
+ fractionalDigits: dto.fractional_digits
262
+ })
263
+ };
264
+
265
+ // src/universal/types/blockchain/core.ts
229
266
  var ETHEREUM_CHAINS = {
230
267
  ethereum_mainnet: true,
231
268
  ethereum_sepolia: true,
@@ -248,8 +285,9 @@ var SolanaChain = (value) => {
248
285
  }
249
286
  return value;
250
287
  };
288
+ var isChain = (value) => Object.keys(ETHEREUM_CHAINS).includes(value) || Object.keys(SOLANA_CHAINS).includes(value);
251
289
  var Chain = (value) => {
252
- if (!Object.keys(ETHEREUM_CHAINS).includes(value) && !Object.keys(SOLANA_CHAINS).includes(value)) {
290
+ if (!isChain(value)) {
253
291
  throw new ValidationError(`Unsupported chain: "${value}"`);
254
292
  }
255
293
  return value;
@@ -321,226 +359,306 @@ var StablecoinSymbol = (value) => value;
321
359
  var KnownAssetSymbol = StablecoinSymbol;
322
360
  var Bps = (value) => value;
323
361
 
324
- // src/shared/types/blockchain/ui.ts
325
- var FormattedAmountUi = (value) => value;
326
- var FormattedPercentUi = (value) => value;
327
- var TxExplorerUrl = (value) => value;
328
- var ShortenedWalletAddress = (value) => value;
329
- var FormattedAmountAssetUi = (value) => value;
330
- var AssetIconUrl = (value) => value;
331
-
332
- // src/shared/core/blockchain/chain.ts
333
- var CHAIN_IDS = {
334
- ethereum_mainnet: 1,
335
- ethereum_sepolia: 11155111,
336
- base_mainnet: 8453,
337
- base_sepolia: 84532
362
+ // src/universal/types/offer.ts
363
+ var OfferId = (value) => value;
364
+ var OfferSlug = (value) => value;
365
+ var Offer = {
366
+ fromDto: (dto) => {
367
+ if (!Array.isArray(dto.tokens)) {
368
+ throw new ValidationError(
369
+ `Offer.tokens: expected an array, got ${typeof dto.tokens}`
370
+ );
371
+ }
372
+ return {
373
+ id: OfferId(dto.id),
374
+ slug: OfferSlug(dto.slug),
375
+ type: dto.type,
376
+ tagline: dto.tagline,
377
+ bannerUrl: dto.banner_url,
378
+ logoUrl: dto.logo_url,
379
+ startsAt: new Date(dto.starts_at),
380
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
381
+ tokens: OfferToken.listFromDto(dto.tokens)
382
+ };
383
+ }
338
384
  };
339
- function getChainId(chain) {
340
- return CHAIN_IDS[chain];
385
+ var OfferToken = {
386
+ fromDto: (dto) => ({
387
+ role: dto.role,
388
+ chain: Chain(dto.chain),
389
+ address: EvmContractAddress(dto.address)
390
+ }),
391
+ /**
392
+ * Maps an offer's token list, dropping every token on a chain this SDK does
393
+ * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
394
+ * plain `.map` would throw out of `Offer.fromDto` and, through
395
+ * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
396
+ * one Base token blanked production's offers list. Dropping costs that
397
+ * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
398
+ * so nobody could have looked it up anyway.
399
+ *
400
+ * Same shape as `TokenMetadata.fromRegistryDto`.
401
+ */
402
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
403
+ };
404
+
405
+ // src/universal/types/trading.ts
406
+ var Ticker = (value) => value;
407
+ var Isin = (value) => value;
408
+
409
+ // src/universal/core/shared/utils/crypto.ts
410
+ async function sha256(data) {
411
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
412
+ const buffer = bytes.buffer.slice(
413
+ bytes.byteOffset,
414
+ bytes.byteOffset + bytes.byteLength
415
+ );
416
+ return crypto.subtle.digest("SHA-256", buffer);
341
417
  }
342
- function chainFromId(chainId) {
343
- const chains = Object.keys(CHAIN_IDS);
344
- const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
345
- if (!chain) {
346
- throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
418
+ function arrayBufferToBase64Url(buffer, padding = true) {
419
+ const bytes = new Uint8Array(buffer);
420
+ let binary = "";
421
+ for (let i = 0; i < bytes.length; i++) {
422
+ binary += String.fromCharCode(bytes[i]);
347
423
  }
348
- return chain;
349
- }
350
- function getNetworkName(chain) {
351
- switch (chain) {
352
- case "ethereum_mainnet":
353
- return "Ethereum";
354
- case "ethereum_sepolia":
355
- return "Ethereum Sepolia";
356
- case "base_mainnet":
357
- return "Base";
358
- case "base_sepolia":
359
- return "Base Sepolia";
360
- default: {
361
- const _exhaustive = chain;
362
- return _exhaustive;
363
- }
424
+ let base64 = btoa(binary);
425
+ base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
426
+ if (!padding) {
427
+ base64 = base64.replace(/=+$/, "");
364
428
  }
429
+ return base64;
365
430
  }
366
- function txExplorerUrl(chain, txHash) {
367
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
431
+ function generateSecureRandomBase64Url(byteLength) {
432
+ const bytes = new Uint8Array(byteLength);
433
+ crypto.getRandomValues(bytes);
434
+ const buffer = bytes.buffer;
435
+ return arrayBufferToBase64Url(buffer, false);
368
436
  }
369
- function explorerBaseUrl(chain) {
370
- switch (chain) {
371
- case "ethereum_mainnet":
372
- return "https://etherscan.io";
373
- case "ethereum_sepolia":
374
- return "https://sepolia.etherscan.io";
375
- case "base_mainnet":
376
- return "https://basescan.org";
377
- case "base_sepolia":
378
- return "https://sepolia-explorer.base.org";
379
- default: {
380
- const _exhaustive = chain;
381
- return _exhaustive;
382
- }
437
+ function getUUIDv4() {
438
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
439
+ return crypto.randomUUID();
440
+ }
441
+ if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
442
+ const bytes = new Uint8Array(16);
443
+ crypto.getRandomValues(bytes);
444
+ bytes[6] = bytes[6] & 15 | 64;
445
+ bytes[8] = bytes[8] & 63 | 128;
446
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
447
+ return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
448
+ }
449
+ return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
450
+ }
451
+ function notBlankStringOrNull(value) {
452
+ if (value?.trim()) {
453
+ return value;
454
+ } else {
455
+ return null;
383
456
  }
384
457
  }
385
458
 
386
- // src/shared/types/providers/superstate/swap.ts
387
- var SwapAuthorization = {
459
+ // src/universal/types/offer-detail.ts
460
+ var OfferOptionId = (value) => value;
461
+ var OfferOptionSlug = (value) => value;
462
+ var OfferSwapContract = {
388
463
  fromDto: (dto) => ({
389
- authorized: dto.authorized
464
+ chain: Chain(dto.chain),
465
+ address: EvmContractAddress(dto.address)
390
466
  })
391
467
  };
392
- var SwapPreview = {
393
- fromDto: (dto) => ({
394
- inputAmount: parseUint256(
395
- BigInt(dto.pay_input_amount),
396
- "SwapPreview.pay_input_amount"
397
- ),
398
- fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
399
- outputAmount: parseUint256(
400
- BigInt(dto.receive_output_amount),
401
- "SwapPreview.receive_output_amount"
402
- )
403
- })
468
+ var OfferDetail = {
469
+ fromDto: (dto) => {
470
+ if (!Array.isArray(dto.funding_assets)) {
471
+ throw new ValidationError(
472
+ `OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
473
+ );
474
+ }
475
+ if (!Array.isArray(dto.options)) {
476
+ throw new ValidationError(
477
+ `OfferDetail.options: expected an array, got ${typeof dto.options}`
478
+ );
479
+ }
480
+ if (!Array.isArray(dto.terms)) {
481
+ throw new ValidationError(
482
+ `OfferDetail.terms: expected an array, got ${typeof dto.terms}`
483
+ );
484
+ }
485
+ if (!Array.isArray(dto.links)) {
486
+ throw new ValidationError(
487
+ `OfferDetail.links: expected an array, got ${typeof dto.links}`
488
+ );
489
+ }
490
+ if (!Array.isArray(dto.faqs)) {
491
+ throw new ValidationError(
492
+ `OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
493
+ );
494
+ }
495
+ if (!Array.isArray(dto.milestones)) {
496
+ throw new ValidationError(
497
+ `OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
498
+ );
499
+ }
500
+ if (!Array.isArray(dto.tokens)) {
501
+ throw new ValidationError(
502
+ `OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
503
+ );
504
+ }
505
+ const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
506
+ if (!Array.isArray(swapContracts)) {
507
+ throw new ValidationError(
508
+ `OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
509
+ );
510
+ }
511
+ const isin = notBlankStringOrNull(dto.isin);
512
+ const ticker = notBlankStringOrNull(dto.ticker);
513
+ return {
514
+ id: OfferId(dto.id),
515
+ slug: OfferSlug(dto.slug),
516
+ type: dto.type,
517
+ name: dto.name,
518
+ asset: Asset.fromDto(dto.asset),
519
+ fundingAssets: dto.funding_assets.map(Asset.fromDto),
520
+ tokens: OfferToken.listFromDto(dto.tokens),
521
+ swapContracts: swapContracts.map(OfferSwapContract.fromDto),
522
+ about: notBlankStringOrNull(dto.about),
523
+ tagline: dto.tagline,
524
+ bannerUrl: dto.banner_url,
525
+ logoUrl: dto.logo_url,
526
+ category: dto.category,
527
+ issuer: notBlankStringOrNull(dto.issuer),
528
+ isin: isin === null ? null : Isin(isin),
529
+ ticker: ticker === null ? null : Ticker(ticker),
530
+ instrumentType: notBlankStringOrNull(dto.instrument_type),
531
+ listingVenue: notBlankStringOrNull(dto.listing_venue),
532
+ startsAt: new Date(dto.starts_at),
533
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
534
+ faqs: dto.faqs.map(FaqItem.fromDto),
535
+ links: dto.links.map(Link.fromDto),
536
+ milestones: dto.milestones.map(Milestone.fromDto),
537
+ options: dto.options.map(OfferOption.fromDto),
538
+ terms: dto.terms.map(TermItem.fromDto)
539
+ };
540
+ }
404
541
  };
405
- var SwapStatus = {
542
+ var OfferOption = {
406
543
  fromDto: (dto) => ({
407
- stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
408
- swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
544
+ id: OfferOptionId(dto.id),
545
+ slug: OfferOptionSlug(dto.slug),
546
+ bidIncrement: dto.bid_increment,
547
+ floorPriceUsd: dto.floor_price_usd,
548
+ minimumPurchaseUsd: dto.minimum_purchase_usd,
549
+ priceUsd: dto.price_usd,
550
+ saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
551
+ totalTokenSupply: dto.total_token_supply
409
552
  })
410
553
  };
411
- var TokenAllowance = {
554
+ var FaqItem = {
412
555
  fromDto: (dto) => ({
413
- allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
556
+ question: notBlankStringOrNull(dto.question),
557
+ answer: notBlankStringOrNull(dto.answer)
414
558
  })
415
559
  };
416
- var TokenBalance = {
560
+ var Link = {
417
561
  fromDto: (dto) => ({
418
- balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
562
+ label: notBlankStringOrNull(dto.label),
563
+ url: notBlankStringOrNull(dto.url)
419
564
  })
420
565
  };
421
- var AllowWalletResponse = {
422
- fromDto: (dto) => {
423
- switch (dto.action) {
424
- case "broadcast_transaction":
425
- return {
426
- action: "broadcast_transaction",
427
- to: EvmContractAddress(dto.to),
428
- data: HexEncodedTransactionData(dto.data)
429
- };
430
- case "none":
431
- return {
432
- action: "none",
433
- alreadyAllowed: dto.already_allowed
434
- };
435
- default: {
436
- const _exhaustive = dto;
437
- return _exhaustive;
438
- }
566
+ var TermItem = {
567
+ fromDto: (dto) => ({
568
+ key: notBlankStringOrNull(dto.key),
569
+ value: notBlankStringOrNull(dto.value)
570
+ })
571
+ };
572
+ var Milestone = {
573
+ fromDto: (dto) => ({
574
+ name: notBlankStringOrNull(dto.name),
575
+ schedule: notBlankStringOrNull(dto.schedule),
576
+ status: dto.status
577
+ })
578
+ };
579
+
580
+ // src/universal/types/providers/coin-list/token-sale.ts
581
+ var ParticipationId = (value) => value;
582
+ var Blockchain = (value) => value;
583
+ var WalletAddress = (value) => value;
584
+ var ParticipationsPaginationParams = {
585
+ toQueryParams: (params) => {
586
+ const queryParams = PaginationParams.toQueryParams(params);
587
+ if (params.offerId) {
588
+ queryParams["filters[0][field]"] = "offer_id";
589
+ queryParams["filters[0][op]"] = "==";
590
+ queryParams["filters[0][value]"] = params.offerId;
439
591
  }
592
+ return queryParams;
593
+ }
594
+ };
595
+ var Participation = {
596
+ /** Maps API DTO shape into the SDK participation domain model. */
597
+ fromDto: (dto) => {
598
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
599
+ return {
600
+ id: ParticipationId(dto.id),
601
+ offerId: OfferId(dto.offer_id),
602
+ offerOptionId: OfferOptionId(dto.offer_option_id),
603
+ status: dto.status,
604
+ amount: dto.amount,
605
+ displayAmount: dto.amount_string,
606
+ asset: Asset.fromDto(dto.asset),
607
+ chain: Blockchain(dto.chain),
608
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
609
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
610
+ walletAddress: walletAddress ? WalletAddress(walletAddress) : null
611
+ };
440
612
  }
441
613
  };
614
+ var CreateParticipationParams = {
615
+ /** Maps participation creation params into API DTO payload. */
616
+ toDto: (params) => ({
617
+ offer_id: params.offerId,
618
+ offer_option_id: params.offerOptionId,
619
+ chain: params.chain,
620
+ wallet_address: params.walletAddress,
621
+ amount: params.amount,
622
+ asset_id: params.assetId,
623
+ approval_transaction_hash: params.approvalTransactionHash
624
+ })
625
+ };
442
626
 
443
- // src/shared/api/frontline/providers/superstate/swap.ts
444
- async function getSwapAuthorization(api, params) {
445
- const dto = await api.send({
446
- method: "GET",
447
- url: "/v1/wallet/authorized",
448
- queryParams: {
449
- chain: params.chain,
450
- contract_address: params.contractAddress,
451
- wallet_address: params.walletAddress
452
- },
453
- attributes: Attributes.protected()
454
- });
455
- return SwapAuthorization.fromDto(dto);
456
- }
457
- async function getSwapOutputToken(api, params) {
458
- const dto = await api.send({
459
- method: "GET",
460
- url: "/v1/swap/output-token",
461
- queryParams: {
462
- chain: params.chain,
463
- contract_address: params.contractAddress
464
- },
465
- attributes: Attributes.protected()
466
- });
467
- return toErc20Asset(dto);
468
- }
469
- async function getSwapPreview(api, params) {
470
- const dto = await api.send({
471
- method: "GET",
472
- url: "/v1/swap/preview",
473
- queryParams: {
474
- chain: params.chain,
475
- contract_address: params.contractAddress,
476
- input_token: params.inputToken,
477
- amount: params.amount.toString()
478
- },
479
- attributes: Attributes.protected()
480
- });
481
- return SwapPreview.fromDto(dto);
482
- }
483
- async function getSwapStatus(api, params) {
484
- const dto = await api.send({
485
- method: "GET",
486
- url: "/v1/swap/status",
487
- queryParams: {
488
- chain: params.chain,
489
- contract_address: params.contractAddress
490
- },
491
- attributes: Attributes.protected()
492
- });
493
- return SwapStatus.fromDto(dto);
627
+ // src/universal/api/frontline/providers/coin-list/token-sale.ts
628
+ async function fetchParticipations(api, offerId) {
629
+ return fetchAllPages(
630
+ (params) => fetchParticipationsPage(api, params),
631
+ { offerId }
632
+ );
494
633
  }
495
- async function getTokenAllowance(api, params) {
496
- const dto = await api.send({
634
+ async function fetchParticipationsPage(api, params) {
635
+ const pageDto = await api.send({
497
636
  method: "GET",
498
- url: "/v1/token/allowance",
499
- queryParams: {
500
- chain: params.chain,
501
- token_address: params.tokenAddress,
502
- owner: params.owner,
503
- spender: params.spender
504
- },
637
+ url: "/v1/participations",
638
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
505
639
  attributes: Attributes.protected()
506
640
  });
507
- return TokenAllowance.fromDto(dto);
641
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
508
642
  }
509
- async function getTokenBalance(api, params) {
643
+ async function fetchParticipation(api, id) {
510
644
  const dto = await api.send({
511
645
  method: "GET",
512
- url: "/v1/token/balance",
513
- queryParams: {
514
- chain: params.chain,
515
- token_address: params.tokenAddress,
516
- owner: params.owner
517
- },
646
+ url: `/v1/participations/${id}`,
518
647
  attributes: Attributes.protected()
519
648
  });
520
- return TokenBalance.fromDto(dto);
649
+ return Participation.fromDto(dto);
521
650
  }
522
- async function allowWallet(api, params) {
651
+ async function createParticipation(api, params) {
523
652
  const dto = await api.send({
524
653
  method: "POST",
525
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
526
- body: {
527
- wallet_address: params.walletAddress,
528
- chain: params.chain,
529
- signature: params.signature
530
- },
654
+ url: "/v1/participations",
655
+ body: CreateParticipationParams.toDto(params),
531
656
  attributes: Attributes.protected()
532
657
  });
533
- return AllowWalletResponse.fromDto(dto);
534
- }
535
- function toErc20Asset(dto) {
536
- return {
537
- name: dto.name,
538
- symbol: AssetSymbol(dto.symbol),
539
- decimals: AssetDecimals(dto.decimals)
540
- };
658
+ return Participation.fromDto(dto);
541
659
  }
542
660
 
543
- // src/shared/core/observability/log-cause.ts
661
+ // src/universal/core/shared/observability/log-cause.ts
544
662
  function classifyLogCause(error) {
545
663
  if (error instanceof HttpError) {
546
664
  return httpCause(error);
@@ -606,7 +724,7 @@ function apiErrorEventId(error) {
606
724
  return typeof eventId === "string" ? eventId : null;
607
725
  }
608
726
 
609
- // src/shared/core/observability/internal-logger.ts
727
+ // src/universal/core/shared/observability/internal-logger.ts
610
728
  function internalLogger(logger, scope) {
611
729
  return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
612
730
  }
@@ -689,27 +807,47 @@ var noopInternalLogger = {
689
807
  wrap: (_op, _params, run) => run()
690
808
  };
691
809
 
692
- // src/shared/core/blockchain/erc20/erc20-namespace.ts
693
- var Erc20NamespaceImpl = class {
810
+ // src/universal/core/checkout/coin-list/token-sale-namespace.ts
811
+ var CoinListTokenSaleNamespaceImpl = class {
694
812
  constructor(ctx) {
695
813
  this.ctx = ctx;
696
- this.log = internalLogger(ctx.logger, "ERC20");
814
+ this.log = internalLogger(ctx.logger, "TOKEN_SALE");
697
815
  }
698
- async getAllowance(params) {
699
- return this.log.wrap("getAllowance", params, async () => {
816
+ async list(offerId) {
817
+ return this.log.wrap("list", offerId, async () => {
700
818
  await this.ctx.ensureUserAuthenticated();
701
- return getTokenAllowance(this.ctx.api, params);
819
+ return fetchParticipations(this.ctx.api, offerId);
702
820
  });
703
821
  }
704
- async getBalance(params) {
705
- return this.log.wrap("getBalance", params, async () => {
822
+ async listPage(params) {
823
+ return this.log.wrap("listPage", params, async () => {
706
824
  await this.ctx.ensureUserAuthenticated();
707
- return getTokenBalance(this.ctx.api, params);
825
+ return fetchParticipationsPage(this.ctx.api, params);
826
+ });
827
+ }
828
+ async get(id) {
829
+ return this.log.wrap("get", id, async () => {
830
+ await this.ctx.ensureUserAuthenticated();
831
+ return fetchParticipation(this.ctx.api, id);
832
+ });
833
+ }
834
+ async createParticipation(params) {
835
+ return this.log.wrap("createParticipation", params, async () => {
836
+ await this.ctx.ensureUserAuthenticated();
837
+ return createParticipation(this.ctx.api, params);
708
838
  });
709
839
  }
710
840
  };
711
841
 
712
- // src/shared/core/blockchain/formatters.ts
842
+ // src/universal/types/blockchain/ui.ts
843
+ var FormattedAmountUi = (value) => value;
844
+ var FormattedPercentUi = (value) => value;
845
+ var TxExplorerUrl = (value) => value;
846
+ var ShortenedWalletAddress = (value) => value;
847
+ var FormattedAmountAssetUi = (value) => value;
848
+ var AssetIconUrl = (value) => value;
849
+
850
+ // src/universal/core/shared/blockchain/formatters.ts
713
851
  import { formatUnits } from "viem";
714
852
  function shortenAddress(address) {
715
853
  const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
@@ -804,32 +942,86 @@ function formattedUsdPrice(amount, locale) {
804
942
  );
805
943
  }
806
944
 
807
- // src/shared/core/blockchain/math.ts
808
- import { parseUnits } from "viem";
809
- function blockchainAmountFromRawOrThrow({
810
- label,
811
- raw,
812
- decimals
813
- }) {
814
- const trimmed = raw.trim();
815
- if (trimmed === "") {
816
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
817
- }
818
- let value;
819
- try {
820
- value = BigInt(trimmed);
821
- } catch {
822
- throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
823
- }
824
- try {
825
- return BlockchainAmount({ raw: assertUint256(value), decimals });
826
- } catch {
827
- throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
945
+ // src/universal/core/shared/blockchain/chain.ts
946
+ var CHAIN_IDS = {
947
+ ethereum_mainnet: 1,
948
+ ethereum_sepolia: 11155111,
949
+ base_mainnet: 8453,
950
+ base_sepolia: 84532
951
+ };
952
+ function getChainId(chain) {
953
+ return CHAIN_IDS[chain];
954
+ }
955
+ function chainFromId(chainId) {
956
+ const chains = Object.keys(CHAIN_IDS);
957
+ const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
958
+ if (!chain) {
959
+ throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
828
960
  }
961
+ return chain;
829
962
  }
830
- function parseBlockchainAmount(amount, decimals) {
831
- const trimmed = amount.trim();
832
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
963
+ function getNetworkName(chain) {
964
+ switch (chain) {
965
+ case "ethereum_mainnet":
966
+ return "Ethereum";
967
+ case "ethereum_sepolia":
968
+ return "Ethereum Sepolia";
969
+ case "base_mainnet":
970
+ return "Base";
971
+ case "base_sepolia":
972
+ return "Base Sepolia";
973
+ default: {
974
+ const _exhaustive = chain;
975
+ return _exhaustive;
976
+ }
977
+ }
978
+ }
979
+ function txExplorerUrl(chain, txHash) {
980
+ return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
981
+ }
982
+ function explorerBaseUrl(chain) {
983
+ switch (chain) {
984
+ case "ethereum_mainnet":
985
+ return "https://etherscan.io";
986
+ case "ethereum_sepolia":
987
+ return "https://sepolia.etherscan.io";
988
+ case "base_mainnet":
989
+ return "https://basescan.org";
990
+ case "base_sepolia":
991
+ return "https://sepolia-explorer.base.org";
992
+ default: {
993
+ const _exhaustive = chain;
994
+ return _exhaustive;
995
+ }
996
+ }
997
+ }
998
+
999
+ // src/universal/core/shared/blockchain/math.ts
1000
+ import { parseUnits } from "viem";
1001
+ function blockchainAmountFromRawOrThrow({
1002
+ label,
1003
+ raw,
1004
+ decimals
1005
+ }) {
1006
+ const trimmed = raw.trim();
1007
+ if (trimmed === "") {
1008
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1009
+ }
1010
+ let value;
1011
+ try {
1012
+ value = BigInt(trimmed);
1013
+ } catch {
1014
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1015
+ }
1016
+ try {
1017
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
1018
+ } catch {
1019
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1020
+ }
1021
+ }
1022
+ function parseBlockchainAmount(amount, decimals) {
1023
+ const trimmed = amount.trim();
1024
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
833
1025
  if (trimmed.startsWith("-")) {
834
1026
  return { valid: false, reason: { type: "negative" } };
835
1027
  }
@@ -849,366 +1041,18 @@ function parseBlockchainAmount(amount, decimals) {
849
1041
  try {
850
1042
  const raw = parseUnits(trimmed, decimals);
851
1043
  if (raw > MAX_UINT_256) {
852
- return { valid: false, reason: { type: "overflow" } };
853
- }
854
- return {
855
- valid: true,
856
- amount: BlockchainAmount({ raw, decimals })
857
- };
858
- } catch {
859
- return { valid: false, reason: { type: "invalid-format" } };
860
- }
861
- }
862
-
863
- // src/shared/types/pagination.ts
864
- var Cursor = (value) => value;
865
- var PaginatedResponse = {
866
- fromDto: (dto, itemMapper) => ({
867
- data: dto.data.map(itemMapper),
868
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
869
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
870
- })
871
- };
872
- var PaginationParams = {
873
- toQueryParams: (params) => {
874
- const queryParams = {};
875
- if (params.after) {
876
- queryParams.starting_after = params.after;
877
- }
878
- if (params.before) {
879
- queryParams.starting_before = params.before;
880
- }
881
- if (params.limit) {
882
- queryParams.limit = params.limit;
883
- }
884
- return queryParams;
885
- }
886
- };
887
-
888
- // src/shared/types/asset.ts
889
- var AssetId = (value) => value;
890
- var AssetCode = (value) => value;
891
- var Asset = {
892
- fromDto: (dto) => ({
893
- id: AssetId(dto.id),
894
- code: AssetCode(dto.code),
895
- name: dto.name,
896
- fractionalDigits: dto.fractional_digits
897
- })
898
- };
899
-
900
- // src/shared/types/offer.ts
901
- var OfferId = (value) => value;
902
- var OfferSlug = (value) => value;
903
- var Offer = {
904
- fromDto: (dto) => {
905
- if (!Array.isArray(dto.tokens)) {
906
- throw new ValidationError(
907
- `Offer.tokens: expected an array, got ${typeof dto.tokens}`
908
- );
909
- }
910
- return {
911
- id: OfferId(dto.id),
912
- slug: OfferSlug(dto.slug),
913
- type: dto.type,
914
- tagline: dto.tagline,
915
- bannerUrl: dto.banner_url,
916
- logoUrl: dto.logo_url,
917
- startsAt: new Date(dto.starts_at),
918
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
919
- tokens: dto.tokens.map(OfferToken.fromDto)
920
- };
921
- }
922
- };
923
- var OfferToken = {
924
- fromDto: (dto) => ({
925
- role: dto.role,
926
- chain: Chain(dto.chain),
927
- address: EvmContractAddress(dto.address)
928
- })
929
- };
930
-
931
- // src/shared/core/utils/crypto.ts
932
- async function sha256(data) {
933
- const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
934
- const buffer = bytes.buffer.slice(
935
- bytes.byteOffset,
936
- bytes.byteOffset + bytes.byteLength
937
- );
938
- return crypto.subtle.digest("SHA-256", buffer);
939
- }
940
- function arrayBufferToBase64Url(buffer, padding = true) {
941
- const bytes = new Uint8Array(buffer);
942
- let binary = "";
943
- for (let i = 0; i < bytes.length; i++) {
944
- binary += String.fromCharCode(bytes[i]);
945
- }
946
- let base64 = btoa(binary);
947
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
948
- if (!padding) {
949
- base64 = base64.replace(/=+$/, "");
950
- }
951
- return base64;
952
- }
953
- function generateSecureRandomBase64Url(byteLength) {
954
- const bytes = new Uint8Array(byteLength);
955
- crypto.getRandomValues(bytes);
956
- const buffer = bytes.buffer;
957
- return arrayBufferToBase64Url(buffer, false);
958
- }
959
- function getUUIDv4() {
960
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
961
- return crypto.randomUUID();
962
- }
963
- if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
964
- const bytes = new Uint8Array(16);
965
- crypto.getRandomValues(bytes);
966
- bytes[6] = bytes[6] & 15 | 64;
967
- bytes[8] = bytes[8] & 63 | 128;
968
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
969
- return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
970
- }
971
- return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
972
- }
973
- function notBlankStringOrNull(value) {
974
- if (value?.trim()) {
975
- return value;
976
- } else {
977
- return null;
978
- }
979
- }
980
-
981
- // src/shared/types/offer-detail.ts
982
- var OfferOptionId = (value) => value;
983
- var OfferOptionSlug = (value) => value;
984
- var OfferSwapContract = {
985
- fromDto: (dto) => ({
986
- chain: Chain(dto.chain),
987
- address: EvmContractAddress(dto.address)
988
- })
989
- };
990
- var OfferDetail = {
991
- fromDto: (dto) => {
992
- if (!Array.isArray(dto.funding_assets)) {
993
- throw new ValidationError(
994
- `OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
995
- );
996
- }
997
- if (!Array.isArray(dto.options)) {
998
- throw new ValidationError(
999
- `OfferDetail.options: expected an array, got ${typeof dto.options}`
1000
- );
1001
- }
1002
- if (!Array.isArray(dto.terms)) {
1003
- throw new ValidationError(
1004
- `OfferDetail.terms: expected an array, got ${typeof dto.terms}`
1005
- );
1006
- }
1007
- if (!Array.isArray(dto.links)) {
1008
- throw new ValidationError(
1009
- `OfferDetail.links: expected an array, got ${typeof dto.links}`
1010
- );
1011
- }
1012
- if (!Array.isArray(dto.faqs)) {
1013
- throw new ValidationError(
1014
- `OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
1015
- );
1016
- }
1017
- if (!Array.isArray(dto.milestones)) {
1018
- throw new ValidationError(
1019
- `OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
1020
- );
1021
- }
1022
- if (!Array.isArray(dto.tokens)) {
1023
- throw new ValidationError(
1024
- `OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
1025
- );
1026
- }
1027
- const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
1028
- if (!Array.isArray(swapContracts)) {
1029
- throw new ValidationError(
1030
- `OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
1031
- );
1032
- }
1033
- return {
1034
- id: OfferId(dto.id),
1035
- slug: OfferSlug(dto.slug),
1036
- type: dto.type,
1037
- name: dto.name,
1038
- asset: Asset.fromDto(dto.asset),
1039
- fundingAssets: dto.funding_assets.map(Asset.fromDto),
1040
- tokens: dto.tokens.map(OfferToken.fromDto),
1041
- swapContracts: swapContracts.map(OfferSwapContract.fromDto),
1042
- about: notBlankStringOrNull(dto.about),
1043
- tagline: dto.tagline,
1044
- bannerUrl: dto.banner_url,
1045
- logoUrl: dto.logo_url,
1046
- category: dto.category,
1047
- startsAt: new Date(dto.starts_at),
1048
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1049
- faqs: dto.faqs.map(FaqItem.fromDto),
1050
- links: dto.links.map(Link.fromDto),
1051
- milestones: dto.milestones.map(Milestone.fromDto),
1052
- options: dto.options.map(OfferOption.fromDto),
1053
- terms: dto.terms.map(TermItem.fromDto)
1054
- };
1055
- }
1056
- };
1057
- var OfferOption = {
1058
- fromDto: (dto) => ({
1059
- id: OfferOptionId(dto.id),
1060
- slug: OfferOptionSlug(dto.slug),
1061
- bidIncrement: dto.bid_increment,
1062
- floorPriceUsd: dto.floor_price_usd,
1063
- minimumPurchaseUsd: dto.minimum_purchase_usd,
1064
- priceUsd: dto.price_usd,
1065
- saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
1066
- totalTokenSupply: dto.total_token_supply
1067
- })
1068
- };
1069
- var FaqItem = {
1070
- fromDto: (dto) => ({
1071
- question: notBlankStringOrNull(dto.question),
1072
- answer: notBlankStringOrNull(dto.answer)
1073
- })
1074
- };
1075
- var Link = {
1076
- fromDto: (dto) => ({
1077
- label: notBlankStringOrNull(dto.label),
1078
- url: notBlankStringOrNull(dto.url)
1079
- })
1080
- };
1081
- var TermItem = {
1082
- fromDto: (dto) => ({
1083
- key: notBlankStringOrNull(dto.key),
1084
- value: notBlankStringOrNull(dto.value)
1085
- })
1086
- };
1087
- var Milestone = {
1088
- fromDto: (dto) => ({
1089
- name: notBlankStringOrNull(dto.name),
1090
- schedule: notBlankStringOrNull(dto.schedule),
1091
- status: dto.status
1092
- })
1093
- };
1094
-
1095
- // src/shared/types/providers/coin-list/token-sale.ts
1096
- var ParticipationId = (value) => value;
1097
- var Blockchain = (value) => value;
1098
- var WalletAddress = (value) => value;
1099
- var ParticipationsPaginationParams = {
1100
- toQueryParams: (params) => {
1101
- const queryParams = PaginationParams.toQueryParams(params);
1102
- if (params.offerId) {
1103
- queryParams["filters[0][field]"] = "offer_id";
1104
- queryParams["filters[0][op]"] = "==";
1105
- queryParams["filters[0][value]"] = params.offerId;
1106
- }
1107
- return queryParams;
1108
- }
1109
- };
1110
- var Participation = {
1111
- /** Maps API DTO shape into the SDK participation domain model. */
1112
- fromDto: (dto) => {
1113
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
1114
- return {
1115
- id: ParticipationId(dto.id),
1116
- offerId: OfferId(dto.offer_id),
1117
- offerOptionId: OfferOptionId(dto.offer_option_id),
1118
- status: dto.status,
1119
- amount: dto.amount,
1120
- displayAmount: dto.amount_string,
1121
- asset: Asset.fromDto(dto.asset),
1122
- chain: Blockchain(dto.chain),
1123
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1124
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1125
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1126
- };
1127
- }
1128
- };
1129
- var CreateParticipationParams = {
1130
- /** Maps participation creation params into API DTO payload. */
1131
- toDto: (params) => ({
1132
- offer_id: params.offerId,
1133
- offer_option_id: params.offerOptionId,
1134
- chain: params.chain,
1135
- wallet_address: params.walletAddress,
1136
- amount: params.amount,
1137
- asset_id: params.assetId,
1138
- approval_transaction_hash: params.approvalTransactionHash
1139
- })
1140
- };
1141
-
1142
- // src/shared/api/frontline/providers/coin-list/token-sale.ts
1143
- async function fetchParticipations(api, offerId) {
1144
- return fetchAllPages(
1145
- (params) => fetchParticipationsPage(api, params),
1146
- { offerId }
1147
- );
1148
- }
1149
- async function fetchParticipationsPage(api, params) {
1150
- const pageDto = await api.send({
1151
- method: "GET",
1152
- url: "/v1/participations",
1153
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
1154
- attributes: Attributes.protected()
1155
- });
1156
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1157
- }
1158
- async function fetchParticipation(api, id) {
1159
- const dto = await api.send({
1160
- method: "GET",
1161
- url: `/v1/participations/${id}`,
1162
- attributes: Attributes.protected()
1163
- });
1164
- return Participation.fromDto(dto);
1165
- }
1166
- async function createParticipation(api, params) {
1167
- const dto = await api.send({
1168
- method: "POST",
1169
- url: "/v1/participations",
1170
- body: CreateParticipationParams.toDto(params),
1171
- attributes: Attributes.protected()
1172
- });
1173
- return Participation.fromDto(dto);
1174
- }
1175
-
1176
- // src/shared/core/checkout/coin-list/token-sale-namespace.ts
1177
- var CoinListTokenSaleNamespaceImpl = class {
1178
- constructor(ctx) {
1179
- this.ctx = ctx;
1180
- this.log = internalLogger(ctx.logger, "TOKEN_SALE");
1181
- }
1182
- async list(offerId) {
1183
- return this.log.wrap("list", offerId, async () => {
1184
- await this.ctx.ensureUserAuthenticated();
1185
- return fetchParticipations(this.ctx.api, offerId);
1186
- });
1187
- }
1188
- async listPage(params) {
1189
- return this.log.wrap("listPage", params, async () => {
1190
- await this.ctx.ensureUserAuthenticated();
1191
- return fetchParticipationsPage(this.ctx.api, params);
1192
- });
1193
- }
1194
- async get(id) {
1195
- return this.log.wrap("get", id, async () => {
1196
- await this.ctx.ensureUserAuthenticated();
1197
- return fetchParticipation(this.ctx.api, id);
1198
- });
1199
- }
1200
- async createParticipation(params) {
1201
- return this.log.wrap("createParticipation", params, async () => {
1202
- await this.ctx.ensureUserAuthenticated();
1203
- return createParticipation(this.ctx.api, params);
1204
- });
1044
+ return { valid: false, reason: { type: "overflow" } };
1045
+ }
1046
+ return {
1047
+ valid: true,
1048
+ amount: BlockchainAmount({ raw, decimals })
1049
+ };
1050
+ } catch {
1051
+ return { valid: false, reason: { type: "invalid-format" } };
1205
1052
  }
1206
- };
1207
-
1208
- // src/shared/types/trading.ts
1209
- var Ticker = (value) => value;
1053
+ }
1210
1054
 
1211
- // src/shared/types/providers/ondo/ondo.ts
1055
+ // src/universal/types/providers/ondo/ondo.ts
1212
1056
  var OndoTradingStatus = {
1213
1057
  fromDto: (dto) => {
1214
1058
  if (!dto.tradable) return { type: "not-tradable", side: dto.side };
@@ -1374,7 +1218,7 @@ function parseExpiresAt(value) {
1374
1218
  return date;
1375
1219
  }
1376
1220
 
1377
- // src/shared/api/frontline/providers/ondo/ondo.ts
1221
+ // src/universal/api/frontline/providers/ondo/ondo.ts
1378
1222
  async function getOndoTradingStatus(api, params) {
1379
1223
  const dto = await api.send({
1380
1224
  method: "GET",
@@ -1469,7 +1313,7 @@ function sizeParam(params) {
1469
1313
  return { notional_value: notionalValue };
1470
1314
  }
1471
1315
 
1472
- // src/shared/core/checkout/ondo/ondo-namespace.ts
1316
+ // src/universal/core/checkout/ondo/ondo-namespace.ts
1473
1317
  var OndoNamespaceImpl = class {
1474
1318
  constructor(ctx) {
1475
1319
  this.ctx = ctx;
@@ -1501,7 +1345,164 @@ var OndoNamespaceImpl = class {
1501
1345
  }
1502
1346
  };
1503
1347
 
1504
- // src/shared/core/checkout/superstate/swap-namespace.ts
1348
+ // src/universal/types/providers/superstate/swap.ts
1349
+ var SwapAuthorization = {
1350
+ fromDto: (dto) => ({
1351
+ authorized: dto.authorized
1352
+ })
1353
+ };
1354
+ var SwapPreview = {
1355
+ fromDto: (dto) => ({
1356
+ inputAmount: parseUint256(
1357
+ BigInt(dto.pay_input_amount),
1358
+ "SwapPreview.pay_input_amount"
1359
+ ),
1360
+ fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
1361
+ outputAmount: parseUint256(
1362
+ BigInt(dto.receive_output_amount),
1363
+ "SwapPreview.receive_output_amount"
1364
+ )
1365
+ })
1366
+ };
1367
+ var SwapStatus = {
1368
+ fromDto: (dto) => ({
1369
+ stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
1370
+ swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
1371
+ })
1372
+ };
1373
+ var TokenAllowance = {
1374
+ fromDto: (dto) => ({
1375
+ allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
1376
+ })
1377
+ };
1378
+ var TokenBalance = {
1379
+ fromDto: (dto) => ({
1380
+ balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
1381
+ })
1382
+ };
1383
+ var AllowWalletResponse = {
1384
+ fromDto: (dto) => {
1385
+ switch (dto.action) {
1386
+ case "broadcast_transaction":
1387
+ return {
1388
+ action: "broadcast_transaction",
1389
+ to: EvmContractAddress(dto.to),
1390
+ data: HexEncodedTransactionData(dto.data)
1391
+ };
1392
+ case "none":
1393
+ return {
1394
+ action: "none",
1395
+ alreadyAllowed: dto.already_allowed
1396
+ };
1397
+ default: {
1398
+ const _exhaustive = dto;
1399
+ return _exhaustive;
1400
+ }
1401
+ }
1402
+ }
1403
+ };
1404
+
1405
+ // src/universal/api/frontline/providers/superstate/swap.ts
1406
+ async function getSwapAuthorization(api, params) {
1407
+ const dto = await api.send({
1408
+ method: "GET",
1409
+ url: "/v1/wallet/authorized",
1410
+ queryParams: {
1411
+ chain: params.chain,
1412
+ contract_address: params.contractAddress,
1413
+ wallet_address: params.walletAddress
1414
+ },
1415
+ attributes: Attributes.protected()
1416
+ });
1417
+ return SwapAuthorization.fromDto(dto);
1418
+ }
1419
+ async function getSwapOutputToken(api, params) {
1420
+ const dto = await api.send({
1421
+ method: "GET",
1422
+ url: "/v1/swap/output-token",
1423
+ queryParams: {
1424
+ chain: params.chain,
1425
+ contract_address: params.contractAddress
1426
+ },
1427
+ attributes: Attributes.protected()
1428
+ });
1429
+ return toErc20Asset(dto);
1430
+ }
1431
+ async function getSwapPreview(api, params) {
1432
+ const dto = await api.send({
1433
+ method: "GET",
1434
+ url: "/v1/swap/preview",
1435
+ queryParams: {
1436
+ chain: params.chain,
1437
+ contract_address: params.contractAddress,
1438
+ input_token: params.inputToken,
1439
+ amount: params.amount.toString()
1440
+ },
1441
+ attributes: Attributes.protected()
1442
+ });
1443
+ return SwapPreview.fromDto(dto);
1444
+ }
1445
+ async function getSwapStatus(api, params) {
1446
+ const dto = await api.send({
1447
+ method: "GET",
1448
+ url: "/v1/swap/status",
1449
+ queryParams: {
1450
+ chain: params.chain,
1451
+ contract_address: params.contractAddress
1452
+ },
1453
+ attributes: Attributes.protected()
1454
+ });
1455
+ return SwapStatus.fromDto(dto);
1456
+ }
1457
+ async function getTokenAllowance(api, params) {
1458
+ const dto = await api.send({
1459
+ method: "GET",
1460
+ url: "/v1/token/allowance",
1461
+ queryParams: {
1462
+ chain: params.chain,
1463
+ token_address: params.tokenAddress,
1464
+ owner: params.owner,
1465
+ spender: params.spender
1466
+ },
1467
+ attributes: Attributes.protected()
1468
+ });
1469
+ return TokenAllowance.fromDto(dto);
1470
+ }
1471
+ async function getTokenBalance(api, params) {
1472
+ const dto = await api.send({
1473
+ method: "GET",
1474
+ url: "/v1/token/balance",
1475
+ queryParams: {
1476
+ chain: params.chain,
1477
+ token_address: params.tokenAddress,
1478
+ owner: params.owner
1479
+ },
1480
+ attributes: Attributes.protected()
1481
+ });
1482
+ return TokenBalance.fromDto(dto);
1483
+ }
1484
+ async function allowWallet(api, params) {
1485
+ const dto = await api.send({
1486
+ method: "POST",
1487
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
1488
+ body: {
1489
+ wallet_address: params.walletAddress,
1490
+ chain: params.chain,
1491
+ signature: params.signature
1492
+ },
1493
+ attributes: Attributes.protected()
1494
+ });
1495
+ return AllowWalletResponse.fromDto(dto);
1496
+ }
1497
+ function toErc20Asset(dto) {
1498
+ return {
1499
+ name: dto.name,
1500
+ symbol: AssetSymbol(dto.symbol),
1501
+ decimals: AssetDecimals(dto.decimals)
1502
+ };
1503
+ }
1504
+
1505
+ // src/universal/core/checkout/superstate/swap-namespace.ts
1505
1506
  var SuperstateSwapNamespaceImpl = class {
1506
1507
  constructor(ctx) {
1507
1508
  this.ctx = ctx;
@@ -1539,7 +1540,7 @@ var SuperstateSwapNamespaceImpl = class {
1539
1540
  }
1540
1541
  };
1541
1542
 
1542
- // src/shared/types/document-submission.ts
1543
+ // src/universal/types/document-submission.ts
1543
1544
  var DocumentSubmission = {
1544
1545
  fromDto: (dto) => ({
1545
1546
  status: dto.status,
@@ -1547,14 +1548,14 @@ var DocumentSubmission = {
1547
1548
  })
1548
1549
  };
1549
1550
 
1550
- // src/shared/types/kyc.ts
1551
+ // src/universal/types/kyc.ts
1551
1552
  var KycToken = {
1552
1553
  fromDto: (dto) => ({
1553
1554
  token: dto.token
1554
1555
  })
1555
1556
  };
1556
1557
 
1557
- // src/shared/types/pii.ts
1558
+ // src/universal/types/pii.ts
1558
1559
  var Iso2CountryCode = (value) => value;
1559
1560
  var PiiJurisdiction = {
1560
1561
  fromDto: (dto) => ({
@@ -1582,7 +1583,7 @@ var Pii = {
1582
1583
  })
1583
1584
  };
1584
1585
 
1585
- // src/shared/types/requirement.ts
1586
+ // src/universal/types/requirement.ts
1586
1587
  var RequirementId = (value) => value;
1587
1588
  var Requirement = {
1588
1589
  fromDto: (dto) => ({
@@ -1603,7 +1604,7 @@ var RequirementStatusInfo = {
1603
1604
  )
1604
1605
  };
1605
1606
 
1606
- // src/shared/api/frontline/documents.ts
1607
+ // src/universal/api/frontline/documents.ts
1607
1608
  async function submitDocument(api, documentType, fields) {
1608
1609
  const dto = await api.send({
1609
1610
  method: "POST",
@@ -1614,7 +1615,7 @@ async function submitDocument(api, documentType, fields) {
1614
1615
  return DocumentSubmission.fromDto(dto);
1615
1616
  }
1616
1617
 
1617
- // src/shared/api/frontline/kyc.ts
1618
+ // src/universal/api/frontline/kyc.ts
1618
1619
  async function createKycToken(api, levelName, reset) {
1619
1620
  const dto = await api.send({
1620
1621
  method: "POST",
@@ -1628,7 +1629,7 @@ async function createKycToken(api, levelName, reset) {
1628
1629
  return KycToken.fromDto(dto);
1629
1630
  }
1630
1631
 
1631
- // src/shared/api/frontline/pii.ts
1632
+ // src/universal/api/frontline/pii.ts
1632
1633
  async function fetchPii(api) {
1633
1634
  const dto = await api.send({
1634
1635
  method: "GET",
@@ -1638,7 +1639,7 @@ async function fetchPii(api) {
1638
1639
  return Pii.fromDto(dto);
1639
1640
  }
1640
1641
 
1641
- // src/shared/api/frontline/requirements.ts
1642
+ // src/universal/api/frontline/requirements.ts
1642
1643
  async function fetchOfferRequirements(api, offerId, clientCreds) {
1643
1644
  const response = await api.send({
1644
1645
  method: "GET",
@@ -1664,7 +1665,7 @@ async function fetchRequirementStatuses(api, offerId) {
1664
1665
  return RequirementStatusInfo.fromStatusesDto(response);
1665
1666
  }
1666
1667
 
1667
- // src/shared/core/requirements/requirements-namespace.ts
1668
+ // src/universal/core/requirements/requirements-namespace.ts
1668
1669
  var RequirementsNamespaceImpl = class {
1669
1670
  constructor(ctx) {
1670
1671
  this.ctx = ctx;
@@ -1714,7 +1715,27 @@ var RequirementsNamespaceImpl = class {
1714
1715
  }
1715
1716
  };
1716
1717
 
1717
- // src/shared/types/token-metadata.ts
1718
+ // src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
1719
+ var Erc20NamespaceImpl = class {
1720
+ constructor(ctx) {
1721
+ this.ctx = ctx;
1722
+ this.log = internalLogger(ctx.logger, "ERC20");
1723
+ }
1724
+ async getAllowance(params) {
1725
+ return this.log.wrap("getAllowance", params, async () => {
1726
+ await this.ctx.ensureUserAuthenticated();
1727
+ return getTokenAllowance(this.ctx.api, params);
1728
+ });
1729
+ }
1730
+ async getBalance(params) {
1731
+ return this.log.wrap("getBalance", params, async () => {
1732
+ await this.ctx.ensureUserAuthenticated();
1733
+ return getTokenBalance(this.ctx.api, params);
1734
+ });
1735
+ }
1736
+ };
1737
+
1738
+ // src/universal/types/token-metadata.ts
1718
1739
  var TokenLogoUrl = (value) => value;
1719
1740
  var TokenLogo = {
1720
1741
  /** `baseUrl` is the registry origin; registry URLs are root-relative. */
@@ -1797,10 +1818,10 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
1797
1818
  url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
1798
1819
  );
1799
1820
 
1800
- // src/shared/api/nabu/tokens.ts
1821
+ // src/universal/api/nabu/tokens.ts
1801
1822
  import { getAddress } from "viem";
1802
1823
 
1803
- // src/shared/api/frontline/config.ts
1824
+ // src/universal/api/frontline/config.ts
1804
1825
  var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
1805
1826
  var HEADER_API_VERSION = "X-API-Version";
1806
1827
  var HEADER_USER_AGENT = "User-Agent";
@@ -1813,7 +1834,7 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
1813
1834
  var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
1814
1835
  var WALLET_PATH = "/wallet";
1815
1836
 
1816
- // src/shared/api/http-client.ts
1837
+ // src/universal/api/http-client.ts
1817
1838
  var HttpClient = class {
1818
1839
  constructor(config, middleware = {}, logger = null, options = {}) {
1819
1840
  this.config = config;
@@ -1969,7 +1990,7 @@ function describeRequestUnredacted(request) {
1969
1990
  };
1970
1991
  }
1971
1992
 
1972
- // src/shared/api/nabu/tokens.ts
1993
+ // src/universal/api/nabu/tokens.ts
1973
1994
  function createNabuApiClient(baseUrl, logger = null) {
1974
1995
  return new HttpClient({ baseUrl }, {}, logger);
1975
1996
  }
@@ -2060,10 +2081,10 @@ function checksummed(address) {
2060
2081
  }
2061
2082
  }
2062
2083
 
2063
- // src/shared/core/tokens/tokens-namespace.ts
2084
+ // src/universal/core/tokens/tokens-namespace.ts
2064
2085
  var TokensNamespaceImpl = class {
2065
2086
  /**
2066
- * Takes the registry origin rather than a `SharedNamespaceContext`: the
2087
+ * Takes the registry origin rather than a `UniversalNamespaceContext`: the
2067
2088
  * registry is unauthenticated and on its own host, so the frontline sender
2068
2089
  * and the auth check would both be dead weight here.
2069
2090
  */
@@ -2087,7 +2108,7 @@ var TokensNamespaceImpl = class {
2087
2108
  }
2088
2109
  };
2089
2110
 
2090
- // src/shared/types/offer-option-address.ts
2111
+ // src/universal/types/offer-option-address.ts
2091
2112
  var OfferOptionAddressId = (value) => value;
2092
2113
  var OfferOptionAddress = {
2093
2114
  /** Maps the API DTO into the SDK offer-option-address domain model. */
@@ -2109,7 +2130,7 @@ var ConnectExternalWalletParams = {
2109
2130
  })
2110
2131
  };
2111
2132
 
2112
- // src/shared/types/wallet-ownership-challenge.ts
2133
+ // src/universal/types/wallet-ownership-challenge.ts
2113
2134
  var WalletOwnershipChallenge = {
2114
2135
  /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
2115
2136
  fromDto: (dto) => ({
@@ -2148,7 +2169,7 @@ var CreateWalletOwnershipChallengeParams = {
2148
2169
  }
2149
2170
  };
2150
2171
 
2151
- // src/shared/api/frontline/wallet-connect.ts
2172
+ // src/universal/api/frontline/wallet-connect.ts
2152
2173
  async function createWalletOwnershipChallenge(api, params) {
2153
2174
  const dto = await api.send({
2154
2175
  method: "POST",
@@ -2185,7 +2206,7 @@ async function removeOptionAddress(api, offerId, addressId) {
2185
2206
  return OfferOptionAddress.fromDto(dto);
2186
2207
  }
2187
2208
 
2188
- // src/shared/core/wallets/wallets-namespace.ts
2209
+ // src/universal/core/wallets/wallets-namespace.ts
2189
2210
  var WalletsNamespaceImpl = class {
2190
2211
  constructor(ctx) {
2191
2212
  this.ctx = ctx;
@@ -2228,7 +2249,7 @@ var WalletsNamespaceImpl = class {
2228
2249
  }
2229
2250
  };
2230
2251
 
2231
- // src/shared/types/oauth-session.ts
2252
+ // src/universal/types/oauth-session.ts
2232
2253
  var ClientCredentialsOAuth = (value) => value;
2233
2254
  var OAuthRefreshToken = (value) => value;
2234
2255
  var OAuthSession = {
@@ -2244,7 +2265,7 @@ var OAuthSession = {
2244
2265
  }
2245
2266
  };
2246
2267
 
2247
- // src/shared/api/frontline/offers.ts
2268
+ // src/universal/api/frontline/offers.ts
2248
2269
  async function fetchOffers(api, clientCreds) {
2249
2270
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
2250
2271
  }
@@ -2301,10 +2322,17 @@ export {
2301
2322
  internalLogger,
2302
2323
  HttpClient,
2303
2324
  fetchAllPages,
2325
+ Cursor,
2326
+ PaginatedResponse,
2327
+ PaginationParams,
2328
+ AssetId,
2329
+ AssetCode,
2330
+ Asset,
2304
2331
  ETHEREUM_CHAINS,
2305
2332
  EthereumChain,
2306
2333
  SOLANA_CHAINS,
2307
2334
  SolanaChain,
2335
+ isChain,
2308
2336
  Chain,
2309
2337
  EvmWalletAddress,
2310
2338
  EvmContractAddress,
@@ -2321,44 +2349,12 @@ export {
2321
2349
  StablecoinSymbol,
2322
2350
  KnownAssetSymbol,
2323
2351
  Bps,
2324
- FormattedAmountUi,
2325
- FormattedPercentUi,
2326
- TxExplorerUrl,
2327
- ShortenedWalletAddress,
2328
- FormattedAmountAssetUi,
2329
- AssetIconUrl,
2330
- getChainId,
2331
- chainFromId,
2332
- getNetworkName,
2333
- txExplorerUrl,
2334
- SwapAuthorization,
2335
- SwapPreview,
2336
- SwapStatus,
2337
- TokenAllowance,
2338
- TokenBalance,
2339
- AllowWalletResponse,
2340
- Erc20NamespaceImpl,
2341
- shortenAddress,
2342
- formatAmount,
2343
- formatRawAmount,
2344
- formatCompactAmount,
2345
- formatBpsAsPercent,
2346
- usdAmount,
2347
- assetAmount,
2348
- NA_AMOUNT_ASSET_UI,
2349
- formattedUsdPrice,
2350
- blockchainAmountFromRawOrThrow,
2351
- parseBlockchainAmount,
2352
- Cursor,
2353
- PaginatedResponse,
2354
- PaginationParams,
2355
- AssetId,
2356
- AssetCode,
2357
- Asset,
2358
2352
  OfferId,
2359
2353
  OfferSlug,
2360
2354
  Offer,
2361
2355
  OfferToken,
2356
+ Ticker,
2357
+ Isin,
2362
2358
  OfferOptionId,
2363
2359
  OfferOptionSlug,
2364
2360
  OfferSwapContract,
@@ -2375,12 +2371,38 @@ export {
2375
2371
  Participation,
2376
2372
  CreateParticipationParams,
2377
2373
  CoinListTokenSaleNamespaceImpl,
2378
- Ticker,
2374
+ FormattedAmountUi,
2375
+ FormattedPercentUi,
2376
+ TxExplorerUrl,
2377
+ ShortenedWalletAddress,
2378
+ FormattedAmountAssetUi,
2379
+ AssetIconUrl,
2380
+ shortenAddress,
2381
+ formatAmount,
2382
+ formatRawAmount,
2383
+ formatCompactAmount,
2384
+ formatBpsAsPercent,
2385
+ usdAmount,
2386
+ assetAmount,
2387
+ NA_AMOUNT_ASSET_UI,
2388
+ formattedUsdPrice,
2389
+ getChainId,
2390
+ chainFromId,
2391
+ getNetworkName,
2392
+ txExplorerUrl,
2393
+ blockchainAmountFromRawOrThrow,
2394
+ parseBlockchainAmount,
2379
2395
  OndoTradingStatus,
2380
2396
  OndoQuote,
2381
2397
  OndoBuyTransaction,
2382
2398
  OndoSellTransaction,
2383
2399
  OndoNamespaceImpl,
2400
+ SwapAuthorization,
2401
+ SwapPreview,
2402
+ SwapStatus,
2403
+ TokenAllowance,
2404
+ TokenBalance,
2405
+ AllowWalletResponse,
2384
2406
  SuperstateSwapNamespaceImpl,
2385
2407
  fetchOffers,
2386
2408
  fetchOffersPage,
@@ -2396,6 +2418,7 @@ export {
2396
2418
  RequirementStatusInfo,
2397
2419
  fetchOfferRequirements,
2398
2420
  RequirementsNamespaceImpl,
2421
+ Erc20NamespaceImpl,
2399
2422
  TokenLogoUrl,
2400
2423
  TokenLogo,
2401
2424
  TokenMetadata,
@@ -2410,4 +2433,4 @@ export {
2410
2433
  OAuthRefreshToken,
2411
2434
  OAuthSession
2412
2435
  };
2413
- //# sourceMappingURL=chunk-3ATIDGVR.js.map
2436
+ //# sourceMappingURL=chunk-D42IQHQZ.js.map