@coinlist-co/react 0.12.1-rc.139e98c → 0.12.1-rc.a230abc

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-6CQHDASY.js → chunk-GFLU5OMP.js} +624 -624
  2. package/dist/chunk-GFLU5OMP.js.map +1 -0
  3. package/dist/{chunk-F6WGUKZC.js → chunk-HLL7IBIS.js} +9 -9
  4. package/dist/chunk-HLL7IBIS.js.map +1 -0
  5. package/dist/{chunk-ZFBEI3BW.js → chunk-RPE7XIBV.js} +126 -126
  6. package/dist/chunk-RPE7XIBV.js.map +1 -0
  7. package/dist/client/index.cjs +1321 -1323
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +149 -149
  10. package/dist/client/index.d.ts +149 -149
  11. package/dist/client/index.js +476 -476
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-DOm9VKVm.d.cts → collections-CAfs2Eww.d.cts} +1 -1
  14. package/dist/{collections-aCv-Wr2a.d.ts → collections-DZZFrizd.d.ts} +1 -1
  15. package/dist/{config-DIaFzrMW.d.cts → config-D19ktBr0.d.cts} +13 -13
  16. package/dist/{config-DIaFzrMW.d.ts → config-D19ktBr0.d.ts} +13 -13
  17. package/dist/server/index.cjs +232 -232
  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/{universal → shared}/index.cjs +955 -957
  24. package/dist/shared/index.cjs.map +1 -0
  25. package/dist/{universal → shared}/index.d.cts +557 -557
  26. package/dist/{universal → shared}/index.d.ts +557 -557
  27. package/dist/{universal → shared}/index.js +2 -2
  28. package/package.json +5 -5
  29. package/dist/chunk-6CQHDASY.js.map +0 -1
  30. package/dist/chunk-F6WGUKZC.js.map +0 -1
  31. package/dist/chunk-ZFBEI3BW.js.map +0 -1
  32. package/dist/universal/index.cjs.map +0 -1
  33. /package/dist/{universal → shared}/index.js.map +0 -0
@@ -1,4 +1,4 @@
1
- // src/universal/api/http-attributes.ts
1
+ // src/shared/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/universal/api/http.ts
56
+ // src/shared/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/universal/types/errors.ts
180
+ // src/shared/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/universal/api/pagination.ts
212
+ // src/shared/api/pagination.ts
213
213
  async function fetchAllPages(fetchPage, baseParams) {
214
214
  const items = [];
215
215
  let cursor = null;
@@ -225,44 +225,7 @@ async function fetchAllPages(fetchPage, baseParams) {
225
225
  return items;
226
226
  }
227
227
 
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
228
+ // src/shared/types/blockchain/core.ts
266
229
  var ETHEREUM_CHAINS = {
267
230
  ethereum_mainnet: true,
268
231
  ethereum_sepolia: true,
@@ -359,295 +322,226 @@ var StablecoinSymbol = (value) => value;
359
322
  var KnownAssetSymbol = StablecoinSymbol;
360
323
  var Bps = (value) => value;
361
324
 
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
- }
384
- };
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
- };
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;
404
332
 
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);
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
339
+ };
340
+ function getChainId(chain) {
341
+ return CHAIN_IDS[chain];
413
342
  }
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]);
419
- }
420
- let base64 = btoa(binary);
421
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
422
- if (!padding) {
423
- base64 = base64.replace(/=+$/, "");
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}"`);
424
348
  }
425
- return base64;
426
- }
427
- function generateSecureRandomBase64Url(byteLength) {
428
- const bytes = new Uint8Array(byteLength);
429
- crypto.getRandomValues(bytes);
430
- const buffer = bytes.buffer;
431
- return arrayBufferToBase64Url(buffer, false);
349
+ return chain;
432
350
  }
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("")}`;
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
+ }
444
365
  }
445
- return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
446
366
  }
447
- function notBlankStringOrNull(value) {
448
- if (value?.trim()) {
449
- return value;
450
- } else {
451
- return null;
367
+ function txExplorerUrl(chain, txHash) {
368
+ return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
369
+ }
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
+ }
452
384
  }
453
385
  }
454
386
 
455
- // src/universal/types/offer-detail.ts
456
- var OfferOptionId = (value) => value;
457
- var OfferOptionSlug = (value) => value;
458
- var OfferSwapContract = {
387
+ // src/shared/types/providers/superstate/swap.ts
388
+ var SwapAuthorization = {
459
389
  fromDto: (dto) => ({
460
- chain: Chain(dto.chain),
461
- address: EvmContractAddress(dto.address)
390
+ authorized: dto.authorized
462
391
  })
463
392
  };
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
- }
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
+ })
530
405
  };
531
- var OfferOption = {
406
+ var SwapStatus = {
532
407
  fromDto: (dto) => ({
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
541
- })
542
- };
543
- var FaqItem = {
544
- fromDto: (dto) => ({
545
- question: notBlankStringOrNull(dto.question),
546
- answer: notBlankStringOrNull(dto.answer)
547
- })
548
- };
549
- var Link = {
550
- fromDto: (dto) => ({
551
- label: notBlankStringOrNull(dto.label),
552
- url: notBlankStringOrNull(dto.url)
408
+ stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
409
+ swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
553
410
  })
554
411
  };
555
- var TermItem = {
412
+ var TokenAllowance = {
556
413
  fromDto: (dto) => ({
557
- key: notBlankStringOrNull(dto.key),
558
- value: notBlankStringOrNull(dto.value)
414
+ allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
559
415
  })
560
416
  };
561
- var Milestone = {
417
+ var TokenBalance = {
562
418
  fromDto: (dto) => ({
563
- name: notBlankStringOrNull(dto.name),
564
- schedule: notBlankStringOrNull(dto.schedule),
565
- status: dto.status
419
+ balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
566
420
  })
567
421
  };
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;
580
- }
581
- return queryParams;
582
- }
583
- };
584
- var Participation = {
585
- /** Maps API DTO shape into the SDK participation domain model. */
422
+ var AllowWalletResponse = {
586
423
  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
- };
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
+ }
440
+ }
601
441
  }
602
442
  };
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
- };
615
443
 
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
- );
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);
622
457
  }
623
- async function fetchParticipationsPage(api, params) {
624
- const pageDto = await api.send({
458
+ async function getSwapOutputToken(api, params) {
459
+ const dto = await api.send({
625
460
  method: "GET",
626
- url: "/v1/participations",
627
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
461
+ url: "/v1/swap/output-token",
462
+ queryParams: {
463
+ chain: params.chain,
464
+ contract_address: params.contractAddress
465
+ },
628
466
  attributes: Attributes.protected()
629
467
  });
630
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
468
+ return toErc20Asset(dto);
631
469
  }
632
- async function fetchParticipation(api, id) {
470
+ async function getSwapPreview(api, params) {
633
471
  const dto = await api.send({
634
472
  method: "GET",
635
- url: `/v1/participations/${id}`,
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
+ },
636
480
  attributes: Attributes.protected()
637
481
  });
638
- return Participation.fromDto(dto);
482
+ return SwapPreview.fromDto(dto);
639
483
  }
640
- async function createParticipation(api, params) {
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);
495
+ }
496
+ async function getTokenAllowance(api, params) {
497
+ const dto = await api.send({
498
+ 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
+ },
506
+ attributes: Attributes.protected()
507
+ });
508
+ return TokenAllowance.fromDto(dto);
509
+ }
510
+ async function getTokenBalance(api, params) {
511
+ const dto = await api.send({
512
+ method: "GET",
513
+ url: "/v1/token/balance",
514
+ queryParams: {
515
+ chain: params.chain,
516
+ token_address: params.tokenAddress,
517
+ owner: params.owner
518
+ },
519
+ attributes: Attributes.protected()
520
+ });
521
+ return TokenBalance.fromDto(dto);
522
+ }
523
+ async function allowWallet(api, params) {
641
524
  const dto = await api.send({
642
525
  method: "POST",
643
- url: "/v1/participations",
644
- body: CreateParticipationParams.toDto(params),
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
+ },
645
532
  attributes: Attributes.protected()
646
533
  });
647
- return Participation.fromDto(dto);
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
+ };
648
542
  }
649
543
 
650
- // src/universal/core/shared/observability/log-cause.ts
544
+ // src/shared/core/observability/log-cause.ts
651
545
  function classifyLogCause(error) {
652
546
  if (error instanceof HttpError) {
653
547
  return httpCause(error);
@@ -713,7 +607,7 @@ function apiErrorEventId(error) {
713
607
  return typeof eventId === "string" ? eventId : null;
714
608
  }
715
609
 
716
- // src/universal/core/shared/observability/internal-logger.ts
610
+ // src/shared/core/observability/internal-logger.ts
717
611
  function internalLogger(logger, scope) {
718
612
  return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
719
613
  }
@@ -796,47 +690,27 @@ var noopInternalLogger = {
796
690
  wrap: (_op, _params, run) => run()
797
691
  };
798
692
 
799
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
800
- var CoinListTokenSaleNamespaceImpl = class {
693
+ // src/shared/core/blockchain/erc20/erc20-namespace.ts
694
+ var Erc20NamespaceImpl = class {
801
695
  constructor(ctx) {
802
696
  this.ctx = ctx;
803
- this.log = internalLogger(ctx.logger, "TOKEN_SALE");
804
- }
805
- async list(offerId) {
806
- return this.log.wrap("list", offerId, async () => {
807
- await this.ctx.ensureUserAuthenticated();
808
- return fetchParticipations(this.ctx.api, offerId);
809
- });
810
- }
811
- async listPage(params) {
812
- return this.log.wrap("listPage", params, async () => {
813
- await this.ctx.ensureUserAuthenticated();
814
- return fetchParticipationsPage(this.ctx.api, params);
815
- });
697
+ this.log = internalLogger(ctx.logger, "ERC20");
816
698
  }
817
- async get(id) {
818
- return this.log.wrap("get", id, async () => {
699
+ async getAllowance(params) {
700
+ return this.log.wrap("getAllowance", params, async () => {
819
701
  await this.ctx.ensureUserAuthenticated();
820
- return fetchParticipation(this.ctx.api, id);
702
+ return getTokenAllowance(this.ctx.api, params);
821
703
  });
822
704
  }
823
- async createParticipation(params) {
824
- return this.log.wrap("createParticipation", params, async () => {
705
+ async getBalance(params) {
706
+ return this.log.wrap("getBalance", params, async () => {
825
707
  await this.ctx.ensureUserAuthenticated();
826
- return createParticipation(this.ctx.api, params);
708
+ return getTokenBalance(this.ctx.api, params);
827
709
  });
828
710
  }
829
711
  };
830
712
 
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
+ // src/shared/core/blockchain/formatters.ts
840
714
  import { formatUnits } from "viem";
841
715
  function shortenAddress(address) {
842
716
  const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
@@ -931,70 +805,16 @@ function formattedUsdPrice(amount, locale) {
931
805
  );
932
806
  }
933
807
 
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];
943
- }
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}"`);
949
- }
950
- return chain;
951
- }
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;
965
- }
966
- }
967
- }
968
- function txExplorerUrl(chain, txHash) {
969
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
970
- }
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
- }
985
- }
986
- }
987
-
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}")`);
808
+ // src/shared/core/blockchain/math.ts
809
+ import { parseUnits } from "viem";
810
+ function blockchainAmountFromRawOrThrow({
811
+ label,
812
+ raw,
813
+ decimals
814
+ }) {
815
+ const trimmed = raw.trim();
816
+ if (trimmed === "") {
817
+ throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
998
818
  }
999
819
  let value;
1000
820
  try {
@@ -1039,12 +859,369 @@ function parseBlockchainAmount(amount, decimals) {
1039
859
  } catch {
1040
860
  return { valid: false, reason: { type: "invalid-format" } };
1041
861
  }
1042
- }
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
+ });
1218
+ }
1219
+ };
1043
1220
 
1044
- // src/universal/types/trading.ts
1221
+ // src/shared/types/trading.ts
1045
1222
  var Ticker = (value) => value;
1046
1223
 
1047
- // src/universal/types/providers/ondo/ondo.ts
1224
+ // src/shared/types/providers/ondo/ondo.ts
1048
1225
  var OndoTradingStatus = {
1049
1226
  fromDto: (dto) => {
1050
1227
  if (!dto.tradable) return { type: "not-tradable", side: dto.side };
@@ -1210,7 +1387,7 @@ function parseExpiresAt(value) {
1210
1387
  return date;
1211
1388
  }
1212
1389
 
1213
- // src/universal/api/frontline/providers/ondo/ondo.ts
1390
+ // src/shared/api/frontline/providers/ondo/ondo.ts
1214
1391
  async function getOndoTradingStatus(api, params) {
1215
1392
  const dto = await api.send({
1216
1393
  method: "GET",
@@ -1305,7 +1482,7 @@ function sizeParam(params) {
1305
1482
  return { notional_value: notionalValue };
1306
1483
  }
1307
1484
 
1308
- // src/universal/core/checkout/ondo/ondo-namespace.ts
1485
+ // src/shared/core/checkout/ondo/ondo-namespace.ts
1309
1486
  var OndoNamespaceImpl = class {
1310
1487
  constructor(ctx) {
1311
1488
  this.ctx = ctx;
@@ -1337,164 +1514,7 @@ var OndoNamespaceImpl = class {
1337
1514
  }
1338
1515
  };
1339
1516
 
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
1517
+ // src/shared/core/checkout/superstate/swap-namespace.ts
1498
1518
  var SuperstateSwapNamespaceImpl = class {
1499
1519
  constructor(ctx) {
1500
1520
  this.ctx = ctx;
@@ -1532,7 +1552,7 @@ var SuperstateSwapNamespaceImpl = class {
1532
1552
  }
1533
1553
  };
1534
1554
 
1535
- // src/universal/types/document-submission.ts
1555
+ // src/shared/types/document-submission.ts
1536
1556
  var DocumentSubmission = {
1537
1557
  fromDto: (dto) => ({
1538
1558
  status: dto.status,
@@ -1540,14 +1560,14 @@ var DocumentSubmission = {
1540
1560
  })
1541
1561
  };
1542
1562
 
1543
- // src/universal/types/kyc.ts
1563
+ // src/shared/types/kyc.ts
1544
1564
  var KycToken = {
1545
1565
  fromDto: (dto) => ({
1546
1566
  token: dto.token
1547
1567
  })
1548
1568
  };
1549
1569
 
1550
- // src/universal/types/pii.ts
1570
+ // src/shared/types/pii.ts
1551
1571
  var Iso2CountryCode = (value) => value;
1552
1572
  var PiiJurisdiction = {
1553
1573
  fromDto: (dto) => ({
@@ -1575,7 +1595,7 @@ var Pii = {
1575
1595
  })
1576
1596
  };
1577
1597
 
1578
- // src/universal/types/requirement.ts
1598
+ // src/shared/types/requirement.ts
1579
1599
  var RequirementId = (value) => value;
1580
1600
  var Requirement = {
1581
1601
  fromDto: (dto) => ({
@@ -1596,7 +1616,7 @@ var RequirementStatusInfo = {
1596
1616
  )
1597
1617
  };
1598
1618
 
1599
- // src/universal/api/frontline/documents.ts
1619
+ // src/shared/api/frontline/documents.ts
1600
1620
  async function submitDocument(api, documentType, fields) {
1601
1621
  const dto = await api.send({
1602
1622
  method: "POST",
@@ -1607,7 +1627,7 @@ async function submitDocument(api, documentType, fields) {
1607
1627
  return DocumentSubmission.fromDto(dto);
1608
1628
  }
1609
1629
 
1610
- // src/universal/api/frontline/kyc.ts
1630
+ // src/shared/api/frontline/kyc.ts
1611
1631
  async function createKycToken(api, levelName, reset) {
1612
1632
  const dto = await api.send({
1613
1633
  method: "POST",
@@ -1621,7 +1641,7 @@ async function createKycToken(api, levelName, reset) {
1621
1641
  return KycToken.fromDto(dto);
1622
1642
  }
1623
1643
 
1624
- // src/universal/api/frontline/pii.ts
1644
+ // src/shared/api/frontline/pii.ts
1625
1645
  async function fetchPii(api) {
1626
1646
  const dto = await api.send({
1627
1647
  method: "GET",
@@ -1631,7 +1651,7 @@ async function fetchPii(api) {
1631
1651
  return Pii.fromDto(dto);
1632
1652
  }
1633
1653
 
1634
- // src/universal/api/frontline/requirements.ts
1654
+ // src/shared/api/frontline/requirements.ts
1635
1655
  async function fetchOfferRequirements(api, offerId, clientCreds) {
1636
1656
  const response = await api.send({
1637
1657
  method: "GET",
@@ -1657,7 +1677,7 @@ async function fetchRequirementStatuses(api, offerId) {
1657
1677
  return RequirementStatusInfo.fromStatusesDto(response);
1658
1678
  }
1659
1679
 
1660
- // src/universal/core/requirements/requirements-namespace.ts
1680
+ // src/shared/core/requirements/requirements-namespace.ts
1661
1681
  var RequirementsNamespaceImpl = class {
1662
1682
  constructor(ctx) {
1663
1683
  this.ctx = ctx;
@@ -1707,27 +1727,7 @@ var RequirementsNamespaceImpl = class {
1707
1727
  }
1708
1728
  };
1709
1729
 
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
1730
+ // src/shared/types/token-metadata.ts
1731
1731
  var TokenLogoUrl = (value) => value;
1732
1732
  var TokenLogo = {
1733
1733
  /** `baseUrl` is the registry origin; registry URLs are root-relative. */
@@ -1810,10 +1810,10 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
1810
1810
  url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
1811
1811
  );
1812
1812
 
1813
- // src/universal/api/nabu/tokens.ts
1813
+ // src/shared/api/nabu/tokens.ts
1814
1814
  import { getAddress } from "viem";
1815
1815
 
1816
- // src/universal/api/frontline/config.ts
1816
+ // src/shared/api/frontline/config.ts
1817
1817
  var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
1818
1818
  var HEADER_API_VERSION = "X-API-Version";
1819
1819
  var HEADER_USER_AGENT = "User-Agent";
@@ -1826,7 +1826,7 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
1826
1826
  var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
1827
1827
  var WALLET_PATH = "/wallet";
1828
1828
 
1829
- // src/universal/api/http-client.ts
1829
+ // src/shared/api/http-client.ts
1830
1830
  var HttpClient = class {
1831
1831
  constructor(config, middleware = {}, logger = null, options = {}) {
1832
1832
  this.config = config;
@@ -1982,7 +1982,7 @@ function describeRequestUnredacted(request) {
1982
1982
  };
1983
1983
  }
1984
1984
 
1985
- // src/universal/api/nabu/tokens.ts
1985
+ // src/shared/api/nabu/tokens.ts
1986
1986
  function createNabuApiClient(baseUrl, logger = null) {
1987
1987
  return new HttpClient({ baseUrl }, {}, logger);
1988
1988
  }
@@ -2073,10 +2073,10 @@ function checksummed(address) {
2073
2073
  }
2074
2074
  }
2075
2075
 
2076
- // src/universal/core/tokens/tokens-namespace.ts
2076
+ // src/shared/core/tokens/tokens-namespace.ts
2077
2077
  var TokensNamespaceImpl = class {
2078
2078
  /**
2079
- * Takes the registry origin rather than a `UniversalNamespaceContext`: the
2079
+ * Takes the registry origin rather than a `SharedNamespaceContext`: the
2080
2080
  * registry is unauthenticated and on its own host, so the frontline sender
2081
2081
  * and the auth check would both be dead weight here.
2082
2082
  */
@@ -2100,7 +2100,7 @@ var TokensNamespaceImpl = class {
2100
2100
  }
2101
2101
  };
2102
2102
 
2103
- // src/universal/types/offer-option-address.ts
2103
+ // src/shared/types/offer-option-address.ts
2104
2104
  var OfferOptionAddressId = (value) => value;
2105
2105
  var OfferOptionAddress = {
2106
2106
  /** Maps the API DTO into the SDK offer-option-address domain model. */
@@ -2122,7 +2122,7 @@ var ConnectExternalWalletParams = {
2122
2122
  })
2123
2123
  };
2124
2124
 
2125
- // src/universal/types/wallet-ownership-challenge.ts
2125
+ // src/shared/types/wallet-ownership-challenge.ts
2126
2126
  var WalletOwnershipChallenge = {
2127
2127
  /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
2128
2128
  fromDto: (dto) => ({
@@ -2161,7 +2161,7 @@ var CreateWalletOwnershipChallengeParams = {
2161
2161
  }
2162
2162
  };
2163
2163
 
2164
- // src/universal/api/frontline/wallet-connect.ts
2164
+ // src/shared/api/frontline/wallet-connect.ts
2165
2165
  async function createWalletOwnershipChallenge(api, params) {
2166
2166
  const dto = await api.send({
2167
2167
  method: "POST",
@@ -2198,7 +2198,7 @@ async function removeOptionAddress(api, offerId, addressId) {
2198
2198
  return OfferOptionAddress.fromDto(dto);
2199
2199
  }
2200
2200
 
2201
- // src/universal/core/wallets/wallets-namespace.ts
2201
+ // src/shared/core/wallets/wallets-namespace.ts
2202
2202
  var WalletsNamespaceImpl = class {
2203
2203
  constructor(ctx) {
2204
2204
  this.ctx = ctx;
@@ -2241,7 +2241,7 @@ var WalletsNamespaceImpl = class {
2241
2241
  }
2242
2242
  };
2243
2243
 
2244
- // src/universal/types/oauth-session.ts
2244
+ // src/shared/types/oauth-session.ts
2245
2245
  var ClientCredentialsOAuth = (value) => value;
2246
2246
  var OAuthRefreshToken = (value) => value;
2247
2247
  var OAuthSession = {
@@ -2257,7 +2257,7 @@ var OAuthSession = {
2257
2257
  }
2258
2258
  };
2259
2259
 
2260
- // src/universal/api/frontline/offers.ts
2260
+ // src/shared/api/frontline/offers.ts
2261
2261
  async function fetchOffers(api, clientCreds) {
2262
2262
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
2263
2263
  }
@@ -2314,12 +2314,6 @@ export {
2314
2314
  internalLogger,
2315
2315
  HttpClient,
2316
2316
  fetchAllPages,
2317
- Cursor,
2318
- PaginatedResponse,
2319
- PaginationParams,
2320
- AssetId,
2321
- AssetCode,
2322
- Asset,
2323
2317
  ETHEREUM_CHAINS,
2324
2318
  EthereumChain,
2325
2319
  SOLANA_CHAINS,
@@ -2341,6 +2335,40 @@ export {
2341
2335
  StablecoinSymbol,
2342
2336
  KnownAssetSymbol,
2343
2337
  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,
2344
2372
  OfferId,
2345
2373
  OfferSlug,
2346
2374
  Offer,
@@ -2361,39 +2389,12 @@ export {
2361
2389
  Participation,
2362
2390
  CreateParticipationParams,
2363
2391
  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,
2385
2392
  Ticker,
2386
2393
  OndoTradingStatus,
2387
2394
  OndoQuote,
2388
2395
  OndoBuyTransaction,
2389
2396
  OndoSellTransaction,
2390
2397
  OndoNamespaceImpl,
2391
- SwapAuthorization,
2392
- SwapPreview,
2393
- SwapStatus,
2394
- TokenAllowance,
2395
- TokenBalance,
2396
- AllowWalletResponse,
2397
2398
  SuperstateSwapNamespaceImpl,
2398
2399
  fetchOffers,
2399
2400
  fetchOffersPage,
@@ -2409,7 +2410,6 @@ export {
2409
2410
  RequirementStatusInfo,
2410
2411
  fetchOfferRequirements,
2411
2412
  RequirementsNamespaceImpl,
2412
- Erc20NamespaceImpl,
2413
2413
  TokenLogoUrl,
2414
2414
  TokenLogo,
2415
2415
  TokenMetadata,
@@ -2424,4 +2424,4 @@ export {
2424
2424
  OAuthRefreshToken,
2425
2425
  OAuthSession
2426
2426
  };
2427
- //# sourceMappingURL=chunk-6CQHDASY.js.map
2427
+ //# sourceMappingURL=chunk-GFLU5OMP.js.map