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

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-3ATIDGVR.js → chunk-6CQHDASY.js} +651 -637
  2. package/dist/chunk-6CQHDASY.js.map +1 -0
  3. package/dist/{chunk-SOMNMOBU.js → chunk-F6WGUKZC.js} +9 -9
  4. package/dist/chunk-F6WGUKZC.js.map +1 -0
  5. package/dist/{chunk-2XBPKC4C.js → chunk-ZFBEI3BW.js} +126 -126
  6. package/dist/chunk-ZFBEI3BW.js.map +1 -0
  7. package/dist/client/index.cjs +1541 -1398
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +357 -230
  10. package/dist/client/index.d.ts +357 -230
  11. package/dist/client/index.js +840 -717
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-DNbBE6Pk.d.cts → collections-DOm9VKVm.d.cts} +1 -1
  14. package/dist/{collections-DVCh4jUp.d.ts → collections-aCv-Wr2a.d.ts} +1 -1
  15. package/dist/{config-DFYAM0GD.d.cts → config-DIaFzrMW.d.cts} +31 -13
  16. package/dist/{config-DFYAM0GD.d.ts → config-DIaFzrMW.d.ts} +31 -13
  17. package/dist/server/index.cjs +249 -236
  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 -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 +4 -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,295 @@ 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/core/shared/utils/crypto.ts
406
+ async function sha256(data) {
407
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
408
+ const buffer = bytes.buffer.slice(
409
+ bytes.byteOffset,
410
+ bytes.byteOffset + bytes.byteLength
411
+ );
412
+ return crypto.subtle.digest("SHA-256", buffer);
341
413
  }
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}"`);
414
+ function arrayBufferToBase64Url(buffer, padding = true) {
415
+ const bytes = new Uint8Array(buffer);
416
+ let binary = "";
417
+ for (let i = 0; i < bytes.length; i++) {
418
+ binary += String.fromCharCode(bytes[i]);
347
419
  }
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
- }
420
+ let base64 = btoa(binary);
421
+ base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
422
+ if (!padding) {
423
+ base64 = base64.replace(/=+$/, "");
364
424
  }
425
+ return base64;
365
426
  }
366
- function txExplorerUrl(chain, txHash) {
367
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
427
+ function generateSecureRandomBase64Url(byteLength) {
428
+ const bytes = new Uint8Array(byteLength);
429
+ crypto.getRandomValues(bytes);
430
+ const buffer = bytes.buffer;
431
+ return arrayBufferToBase64Url(buffer, false);
368
432
  }
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
- }
433
+ function getUUIDv4() {
434
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
435
+ return crypto.randomUUID();
436
+ }
437
+ if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
438
+ const bytes = new Uint8Array(16);
439
+ crypto.getRandomValues(bytes);
440
+ bytes[6] = bytes[6] & 15 | 64;
441
+ bytes[8] = bytes[8] & 63 | 128;
442
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
443
+ 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("")}`;
444
+ }
445
+ return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
446
+ }
447
+ function notBlankStringOrNull(value) {
448
+ if (value?.trim()) {
449
+ return value;
450
+ } else {
451
+ return null;
383
452
  }
384
453
  }
385
454
 
386
- // src/shared/types/providers/superstate/swap.ts
387
- var SwapAuthorization = {
455
+ // src/universal/types/offer-detail.ts
456
+ var OfferOptionId = (value) => value;
457
+ var OfferOptionSlug = (value) => value;
458
+ var OfferSwapContract = {
388
459
  fromDto: (dto) => ({
389
- authorized: dto.authorized
460
+ chain: Chain(dto.chain),
461
+ address: EvmContractAddress(dto.address)
390
462
  })
391
463
  };
392
- var SwapPreview = {
464
+ var OfferDetail = {
465
+ fromDto: (dto) => {
466
+ if (!Array.isArray(dto.funding_assets)) {
467
+ throw new ValidationError(
468
+ `OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
469
+ );
470
+ }
471
+ if (!Array.isArray(dto.options)) {
472
+ throw new ValidationError(
473
+ `OfferDetail.options: expected an array, got ${typeof dto.options}`
474
+ );
475
+ }
476
+ if (!Array.isArray(dto.terms)) {
477
+ throw new ValidationError(
478
+ `OfferDetail.terms: expected an array, got ${typeof dto.terms}`
479
+ );
480
+ }
481
+ if (!Array.isArray(dto.links)) {
482
+ throw new ValidationError(
483
+ `OfferDetail.links: expected an array, got ${typeof dto.links}`
484
+ );
485
+ }
486
+ if (!Array.isArray(dto.faqs)) {
487
+ throw new ValidationError(
488
+ `OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
489
+ );
490
+ }
491
+ if (!Array.isArray(dto.milestones)) {
492
+ throw new ValidationError(
493
+ `OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
494
+ );
495
+ }
496
+ if (!Array.isArray(dto.tokens)) {
497
+ throw new ValidationError(
498
+ `OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
499
+ );
500
+ }
501
+ const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
502
+ if (!Array.isArray(swapContracts)) {
503
+ throw new ValidationError(
504
+ `OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
505
+ );
506
+ }
507
+ return {
508
+ id: OfferId(dto.id),
509
+ slug: OfferSlug(dto.slug),
510
+ type: dto.type,
511
+ name: dto.name,
512
+ asset: Asset.fromDto(dto.asset),
513
+ fundingAssets: dto.funding_assets.map(Asset.fromDto),
514
+ tokens: OfferToken.listFromDto(dto.tokens),
515
+ swapContracts: swapContracts.map(OfferSwapContract.fromDto),
516
+ about: notBlankStringOrNull(dto.about),
517
+ tagline: dto.tagline,
518
+ bannerUrl: dto.banner_url,
519
+ logoUrl: dto.logo_url,
520
+ category: dto.category,
521
+ startsAt: new Date(dto.starts_at),
522
+ endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
523
+ faqs: dto.faqs.map(FaqItem.fromDto),
524
+ links: dto.links.map(Link.fromDto),
525
+ milestones: dto.milestones.map(Milestone.fromDto),
526
+ options: dto.options.map(OfferOption.fromDto),
527
+ terms: dto.terms.map(TermItem.fromDto)
528
+ };
529
+ }
530
+ };
531
+ var OfferOption = {
393
532
  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
- )
533
+ id: OfferOptionId(dto.id),
534
+ slug: OfferOptionSlug(dto.slug),
535
+ bidIncrement: dto.bid_increment,
536
+ floorPriceUsd: dto.floor_price_usd,
537
+ minimumPurchaseUsd: dto.minimum_purchase_usd,
538
+ priceUsd: dto.price_usd,
539
+ saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
540
+ totalTokenSupply: dto.total_token_supply
403
541
  })
404
542
  };
405
- var SwapStatus = {
543
+ var FaqItem = {
406
544
  fromDto: (dto) => ({
407
- stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
408
- swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
545
+ question: notBlankStringOrNull(dto.question),
546
+ answer: notBlankStringOrNull(dto.answer)
409
547
  })
410
548
  };
411
- var TokenAllowance = {
549
+ var Link = {
412
550
  fromDto: (dto) => ({
413
- allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
551
+ label: notBlankStringOrNull(dto.label),
552
+ url: notBlankStringOrNull(dto.url)
414
553
  })
415
554
  };
416
- var TokenBalance = {
555
+ var TermItem = {
417
556
  fromDto: (dto) => ({
418
- balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
557
+ key: notBlankStringOrNull(dto.key),
558
+ value: notBlankStringOrNull(dto.value)
419
559
  })
420
560
  };
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
- }
561
+ var Milestone = {
562
+ fromDto: (dto) => ({
563
+ name: notBlankStringOrNull(dto.name),
564
+ schedule: notBlankStringOrNull(dto.schedule),
565
+ status: dto.status
566
+ })
567
+ };
568
+
569
+ // src/universal/types/providers/coin-list/token-sale.ts
570
+ var ParticipationId = (value) => value;
571
+ var Blockchain = (value) => value;
572
+ var WalletAddress = (value) => value;
573
+ var ParticipationsPaginationParams = {
574
+ toQueryParams: (params) => {
575
+ const queryParams = PaginationParams.toQueryParams(params);
576
+ if (params.offerId) {
577
+ queryParams["filters[0][field]"] = "offer_id";
578
+ queryParams["filters[0][op]"] = "==";
579
+ queryParams["filters[0][value]"] = params.offerId;
439
580
  }
581
+ return queryParams;
582
+ }
583
+ };
584
+ var Participation = {
585
+ /** Maps API DTO shape into the SDK participation domain model. */
586
+ fromDto: (dto) => {
587
+ const walletAddress = notBlankStringOrNull(dto.wallet_address);
588
+ return {
589
+ id: ParticipationId(dto.id),
590
+ offerId: OfferId(dto.offer_id),
591
+ offerOptionId: OfferOptionId(dto.offer_option_id),
592
+ status: dto.status,
593
+ amount: dto.amount,
594
+ displayAmount: dto.amount_string,
595
+ asset: Asset.fromDto(dto.asset),
596
+ chain: Blockchain(dto.chain),
597
+ insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
598
+ updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
599
+ walletAddress: walletAddress ? WalletAddress(walletAddress) : null
600
+ };
440
601
  }
441
602
  };
603
+ var CreateParticipationParams = {
604
+ /** Maps participation creation params into API DTO payload. */
605
+ toDto: (params) => ({
606
+ offer_id: params.offerId,
607
+ offer_option_id: params.offerOptionId,
608
+ chain: params.chain,
609
+ wallet_address: params.walletAddress,
610
+ amount: params.amount,
611
+ asset_id: params.assetId,
612
+ approval_transaction_hash: params.approvalTransactionHash
613
+ })
614
+ };
442
615
 
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);
616
+ // src/universal/api/frontline/providers/coin-list/token-sale.ts
617
+ async function fetchParticipations(api, offerId) {
618
+ return fetchAllPages(
619
+ (params) => fetchParticipationsPage(api, params),
620
+ { offerId }
621
+ );
494
622
  }
495
- async function getTokenAllowance(api, params) {
496
- const dto = await api.send({
623
+ async function fetchParticipationsPage(api, params) {
624
+ const pageDto = await api.send({
497
625
  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
- },
626
+ url: "/v1/participations",
627
+ queryParams: ParticipationsPaginationParams.toQueryParams(params),
505
628
  attributes: Attributes.protected()
506
629
  });
507
- return TokenAllowance.fromDto(dto);
630
+ return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
508
631
  }
509
- async function getTokenBalance(api, params) {
632
+ async function fetchParticipation(api, id) {
510
633
  const dto = await api.send({
511
634
  method: "GET",
512
- url: "/v1/token/balance",
513
- queryParams: {
514
- chain: params.chain,
515
- token_address: params.tokenAddress,
516
- owner: params.owner
517
- },
635
+ url: `/v1/participations/${id}`,
518
636
  attributes: Attributes.protected()
519
637
  });
520
- return TokenBalance.fromDto(dto);
638
+ return Participation.fromDto(dto);
521
639
  }
522
- async function allowWallet(api, params) {
640
+ async function createParticipation(api, params) {
523
641
  const dto = await api.send({
524
642
  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
- },
643
+ url: "/v1/participations",
644
+ body: CreateParticipationParams.toDto(params),
531
645
  attributes: Attributes.protected()
532
646
  });
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
- };
647
+ return Participation.fromDto(dto);
541
648
  }
542
649
 
543
- // src/shared/core/observability/log-cause.ts
650
+ // src/universal/core/shared/observability/log-cause.ts
544
651
  function classifyLogCause(error) {
545
652
  if (error instanceof HttpError) {
546
653
  return httpCause(error);
@@ -606,7 +713,7 @@ function apiErrorEventId(error) {
606
713
  return typeof eventId === "string" ? eventId : null;
607
714
  }
608
715
 
609
- // src/shared/core/observability/internal-logger.ts
716
+ // src/universal/core/shared/observability/internal-logger.ts
610
717
  function internalLogger(logger, scope) {
611
718
  return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
612
719
  }
@@ -689,27 +796,47 @@ var noopInternalLogger = {
689
796
  wrap: (_op, _params, run) => run()
690
797
  };
691
798
 
692
- // src/shared/core/blockchain/erc20/erc20-namespace.ts
693
- var Erc20NamespaceImpl = class {
799
+ // src/universal/core/checkout/coin-list/token-sale-namespace.ts
800
+ var CoinListTokenSaleNamespaceImpl = class {
694
801
  constructor(ctx) {
695
802
  this.ctx = ctx;
696
- this.log = internalLogger(ctx.logger, "ERC20");
803
+ this.log = internalLogger(ctx.logger, "TOKEN_SALE");
697
804
  }
698
- async getAllowance(params) {
699
- return this.log.wrap("getAllowance", params, async () => {
805
+ async list(offerId) {
806
+ return this.log.wrap("list", offerId, async () => {
700
807
  await this.ctx.ensureUserAuthenticated();
701
- return getTokenAllowance(this.ctx.api, params);
808
+ return fetchParticipations(this.ctx.api, offerId);
702
809
  });
703
810
  }
704
- async getBalance(params) {
705
- return this.log.wrap("getBalance", params, async () => {
811
+ async listPage(params) {
812
+ return this.log.wrap("listPage", params, async () => {
706
813
  await this.ctx.ensureUserAuthenticated();
707
- return getTokenBalance(this.ctx.api, params);
814
+ return fetchParticipationsPage(this.ctx.api, params);
815
+ });
816
+ }
817
+ async get(id) {
818
+ return this.log.wrap("get", id, async () => {
819
+ await this.ctx.ensureUserAuthenticated();
820
+ return fetchParticipation(this.ctx.api, id);
821
+ });
822
+ }
823
+ async createParticipation(params) {
824
+ return this.log.wrap("createParticipation", params, async () => {
825
+ await this.ctx.ensureUserAuthenticated();
826
+ return createParticipation(this.ctx.api, params);
708
827
  });
709
828
  }
710
829
  };
711
830
 
712
- // src/shared/core/blockchain/formatters.ts
831
+ // src/universal/types/blockchain/ui.ts
832
+ var FormattedAmountUi = (value) => value;
833
+ var FormattedPercentUi = (value) => value;
834
+ var TxExplorerUrl = (value) => value;
835
+ var ShortenedWalletAddress = (value) => value;
836
+ var FormattedAmountAssetUi = (value) => value;
837
+ var AssetIconUrl = (value) => value;
838
+
839
+ // src/universal/core/shared/blockchain/formatters.ts
713
840
  import { formatUnits } from "viem";
714
841
  function shortenAddress(address) {
715
842
  const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
@@ -804,411 +931,120 @@ function formattedUsdPrice(amount, locale) {
804
931
  );
805
932
  }
806
933
 
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})`);
828
- }
934
+ // src/universal/core/shared/blockchain/chain.ts
935
+ var CHAIN_IDS = {
936
+ ethereum_mainnet: 1,
937
+ ethereum_sepolia: 11155111,
938
+ base_mainnet: 8453,
939
+ base_sepolia: 84532
940
+ };
941
+ function getChainId(chain) {
942
+ return CHAIN_IDS[chain];
829
943
  }
830
- function parseBlockchainAmount(amount, decimals) {
831
- const trimmed = amount.trim();
832
- if (trimmed === "") return { valid: false, reason: { type: "empty" } };
833
- if (trimmed.startsWith("-")) {
834
- return { valid: false, reason: { type: "negative" } };
835
- }
836
- if (/[eE]/.test(trimmed)) {
837
- return { valid: false, reason: { type: "invalid-format" } };
838
- }
839
- if (!/^\d+(\.\d+)?$/.test(trimmed)) {
840
- return { valid: false, reason: { type: "invalid-format" } };
841
- }
842
- const [, fraction = ""] = trimmed.split(".");
843
- if (fraction.length > decimals) {
844
- return {
845
- valid: false,
846
- reason: { type: "too-many-decimals", maxDecimals: decimals }
847
- };
848
- }
849
- try {
850
- const raw = parseUnits(trimmed, decimals);
851
- 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" } };
944
+ function chainFromId(chainId) {
945
+ const chains = Object.keys(CHAIN_IDS);
946
+ const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
947
+ if (!chain) {
948
+ throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
860
949
  }
950
+ return chain;
861
951
  }
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
- );
952
+ function getNetworkName(chain) {
953
+ switch (chain) {
954
+ case "ethereum_mainnet":
955
+ return "Ethereum";
956
+ case "ethereum_sepolia":
957
+ return "Ethereum Sepolia";
958
+ case "base_mainnet":
959
+ return "Base";
960
+ case "base_sepolia":
961
+ return "Base Sepolia";
962
+ default: {
963
+ const _exhaustive = chain;
964
+ return _exhaustive;
909
965
  }
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
966
  }
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
967
  }
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)}`;
968
+ function txExplorerUrl(chain, txHash) {
969
+ return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
972
970
  }
973
- function notBlankStringOrNull(value) {
974
- if (value?.trim()) {
975
- return value;
976
- } else {
977
- return null;
971
+ function explorerBaseUrl(chain) {
972
+ switch (chain) {
973
+ case "ethereum_mainnet":
974
+ return "https://etherscan.io";
975
+ case "ethereum_sepolia":
976
+ return "https://sepolia.etherscan.io";
977
+ case "base_mainnet":
978
+ return "https://basescan.org";
979
+ case "base_sepolia":
980
+ return "https://sepolia-explorer.base.org";
981
+ default: {
982
+ const _exhaustive = chain;
983
+ return _exhaustive;
984
+ }
978
985
  }
979
986
  }
980
987
 
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
- };
988
+ // src/universal/core/shared/blockchain/math.ts
989
+ import { parseUnits } from "viem";
990
+ function blockchainAmountFromRawOrThrow({
991
+ label,
992
+ raw,
993
+ decimals
994
+ }) {
995
+ const trimmed = raw.trim();
996
+ if (trimmed === "") {
997
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1055
998
  }
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;
999
+ let value;
1000
+ try {
1001
+ value = BigInt(trimmed);
1002
+ } catch {
1003
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
1108
1004
  }
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
- };
1005
+ try {
1006
+ return BlockchainAmount({ raw: assertUint256(value), decimals });
1007
+ } catch {
1008
+ throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
1127
1009
  }
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
1010
  }
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
- });
1011
+ function parseBlockchainAmount(amount, decimals) {
1012
+ const trimmed = amount.trim();
1013
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
1014
+ if (trimmed.startsWith("-")) {
1015
+ return { valid: false, reason: { type: "negative" } };
1187
1016
  }
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
- });
1017
+ if (/[eE]/.test(trimmed)) {
1018
+ return { valid: false, reason: { type: "invalid-format" } };
1193
1019
  }
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
- });
1020
+ if (!/^\d+(\.\d+)?$/.test(trimmed)) {
1021
+ return { valid: false, reason: { type: "invalid-format" } };
1199
1022
  }
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
- });
1023
+ const [, fraction = ""] = trimmed.split(".");
1024
+ if (fraction.length > decimals) {
1025
+ return {
1026
+ valid: false,
1027
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
1028
+ };
1205
1029
  }
1206
- };
1030
+ try {
1031
+ const raw = parseUnits(trimmed, decimals);
1032
+ if (raw > MAX_UINT_256) {
1033
+ return { valid: false, reason: { type: "overflow" } };
1034
+ }
1035
+ return {
1036
+ valid: true,
1037
+ amount: BlockchainAmount({ raw, decimals })
1038
+ };
1039
+ } catch {
1040
+ return { valid: false, reason: { type: "invalid-format" } };
1041
+ }
1042
+ }
1207
1043
 
1208
- // src/shared/types/trading.ts
1044
+ // src/universal/types/trading.ts
1209
1045
  var Ticker = (value) => value;
1210
1046
 
1211
- // src/shared/types/providers/ondo/ondo.ts
1047
+ // src/universal/types/providers/ondo/ondo.ts
1212
1048
  var OndoTradingStatus = {
1213
1049
  fromDto: (dto) => {
1214
1050
  if (!dto.tradable) return { type: "not-tradable", side: dto.side };
@@ -1374,7 +1210,7 @@ function parseExpiresAt(value) {
1374
1210
  return date;
1375
1211
  }
1376
1212
 
1377
- // src/shared/api/frontline/providers/ondo/ondo.ts
1213
+ // src/universal/api/frontline/providers/ondo/ondo.ts
1378
1214
  async function getOndoTradingStatus(api, params) {
1379
1215
  const dto = await api.send({
1380
1216
  method: "GET",
@@ -1469,7 +1305,7 @@ function sizeParam(params) {
1469
1305
  return { notional_value: notionalValue };
1470
1306
  }
1471
1307
 
1472
- // src/shared/core/checkout/ondo/ondo-namespace.ts
1308
+ // src/universal/core/checkout/ondo/ondo-namespace.ts
1473
1309
  var OndoNamespaceImpl = class {
1474
1310
  constructor(ctx) {
1475
1311
  this.ctx = ctx;
@@ -1501,7 +1337,164 @@ var OndoNamespaceImpl = class {
1501
1337
  }
1502
1338
  };
1503
1339
 
1504
- // src/shared/core/checkout/superstate/swap-namespace.ts
1340
+ // src/universal/types/providers/superstate/swap.ts
1341
+ var SwapAuthorization = {
1342
+ fromDto: (dto) => ({
1343
+ authorized: dto.authorized
1344
+ })
1345
+ };
1346
+ var SwapPreview = {
1347
+ fromDto: (dto) => ({
1348
+ inputAmount: parseUint256(
1349
+ BigInt(dto.pay_input_amount),
1350
+ "SwapPreview.pay_input_amount"
1351
+ ),
1352
+ fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
1353
+ outputAmount: parseUint256(
1354
+ BigInt(dto.receive_output_amount),
1355
+ "SwapPreview.receive_output_amount"
1356
+ )
1357
+ })
1358
+ };
1359
+ var SwapStatus = {
1360
+ fromDto: (dto) => ({
1361
+ stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
1362
+ swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
1363
+ })
1364
+ };
1365
+ var TokenAllowance = {
1366
+ fromDto: (dto) => ({
1367
+ allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
1368
+ })
1369
+ };
1370
+ var TokenBalance = {
1371
+ fromDto: (dto) => ({
1372
+ balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
1373
+ })
1374
+ };
1375
+ var AllowWalletResponse = {
1376
+ fromDto: (dto) => {
1377
+ switch (dto.action) {
1378
+ case "broadcast_transaction":
1379
+ return {
1380
+ action: "broadcast_transaction",
1381
+ to: EvmContractAddress(dto.to),
1382
+ data: HexEncodedTransactionData(dto.data)
1383
+ };
1384
+ case "none":
1385
+ return {
1386
+ action: "none",
1387
+ alreadyAllowed: dto.already_allowed
1388
+ };
1389
+ default: {
1390
+ const _exhaustive = dto;
1391
+ return _exhaustive;
1392
+ }
1393
+ }
1394
+ }
1395
+ };
1396
+
1397
+ // src/universal/api/frontline/providers/superstate/swap.ts
1398
+ async function getSwapAuthorization(api, params) {
1399
+ const dto = await api.send({
1400
+ method: "GET",
1401
+ url: "/v1/wallet/authorized",
1402
+ queryParams: {
1403
+ chain: params.chain,
1404
+ contract_address: params.contractAddress,
1405
+ wallet_address: params.walletAddress
1406
+ },
1407
+ attributes: Attributes.protected()
1408
+ });
1409
+ return SwapAuthorization.fromDto(dto);
1410
+ }
1411
+ async function getSwapOutputToken(api, params) {
1412
+ const dto = await api.send({
1413
+ method: "GET",
1414
+ url: "/v1/swap/output-token",
1415
+ queryParams: {
1416
+ chain: params.chain,
1417
+ contract_address: params.contractAddress
1418
+ },
1419
+ attributes: Attributes.protected()
1420
+ });
1421
+ return toErc20Asset(dto);
1422
+ }
1423
+ async function getSwapPreview(api, params) {
1424
+ const dto = await api.send({
1425
+ method: "GET",
1426
+ url: "/v1/swap/preview",
1427
+ queryParams: {
1428
+ chain: params.chain,
1429
+ contract_address: params.contractAddress,
1430
+ input_token: params.inputToken,
1431
+ amount: params.amount.toString()
1432
+ },
1433
+ attributes: Attributes.protected()
1434
+ });
1435
+ return SwapPreview.fromDto(dto);
1436
+ }
1437
+ async function getSwapStatus(api, params) {
1438
+ const dto = await api.send({
1439
+ method: "GET",
1440
+ url: "/v1/swap/status",
1441
+ queryParams: {
1442
+ chain: params.chain,
1443
+ contract_address: params.contractAddress
1444
+ },
1445
+ attributes: Attributes.protected()
1446
+ });
1447
+ return SwapStatus.fromDto(dto);
1448
+ }
1449
+ async function getTokenAllowance(api, params) {
1450
+ const dto = await api.send({
1451
+ method: "GET",
1452
+ url: "/v1/token/allowance",
1453
+ queryParams: {
1454
+ chain: params.chain,
1455
+ token_address: params.tokenAddress,
1456
+ owner: params.owner,
1457
+ spender: params.spender
1458
+ },
1459
+ attributes: Attributes.protected()
1460
+ });
1461
+ return TokenAllowance.fromDto(dto);
1462
+ }
1463
+ async function getTokenBalance(api, params) {
1464
+ const dto = await api.send({
1465
+ method: "GET",
1466
+ url: "/v1/token/balance",
1467
+ queryParams: {
1468
+ chain: params.chain,
1469
+ token_address: params.tokenAddress,
1470
+ owner: params.owner
1471
+ },
1472
+ attributes: Attributes.protected()
1473
+ });
1474
+ return TokenBalance.fromDto(dto);
1475
+ }
1476
+ async function allowWallet(api, params) {
1477
+ const dto = await api.send({
1478
+ method: "POST",
1479
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
1480
+ body: {
1481
+ wallet_address: params.walletAddress,
1482
+ chain: params.chain,
1483
+ signature: params.signature
1484
+ },
1485
+ attributes: Attributes.protected()
1486
+ });
1487
+ return AllowWalletResponse.fromDto(dto);
1488
+ }
1489
+ function toErc20Asset(dto) {
1490
+ return {
1491
+ name: dto.name,
1492
+ symbol: AssetSymbol(dto.symbol),
1493
+ decimals: AssetDecimals(dto.decimals)
1494
+ };
1495
+ }
1496
+
1497
+ // src/universal/core/checkout/superstate/swap-namespace.ts
1505
1498
  var SuperstateSwapNamespaceImpl = class {
1506
1499
  constructor(ctx) {
1507
1500
  this.ctx = ctx;
@@ -1539,7 +1532,7 @@ var SuperstateSwapNamespaceImpl = class {
1539
1532
  }
1540
1533
  };
1541
1534
 
1542
- // src/shared/types/document-submission.ts
1535
+ // src/universal/types/document-submission.ts
1543
1536
  var DocumentSubmission = {
1544
1537
  fromDto: (dto) => ({
1545
1538
  status: dto.status,
@@ -1547,14 +1540,14 @@ var DocumentSubmission = {
1547
1540
  })
1548
1541
  };
1549
1542
 
1550
- // src/shared/types/kyc.ts
1543
+ // src/universal/types/kyc.ts
1551
1544
  var KycToken = {
1552
1545
  fromDto: (dto) => ({
1553
1546
  token: dto.token
1554
1547
  })
1555
1548
  };
1556
1549
 
1557
- // src/shared/types/pii.ts
1550
+ // src/universal/types/pii.ts
1558
1551
  var Iso2CountryCode = (value) => value;
1559
1552
  var PiiJurisdiction = {
1560
1553
  fromDto: (dto) => ({
@@ -1582,7 +1575,7 @@ var Pii = {
1582
1575
  })
1583
1576
  };
1584
1577
 
1585
- // src/shared/types/requirement.ts
1578
+ // src/universal/types/requirement.ts
1586
1579
  var RequirementId = (value) => value;
1587
1580
  var Requirement = {
1588
1581
  fromDto: (dto) => ({
@@ -1603,7 +1596,7 @@ var RequirementStatusInfo = {
1603
1596
  )
1604
1597
  };
1605
1598
 
1606
- // src/shared/api/frontline/documents.ts
1599
+ // src/universal/api/frontline/documents.ts
1607
1600
  async function submitDocument(api, documentType, fields) {
1608
1601
  const dto = await api.send({
1609
1602
  method: "POST",
@@ -1614,7 +1607,7 @@ async function submitDocument(api, documentType, fields) {
1614
1607
  return DocumentSubmission.fromDto(dto);
1615
1608
  }
1616
1609
 
1617
- // src/shared/api/frontline/kyc.ts
1610
+ // src/universal/api/frontline/kyc.ts
1618
1611
  async function createKycToken(api, levelName, reset) {
1619
1612
  const dto = await api.send({
1620
1613
  method: "POST",
@@ -1628,7 +1621,7 @@ async function createKycToken(api, levelName, reset) {
1628
1621
  return KycToken.fromDto(dto);
1629
1622
  }
1630
1623
 
1631
- // src/shared/api/frontline/pii.ts
1624
+ // src/universal/api/frontline/pii.ts
1632
1625
  async function fetchPii(api) {
1633
1626
  const dto = await api.send({
1634
1627
  method: "GET",
@@ -1638,7 +1631,7 @@ async function fetchPii(api) {
1638
1631
  return Pii.fromDto(dto);
1639
1632
  }
1640
1633
 
1641
- // src/shared/api/frontline/requirements.ts
1634
+ // src/universal/api/frontline/requirements.ts
1642
1635
  async function fetchOfferRequirements(api, offerId, clientCreds) {
1643
1636
  const response = await api.send({
1644
1637
  method: "GET",
@@ -1664,7 +1657,7 @@ async function fetchRequirementStatuses(api, offerId) {
1664
1657
  return RequirementStatusInfo.fromStatusesDto(response);
1665
1658
  }
1666
1659
 
1667
- // src/shared/core/requirements/requirements-namespace.ts
1660
+ // src/universal/core/requirements/requirements-namespace.ts
1668
1661
  var RequirementsNamespaceImpl = class {
1669
1662
  constructor(ctx) {
1670
1663
  this.ctx = ctx;
@@ -1714,7 +1707,27 @@ var RequirementsNamespaceImpl = class {
1714
1707
  }
1715
1708
  };
1716
1709
 
1717
- // src/shared/types/token-metadata.ts
1710
+ // src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
1711
+ var Erc20NamespaceImpl = class {
1712
+ constructor(ctx) {
1713
+ this.ctx = ctx;
1714
+ this.log = internalLogger(ctx.logger, "ERC20");
1715
+ }
1716
+ async getAllowance(params) {
1717
+ return this.log.wrap("getAllowance", params, async () => {
1718
+ await this.ctx.ensureUserAuthenticated();
1719
+ return getTokenAllowance(this.ctx.api, params);
1720
+ });
1721
+ }
1722
+ async getBalance(params) {
1723
+ return this.log.wrap("getBalance", params, async () => {
1724
+ await this.ctx.ensureUserAuthenticated();
1725
+ return getTokenBalance(this.ctx.api, params);
1726
+ });
1727
+ }
1728
+ };
1729
+
1730
+ // src/universal/types/token-metadata.ts
1718
1731
  var TokenLogoUrl = (value) => value;
1719
1732
  var TokenLogo = {
1720
1733
  /** `baseUrl` is the registry origin; registry URLs are root-relative. */
@@ -1797,10 +1810,10 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
1797
1810
  url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
1798
1811
  );
1799
1812
 
1800
- // src/shared/api/nabu/tokens.ts
1813
+ // src/universal/api/nabu/tokens.ts
1801
1814
  import { getAddress } from "viem";
1802
1815
 
1803
- // src/shared/api/frontline/config.ts
1816
+ // src/universal/api/frontline/config.ts
1804
1817
  var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
1805
1818
  var HEADER_API_VERSION = "X-API-Version";
1806
1819
  var HEADER_USER_AGENT = "User-Agent";
@@ -1813,7 +1826,7 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
1813
1826
  var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
1814
1827
  var WALLET_PATH = "/wallet";
1815
1828
 
1816
- // src/shared/api/http-client.ts
1829
+ // src/universal/api/http-client.ts
1817
1830
  var HttpClient = class {
1818
1831
  constructor(config, middleware = {}, logger = null, options = {}) {
1819
1832
  this.config = config;
@@ -1969,7 +1982,7 @@ function describeRequestUnredacted(request) {
1969
1982
  };
1970
1983
  }
1971
1984
 
1972
- // src/shared/api/nabu/tokens.ts
1985
+ // src/universal/api/nabu/tokens.ts
1973
1986
  function createNabuApiClient(baseUrl, logger = null) {
1974
1987
  return new HttpClient({ baseUrl }, {}, logger);
1975
1988
  }
@@ -2060,10 +2073,10 @@ function checksummed(address) {
2060
2073
  }
2061
2074
  }
2062
2075
 
2063
- // src/shared/core/tokens/tokens-namespace.ts
2076
+ // src/universal/core/tokens/tokens-namespace.ts
2064
2077
  var TokensNamespaceImpl = class {
2065
2078
  /**
2066
- * Takes the registry origin rather than a `SharedNamespaceContext`: the
2079
+ * Takes the registry origin rather than a `UniversalNamespaceContext`: the
2067
2080
  * registry is unauthenticated and on its own host, so the frontline sender
2068
2081
  * and the auth check would both be dead weight here.
2069
2082
  */
@@ -2087,7 +2100,7 @@ var TokensNamespaceImpl = class {
2087
2100
  }
2088
2101
  };
2089
2102
 
2090
- // src/shared/types/offer-option-address.ts
2103
+ // src/universal/types/offer-option-address.ts
2091
2104
  var OfferOptionAddressId = (value) => value;
2092
2105
  var OfferOptionAddress = {
2093
2106
  /** Maps the API DTO into the SDK offer-option-address domain model. */
@@ -2109,7 +2122,7 @@ var ConnectExternalWalletParams = {
2109
2122
  })
2110
2123
  };
2111
2124
 
2112
- // src/shared/types/wallet-ownership-challenge.ts
2125
+ // src/universal/types/wallet-ownership-challenge.ts
2113
2126
  var WalletOwnershipChallenge = {
2114
2127
  /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
2115
2128
  fromDto: (dto) => ({
@@ -2148,7 +2161,7 @@ var CreateWalletOwnershipChallengeParams = {
2148
2161
  }
2149
2162
  };
2150
2163
 
2151
- // src/shared/api/frontline/wallet-connect.ts
2164
+ // src/universal/api/frontline/wallet-connect.ts
2152
2165
  async function createWalletOwnershipChallenge(api, params) {
2153
2166
  const dto = await api.send({
2154
2167
  method: "POST",
@@ -2185,7 +2198,7 @@ async function removeOptionAddress(api, offerId, addressId) {
2185
2198
  return OfferOptionAddress.fromDto(dto);
2186
2199
  }
2187
2200
 
2188
- // src/shared/core/wallets/wallets-namespace.ts
2201
+ // src/universal/core/wallets/wallets-namespace.ts
2189
2202
  var WalletsNamespaceImpl = class {
2190
2203
  constructor(ctx) {
2191
2204
  this.ctx = ctx;
@@ -2228,7 +2241,7 @@ var WalletsNamespaceImpl = class {
2228
2241
  }
2229
2242
  };
2230
2243
 
2231
- // src/shared/types/oauth-session.ts
2244
+ // src/universal/types/oauth-session.ts
2232
2245
  var ClientCredentialsOAuth = (value) => value;
2233
2246
  var OAuthRefreshToken = (value) => value;
2234
2247
  var OAuthSession = {
@@ -2244,7 +2257,7 @@ var OAuthSession = {
2244
2257
  }
2245
2258
  };
2246
2259
 
2247
- // src/shared/api/frontline/offers.ts
2260
+ // src/universal/api/frontline/offers.ts
2248
2261
  async function fetchOffers(api, clientCreds) {
2249
2262
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
2250
2263
  }
@@ -2301,10 +2314,17 @@ export {
2301
2314
  internalLogger,
2302
2315
  HttpClient,
2303
2316
  fetchAllPages,
2317
+ Cursor,
2318
+ PaginatedResponse,
2319
+ PaginationParams,
2320
+ AssetId,
2321
+ AssetCode,
2322
+ Asset,
2304
2323
  ETHEREUM_CHAINS,
2305
2324
  EthereumChain,
2306
2325
  SOLANA_CHAINS,
2307
2326
  SolanaChain,
2327
+ isChain,
2308
2328
  Chain,
2309
2329
  EvmWalletAddress,
2310
2330
  EvmContractAddress,
@@ -2321,40 +2341,6 @@ export {
2321
2341
  StablecoinSymbol,
2322
2342
  KnownAssetSymbol,
2323
2343
  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
2344
  OfferId,
2359
2345
  OfferSlug,
2360
2346
  Offer,
@@ -2375,12 +2361,39 @@ export {
2375
2361
  Participation,
2376
2362
  CreateParticipationParams,
2377
2363
  CoinListTokenSaleNamespaceImpl,
2364
+ FormattedAmountUi,
2365
+ FormattedPercentUi,
2366
+ TxExplorerUrl,
2367
+ ShortenedWalletAddress,
2368
+ FormattedAmountAssetUi,
2369
+ AssetIconUrl,
2370
+ shortenAddress,
2371
+ formatAmount,
2372
+ formatRawAmount,
2373
+ formatCompactAmount,
2374
+ formatBpsAsPercent,
2375
+ usdAmount,
2376
+ assetAmount,
2377
+ NA_AMOUNT_ASSET_UI,
2378
+ formattedUsdPrice,
2379
+ getChainId,
2380
+ chainFromId,
2381
+ getNetworkName,
2382
+ txExplorerUrl,
2383
+ blockchainAmountFromRawOrThrow,
2384
+ parseBlockchainAmount,
2378
2385
  Ticker,
2379
2386
  OndoTradingStatus,
2380
2387
  OndoQuote,
2381
2388
  OndoBuyTransaction,
2382
2389
  OndoSellTransaction,
2383
2390
  OndoNamespaceImpl,
2391
+ SwapAuthorization,
2392
+ SwapPreview,
2393
+ SwapStatus,
2394
+ TokenAllowance,
2395
+ TokenBalance,
2396
+ AllowWalletResponse,
2384
2397
  SuperstateSwapNamespaceImpl,
2385
2398
  fetchOffers,
2386
2399
  fetchOffersPage,
@@ -2396,6 +2409,7 @@ export {
2396
2409
  RequirementStatusInfo,
2397
2410
  fetchOfferRequirements,
2398
2411
  RequirementsNamespaceImpl,
2412
+ Erc20NamespaceImpl,
2399
2413
  TokenLogoUrl,
2400
2414
  TokenLogo,
2401
2415
  TokenMetadata,
@@ -2410,4 +2424,4 @@ export {
2410
2424
  OAuthRefreshToken,
2411
2425
  OAuthSession
2412
2426
  };
2413
- //# sourceMappingURL=chunk-3ATIDGVR.js.map
2427
+ //# sourceMappingURL=chunk-6CQHDASY.js.map