@coinlist-co/react 0.12.1-rc.a230abc → 0.12.1-rc.b45777f

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-HLL7IBIS.js → chunk-3ZZCK4IT.js} +9 -9
  2. package/dist/chunk-3ZZCK4IT.js.map +1 -0
  3. package/dist/{chunk-GFLU5OMP.js → chunk-D42IQHQZ.js} +649 -640
  4. package/dist/chunk-D42IQHQZ.js.map +1 -0
  5. package/dist/{chunk-RPE7XIBV.js → chunk-ZUVVNZJJ.js} +126 -126
  6. package/dist/chunk-ZUVVNZJJ.js.map +1 -0
  7. package/dist/client/index.cjs +1368 -1321
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +231 -165
  10. package/dist/client/index.d.ts +231 -165
  11. package/dist/client/index.js +537 -500
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-DZZFrizd.d.ts → collections-CMoojQ9M.d.ts} +1 -1
  14. package/dist/{collections-CAfs2Eww.d.cts → collections-koI4cjYa.d.cts} +1 -1
  15. package/dist/{config-D19ktBr0.d.cts → config-BmK0t-XO.d.cts} +82 -17
  16. package/dist/{config-D19ktBr0.d.ts → config-BmK0t-XO.d.ts} +82 -17
  17. package/dist/server/index.cjs +242 -234
  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 +860 -848
  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 +4 -2
  28. package/package.json +6 -5
  29. package/dist/chunk-GFLU5OMP.js.map +0 -1
  30. package/dist/chunk-HLL7IBIS.js.map +0 -1
  31. package/dist/chunk-RPE7XIBV.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,
@@ -322,226 +359,306 @@ var StablecoinSymbol = (value) => value;
322
359
  var KnownAssetSymbol = StablecoinSymbol;
323
360
  var Bps = (value) => value;
324
361
 
325
- // src/shared/types/blockchain/ui.ts
326
- var FormattedAmountUi = (value) => value;
327
- var FormattedPercentUi = (value) => value;
328
- var TxExplorerUrl = (value) => value;
329
- var ShortenedWalletAddress = (value) => value;
330
- var FormattedAmountAssetUi = (value) => value;
331
- var AssetIconUrl = (value) => value;
332
-
333
- // src/shared/core/blockchain/chain.ts
334
- var CHAIN_IDS = {
335
- ethereum_mainnet: 1,
336
- ethereum_sepolia: 11155111,
337
- base_mainnet: 8453,
338
- 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
+ }
339
384
  };
340
- function getChainId(chain) {
341
- 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);
342
417
  }
343
- function chainFromId(chainId) {
344
- const chains = Object.keys(CHAIN_IDS);
345
- const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
346
- if (!chain) {
347
- 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]);
348
423
  }
349
- return chain;
350
- }
351
- function getNetworkName(chain) {
352
- switch (chain) {
353
- case "ethereum_mainnet":
354
- return "Ethereum";
355
- case "ethereum_sepolia":
356
- return "Ethereum Sepolia";
357
- case "base_mainnet":
358
- return "Base";
359
- case "base_sepolia":
360
- return "Base Sepolia";
361
- default: {
362
- const _exhaustive = chain;
363
- return _exhaustive;
364
- }
424
+ let base64 = btoa(binary);
425
+ base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
426
+ if (!padding) {
427
+ base64 = base64.replace(/=+$/, "");
365
428
  }
429
+ return base64;
366
430
  }
367
- function txExplorerUrl(chain, txHash) {
368
- 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);
369
436
  }
370
- function explorerBaseUrl(chain) {
371
- switch (chain) {
372
- case "ethereum_mainnet":
373
- return "https://etherscan.io";
374
- case "ethereum_sepolia":
375
- return "https://sepolia.etherscan.io";
376
- case "base_mainnet":
377
- return "https://basescan.org";
378
- case "base_sepolia":
379
- return "https://sepolia-explorer.base.org";
380
- default: {
381
- const _exhaustive = chain;
382
- return _exhaustive;
383
- }
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;
384
456
  }
385
457
  }
386
458
 
387
- // src/shared/types/providers/superstate/swap.ts
388
- var SwapAuthorization = {
389
- fromDto: (dto) => ({
390
- authorized: dto.authorized
391
- })
392
- };
393
- var SwapPreview = {
394
- fromDto: (dto) => ({
395
- inputAmount: parseUint256(
396
- BigInt(dto.pay_input_amount),
397
- "SwapPreview.pay_input_amount"
398
- ),
399
- fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
400
- outputAmount: parseUint256(
401
- BigInt(dto.receive_output_amount),
402
- "SwapPreview.receive_output_amount"
403
- )
404
- })
405
- };
406
- var SwapStatus = {
407
- fromDto: (dto) => ({
408
- stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
409
- swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
410
- })
411
- };
412
- var TokenAllowance = {
413
- fromDto: (dto) => ({
414
- allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
415
- })
416
- };
417
- var TokenBalance = {
459
+ // src/universal/types/offer-detail.ts
460
+ var OfferOptionId = (value) => value;
461
+ var OfferOptionSlug = (value) => value;
462
+ var OfferSwapContract = {
418
463
  fromDto: (dto) => ({
419
- balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
464
+ chain: Chain(dto.chain),
465
+ address: EvmContractAddress(dto.address)
420
466
  })
421
467
  };
422
- var AllowWalletResponse = {
468
+ var OfferDetail = {
423
469
  fromDto: (dto) => {
424
- switch (dto.action) {
425
- case "broadcast_transaction":
426
- return {
427
- action: "broadcast_transaction",
428
- to: EvmContractAddress(dto.to),
429
- data: HexEncodedTransactionData(dto.data)
430
- };
431
- case "none":
432
- return {
433
- action: "none",
434
- alreadyAllowed: dto.already_allowed
435
- };
436
- default: {
437
- const _exhaustive = dto;
438
- return _exhaustive;
439
- }
470
+ if (!Array.isArray(dto.funding_assets)) {
471
+ throw new ValidationError(
472
+ `OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
473
+ );
440
474
  }
441
- }
442
- };
443
-
444
- // src/shared/api/frontline/providers/superstate/swap.ts
445
- async function getSwapAuthorization(api, params) {
446
- const dto = await api.send({
447
- method: "GET",
448
- url: "/v1/wallet/authorized",
449
- queryParams: {
450
- chain: params.chain,
451
- contract_address: params.contractAddress,
452
- wallet_address: params.walletAddress
453
- },
454
- attributes: Attributes.protected()
455
- });
456
- return SwapAuthorization.fromDto(dto);
457
- }
458
- async function getSwapOutputToken(api, params) {
459
- const dto = await api.send({
460
- method: "GET",
461
- url: "/v1/swap/output-token",
462
- queryParams: {
463
- chain: params.chain,
464
- contract_address: params.contractAddress
465
- },
466
- attributes: Attributes.protected()
467
- });
468
- return toErc20Asset(dto);
469
- }
470
- async function getSwapPreview(api, params) {
471
- const dto = await api.send({
472
- method: "GET",
473
- url: "/v1/swap/preview",
474
- queryParams: {
475
- chain: params.chain,
476
- contract_address: params.contractAddress,
477
- input_token: params.inputToken,
478
- amount: params.amount.toString()
479
- },
480
- attributes: Attributes.protected()
481
- });
482
- return SwapPreview.fromDto(dto);
483
- }
484
- async function getSwapStatus(api, params) {
485
- const dto = await api.send({
486
- method: "GET",
487
- url: "/v1/swap/status",
488
- queryParams: {
489
- chain: params.chain,
490
- contract_address: params.contractAddress
491
- },
492
- attributes: Attributes.protected()
493
- });
494
- return SwapStatus.fromDto(dto);
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
+ }
541
+ };
542
+ var OfferOption = {
543
+ fromDto: (dto) => ({
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
552
+ })
553
+ };
554
+ var FaqItem = {
555
+ fromDto: (dto) => ({
556
+ question: notBlankStringOrNull(dto.question),
557
+ answer: notBlankStringOrNull(dto.answer)
558
+ })
559
+ };
560
+ var Link = {
561
+ fromDto: (dto) => ({
562
+ label: notBlankStringOrNull(dto.label),
563
+ url: notBlankStringOrNull(dto.url)
564
+ })
565
+ };
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;
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
+ };
612
+ }
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
+ };
626
+
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
+ );
495
633
  }
496
- async function getTokenAllowance(api, params) {
497
- const dto = await api.send({
634
+ async function fetchParticipationsPage(api, params) {
635
+ const pageDto = await api.send({
498
636
  method: "GET",
499
- url: "/v1/token/allowance",
500
- queryParams: {
501
- chain: params.chain,
502
- token_address: params.tokenAddress,
503
- owner: params.owner,
504
- spender: params.spender
505
- },
637
+ url: "/v1/participations",
638
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
506
639
  attributes: Attributes.protected()
507
640
  });
508
- return TokenAllowance.fromDto(dto);
641
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
509
642
  }
510
- async function getTokenBalance(api, params) {
643
+ async function fetchParticipation(api, id) {
511
644
  const dto = await api.send({
512
645
  method: "GET",
513
- url: "/v1/token/balance",
514
- queryParams: {
515
- chain: params.chain,
516
- token_address: params.tokenAddress,
517
- owner: params.owner
518
- },
646
+ url: `/v1/participations/${id}`,
519
647
  attributes: Attributes.protected()
520
648
  });
521
- return TokenBalance.fromDto(dto);
649
+ return Participation.fromDto(dto);
522
650
  }
523
- async function allowWallet(api, params) {
651
+ async function createParticipation(api, params) {
524
652
  const dto = await api.send({
525
653
  method: "POST",
526
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
527
- body: {
528
- wallet_address: params.walletAddress,
529
- chain: params.chain,
530
- signature: params.signature
531
- },
654
+ url: "/v1/participations",
655
+ body: CreateParticipationParams.toDto(params),
532
656
  attributes: Attributes.protected()
533
657
  });
534
- return AllowWalletResponse.fromDto(dto);
535
- }
536
- function toErc20Asset(dto) {
537
- return {
538
- name: dto.name,
539
- symbol: AssetSymbol(dto.symbol),
540
- decimals: AssetDecimals(dto.decimals)
541
- };
658
+ return Participation.fromDto(dto);
542
659
  }
543
660
 
544
- // src/shared/core/observability/log-cause.ts
661
+ // src/universal/core/shared/observability/log-cause.ts
545
662
  function classifyLogCause(error) {
546
663
  if (error instanceof HttpError) {
547
664
  return httpCause(error);
@@ -607,7 +724,7 @@ function apiErrorEventId(error) {
607
724
  return typeof eventId === "string" ? eventId : null;
608
725
  }
609
726
 
610
- // src/shared/core/observability/internal-logger.ts
727
+ // src/universal/core/shared/observability/internal-logger.ts
611
728
  function internalLogger(logger, scope) {
612
729
  return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
613
730
  }
@@ -690,27 +807,47 @@ var noopInternalLogger = {
690
807
  wrap: (_op, _params, run) => run()
691
808
  };
692
809
 
693
- // src/shared/core/blockchain/erc20/erc20-namespace.ts
694
- var Erc20NamespaceImpl = class {
810
+ // src/universal/core/checkout/coin-list/token-sale-namespace.ts
811
+ var CoinListTokenSaleNamespaceImpl = class {
695
812
  constructor(ctx) {
696
813
  this.ctx = ctx;
697
- this.log = internalLogger(ctx.logger, "ERC20");
814
+ this.log = internalLogger(ctx.logger, "TOKEN_SALE");
698
815
  }
699
- async getAllowance(params) {
700
- return this.log.wrap("getAllowance", params, async () => {
816
+ async list(offerId) {
817
+ return this.log.wrap("list", offerId, async () => {
701
818
  await this.ctx.ensureUserAuthenticated();
702
- return getTokenAllowance(this.ctx.api, params);
819
+ return fetchParticipations(this.ctx.api, offerId);
703
820
  });
704
821
  }
705
- async getBalance(params) {
706
- return this.log.wrap("getBalance", params, async () => {
822
+ async listPage(params) {
823
+ return this.log.wrap("listPage", params, async () => {
707
824
  await this.ctx.ensureUserAuthenticated();
708
- 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);
709
838
  });
710
839
  }
711
840
  };
712
841
 
713
- // 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
714
851
  import { formatUnits } from "viem";
715
852
  function shortenAddress(address) {
716
853
  const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
@@ -805,9 +942,63 @@ function formattedUsdPrice(amount, locale) {
805
942
  );
806
943
  }
807
944
 
808
- // src/shared/core/blockchain/math.ts
809
- import { parseUnits } from "viem";
810
- function blockchainAmountFromRawOrThrow({
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}"`);
960
+ }
961
+ return chain;
962
+ }
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({
811
1002
  label,
812
1003
  raw,
813
1004
  decimals
@@ -850,378 +1041,18 @@ function parseBlockchainAmount(amount, decimals) {
850
1041
  try {
851
1042
  const raw = parseUnits(trimmed, decimals);
852
1043
  if (raw > MAX_UINT_256) {
853
- return { valid: false, reason: { type: "overflow" } };
854
- }
855
- return {
856
- valid: true,
857
- amount: BlockchainAmount({ raw, decimals })
858
- };
859
- } catch {
860
- return { valid: false, reason: { type: "invalid-format" } };
861
- }
862
- }
863
-
864
- // src/shared/types/pagination.ts
865
- var Cursor = (value) => value;
866
- var PaginatedResponse = {
867
- fromDto: (dto, itemMapper) => ({
868
- data: dto.data.map(itemMapper),
869
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
870
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
871
- })
872
- };
873
- var PaginationParams = {
874
- toQueryParams: (params) => {
875
- const queryParams = {};
876
- if (params.after) {
877
- queryParams.starting_after = params.after;
878
- }
879
- if (params.before) {
880
- queryParams.starting_before = params.before;
881
- }
882
- if (params.limit) {
883
- queryParams.limit = params.limit;
884
- }
885
- return queryParams;
886
- }
887
- };
888
-
889
- // src/shared/types/asset.ts
890
- var AssetId = (value) => value;
891
- var AssetCode = (value) => value;
892
- var Asset = {
893
- fromDto: (dto) => ({
894
- id: AssetId(dto.id),
895
- code: AssetCode(dto.code),
896
- name: dto.name,
897
- fractionalDigits: dto.fractional_digits
898
- })
899
- };
900
-
901
- // src/shared/types/offer.ts
902
- var OfferId = (value) => value;
903
- var OfferSlug = (value) => value;
904
- var Offer = {
905
- fromDto: (dto) => {
906
- if (!Array.isArray(dto.tokens)) {
907
- throw new ValidationError(
908
- `Offer.tokens: expected an array, got ${typeof dto.tokens}`
909
- );
910
- }
911
- return {
912
- id: OfferId(dto.id),
913
- slug: OfferSlug(dto.slug),
914
- type: dto.type,
915
- tagline: dto.tagline,
916
- bannerUrl: dto.banner_url,
917
- logoUrl: dto.logo_url,
918
- startsAt: new Date(dto.starts_at),
919
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
920
- tokens: OfferToken.listFromDto(dto.tokens)
921
- };
922
- }
923
- };
924
- var OfferToken = {
925
- fromDto: (dto) => ({
926
- role: dto.role,
927
- chain: Chain(dto.chain),
928
- address: EvmContractAddress(dto.address)
929
- }),
930
- /**
931
- * Maps an offer's token list, dropping every token on a chain this SDK does
932
- * not name. Frontline's chain registry runs ahead of {@link Chain}, and a
933
- * plain `.map` would throw out of `Offer.fromDto` and, through
934
- * `PaginatedResponse.fromDto`, reject the whole offers page - which is how
935
- * one Base token blanked production's offers list. Dropping costs that
936
- * token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
937
- * so nobody could have looked it up anyway.
938
- *
939
- * Same shape as `TokenMetadata.fromRegistryDto`.
940
- */
941
- listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
942
- };
943
-
944
- // src/shared/core/utils/crypto.ts
945
- async function sha256(data) {
946
- const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
947
- const buffer = bytes.buffer.slice(
948
- bytes.byteOffset,
949
- bytes.byteOffset + bytes.byteLength
950
- );
951
- return crypto.subtle.digest("SHA-256", buffer);
952
- }
953
- function arrayBufferToBase64Url(buffer, padding = true) {
954
- const bytes = new Uint8Array(buffer);
955
- let binary = "";
956
- for (let i = 0; i < bytes.length; i++) {
957
- binary += String.fromCharCode(bytes[i]);
958
- }
959
- let base64 = btoa(binary);
960
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
961
- if (!padding) {
962
- base64 = base64.replace(/=+$/, "");
963
- }
964
- return base64;
965
- }
966
- function generateSecureRandomBase64Url(byteLength) {
967
- const bytes = new Uint8Array(byteLength);
968
- crypto.getRandomValues(bytes);
969
- const buffer = bytes.buffer;
970
- return arrayBufferToBase64Url(buffer, false);
971
- }
972
- function getUUIDv4() {
973
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
974
- return crypto.randomUUID();
975
- }
976
- if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
977
- const bytes = new Uint8Array(16);
978
- crypto.getRandomValues(bytes);
979
- bytes[6] = bytes[6] & 15 | 64;
980
- bytes[8] = bytes[8] & 63 | 128;
981
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
982
- 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("")}`;
983
- }
984
- return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
985
- }
986
- function notBlankStringOrNull(value) {
987
- if (value?.trim()) {
988
- return value;
989
- } else {
990
- return null;
991
- }
992
- }
993
-
994
- // src/shared/types/offer-detail.ts
995
- var OfferOptionId = (value) => value;
996
- var OfferOptionSlug = (value) => value;
997
- var OfferSwapContract = {
998
- fromDto: (dto) => ({
999
- chain: Chain(dto.chain),
1000
- address: EvmContractAddress(dto.address)
1001
- })
1002
- };
1003
- var OfferDetail = {
1004
- fromDto: (dto) => {
1005
- if (!Array.isArray(dto.funding_assets)) {
1006
- throw new ValidationError(
1007
- `OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
1008
- );
1009
- }
1010
- if (!Array.isArray(dto.options)) {
1011
- throw new ValidationError(
1012
- `OfferDetail.options: expected an array, got ${typeof dto.options}`
1013
- );
1014
- }
1015
- if (!Array.isArray(dto.terms)) {
1016
- throw new ValidationError(
1017
- `OfferDetail.terms: expected an array, got ${typeof dto.terms}`
1018
- );
1019
- }
1020
- if (!Array.isArray(dto.links)) {
1021
- throw new ValidationError(
1022
- `OfferDetail.links: expected an array, got ${typeof dto.links}`
1023
- );
1024
- }
1025
- if (!Array.isArray(dto.faqs)) {
1026
- throw new ValidationError(
1027
- `OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
1028
- );
1029
- }
1030
- if (!Array.isArray(dto.milestones)) {
1031
- throw new ValidationError(
1032
- `OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
1033
- );
1034
- }
1035
- if (!Array.isArray(dto.tokens)) {
1036
- throw new ValidationError(
1037
- `OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
1038
- );
1039
- }
1040
- const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
1041
- if (!Array.isArray(swapContracts)) {
1042
- throw new ValidationError(
1043
- `OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
1044
- );
1045
- }
1046
- return {
1047
- id: OfferId(dto.id),
1048
- slug: OfferSlug(dto.slug),
1049
- type: dto.type,
1050
- name: dto.name,
1051
- asset: Asset.fromDto(dto.asset),
1052
- fundingAssets: dto.funding_assets.map(Asset.fromDto),
1053
- tokens: OfferToken.listFromDto(dto.tokens),
1054
- swapContracts: swapContracts.map(OfferSwapContract.fromDto),
1055
- about: notBlankStringOrNull(dto.about),
1056
- tagline: dto.tagline,
1057
- bannerUrl: dto.banner_url,
1058
- logoUrl: dto.logo_url,
1059
- category: dto.category,
1060
- startsAt: new Date(dto.starts_at),
1061
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
1062
- faqs: dto.faqs.map(FaqItem.fromDto),
1063
- links: dto.links.map(Link.fromDto),
1064
- milestones: dto.milestones.map(Milestone.fromDto),
1065
- options: dto.options.map(OfferOption.fromDto),
1066
- terms: dto.terms.map(TermItem.fromDto)
1067
- };
1068
- }
1069
- };
1070
- var OfferOption = {
1071
- fromDto: (dto) => ({
1072
- id: OfferOptionId(dto.id),
1073
- slug: OfferOptionSlug(dto.slug),
1074
- bidIncrement: dto.bid_increment,
1075
- floorPriceUsd: dto.floor_price_usd,
1076
- minimumPurchaseUsd: dto.minimum_purchase_usd,
1077
- priceUsd: dto.price_usd,
1078
- saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
1079
- totalTokenSupply: dto.total_token_supply
1080
- })
1081
- };
1082
- var FaqItem = {
1083
- fromDto: (dto) => ({
1084
- question: notBlankStringOrNull(dto.question),
1085
- answer: notBlankStringOrNull(dto.answer)
1086
- })
1087
- };
1088
- var Link = {
1089
- fromDto: (dto) => ({
1090
- label: notBlankStringOrNull(dto.label),
1091
- url: notBlankStringOrNull(dto.url)
1092
- })
1093
- };
1094
- var TermItem = {
1095
- fromDto: (dto) => ({
1096
- key: notBlankStringOrNull(dto.key),
1097
- value: notBlankStringOrNull(dto.value)
1098
- })
1099
- };
1100
- var Milestone = {
1101
- fromDto: (dto) => ({
1102
- name: notBlankStringOrNull(dto.name),
1103
- schedule: notBlankStringOrNull(dto.schedule),
1104
- status: dto.status
1105
- })
1106
- };
1107
-
1108
- // src/shared/types/providers/coin-list/token-sale.ts
1109
- var ParticipationId = (value) => value;
1110
- var Blockchain = (value) => value;
1111
- var WalletAddress = (value) => value;
1112
- var ParticipationsPaginationParams = {
1113
- toQueryParams: (params) => {
1114
- const queryParams = PaginationParams.toQueryParams(params);
1115
- if (params.offerId) {
1116
- queryParams["filters[0][field]"] = "offer_id";
1117
- queryParams["filters[0][op]"] = "==";
1118
- queryParams["filters[0][value]"] = params.offerId;
1119
- }
1120
- return queryParams;
1121
- }
1122
- };
1123
- var Participation = {
1124
- /** Maps API DTO shape into the SDK participation domain model. */
1125
- fromDto: (dto) => {
1126
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
1127
- return {
1128
- id: ParticipationId(dto.id),
1129
- offerId: OfferId(dto.offer_id),
1130
- offerOptionId: OfferOptionId(dto.offer_option_id),
1131
- status: dto.status,
1132
- amount: dto.amount,
1133
- displayAmount: dto.amount_string,
1134
- asset: Asset.fromDto(dto.asset),
1135
- chain: Blockchain(dto.chain),
1136
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1137
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1138
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1139
- };
1140
- }
1141
- };
1142
- var CreateParticipationParams = {
1143
- /** Maps participation creation params into API DTO payload. */
1144
- toDto: (params) => ({
1145
- offer_id: params.offerId,
1146
- offer_option_id: params.offerOptionId,
1147
- chain: params.chain,
1148
- wallet_address: params.walletAddress,
1149
- amount: params.amount,
1150
- asset_id: params.assetId,
1151
- approval_transaction_hash: params.approvalTransactionHash
1152
- })
1153
- };
1154
-
1155
- // src/shared/api/frontline/providers/coin-list/token-sale.ts
1156
- async function fetchParticipations(api, offerId) {
1157
- return fetchAllPages(
1158
- (params) => fetchParticipationsPage(api, params),
1159
- { offerId }
1160
- );
1161
- }
1162
- async function fetchParticipationsPage(api, params) {
1163
- const pageDto = await api.send({
1164
- method: "GET",
1165
- url: "/v1/participations",
1166
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
1167
- attributes: Attributes.protected()
1168
- });
1169
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
1170
- }
1171
- async function fetchParticipation(api, id) {
1172
- const dto = await api.send({
1173
- method: "GET",
1174
- url: `/v1/participations/${id}`,
1175
- attributes: Attributes.protected()
1176
- });
1177
- return Participation.fromDto(dto);
1178
- }
1179
- async function createParticipation(api, params) {
1180
- const dto = await api.send({
1181
- method: "POST",
1182
- url: "/v1/participations",
1183
- body: CreateParticipationParams.toDto(params),
1184
- attributes: Attributes.protected()
1185
- });
1186
- return Participation.fromDto(dto);
1187
- }
1188
-
1189
- // src/shared/core/checkout/coin-list/token-sale-namespace.ts
1190
- var CoinListTokenSaleNamespaceImpl = class {
1191
- constructor(ctx) {
1192
- this.ctx = ctx;
1193
- this.log = internalLogger(ctx.logger, "TOKEN_SALE");
1194
- }
1195
- async list(offerId) {
1196
- return this.log.wrap("list", offerId, async () => {
1197
- await this.ctx.ensureUserAuthenticated();
1198
- return fetchParticipations(this.ctx.api, offerId);
1199
- });
1200
- }
1201
- async listPage(params) {
1202
- return this.log.wrap("listPage", params, async () => {
1203
- await this.ctx.ensureUserAuthenticated();
1204
- return fetchParticipationsPage(this.ctx.api, params);
1205
- });
1206
- }
1207
- async get(id) {
1208
- return this.log.wrap("get", id, async () => {
1209
- await this.ctx.ensureUserAuthenticated();
1210
- return fetchParticipation(this.ctx.api, id);
1211
- });
1212
- }
1213
- async createParticipation(params) {
1214
- return this.log.wrap("createParticipation", params, async () => {
1215
- await this.ctx.ensureUserAuthenticated();
1216
- return createParticipation(this.ctx.api, params);
1217
- });
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" } };
1218
1052
  }
1219
- };
1220
-
1221
- // src/shared/types/trading.ts
1222
- var Ticker = (value) => value;
1053
+ }
1223
1054
 
1224
- // src/shared/types/providers/ondo/ondo.ts
1055
+ // src/universal/types/providers/ondo/ondo.ts
1225
1056
  var OndoTradingStatus = {
1226
1057
  fromDto: (dto) => {
1227
1058
  if (!dto.tradable) return { type: "not-tradable", side: dto.side };
@@ -1387,7 +1218,7 @@ function parseExpiresAt(value) {
1387
1218
  return date;
1388
1219
  }
1389
1220
 
1390
- // src/shared/api/frontline/providers/ondo/ondo.ts
1221
+ // src/universal/api/frontline/providers/ondo/ondo.ts
1391
1222
  async function getOndoTradingStatus(api, params) {
1392
1223
  const dto = await api.send({
1393
1224
  method: "GET",
@@ -1482,7 +1313,7 @@ function sizeParam(params) {
1482
1313
  return { notional_value: notionalValue };
1483
1314
  }
1484
1315
 
1485
- // src/shared/core/checkout/ondo/ondo-namespace.ts
1316
+ // src/universal/core/checkout/ondo/ondo-namespace.ts
1486
1317
  var OndoNamespaceImpl = class {
1487
1318
  constructor(ctx) {
1488
1319
  this.ctx = ctx;
@@ -1514,7 +1345,164 @@ var OndoNamespaceImpl = class {
1514
1345
  }
1515
1346
  };
1516
1347
 
1517
- // 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
1518
1506
  var SuperstateSwapNamespaceImpl = class {
1519
1507
  constructor(ctx) {
1520
1508
  this.ctx = ctx;
@@ -1552,7 +1540,7 @@ var SuperstateSwapNamespaceImpl = class {
1552
1540
  }
1553
1541
  };
1554
1542
 
1555
- // src/shared/types/document-submission.ts
1543
+ // src/universal/types/document-submission.ts
1556
1544
  var DocumentSubmission = {
1557
1545
  fromDto: (dto) => ({
1558
1546
  status: dto.status,
@@ -1560,14 +1548,14 @@ var DocumentSubmission = {
1560
1548
  })
1561
1549
  };
1562
1550
 
1563
- // src/shared/types/kyc.ts
1551
+ // src/universal/types/kyc.ts
1564
1552
  var KycToken = {
1565
1553
  fromDto: (dto) => ({
1566
1554
  token: dto.token
1567
1555
  })
1568
1556
  };
1569
1557
 
1570
- // src/shared/types/pii.ts
1558
+ // src/universal/types/pii.ts
1571
1559
  var Iso2CountryCode = (value) => value;
1572
1560
  var PiiJurisdiction = {
1573
1561
  fromDto: (dto) => ({
@@ -1595,7 +1583,7 @@ var Pii = {
1595
1583
  })
1596
1584
  };
1597
1585
 
1598
- // src/shared/types/requirement.ts
1586
+ // src/universal/types/requirement.ts
1599
1587
  var RequirementId = (value) => value;
1600
1588
  var Requirement = {
1601
1589
  fromDto: (dto) => ({
@@ -1616,7 +1604,7 @@ var RequirementStatusInfo = {
1616
1604
  )
1617
1605
  };
1618
1606
 
1619
- // src/shared/api/frontline/documents.ts
1607
+ // src/universal/api/frontline/documents.ts
1620
1608
  async function submitDocument(api, documentType, fields) {
1621
1609
  const dto = await api.send({
1622
1610
  method: "POST",
@@ -1627,7 +1615,7 @@ async function submitDocument(api, documentType, fields) {
1627
1615
  return DocumentSubmission.fromDto(dto);
1628
1616
  }
1629
1617
 
1630
- // src/shared/api/frontline/kyc.ts
1618
+ // src/universal/api/frontline/kyc.ts
1631
1619
  async function createKycToken(api, levelName, reset) {
1632
1620
  const dto = await api.send({
1633
1621
  method: "POST",
@@ -1641,7 +1629,7 @@ async function createKycToken(api, levelName, reset) {
1641
1629
  return KycToken.fromDto(dto);
1642
1630
  }
1643
1631
 
1644
- // src/shared/api/frontline/pii.ts
1632
+ // src/universal/api/frontline/pii.ts
1645
1633
  async function fetchPii(api) {
1646
1634
  const dto = await api.send({
1647
1635
  method: "GET",
@@ -1651,7 +1639,7 @@ async function fetchPii(api) {
1651
1639
  return Pii.fromDto(dto);
1652
1640
  }
1653
1641
 
1654
- // src/shared/api/frontline/requirements.ts
1642
+ // src/universal/api/frontline/requirements.ts
1655
1643
  async function fetchOfferRequirements(api, offerId, clientCreds) {
1656
1644
  const response = await api.send({
1657
1645
  method: "GET",
@@ -1677,7 +1665,7 @@ async function fetchRequirementStatuses(api, offerId) {
1677
1665
  return RequirementStatusInfo.fromStatusesDto(response);
1678
1666
  }
1679
1667
 
1680
- // src/shared/core/requirements/requirements-namespace.ts
1668
+ // src/universal/core/requirements/requirements-namespace.ts
1681
1669
  var RequirementsNamespaceImpl = class {
1682
1670
  constructor(ctx) {
1683
1671
  this.ctx = ctx;
@@ -1727,7 +1715,27 @@ var RequirementsNamespaceImpl = class {
1727
1715
  }
1728
1716
  };
1729
1717
 
1730
- // 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
1731
1739
  var TokenLogoUrl = (value) => value;
1732
1740
  var TokenLogo = {
1733
1741
  /** `baseUrl` is the registry origin; registry URLs are root-relative. */
@@ -1810,10 +1818,10 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
1810
1818
  url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
1811
1819
  );
1812
1820
 
1813
- // src/shared/api/nabu/tokens.ts
1821
+ // src/universal/api/nabu/tokens.ts
1814
1822
  import { getAddress } from "viem";
1815
1823
 
1816
- // src/shared/api/frontline/config.ts
1824
+ // src/universal/api/frontline/config.ts
1817
1825
  var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
1818
1826
  var HEADER_API_VERSION = "X-API-Version";
1819
1827
  var HEADER_USER_AGENT = "User-Agent";
@@ -1826,7 +1834,7 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
1826
1834
  var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
1827
1835
  var WALLET_PATH = "/wallet";
1828
1836
 
1829
- // src/shared/api/http-client.ts
1837
+ // src/universal/api/http-client.ts
1830
1838
  var HttpClient = class {
1831
1839
  constructor(config, middleware = {}, logger = null, options = {}) {
1832
1840
  this.config = config;
@@ -1982,7 +1990,7 @@ function describeRequestUnredacted(request) {
1982
1990
  };
1983
1991
  }
1984
1992
 
1985
- // src/shared/api/nabu/tokens.ts
1993
+ // src/universal/api/nabu/tokens.ts
1986
1994
  function createNabuApiClient(baseUrl, logger = null) {
1987
1995
  return new HttpClient({ baseUrl }, {}, logger);
1988
1996
  }
@@ -2073,10 +2081,10 @@ function checksummed(address) {
2073
2081
  }
2074
2082
  }
2075
2083
 
2076
- // src/shared/core/tokens/tokens-namespace.ts
2084
+ // src/universal/core/tokens/tokens-namespace.ts
2077
2085
  var TokensNamespaceImpl = class {
2078
2086
  /**
2079
- * Takes the registry origin rather than a `SharedNamespaceContext`: the
2087
+ * Takes the registry origin rather than a `UniversalNamespaceContext`: the
2080
2088
  * registry is unauthenticated and on its own host, so the frontline sender
2081
2089
  * and the auth check would both be dead weight here.
2082
2090
  */
@@ -2100,7 +2108,7 @@ var TokensNamespaceImpl = class {
2100
2108
  }
2101
2109
  };
2102
2110
 
2103
- // src/shared/types/offer-option-address.ts
2111
+ // src/universal/types/offer-option-address.ts
2104
2112
  var OfferOptionAddressId = (value) => value;
2105
2113
  var OfferOptionAddress = {
2106
2114
  /** Maps the API DTO into the SDK offer-option-address domain model. */
@@ -2122,7 +2130,7 @@ var ConnectExternalWalletParams = {
2122
2130
  })
2123
2131
  };
2124
2132
 
2125
- // src/shared/types/wallet-ownership-challenge.ts
2133
+ // src/universal/types/wallet-ownership-challenge.ts
2126
2134
  var WalletOwnershipChallenge = {
2127
2135
  /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
2128
2136
  fromDto: (dto) => ({
@@ -2161,7 +2169,7 @@ var CreateWalletOwnershipChallengeParams = {
2161
2169
  }
2162
2170
  };
2163
2171
 
2164
- // src/shared/api/frontline/wallet-connect.ts
2172
+ // src/universal/api/frontline/wallet-connect.ts
2165
2173
  async function createWalletOwnershipChallenge(api, params) {
2166
2174
  const dto = await api.send({
2167
2175
  method: "POST",
@@ -2198,7 +2206,7 @@ async function removeOptionAddress(api, offerId, addressId) {
2198
2206
  return OfferOptionAddress.fromDto(dto);
2199
2207
  }
2200
2208
 
2201
- // src/shared/core/wallets/wallets-namespace.ts
2209
+ // src/universal/core/wallets/wallets-namespace.ts
2202
2210
  var WalletsNamespaceImpl = class {
2203
2211
  constructor(ctx) {
2204
2212
  this.ctx = ctx;
@@ -2241,7 +2249,7 @@ var WalletsNamespaceImpl = class {
2241
2249
  }
2242
2250
  };
2243
2251
 
2244
- // src/shared/types/oauth-session.ts
2252
+ // src/universal/types/oauth-session.ts
2245
2253
  var ClientCredentialsOAuth = (value) => value;
2246
2254
  var OAuthRefreshToken = (value) => value;
2247
2255
  var OAuthSession = {
@@ -2257,7 +2265,7 @@ var OAuthSession = {
2257
2265
  }
2258
2266
  };
2259
2267
 
2260
- // src/shared/api/frontline/offers.ts
2268
+ // src/universal/api/frontline/offers.ts
2261
2269
  async function fetchOffers(api, clientCreds) {
2262
2270
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
2263
2271
  }
@@ -2314,6 +2322,12 @@ export {
2314
2322
  internalLogger,
2315
2323
  HttpClient,
2316
2324
  fetchAllPages,
2325
+ Cursor,
2326
+ PaginatedResponse,
2327
+ PaginationParams,
2328
+ AssetId,
2329
+ AssetCode,
2330
+ Asset,
2317
2331
  ETHEREUM_CHAINS,
2318
2332
  EthereumChain,
2319
2333
  SOLANA_CHAINS,
@@ -2335,44 +2349,12 @@ export {
2335
2349
  StablecoinSymbol,
2336
2350
  KnownAssetSymbol,
2337
2351
  Bps,
2338
- FormattedAmountUi,
2339
- FormattedPercentUi,
2340
- TxExplorerUrl,
2341
- ShortenedWalletAddress,
2342
- FormattedAmountAssetUi,
2343
- AssetIconUrl,
2344
- getChainId,
2345
- chainFromId,
2346
- getNetworkName,
2347
- txExplorerUrl,
2348
- SwapAuthorization,
2349
- SwapPreview,
2350
- SwapStatus,
2351
- TokenAllowance,
2352
- TokenBalance,
2353
- AllowWalletResponse,
2354
- Erc20NamespaceImpl,
2355
- shortenAddress,
2356
- formatAmount,
2357
- formatRawAmount,
2358
- formatCompactAmount,
2359
- formatBpsAsPercent,
2360
- usdAmount,
2361
- assetAmount,
2362
- NA_AMOUNT_ASSET_UI,
2363
- formattedUsdPrice,
2364
- blockchainAmountFromRawOrThrow,
2365
- parseBlockchainAmount,
2366
- Cursor,
2367
- PaginatedResponse,
2368
- PaginationParams,
2369
- AssetId,
2370
- AssetCode,
2371
- Asset,
2372
2352
  OfferId,
2373
2353
  OfferSlug,
2374
2354
  Offer,
2375
2355
  OfferToken,
2356
+ Ticker,
2357
+ Isin,
2376
2358
  OfferOptionId,
2377
2359
  OfferOptionSlug,
2378
2360
  OfferSwapContract,
@@ -2389,12 +2371,38 @@ export {
2389
2371
  Participation,
2390
2372
  CreateParticipationParams,
2391
2373
  CoinListTokenSaleNamespaceImpl,
2392
- 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,
2393
2395
  OndoTradingStatus,
2394
2396
  OndoQuote,
2395
2397
  OndoBuyTransaction,
2396
2398
  OndoSellTransaction,
2397
2399
  OndoNamespaceImpl,
2400
+ SwapAuthorization,
2401
+ SwapPreview,
2402
+ SwapStatus,
2403
+ TokenAllowance,
2404
+ TokenBalance,
2405
+ AllowWalletResponse,
2398
2406
  SuperstateSwapNamespaceImpl,
2399
2407
  fetchOffers,
2400
2408
  fetchOffersPage,
@@ -2410,6 +2418,7 @@ export {
2410
2418
  RequirementStatusInfo,
2411
2419
  fetchOfferRequirements,
2412
2420
  RequirementsNamespaceImpl,
2421
+ Erc20NamespaceImpl,
2413
2422
  TokenLogoUrl,
2414
2423
  TokenLogo,
2415
2424
  TokenMetadata,
@@ -2424,4 +2433,4 @@ export {
2424
2433
  OAuthRefreshToken,
2425
2434
  OAuthSession
2426
2435
  };
2427
- //# sourceMappingURL=chunk-GFLU5OMP.js.map
2436
+ //# sourceMappingURL=chunk-D42IQHQZ.js.map