@coinlist-co/react 0.6.0 → 0.9.0

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 (39) hide show
  1. package/dist/{chunk-5E3P7AMH.js → chunk-AAER5LOL.js} +3 -1
  2. package/dist/chunk-AAER5LOL.js.map +1 -0
  3. package/dist/chunk-I5YTJ5SL.js +644 -0
  4. package/dist/chunk-I5YTJ5SL.js.map +1 -0
  5. package/dist/{chunk-5C4TEVM7.js → chunk-MKCOK3DF.js} +68 -57
  6. package/dist/chunk-MKCOK3DF.js.map +1 -0
  7. package/dist/chunk-Z2HAA2TI.js +768 -0
  8. package/dist/chunk-Z2HAA2TI.js.map +1 -0
  9. package/dist/client/index.cjs +2895 -230
  10. package/dist/client/index.cjs.map +1 -1
  11. package/dist/client/index.d.cts +902 -29
  12. package/dist/client/index.d.ts +902 -29
  13. package/dist/client/index.js +1980 -211
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/collections-B84Vw55t.d.cts +28 -0
  16. package/dist/collections-BQbFJS3g.d.ts +28 -0
  17. package/dist/requirement-C2w45Q11.d.cts +969 -0
  18. package/dist/requirement-C2w45Q11.d.ts +969 -0
  19. package/dist/server/index.cjs +521 -37
  20. package/dist/server/index.cjs.map +1 -1
  21. package/dist/server/index.d.cts +116 -9
  22. package/dist/server/index.d.ts +116 -9
  23. package/dist/server/index.js +95 -28
  24. package/dist/server/index.js.map +1 -1
  25. package/dist/shared/index.cjs +1245 -72
  26. package/dist/shared/index.cjs.map +1 -1
  27. package/dist/shared/index.d.cts +624 -3
  28. package/dist/shared/index.d.ts +624 -3
  29. package/dist/shared/index.js +216 -5
  30. package/dist/shared/index.js.map +1 -1
  31. package/package.json +7 -3
  32. package/dist/chunk-5C4TEVM7.js.map +0 -1
  33. package/dist/chunk-5E3P7AMH.js.map +0 -1
  34. package/dist/chunk-7SB2GKEU.js +0 -311
  35. package/dist/chunk-7SB2GKEU.js.map +0 -1
  36. package/dist/chunk-UEJVCU2J.js +0 -43
  37. package/dist/chunk-UEJVCU2J.js.map +0 -1
  38. package/dist/requirement-Dk6nYN1c.d.cts +0 -389
  39. package/dist/requirement-Dk6nYN1c.d.ts +0 -389
@@ -20,20 +20,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/shared/index.ts
21
21
  var shared_exports = {};
22
22
  __export(shared_exports, {
23
+ AllowWalletResponse: () => AllowWalletResponse,
23
24
  Asset: () => Asset,
24
25
  AssetCode: () => AssetCode,
26
+ AssetDecimals: () => AssetDecimals,
27
+ AssetIconUrl: () => AssetIconUrl,
25
28
  AssetId: () => AssetId,
29
+ AssetSymbol: () => AssetSymbol,
26
30
  AuthorizationCode: () => AuthorizationCode,
31
+ BPS_DENOM: () => BPS_DENOM,
27
32
  Blockchain: () => Blockchain,
33
+ BlockchainAmount: () => BlockchainAmount,
34
+ Bps: () => Bps,
35
+ ClientCredentialsOAuth: () => ClientCredentialsOAuth,
28
36
  ClientId: () => ClientId,
29
37
  ClientSecret: () => ClientSecret,
30
38
  CodeChallenge: () => CodeChallenge,
31
39
  CodeVerifier: () => CodeVerifier,
40
+ ConnectExternalWalletParams: () => ConnectExternalWalletParams,
32
41
  CreateParticipationParams: () => CreateParticipationParams,
42
+ CreateWalletOwnershipChallengeParams: () => CreateWalletOwnershipChallengeParams,
33
43
  Cursor: () => Cursor,
44
+ DEFAULT_AMOUNT_TO_COMPUTE_PRICE: () => DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
45
+ DEFAULT_SLIPPAGE_BPS: () => DEFAULT_SLIPPAGE_BPS,
46
+ DocumentSubmission: () => DocumentSubmission,
47
+ ERC20_ABI: () => ERC20_ABI,
48
+ EvmContractAddress: () => EvmContractAddress,
49
+ EvmWalletAddress: () => EvmWalletAddress,
34
50
  FaqItem: () => FaqItem,
51
+ FormattedAmountAssetUi: () => FormattedAmountAssetUi,
52
+ FormattedAmountUi: () => FormattedAmountUi,
53
+ FormattedPercentUi: () => FormattedPercentUi,
54
+ HexEncodedTransactionData: () => HexEncodedTransactionData,
55
+ Iso2CountryCode: () => Iso2CountryCode,
56
+ KnownAssetSymbol: () => KnownAssetSymbol,
57
+ KycToken: () => KycToken,
35
58
  Link: () => Link,
59
+ MAX_UINT_256: () => MAX_UINT_256,
36
60
  Milestone: () => Milestone,
61
+ NA_AMOUNT_ASSET_UI: () => NA_AMOUNT_ASSET_UI,
37
62
  NotAuthenticatedError: () => NotAuthenticatedError,
38
63
  NotImplementedError: () => NotImplementedError,
39
64
  OAuthRefreshToken: () => OAuthRefreshToken,
@@ -42,6 +67,8 @@ __export(shared_exports, {
42
67
  OfferDetail: () => OfferDetail,
43
68
  OfferId: () => OfferId,
44
69
  OfferOption: () => OfferOption,
70
+ OfferOptionAddress: () => OfferOptionAddress,
71
+ OfferOptionAddressId: () => OfferOptionAddressId,
45
72
  OfferOptionId: () => OfferOptionId,
46
73
  OfferOptionSlug: () => OfferOptionSlug,
47
74
  OfferSlug: () => OfferSlug,
@@ -51,17 +78,60 @@ __export(shared_exports, {
51
78
  Participation: () => Participation,
52
79
  ParticipationId: () => ParticipationId,
53
80
  ParticipationsPaginationParams: () => ParticipationsPaginationParams,
81
+ Pii: () => Pii,
82
+ PiiAddress: () => PiiAddress,
83
+ PiiJurisdiction: () => PiiJurisdiction,
54
84
  RedirectUri: () => RedirectUri,
55
85
  Requirement: () => Requirement,
56
86
  RequirementId: () => RequirementId,
57
87
  RequirementStatusInfo: () => RequirementStatusInfo,
88
+ SLIPPAGE_OPTIONS_BPS: () => SLIPPAGE_OPTIONS_BPS,
89
+ SUPERSTATE_SWAP_ABI: () => SUPERSTATE_SWAP_ABI,
90
+ SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: () => SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
91
+ SUPERSTATE_TOS_URL: () => SUPERSTATE_TOS_URL,
92
+ SWAP_POLL_INTERVAL_MS: () => SWAP_POLL_INTERVAL_MS,
93
+ ShortenedWalletAddress: () => ShortenedWalletAddress,
94
+ StablecoinSymbol: () => StablecoinSymbol,
95
+ SwapAuthorization: () => SwapAuthorization,
96
+ SwapNamespaceImpl: () => SwapNamespaceImpl,
97
+ SwapPreview: () => SwapPreview,
98
+ SwapQuote: () => SwapQuote,
99
+ SwapStatus: () => SwapStatus,
100
+ TOKEN_REGISTRY: () => TOKEN_REGISTRY,
58
101
  TermItem: () => TermItem,
102
+ TokenAllowance: () => TokenAllowance,
103
+ TokenBalance: () => TokenBalance,
104
+ TxExplorerUrl: () => TxExplorerUrl,
105
+ USDC: () => USDC,
106
+ USDC_SYMBOL: () => USDC_SYMBOL,
107
+ USDT: () => USDT,
108
+ USDT_SYMBOL: () => USDT_SYMBOL,
59
109
  User: () => User,
60
110
  UserEmail: () => UserEmail,
61
111
  UserId: () => UserId,
62
112
  WalletAddress: () => WalletAddress,
113
+ WalletOwnershipChallenge: () => WalletOwnershipChallenge,
114
+ applyBps: () => applyBps,
115
+ assertUint256: () => assertUint256,
116
+ assetAmount: () => assetAmount,
117
+ computePrice: () => computePrice,
118
+ computeSlip: () => computeSlip,
119
+ decodeSwappedOutputAmount: () => decodeSwappedOutputAmount,
63
120
  fetchAllPages: () => fetchAllPages,
64
- generatePKCEParams: () => generatePKCEParams
121
+ formatAmount: () => formatAmount,
122
+ formatBpsAsPercent: () => formatBpsAsPercent,
123
+ formatCompactAmount: () => formatCompactAmount,
124
+ formatRawAmount: () => formatRawAmount,
125
+ formattedPricePerShare: () => formattedPricePerShare,
126
+ formattedUsdPrice: () => formattedUsdPrice,
127
+ generatePKCEParams: () => generatePKCEParams,
128
+ getChainId: () => getChainId,
129
+ getNetworkName: () => getNetworkName,
130
+ isStopped: () => isStopped,
131
+ parseBlockchainAmount: () => parseBlockchainAmount,
132
+ shortenAddress: () => shortenAddress,
133
+ txExplorerUrl: () => txExplorerUrl,
134
+ usdAmount: () => usdAmount
65
135
  });
66
136
  module.exports = __toCommonJS(shared_exports);
67
137
 
@@ -104,14 +174,890 @@ var PaginationParams = {
104
174
  }
105
175
  };
106
176
 
107
- // src/shared/types/oauth.ts
108
- var AuthorizationCode = (value) => value;
109
- var CodeVerifier = (value) => value;
110
- var CodeChallenge = (value) => value;
111
- var PKCEState = (value) => value;
112
- var RedirectUri = (value) => value;
113
- var ClientId = (value) => value;
114
- var ClientSecret = (value) => value;
177
+ // src/shared/core/blockchain/abis/erc20.ts
178
+ var ERC20_ABI = [
179
+ {
180
+ type: "function",
181
+ name: "allowance",
182
+ inputs: [
183
+ { name: "owner", type: "address" },
184
+ { name: "spender", type: "address" }
185
+ ],
186
+ outputs: [{ name: "", type: "uint256" }],
187
+ stateMutability: "view"
188
+ },
189
+ {
190
+ type: "function",
191
+ name: "approve",
192
+ inputs: [
193
+ { name: "spender", type: "address" },
194
+ { name: "amount", type: "uint256" }
195
+ ],
196
+ outputs: [{ name: "", type: "bool" }],
197
+ stateMutability: "nonpayable"
198
+ },
199
+ {
200
+ type: "function",
201
+ name: "balanceOf",
202
+ inputs: [{ name: "account", type: "address" }],
203
+ outputs: [{ name: "", type: "uint256" }],
204
+ stateMutability: "view"
205
+ },
206
+ {
207
+ type: "function",
208
+ name: "decimals",
209
+ inputs: [],
210
+ outputs: [{ name: "", type: "uint8" }],
211
+ stateMutability: "view"
212
+ },
213
+ {
214
+ type: "function",
215
+ name: "name",
216
+ inputs: [],
217
+ outputs: [{ name: "", type: "string" }],
218
+ stateMutability: "view"
219
+ },
220
+ {
221
+ type: "function",
222
+ name: "symbol",
223
+ inputs: [],
224
+ outputs: [{ name: "", type: "string" }],
225
+ stateMutability: "view"
226
+ },
227
+ {
228
+ type: "function",
229
+ name: "totalSupply",
230
+ inputs: [],
231
+ outputs: [{ name: "", type: "uint256" }],
232
+ stateMutability: "view"
233
+ },
234
+ {
235
+ type: "function",
236
+ name: "transfer",
237
+ inputs: [
238
+ { name: "recipient", type: "address" },
239
+ { name: "amount", type: "uint256" }
240
+ ],
241
+ outputs: [{ name: "", type: "bool" }],
242
+ stateMutability: "nonpayable"
243
+ },
244
+ {
245
+ type: "function",
246
+ name: "transferFrom",
247
+ inputs: [
248
+ { name: "sender", type: "address" },
249
+ { name: "recipient", type: "address" },
250
+ { name: "amount", type: "uint256" }
251
+ ],
252
+ outputs: [{ name: "", type: "bool" }],
253
+ stateMutability: "nonpayable"
254
+ },
255
+ {
256
+ type: "event",
257
+ name: "Approval",
258
+ inputs: [
259
+ { name: "owner", type: "address", indexed: true },
260
+ { name: "spender", type: "address", indexed: true },
261
+ { name: "value", type: "uint256", indexed: false }
262
+ ],
263
+ anonymous: false
264
+ },
265
+ {
266
+ type: "event",
267
+ name: "Transfer",
268
+ inputs: [
269
+ { name: "from", type: "address", indexed: true },
270
+ { name: "to", type: "address", indexed: true },
271
+ { name: "value", type: "uint256", indexed: false }
272
+ ],
273
+ anonymous: false
274
+ }
275
+ ];
276
+
277
+ // src/shared/core/blockchain/abis/superstate-swap.ts
278
+ var SUPERSTATE_SWAP_ABI = [
279
+ {
280
+ type: "function",
281
+ name: "authorized",
282
+ inputs: [{ name: "user", type: "address", internalType: "address" }],
283
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
284
+ stateMutability: "view"
285
+ },
286
+ {
287
+ type: "function",
288
+ name: "stopped",
289
+ inputs: [],
290
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
291
+ stateMutability: "view"
292
+ },
293
+ {
294
+ type: "function",
295
+ name: "SWAP_LEVEL",
296
+ inputs: [],
297
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
298
+ stateMutability: "view"
299
+ },
300
+ {
301
+ type: "function",
302
+ name: "preview",
303
+ inputs: [
304
+ { name: "token", type: "address", internalType: "address" },
305
+ { name: "amount", type: "uint256", internalType: "uint256" }
306
+ ],
307
+ outputs: [
308
+ {
309
+ name: "",
310
+ type: "tuple",
311
+ internalType: "struct Preview",
312
+ components: [
313
+ { name: "input", type: "uint256", internalType: "uint256" },
314
+ { name: "fee", type: "uint256", internalType: "uint256" },
315
+ { name: "output", type: "uint256", internalType: "uint256" }
316
+ ]
317
+ }
318
+ ],
319
+ stateMutability: "view"
320
+ },
321
+ {
322
+ type: "function",
323
+ name: "swap",
324
+ inputs: [
325
+ { name: "token", type: "address", internalType: "address" },
326
+ { name: "amount", type: "uint256", internalType: "uint256" },
327
+ { name: "slip", type: "uint256", internalType: "uint256" }
328
+ ],
329
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
330
+ stateMutability: "nonpayable"
331
+ },
332
+ {
333
+ type: "function",
334
+ name: "tokenBalance",
335
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
336
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
337
+ stateMutability: "view"
338
+ },
339
+ {
340
+ type: "function",
341
+ name: "outputToken",
342
+ inputs: [],
343
+ outputs: [{ name: "", type: "address", internalType: "address" }],
344
+ stateMutability: "view"
345
+ },
346
+ {
347
+ type: "function",
348
+ name: "outputTokenBalance",
349
+ inputs: [],
350
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
351
+ stateMutability: "view"
352
+ },
353
+ {
354
+ type: "function",
355
+ name: "totals",
356
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
357
+ outputs: [
358
+ {
359
+ name: "",
360
+ type: "tuple",
361
+ internalType: "struct SwapTotal",
362
+ components: [
363
+ { name: "inputSum", type: "uint256", internalType: "uint256" },
364
+ { name: "feeSum", type: "uint256", internalType: "uint256" },
365
+ { name: "outputSum", type: "uint256", internalType: "uint256" },
366
+ { name: "count", type: "uint256", internalType: "uint256" }
367
+ ]
368
+ }
369
+ ],
370
+ stateMutability: "view"
371
+ },
372
+ {
373
+ type: "function",
374
+ name: "totals",
375
+ inputs: [
376
+ { name: "user", type: "address", internalType: "address" },
377
+ { name: "token", type: "address", internalType: "address" }
378
+ ],
379
+ outputs: [
380
+ {
381
+ name: "",
382
+ type: "tuple",
383
+ internalType: "struct SwapTotal",
384
+ components: [
385
+ { name: "inputSum", type: "uint256", internalType: "uint256" },
386
+ { name: "feeSum", type: "uint256", internalType: "uint256" },
387
+ { name: "outputSum", type: "uint256", internalType: "uint256" },
388
+ { name: "count", type: "uint256", internalType: "uint256" }
389
+ ]
390
+ }
391
+ ],
392
+ stateMutability: "view"
393
+ },
394
+ {
395
+ type: "function",
396
+ name: "transfer",
397
+ inputs: [
398
+ { name: "to", type: "address", internalType: "address" },
399
+ { name: "amount", type: "uint256", internalType: "uint256" }
400
+ ],
401
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
402
+ stateMutability: "nonpayable"
403
+ },
404
+ {
405
+ type: "function",
406
+ name: "transfer",
407
+ inputs: [
408
+ { name: "to", type: "address", internalType: "address" },
409
+ { name: "token", type: "address", internalType: "address" },
410
+ { name: "amount", type: "uint256", internalType: "uint256" }
411
+ ],
412
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
413
+ stateMutability: "nonpayable"
414
+ },
415
+ {
416
+ type: "function",
417
+ name: "setBps",
418
+ inputs: [{ name: "points", type: "uint256", internalType: "uint256" }],
419
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
420
+ stateMutability: "nonpayable"
421
+ },
422
+ {
423
+ type: "event",
424
+ name: "Swapped",
425
+ inputs: [
426
+ { name: "user", type: "address", indexed: true, internalType: "address" },
427
+ {
428
+ name: "inputToken",
429
+ type: "address",
430
+ indexed: true,
431
+ internalType: "address"
432
+ },
433
+ {
434
+ name: "outputToken",
435
+ type: "address",
436
+ indexed: true,
437
+ internalType: "address"
438
+ },
439
+ {
440
+ name: "inputAmount",
441
+ type: "uint256",
442
+ indexed: false,
443
+ internalType: "uint256"
444
+ },
445
+ {
446
+ name: "outputAmount",
447
+ type: "uint256",
448
+ indexed: false,
449
+ internalType: "uint256"
450
+ }
451
+ ],
452
+ anonymous: false
453
+ },
454
+ {
455
+ type: "event",
456
+ name: "Transferred",
457
+ inputs: [
458
+ { name: "to", type: "address", indexed: true, internalType: "address" },
459
+ {
460
+ name: "token",
461
+ type: "address",
462
+ indexed: true,
463
+ internalType: "address"
464
+ },
465
+ {
466
+ name: "amount",
467
+ type: "uint256",
468
+ indexed: false,
469
+ internalType: "uint256"
470
+ }
471
+ ],
472
+ anonymous: false
473
+ },
474
+ {
475
+ type: "error",
476
+ name: "InvalidAddress",
477
+ inputs: []
478
+ },
479
+ {
480
+ type: "error",
481
+ name: "InsufficientAmount",
482
+ inputs: []
483
+ },
484
+ {
485
+ type: "error",
486
+ name: "InvalidAmount",
487
+ inputs: []
488
+ },
489
+ {
490
+ type: "error",
491
+ name: "SwapFailed",
492
+ inputs: [
493
+ { name: "user", type: "address", internalType: "address" },
494
+ { name: "token", type: "address", internalType: "address" }
495
+ ]
496
+ }
497
+ ];
498
+
499
+ // src/shared/types/blockchain/core.ts
500
+ var EvmWalletAddress = (value) => value;
501
+ var EvmContractAddress = (value) => value;
502
+ var HexEncodedTransactionData = (value) => value;
503
+ var AssetDecimals = (value) => value;
504
+ var MAX_UINT_256 = 2n ** 256n - 1n;
505
+ var assertUint256 = (value) => {
506
+ if (value < 0n || value > MAX_UINT_256) {
507
+ throw new Error(`Value out of uint256 bounds: ${value}`);
508
+ }
509
+ return value;
510
+ };
511
+ var BlockchainAmount = Object.assign(
512
+ (value) => value,
513
+ {
514
+ add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
515
+ sub: (a, b) => combineAmounts(a, b, (x, y) => x - y)
516
+ }
517
+ );
518
+ function combineAmounts(a, b, op) {
519
+ if (a.decimals !== b.decimals) {
520
+ throw new Error(
521
+ `Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
522
+ );
523
+ }
524
+ const raw = op(a.raw, b.raw);
525
+ if (raw < 0n || raw > MAX_UINT_256) {
526
+ throw new Error(`BlockchainAmount out of uint256 bounds: ${raw}`);
527
+ }
528
+ return BlockchainAmount({ raw, decimals: a.decimals });
529
+ }
530
+ var AssetSymbol = (value) => value;
531
+ var StablecoinSymbol = (value) => value;
532
+ var KnownAssetSymbol = StablecoinSymbol;
533
+ var Bps = (value) => value;
534
+
535
+ // src/shared/core/blockchain/bps.ts
536
+ var BPS_DENOM = Bps(10000n);
537
+ function applyBps(amount, bps) {
538
+ return assertUint256(amount * bps / BPS_DENOM);
539
+ }
540
+
541
+ // src/shared/types/blockchain/ui.ts
542
+ var FormattedAmountUi = (value) => value;
543
+ var FormattedPercentUi = (value) => value;
544
+ var TxExplorerUrl = (value) => value;
545
+ var ShortenedWalletAddress = (value) => value;
546
+ var FormattedAmountAssetUi = (value) => value;
547
+ var AssetIconUrl = (value) => value;
548
+
549
+ // src/shared/core/blockchain/chain.ts
550
+ function getChainId(chain) {
551
+ switch (chain) {
552
+ case "ethereum_mainnet":
553
+ return 1;
554
+ case "ethereum_sepolia":
555
+ return 11155111;
556
+ default: {
557
+ const _exhaustive = chain;
558
+ return _exhaustive;
559
+ }
560
+ }
561
+ }
562
+ function getNetworkName(chain) {
563
+ switch (chain) {
564
+ case "ethereum_mainnet":
565
+ return "Ethereum";
566
+ case "ethereum_sepolia":
567
+ return "Ethereum Sepolia";
568
+ default: {
569
+ const _exhaustive = chain;
570
+ return _exhaustive;
571
+ }
572
+ }
573
+ }
574
+ function txExplorerUrl(chain, txHash) {
575
+ return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
576
+ }
577
+ function explorerBaseUrl(chain) {
578
+ switch (chain) {
579
+ case "ethereum_mainnet":
580
+ return "https://etherscan.io";
581
+ case "ethereum_sepolia":
582
+ return "https://sepolia.etherscan.io";
583
+ default: {
584
+ const _exhaustive = chain;
585
+ return _exhaustive;
586
+ }
587
+ }
588
+ }
589
+
590
+ // src/shared/core/blockchain/formatters.ts
591
+ var import_viem = require("viem");
592
+
593
+ // src/shared/core/blockchain/swap/math.ts
594
+ function computePrice({
595
+ inputTokenAmount,
596
+ outputTokenAmount
597
+ }) {
598
+ if (outputTokenAmount.raw === 0n) return null;
599
+ const scale = 10n ** BigInt(outputTokenAmount.decimals);
600
+ const raw = assertUint256(
601
+ inputTokenAmount.raw * scale / outputTokenAmount.raw
602
+ );
603
+ return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });
604
+ }
605
+ function computeSlip(amount, slippage) {
606
+ const retained = Bps(assertUint256(BPS_DENOM - slippage));
607
+ const slipRaw = applyBps(amount.raw, retained);
608
+ return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
609
+ }
610
+
611
+ // src/shared/core/blockchain/formatters.ts
612
+ function shortenAddress(address) {
613
+ const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
614
+ return ShortenedWalletAddress(short);
615
+ }
616
+ function formatAmount(amount, locale, options) {
617
+ const decimal = formatRawAmount(amount);
618
+ let [integerPart, fractionPart = ""] = decimal.split(".");
619
+ const maxFractionDigits = options?.maxFractionDigits;
620
+ const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
621
+ if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
622
+ ({ integerPart, fractionPart } = roundFractionHalfUp(
623
+ integerPart,
624
+ fractionPart,
625
+ maxFractionDigits
626
+ ));
627
+ }
628
+ const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
629
+ const integerFormatted = BigInt(integerPart).toLocaleString(locale);
630
+ if (minFractionDigits === 0 && fraction === "") {
631
+ return FormattedAmountUi(integerFormatted);
632
+ }
633
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
634
+ return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
635
+ }
636
+ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
637
+ if (fractionPart.length <= maxFractionDigits) {
638
+ return { integerPart, fractionPart };
639
+ }
640
+ if (maxFractionDigits === 0) {
641
+ const roundUp = fractionPart[0] >= "5";
642
+ const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
643
+ return { integerPart: integer.toString(), fractionPart: "" };
644
+ }
645
+ const trimmed = fractionPart.slice(0, maxFractionDigits);
646
+ if (fractionPart[maxFractionDigits] < "5") {
647
+ return { integerPart, fractionPart: trimmed };
648
+ }
649
+ const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
650
+ let carry = 1;
651
+ for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
652
+ const sum = digits[i] + carry;
653
+ if (sum === 10) {
654
+ digits[i] = 0;
655
+ carry = 1;
656
+ } else {
657
+ digits[i] = sum;
658
+ carry = 0;
659
+ }
660
+ }
661
+ return {
662
+ integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
663
+ fractionPart: digits.join("")
664
+ };
665
+ }
666
+ function formatRawAmount(amount) {
667
+ return (0, import_viem.formatUnits)(amount.raw, amount.decimals);
668
+ }
669
+ function formatCompactAmount(amount, locale) {
670
+ const value = Number(formatRawAmount(amount));
671
+ const formatted = new Intl.NumberFormat(locale, {
672
+ notation: "compact",
673
+ maximumFractionDigits: 2
674
+ }).format(value);
675
+ return FormattedAmountUi(formatted);
676
+ }
677
+ function formatBpsAsPercent(bps, locale) {
678
+ const whole = bps / 100n;
679
+ const fraction = bps % 100n;
680
+ const wholeFormatted = whole.toLocaleString(locale);
681
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
682
+ if (fraction === 0n) {
683
+ return FormattedPercentUi(`${wholeFormatted}%`);
684
+ }
685
+ const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
686
+ return FormattedPercentUi(
687
+ `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
688
+ );
689
+ }
690
+ function usdAmount(amount) {
691
+ return FormattedAmountAssetUi(`$${amount}`);
692
+ }
693
+ function assetAmount(amount, symbol) {
694
+ return FormattedAmountAssetUi(`${amount} ${symbol}`);
695
+ }
696
+ var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
697
+ var USD_FRACTION_DIGITS = AssetDecimals(2);
698
+ function formattedUsdPrice(amount, locale) {
699
+ if (!amount) return NA_AMOUNT_ASSET_UI;
700
+ return usdAmount(
701
+ formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
702
+ );
703
+ }
704
+ function formattedPricePerShare(quote, locale) {
705
+ if (!quote) return NA_AMOUNT_ASSET_UI;
706
+ return formattedUsdPrice(computePrice(quote), locale);
707
+ }
708
+
709
+ // src/shared/core/blockchain/math.ts
710
+ var import_viem2 = require("viem");
711
+ function parseBlockchainAmount(amount, decimals) {
712
+ const trimmed = amount.trim();
713
+ if (trimmed === "") return { valid: false, reason: { type: "empty" } };
714
+ if (trimmed.startsWith("-")) {
715
+ return { valid: false, reason: { type: "negative" } };
716
+ }
717
+ if (/[eE]/.test(trimmed)) {
718
+ return { valid: false, reason: { type: "invalid-format" } };
719
+ }
720
+ if (!/^\d+(\.\d+)?$/.test(trimmed)) {
721
+ return { valid: false, reason: { type: "invalid-format" } };
722
+ }
723
+ const [, fraction = ""] = trimmed.split(".");
724
+ if (fraction.length > decimals) {
725
+ return {
726
+ valid: false,
727
+ reason: { type: "too-many-decimals", maxDecimals: decimals }
728
+ };
729
+ }
730
+ try {
731
+ return {
732
+ valid: true,
733
+ amount: BlockchainAmount({
734
+ raw: (0, import_viem2.parseUnits)(trimmed, decimals),
735
+ decimals
736
+ })
737
+ };
738
+ } catch {
739
+ return { valid: false, reason: { type: "invalid-format" } };
740
+ }
741
+ }
742
+
743
+ // src/shared/core/blockchain/swap/constants.ts
744
+ var SUPERSTATE_TOS_URL = "https://superstate.com/terms";
745
+ var SWAP_POLL_INTERVAL_MS = 15e3;
746
+ var DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1000000n;
747
+ var SLIPPAGE_OPTIONS_BPS = [25n, 50n, 100n, 200n, 500n].map(
748
+ (n) => Bps(n)
749
+ );
750
+ var DEFAULT_SLIPPAGE_BPS = Bps(50n);
751
+ var SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA = EvmContractAddress("0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557");
752
+
753
+ // src/shared/core/blockchain/swap/quote.ts
754
+ var SwapQuote = {
755
+ /**
756
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
757
+ * input and fee are denominated in the input token; the output in the output
758
+ * token.
759
+ */
760
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
761
+ inputTokenAmount: BlockchainAmount({
762
+ raw: preview.inputAmount,
763
+ decimals: inputDecimals
764
+ }),
765
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
766
+ outputTokenAmount: BlockchainAmount({
767
+ raw: preview.outputAmount,
768
+ decimals: outputDecimals
769
+ })
770
+ })
771
+ };
772
+
773
+ // src/shared/core/blockchain/swap/status.ts
774
+ function isStopped(status) {
775
+ return (status.stopped & status.swapLevel) !== 0n;
776
+ }
777
+
778
+ // src/shared/core/blockchain/swap/swapped-event.ts
779
+ var import_viem3 = require("viem");
780
+ function decodeSwappedOutputAmount(receipt, outputDecimals) {
781
+ try {
782
+ const [swapped] = (0, import_viem3.parseEventLogs)({
783
+ abi: SUPERSTATE_SWAP_ABI,
784
+ eventName: "Swapped",
785
+ logs: receipt.logs
786
+ });
787
+ if (!swapped) return null;
788
+ const raw = swapped.args.outputAmount;
789
+ if (raw < 0n || raw > MAX_UINT_256) return null;
790
+ return BlockchainAmount({ raw, decimals: outputDecimals });
791
+ } catch {
792
+ return null;
793
+ }
794
+ }
795
+
796
+ // src/shared/core/blockchain/token-registry.ts
797
+ var USDC_SYMBOL = StablecoinSymbol("USDC");
798
+ var USDC = {
799
+ name: "USD Coin",
800
+ symbol: USDC_SYMBOL,
801
+ decimals: AssetDecimals(6)
802
+ };
803
+ var USDT_SYMBOL = StablecoinSymbol("USDT");
804
+ var USDT = {
805
+ name: "Tether USD",
806
+ symbol: USDT_SYMBOL,
807
+ decimals: AssetDecimals(6)
808
+ };
809
+ var USDC_ADDRESSES = {
810
+ ethereum_mainnet: EvmContractAddress(
811
+ "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
812
+ ),
813
+ ethereum_sepolia: EvmContractAddress(
814
+ "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
815
+ )
816
+ };
817
+ var USDT_ADDRESSES = {
818
+ ethereum_mainnet: EvmContractAddress(
819
+ "0xdac17f958d2ee523a2206206994597c13d831ec7"
820
+ ),
821
+ ethereum_sepolia: EvmContractAddress(
822
+ "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"
823
+ )
824
+ };
825
+ var TOKEN_REGISTRY = {
826
+ erc20: (symbol) => {
827
+ switch (symbol) {
828
+ case "USDC":
829
+ return USDC;
830
+ case "USDT":
831
+ return USDT;
832
+ default:
833
+ throw new Error(`Unknown asset symbol: ${symbol}`);
834
+ }
835
+ },
836
+ contractAddress: (symbol, chain) => {
837
+ switch (symbol) {
838
+ case "USDC":
839
+ return USDC_ADDRESSES[chain];
840
+ case "USDT":
841
+ return USDT_ADDRESSES[chain];
842
+ default:
843
+ throw new Error(`Unknown asset symbol: ${symbol}`);
844
+ }
845
+ }
846
+ };
847
+
848
+ // src/shared/api/http-attributes.ts
849
+ var empty = {};
850
+ var concat = (left, right) => ({
851
+ ...left,
852
+ ...right
853
+ });
854
+ var concatAll = (...items) => {
855
+ let result = empty;
856
+ for (const item of items) {
857
+ result = concat(result, item);
858
+ }
859
+ return result;
860
+ };
861
+ var protectedRequest = () => ({ protected: true });
862
+ var userAgent = () => ({ userAgent: true });
863
+ var idempotencyKey = () => ({
864
+ idempotencyKey: true
865
+ });
866
+ var clientCredentials = (credentials) => ({
867
+ clientCredentials: credentials
868
+ });
869
+ var retryAttempt = (attempt) => ({
870
+ retryAttempt: attempt
871
+ });
872
+ var renewAttempted = (value) => ({
873
+ renewAttempted: value
874
+ });
875
+ var isProtected = (attrs) => attrs?.protected === true;
876
+ var needUserAgent = (attrs) => attrs?.userAgent === true;
877
+ var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
878
+ var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
879
+ var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
880
+ var getClientCredentials = (attrs) => attrs?.clientCredentials;
881
+ var Attributes = {
882
+ empty,
883
+ concat,
884
+ concatAll,
885
+ protected: protectedRequest,
886
+ isProtected,
887
+ userAgent,
888
+ needUserAgent,
889
+ idempotencyKey,
890
+ isIdempotent,
891
+ retryAttempt,
892
+ getRetryAttempt,
893
+ renewAttempted,
894
+ wasRenewAttempted,
895
+ clientCredentials,
896
+ getClientCredentials
897
+ };
898
+
899
+ // src/shared/types/swap.ts
900
+ var SwapAuthorization = {
901
+ fromDto: (dto) => ({
902
+ authorized: dto.authorized
903
+ })
904
+ };
905
+ var SwapPreview = {
906
+ fromDto: (dto) => ({
907
+ inputAmount: assertUint256(BigInt(dto.pay_input_amount)),
908
+ fee: assertUint256(BigInt(dto.fee)),
909
+ outputAmount: assertUint256(BigInt(dto.receive_output_amount))
910
+ })
911
+ };
912
+ var SwapStatus = {
913
+ fromDto: (dto) => ({
914
+ stopped: assertUint256(BigInt(dto.stopped)),
915
+ swapLevel: assertUint256(BigInt(dto.swap_level))
916
+ })
917
+ };
918
+ var TokenAllowance = {
919
+ fromDto: (dto) => ({
920
+ allowance: assertUint256(BigInt(dto.allowance))
921
+ })
922
+ };
923
+ var TokenBalance = {
924
+ fromDto: (dto) => ({
925
+ balance: assertUint256(BigInt(dto.balance))
926
+ })
927
+ };
928
+ var AllowWalletResponse = {
929
+ fromDto: (dto) => {
930
+ switch (dto.action) {
931
+ case "broadcast_transaction":
932
+ return {
933
+ action: "broadcast_transaction",
934
+ to: EvmContractAddress(dto.to),
935
+ data: HexEncodedTransactionData(dto.data)
936
+ };
937
+ case "none":
938
+ return {
939
+ action: "none",
940
+ alreadyAllowed: dto.already_allowed
941
+ };
942
+ default: {
943
+ const _exhaustive = dto;
944
+ return _exhaustive;
945
+ }
946
+ }
947
+ }
948
+ };
949
+
950
+ // src/shared/api/frontline/swap.ts
951
+ async function getSwapAuthorization(api, params) {
952
+ const dto = await api.send({
953
+ method: "GET",
954
+ url: "/v1/wallet/authorized",
955
+ queryParams: {
956
+ chain: params.chain,
957
+ contract_address: params.contractAddress,
958
+ wallet_address: params.walletAddress
959
+ },
960
+ attributes: Attributes.protected()
961
+ });
962
+ return SwapAuthorization.fromDto(dto);
963
+ }
964
+ async function getSwapOutputToken(api, params) {
965
+ const dto = await api.send({
966
+ method: "GET",
967
+ url: "/v1/swap/output-token",
968
+ queryParams: {
969
+ chain: params.chain,
970
+ contract_address: params.contractAddress
971
+ },
972
+ attributes: Attributes.protected()
973
+ });
974
+ return toErc20Asset(dto);
975
+ }
976
+ async function getSwapPreview(api, params) {
977
+ const dto = await api.send({
978
+ method: "GET",
979
+ url: "/v1/swap/preview",
980
+ queryParams: {
981
+ chain: params.chain,
982
+ contract_address: params.contractAddress,
983
+ input_token: params.inputToken,
984
+ amount: params.amount.toString()
985
+ },
986
+ attributes: Attributes.protected()
987
+ });
988
+ return SwapPreview.fromDto(dto);
989
+ }
990
+ async function getSwapStatus(api, params) {
991
+ const dto = await api.send({
992
+ method: "GET",
993
+ url: "/v1/swap/status",
994
+ queryParams: {
995
+ chain: params.chain,
996
+ contract_address: params.contractAddress
997
+ },
998
+ attributes: Attributes.protected()
999
+ });
1000
+ return SwapStatus.fromDto(dto);
1001
+ }
1002
+ async function getTokenAllowance(api, params) {
1003
+ const dto = await api.send({
1004
+ method: "GET",
1005
+ url: "/v1/token/allowance",
1006
+ queryParams: {
1007
+ chain: params.chain,
1008
+ token_address: params.tokenAddress,
1009
+ owner: params.owner,
1010
+ spender: params.spender
1011
+ },
1012
+ attributes: Attributes.protected()
1013
+ });
1014
+ return TokenAllowance.fromDto(dto);
1015
+ }
1016
+ async function getTokenBalance(api, params) {
1017
+ const dto = await api.send({
1018
+ method: "GET",
1019
+ url: "/v1/token/balance",
1020
+ queryParams: {
1021
+ chain: params.chain,
1022
+ token_address: params.tokenAddress,
1023
+ owner: params.owner
1024
+ },
1025
+ attributes: Attributes.protected()
1026
+ });
1027
+ return TokenBalance.fromDto(dto);
1028
+ }
1029
+ async function allowWallet(api, params) {
1030
+ const dto = await api.send({
1031
+ method: "POST",
1032
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
1033
+ body: {
1034
+ wallet_address: params.walletAddress,
1035
+ chain: params.chain,
1036
+ signature: params.signature
1037
+ },
1038
+ attributes: Attributes.protected()
1039
+ });
1040
+ return AllowWalletResponse.fromDto(dto);
1041
+ }
1042
+ function toErc20Asset(dto) {
1043
+ return {
1044
+ name: dto.name,
1045
+ symbol: AssetSymbol(dto.symbol),
1046
+ decimals: AssetDecimals(dto.decimals)
1047
+ };
1048
+ }
1049
+
1050
+ // src/shared/types/asset.ts
1051
+ var AssetId = (value) => value;
1052
+ var AssetCode = (value) => value;
1053
+ var Asset = {
1054
+ fromDto: (dto) => ({
1055
+ id: AssetId(dto.id),
1056
+ code: AssetCode(dto.code),
1057
+ name: dto.name,
1058
+ fractionalDigits: dto.fractional_digits
1059
+ })
1060
+ };
115
1061
 
116
1062
  // src/shared/utils.ts
117
1063
  async function sha256(data) {
@@ -149,64 +1095,6 @@ function notBlankStringOrNull(value) {
149
1095
  }
150
1096
  }
151
1097
 
152
- // src/shared/pkce.ts
153
- async function generatePKCEParams(config) {
154
- const state = generateSecureRandomBase64Url(32);
155
- const codeVerifier = generateSecureRandomBase64Url(32);
156
- const codeChallengeRaw = await sha256(codeVerifier);
157
- const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
158
- return {
159
- clientId: config.clientId,
160
- responseType: "code",
161
- redirectUri: config.redirectUri,
162
- codeChallenge: CodeChallenge(codeChallenge),
163
- codeChallengeMethod: "S256",
164
- state: PKCEState(state),
165
- codeVerifier: CodeVerifier(codeVerifier)
166
- };
167
- }
168
-
169
- // src/shared/types/asset.ts
170
- var AssetId = (value) => value;
171
- var AssetCode = (value) => value;
172
- var Asset = {
173
- fromDto: (dto) => ({
174
- id: AssetId(dto.id),
175
- code: AssetCode(dto.code),
176
- name: dto.name,
177
- fractionalDigits: dto.fractional_digits
178
- })
179
- };
180
-
181
- // src/shared/types/errors.ts
182
- var NotImplementedError = class extends Error {
183
- constructor(message = "Not implemented yet") {
184
- super(message);
185
- this.name = "NotImplementedError";
186
- }
187
- };
188
- var NotAuthenticatedError = class extends Error {
189
- constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
190
- super(message);
191
- this.name = "NotAuthenticatedError";
192
- }
193
- };
194
-
195
- // src/shared/types/oauth-session.ts
196
- var OAuthRefreshToken = (value) => value;
197
- var OAuthSession = {
198
- fromDto: (dto) => {
199
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
200
- return {
201
- accessToken: {
202
- value: dto.access_token,
203
- expiresAt
204
- },
205
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
206
- };
207
- }
208
- };
209
-
210
1098
  // src/shared/types/offer.ts
211
1099
  var OfferId = (value) => value;
212
1100
  var OfferSlug = (value) => value;
@@ -304,6 +1192,188 @@ var Milestone = {
304
1192
  })
305
1193
  };
306
1194
 
1195
+ // src/shared/types/offer-option-address.ts
1196
+ var OfferOptionAddressId = (value) => value;
1197
+ var OfferOptionAddress = {
1198
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
1199
+ fromDto: (dto) => ({
1200
+ id: OfferOptionAddressId(dto.id),
1201
+ offerOptionId: OfferOptionId(dto.offer_option_id),
1202
+ address: EvmWalletAddress(dto.address),
1203
+ protocol: dto.protocol,
1204
+ createdAt: new Date(dto.created_at)
1205
+ })
1206
+ };
1207
+ var ConnectExternalWalletParams = {
1208
+ /** Maps connect-wallet params into the API DTO payload. */
1209
+ toDto: (params) => ({
1210
+ offer_option_id: params.offerOptionId,
1211
+ wallet_address: params.walletAddress,
1212
+ chain: params.chain,
1213
+ signature: params.signature
1214
+ })
1215
+ };
1216
+
1217
+ // src/shared/types/wallet-ownership-challenge.ts
1218
+ var WalletOwnershipChallenge = {
1219
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
1220
+ fromDto: (dto) => ({
1221
+ message: dto.message,
1222
+ expiresAt: new Date(dto.expires_at)
1223
+ })
1224
+ };
1225
+ var CreateWalletOwnershipChallengeParams = {
1226
+ /**
1227
+ * Maps challenge-request params into the API DTO payload. The discriminated
1228
+ * union guarantees SIWE fields are present exactly when `challengeType` is
1229
+ * `siwe`, so the mapping narrows on the discriminant.
1230
+ */
1231
+ toDto: (params) => {
1232
+ switch (params.challengeType) {
1233
+ case "plain":
1234
+ return {
1235
+ wallet_address: params.walletAddress,
1236
+ chain: params.chain,
1237
+ challenge_type: "plain"
1238
+ };
1239
+ case "siwe":
1240
+ return {
1241
+ wallet_address: params.walletAddress,
1242
+ chain: params.chain,
1243
+ challenge_type: "siwe",
1244
+ domain: params.domain,
1245
+ uri: params.uri,
1246
+ statement: params.statement
1247
+ };
1248
+ default: {
1249
+ const _exhaustive = params;
1250
+ return _exhaustive;
1251
+ }
1252
+ }
1253
+ }
1254
+ };
1255
+
1256
+ // src/shared/api/frontline/wallet-connect.ts
1257
+ async function createWalletOwnershipChallenge(api, params) {
1258
+ const dto = await api.send({
1259
+ method: "POST",
1260
+ url: "/v1/wallet-ownership",
1261
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
1262
+ attributes: Attributes.protected()
1263
+ });
1264
+ return WalletOwnershipChallenge.fromDto(dto);
1265
+ }
1266
+
1267
+ // src/shared/core/swap-namespace.ts
1268
+ var SwapNamespaceImpl = class {
1269
+ constructor(ctx) {
1270
+ this.ctx = ctx;
1271
+ }
1272
+ async getAuthorization(params) {
1273
+ await this.ctx.ensureUserAuthenticated();
1274
+ return getSwapAuthorization(this.ctx.api, params);
1275
+ }
1276
+ async getPreview(params) {
1277
+ await this.ctx.ensureUserAuthenticated();
1278
+ return getSwapPreview(this.ctx.api, params);
1279
+ }
1280
+ async getStatus(params) {
1281
+ await this.ctx.ensureUserAuthenticated();
1282
+ return getSwapStatus(this.ctx.api, params);
1283
+ }
1284
+ async getTokenAllowance(params) {
1285
+ await this.ctx.ensureUserAuthenticated();
1286
+ return getTokenAllowance(this.ctx.api, params);
1287
+ }
1288
+ async getTokenBalance(params) {
1289
+ await this.ctx.ensureUserAuthenticated();
1290
+ return getTokenBalance(this.ctx.api, params);
1291
+ }
1292
+ async getOutputToken(params) {
1293
+ await this.ctx.ensureUserAuthenticated();
1294
+ return getSwapOutputToken(this.ctx.api, params);
1295
+ }
1296
+ async requestWalletOwnershipChallenge(params) {
1297
+ await this.ctx.ensureUserAuthenticated();
1298
+ return createWalletOwnershipChallenge(this.ctx.api, params);
1299
+ }
1300
+ async allowWallet(params) {
1301
+ await this.ctx.ensureUserAuthenticated();
1302
+ return allowWallet(this.ctx.api, params);
1303
+ }
1304
+ };
1305
+
1306
+ // src/shared/types/oauth.ts
1307
+ var AuthorizationCode = (value) => value;
1308
+ var CodeVerifier = (value) => value;
1309
+ var CodeChallenge = (value) => value;
1310
+ var PKCEState = (value) => value;
1311
+ var RedirectUri = (value) => value;
1312
+ var ClientId = (value) => value;
1313
+ var ClientSecret = (value) => value;
1314
+
1315
+ // src/shared/pkce.ts
1316
+ async function generatePKCEParams(config) {
1317
+ const state = generateSecureRandomBase64Url(32);
1318
+ const codeVerifier = generateSecureRandomBase64Url(32);
1319
+ const codeChallengeRaw = await sha256(codeVerifier);
1320
+ const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);
1321
+ return {
1322
+ clientId: config.clientId,
1323
+ responseType: "code",
1324
+ redirectUri: config.redirectUri,
1325
+ codeChallenge: CodeChallenge(codeChallenge),
1326
+ codeChallengeMethod: "S256",
1327
+ state: PKCEState(state),
1328
+ codeVerifier: CodeVerifier(codeVerifier)
1329
+ };
1330
+ }
1331
+
1332
+ // src/shared/types/document-submission.ts
1333
+ var DocumentSubmission = {
1334
+ fromDto: (dto) => ({
1335
+ status: dto.status,
1336
+ formType: dto.form_type
1337
+ })
1338
+ };
1339
+
1340
+ // src/shared/types/errors.ts
1341
+ var NotImplementedError = class extends Error {
1342
+ constructor(message = "Not implemented yet") {
1343
+ super(message);
1344
+ this.name = "NotImplementedError";
1345
+ }
1346
+ };
1347
+ var NotAuthenticatedError = class extends Error {
1348
+ constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
1349
+ super(message);
1350
+ this.name = "NotAuthenticatedError";
1351
+ }
1352
+ };
1353
+
1354
+ // src/shared/types/kyc.ts
1355
+ var KycToken = {
1356
+ fromDto: (dto) => ({
1357
+ token: dto.token
1358
+ })
1359
+ };
1360
+
1361
+ // src/shared/types/oauth-session.ts
1362
+ var ClientCredentialsOAuth = (value) => value;
1363
+ var OAuthRefreshToken = (value) => value;
1364
+ var OAuthSession = {
1365
+ fromDto: (dto) => {
1366
+ const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
1367
+ return {
1368
+ accessToken: {
1369
+ value: dto.access_token,
1370
+ expiresAt
1371
+ },
1372
+ ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
1373
+ };
1374
+ }
1375
+ };
1376
+
307
1377
  // src/shared/types/participation.ts
308
1378
  var ParticipationId = (value) => value;
309
1379
  var Blockchain = (value) => value;
@@ -351,6 +1421,34 @@ var CreateParticipationParams = {
351
1421
  })
352
1422
  };
353
1423
 
1424
+ // src/shared/types/pii.ts
1425
+ var Iso2CountryCode = (value) => value;
1426
+ var PiiJurisdiction = {
1427
+ fromDto: (dto) => ({
1428
+ iso2: Iso2CountryCode(dto.iso_2),
1429
+ name: dto.name
1430
+ })
1431
+ };
1432
+ var PiiAddress = {
1433
+ fromDto: (dto) => ({
1434
+ street: dto.street,
1435
+ city: dto.city,
1436
+ state: dto.state,
1437
+ postalCode: dto.postal_code,
1438
+ country: dto.country
1439
+ })
1440
+ };
1441
+ var Pii = {
1442
+ fromDto: (dto) => ({
1443
+ kind: dto.kind,
1444
+ fullLegalName: dto.full_legal_name,
1445
+ dateOfBirth: dto.date_of_birth,
1446
+ jurisdiction: dto.jurisdiction ? PiiJurisdiction.fromDto(dto.jurisdiction) : null,
1447
+ taxId: dto.tax_id,
1448
+ permanentAddress: PiiAddress.fromDto(dto.permanent_address)
1449
+ })
1450
+ };
1451
+
354
1452
  // src/shared/types/requirement.ts
355
1453
  var RequirementId = (value) => value;
356
1454
  var Requirement = {
@@ -361,10 +1459,15 @@ var Requirement = {
361
1459
  })
362
1460
  };
363
1461
  var RequirementStatusInfo = {
364
- fromStatusesDto: (dto) => Object.entries(dto.statuses).map(([id, status]) => ({
365
- id: RequirementId(id),
366
- status
367
- }))
1462
+ fromStatusesDto: (dto) => Object.entries(dto.statuses).map(
1463
+ ([id, value]) => typeof value === "string" ? { id: RequirementId(id), status: value, action: null } : {
1464
+ id: RequirementId(id),
1465
+ status: value.status,
1466
+ action: value.action ?? null,
1467
+ kycLevel: value.kyc_level,
1468
+ kycReset: value.kyc_reset
1469
+ }
1470
+ )
368
1471
  };
369
1472
 
370
1473
  // src/shared/types/user.ts
@@ -378,20 +1481,45 @@ var User = {
378
1481
  };
379
1482
  // Annotate the CommonJS export names for ESM import in node:
380
1483
  0 && (module.exports = {
1484
+ AllowWalletResponse,
381
1485
  Asset,
382
1486
  AssetCode,
1487
+ AssetDecimals,
1488
+ AssetIconUrl,
383
1489
  AssetId,
1490
+ AssetSymbol,
384
1491
  AuthorizationCode,
1492
+ BPS_DENOM,
385
1493
  Blockchain,
1494
+ BlockchainAmount,
1495
+ Bps,
1496
+ ClientCredentialsOAuth,
386
1497
  ClientId,
387
1498
  ClientSecret,
388
1499
  CodeChallenge,
389
1500
  CodeVerifier,
1501
+ ConnectExternalWalletParams,
390
1502
  CreateParticipationParams,
1503
+ CreateWalletOwnershipChallengeParams,
391
1504
  Cursor,
1505
+ DEFAULT_AMOUNT_TO_COMPUTE_PRICE,
1506
+ DEFAULT_SLIPPAGE_BPS,
1507
+ DocumentSubmission,
1508
+ ERC20_ABI,
1509
+ EvmContractAddress,
1510
+ EvmWalletAddress,
392
1511
  FaqItem,
1512
+ FormattedAmountAssetUi,
1513
+ FormattedAmountUi,
1514
+ FormattedPercentUi,
1515
+ HexEncodedTransactionData,
1516
+ Iso2CountryCode,
1517
+ KnownAssetSymbol,
1518
+ KycToken,
393
1519
  Link,
1520
+ MAX_UINT_256,
394
1521
  Milestone,
1522
+ NA_AMOUNT_ASSET_UI,
395
1523
  NotAuthenticatedError,
396
1524
  NotImplementedError,
397
1525
  OAuthRefreshToken,
@@ -400,6 +1528,8 @@ var User = {
400
1528
  OfferDetail,
401
1529
  OfferId,
402
1530
  OfferOption,
1531
+ OfferOptionAddress,
1532
+ OfferOptionAddressId,
403
1533
  OfferOptionId,
404
1534
  OfferOptionSlug,
405
1535
  OfferSlug,
@@ -409,16 +1539,59 @@ var User = {
409
1539
  Participation,
410
1540
  ParticipationId,
411
1541
  ParticipationsPaginationParams,
1542
+ Pii,
1543
+ PiiAddress,
1544
+ PiiJurisdiction,
412
1545
  RedirectUri,
413
1546
  Requirement,
414
1547
  RequirementId,
415
1548
  RequirementStatusInfo,
1549
+ SLIPPAGE_OPTIONS_BPS,
1550
+ SUPERSTATE_SWAP_ABI,
1551
+ SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,
1552
+ SUPERSTATE_TOS_URL,
1553
+ SWAP_POLL_INTERVAL_MS,
1554
+ ShortenedWalletAddress,
1555
+ StablecoinSymbol,
1556
+ SwapAuthorization,
1557
+ SwapNamespaceImpl,
1558
+ SwapPreview,
1559
+ SwapQuote,
1560
+ SwapStatus,
1561
+ TOKEN_REGISTRY,
416
1562
  TermItem,
1563
+ TokenAllowance,
1564
+ TokenBalance,
1565
+ TxExplorerUrl,
1566
+ USDC,
1567
+ USDC_SYMBOL,
1568
+ USDT,
1569
+ USDT_SYMBOL,
417
1570
  User,
418
1571
  UserEmail,
419
1572
  UserId,
420
1573
  WalletAddress,
1574
+ WalletOwnershipChallenge,
1575
+ applyBps,
1576
+ assertUint256,
1577
+ assetAmount,
1578
+ computePrice,
1579
+ computeSlip,
1580
+ decodeSwappedOutputAmount,
421
1581
  fetchAllPages,
422
- generatePKCEParams
1582
+ formatAmount,
1583
+ formatBpsAsPercent,
1584
+ formatCompactAmount,
1585
+ formatRawAmount,
1586
+ formattedPricePerShare,
1587
+ formattedUsdPrice,
1588
+ generatePKCEParams,
1589
+ getChainId,
1590
+ getNetworkName,
1591
+ isStopped,
1592
+ parseBlockchainAmount,
1593
+ shortenAddress,
1594
+ txExplorerUrl,
1595
+ usdAmount
423
1596
  });
424
1597
  //# sourceMappingURL=index.cjs.map