@coinlist-co/react 0.10.1 → 0.11.1-rc.209af8d

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 (38) hide show
  1. package/README.md +32 -0
  2. package/dist/chunk-3Z4PLLV7.js +2249 -0
  3. package/dist/chunk-3Z4PLLV7.js.map +1 -0
  4. package/dist/{chunk-AQVCOWOV.js → chunk-T4ANQVQA.js} +216 -317
  5. package/dist/chunk-T4ANQVQA.js.map +1 -0
  6. package/dist/chunk-YPFS2SAD.js +279 -0
  7. package/dist/chunk-YPFS2SAD.js.map +1 -0
  8. package/dist/client/index.cjs +11325 -3316
  9. package/dist/client/index.cjs.map +1 -1
  10. package/dist/client/index.d.cts +4243 -881
  11. package/dist/client/index.d.ts +4243 -881
  12. package/dist/client/index.js +9103 -2389
  13. package/dist/client/index.js.map +1 -1
  14. package/dist/collections-B0nu_6q5.d.ts +116 -0
  15. package/dist/collections-DdLA4_GN.d.cts +116 -0
  16. package/dist/config-D0r6GyPL.d.cts +2638 -0
  17. package/dist/config-D0r6GyPL.d.ts +2638 -0
  18. package/dist/server/index.cjs +1631 -514
  19. package/dist/server/index.cjs.map +1 -1
  20. package/dist/server/index.d.cts +266 -162
  21. package/dist/server/index.d.ts +266 -162
  22. package/dist/server/index.js +235 -169
  23. package/dist/server/index.js.map +1 -1
  24. package/dist/shared/index.cjs +2235 -926
  25. package/dist/shared/index.cjs.map +1 -1
  26. package/dist/shared/index.d.cts +256 -132
  27. package/dist/shared/index.d.ts +256 -132
  28. package/dist/shared/index.js +102 -28
  29. package/package.json +12 -8
  30. package/dist/chunk-AQVCOWOV.js.map +0 -1
  31. package/dist/chunk-TBU3EBNM.js +0 -442
  32. package/dist/chunk-TBU3EBNM.js.map +0 -1
  33. package/dist/chunk-UOHD7US2.js +0 -855
  34. package/dist/chunk-UOHD7US2.js.map +0 -1
  35. package/dist/collections-Bv1Oxzu_.d.ts +0 -28
  36. package/dist/collections-DDyxbOPZ.d.cts +0 -28
  37. package/dist/requirement-oVZA1INj.d.cts +0 -1040
  38. package/dist/requirement-oVZA1INj.d.ts +0 -1040
@@ -1,855 +0,0 @@
1
- // src/shared/types/blockchain/core.ts
2
- var EvmWalletAddress = (value) => value;
3
- var EvmContractAddress = (value) => value;
4
- var HexEncodedTransactionData = (value) => value;
5
- var AssetDecimals = (value) => value;
6
- var MAX_UINT_256 = 2n ** 256n - 1n;
7
- var assertUint256 = (value) => {
8
- if (value < 0n || value > MAX_UINT_256) {
9
- throw new Error(`Value out of uint256 bounds: ${value}`);
10
- }
11
- return value;
12
- };
13
- var BlockchainAmount = Object.assign(
14
- (value) => value,
15
- {
16
- add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
17
- sub: (a, b) => combineAmounts(a, b, (x, y) => x - y)
18
- }
19
- );
20
- function combineAmounts(a, b, op) {
21
- if (a.decimals !== b.decimals) {
22
- throw new Error(
23
- `Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
24
- );
25
- }
26
- const raw = op(a.raw, b.raw);
27
- if (raw < 0n || raw > MAX_UINT_256) {
28
- throw new Error(`BlockchainAmount out of uint256 bounds: ${raw}`);
29
- }
30
- return BlockchainAmount({ raw, decimals: a.decimals });
31
- }
32
- var AssetSymbol = (value) => value;
33
- var StablecoinSymbol = (value) => value;
34
- var KnownAssetSymbol = StablecoinSymbol;
35
- var Bps = (value) => value;
36
-
37
- // src/shared/types/swap.ts
38
- var SwapAuthorization = {
39
- fromDto: (dto) => ({
40
- authorized: dto.authorized
41
- })
42
- };
43
- var SwapPreview = {
44
- fromDto: (dto) => ({
45
- inputAmount: assertUint256(BigInt(dto.pay_input_amount)),
46
- fee: assertUint256(BigInt(dto.fee)),
47
- outputAmount: assertUint256(BigInt(dto.receive_output_amount))
48
- })
49
- };
50
- var SwapStatus = {
51
- fromDto: (dto) => ({
52
- stopped: assertUint256(BigInt(dto.stopped)),
53
- swapLevel: assertUint256(BigInt(dto.swap_level))
54
- })
55
- };
56
- var TokenAllowance = {
57
- fromDto: (dto) => ({
58
- allowance: assertUint256(BigInt(dto.allowance))
59
- })
60
- };
61
- var TokenBalance = {
62
- fromDto: (dto) => ({
63
- balance: assertUint256(BigInt(dto.balance))
64
- })
65
- };
66
- var AllowWalletResponse = {
67
- fromDto: (dto) => {
68
- switch (dto.action) {
69
- case "broadcast_transaction":
70
- return {
71
- action: "broadcast_transaction",
72
- to: EvmContractAddress(dto.to),
73
- data: HexEncodedTransactionData(dto.data)
74
- };
75
- case "none":
76
- return {
77
- action: "none",
78
- alreadyAllowed: dto.already_allowed
79
- };
80
- default: {
81
- const _exhaustive = dto;
82
- return _exhaustive;
83
- }
84
- }
85
- }
86
- };
87
-
88
- // src/shared/types/asset.ts
89
- var AssetId = (value) => value;
90
- var AssetCode = (value) => value;
91
- var Asset = {
92
- fromDto: (dto) => ({
93
- id: AssetId(dto.id),
94
- code: AssetCode(dto.code),
95
- name: dto.name,
96
- fractionalDigits: dto.fractional_digits
97
- })
98
- };
99
-
100
- // src/shared/types/offer.ts
101
- var OfferId = (value) => value;
102
- var OfferSlug = (value) => value;
103
- var Offer = {
104
- fromDto: (dto) => ({
105
- id: OfferId(dto.id),
106
- slug: OfferSlug(dto.slug),
107
- type: dto.type,
108
- tagline: dto.tagline,
109
- bannerUrl: dto.banner_url,
110
- logoUrl: dto.logo_url,
111
- startsAt: new Date(dto.starts_at),
112
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null
113
- })
114
- };
115
-
116
- // src/shared/utils.ts
117
- async function sha256(data) {
118
- const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
119
- const buffer = bytes.buffer.slice(
120
- bytes.byteOffset,
121
- bytes.byteOffset + bytes.byteLength
122
- );
123
- return crypto.subtle.digest("SHA-256", buffer);
124
- }
125
- function arrayBufferToBase64Url(buffer, padding = true) {
126
- const bytes = new Uint8Array(buffer);
127
- let binary = "";
128
- for (let i = 0; i < bytes.length; i++) {
129
- binary += String.fromCharCode(bytes[i]);
130
- }
131
- let base64 = btoa(binary);
132
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
133
- if (!padding) {
134
- base64 = base64.replace(/=+$/, "");
135
- }
136
- return base64;
137
- }
138
- function generateSecureRandomBase64Url(byteLength) {
139
- const bytes = new Uint8Array(byteLength);
140
- crypto.getRandomValues(bytes);
141
- const buffer = bytes.buffer;
142
- return arrayBufferToBase64Url(buffer, false);
143
- }
144
- function getUUIDv4() {
145
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
146
- return crypto.randomUUID();
147
- }
148
- if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
149
- const bytes = new Uint8Array(16);
150
- crypto.getRandomValues(bytes);
151
- bytes[6] = bytes[6] & 15 | 64;
152
- bytes[8] = bytes[8] & 63 | 128;
153
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
154
- 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("")}`;
155
- }
156
- return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
157
- }
158
- function notBlankStringOrNull(value) {
159
- if (value?.trim()) {
160
- return value;
161
- } else {
162
- return null;
163
- }
164
- }
165
-
166
- // src/shared/types/offer-detail.ts
167
- var OfferOptionId = (value) => value;
168
- var OfferOptionSlug = (value) => value;
169
- var OfferDetail = {
170
- fromDto: (dto) => {
171
- if (!Array.isArray(dto.funding_assets)) {
172
- throw new Error(`funding_assets must be an array`);
173
- }
174
- if (!Array.isArray(dto.options)) {
175
- throw new Error(`options must be an array`);
176
- }
177
- if (!Array.isArray(dto.terms)) {
178
- throw new Error(`terms must be an array`);
179
- }
180
- if (!Array.isArray(dto.links)) {
181
- throw new Error(`links must be an array`);
182
- }
183
- if (!Array.isArray(dto.faqs)) {
184
- throw new Error(`faqs must be an array`);
185
- }
186
- if (!Array.isArray(dto.milestones)) {
187
- throw new Error(`milestones must be an array`);
188
- }
189
- return {
190
- id: OfferId(dto.id),
191
- slug: OfferSlug(dto.slug),
192
- type: dto.type,
193
- name: dto.name,
194
- asset: Asset.fromDto(dto.asset),
195
- fundingAssets: dto.funding_assets.map(Asset.fromDto),
196
- about: notBlankStringOrNull(dto.about),
197
- tagline: dto.tagline,
198
- bannerUrl: dto.banner_url,
199
- logoUrl: dto.logo_url,
200
- category: dto.category,
201
- startsAt: new Date(dto.starts_at),
202
- endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
203
- faqs: dto.faqs.map(FaqItem.fromDto),
204
- links: dto.links.map(Link.fromDto),
205
- milestones: dto.milestones.map(Milestone.fromDto),
206
- options: dto.options.map(OfferOption.fromDto),
207
- terms: dto.terms.map(TermItem.fromDto)
208
- };
209
- }
210
- };
211
- var OfferOption = {
212
- fromDto: (dto) => ({
213
- id: OfferOptionId(dto.id),
214
- slug: OfferOptionSlug(dto.slug),
215
- bidIncrement: dto.bid_increment,
216
- floorPriceUsd: dto.floor_price_usd,
217
- minimumPurchaseUsd: dto.minimum_purchase_usd,
218
- priceUsd: dto.price_usd,
219
- saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
220
- totalTokenSupply: dto.total_token_supply
221
- })
222
- };
223
- var FaqItem = {
224
- fromDto: (dto) => ({
225
- question: notBlankStringOrNull(dto.question),
226
- answer: notBlankStringOrNull(dto.answer)
227
- })
228
- };
229
- var Link = {
230
- fromDto: (dto) => ({
231
- label: notBlankStringOrNull(dto.label),
232
- url: notBlankStringOrNull(dto.url)
233
- })
234
- };
235
- var TermItem = {
236
- fromDto: (dto) => ({
237
- key: notBlankStringOrNull(dto.key),
238
- value: notBlankStringOrNull(dto.value)
239
- })
240
- };
241
- var Milestone = {
242
- fromDto: (dto) => ({
243
- name: notBlankStringOrNull(dto.name),
244
- schedule: notBlankStringOrNull(dto.schedule),
245
- status: dto.status
246
- })
247
- };
248
-
249
- // src/shared/types/offer-option-address.ts
250
- var OfferOptionAddressId = (value) => value;
251
- var OfferOptionAddress = {
252
- /** Maps the API DTO into the SDK offer-option-address domain model. */
253
- fromDto: (dto) => ({
254
- id: OfferOptionAddressId(dto.id),
255
- offerOptionId: OfferOptionId(dto.offer_option_id),
256
- address: EvmWalletAddress(dto.address),
257
- protocol: dto.protocol,
258
- createdAt: new Date(dto.created_at)
259
- })
260
- };
261
- var ConnectExternalWalletParams = {
262
- /** Maps connect-wallet params into the API DTO payload. */
263
- toDto: (params) => ({
264
- offer_option_id: params.offerOptionId,
265
- wallet_address: params.walletAddress,
266
- chain: params.chain,
267
- signature: params.signature
268
- })
269
- };
270
-
271
- // src/shared/types/wallet-ownership-challenge.ts
272
- var WalletOwnershipChallenge = {
273
- /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
274
- fromDto: (dto) => ({
275
- message: dto.message,
276
- expiresAt: new Date(dto.expires_at)
277
- })
278
- };
279
- var CreateWalletOwnershipChallengeParams = {
280
- /**
281
- * Maps challenge-request params into the API DTO payload. The discriminated
282
- * union guarantees SIWE fields are present exactly when `challengeType` is
283
- * `siwe`, so the mapping narrows on the discriminant.
284
- */
285
- toDto: (params) => {
286
- switch (params.challengeType) {
287
- case "plain":
288
- return {
289
- wallet_address: params.walletAddress,
290
- chain: params.chain,
291
- challenge_type: "plain"
292
- };
293
- case "siwe":
294
- return {
295
- wallet_address: params.walletAddress,
296
- chain: params.chain,
297
- challenge_type: "siwe",
298
- domain: params.domain,
299
- uri: params.uri,
300
- statement: params.statement
301
- };
302
- default: {
303
- const _exhaustive = params;
304
- return _exhaustive;
305
- }
306
- }
307
- }
308
- };
309
-
310
- // src/shared/api/http-attributes.ts
311
- var empty = {};
312
- var concat = (left, right) => ({
313
- ...left,
314
- ...right
315
- });
316
- var concatAll = (...items) => {
317
- let result = empty;
318
- for (const item of items) {
319
- result = concat(result, item);
320
- }
321
- return result;
322
- };
323
- var protectedRequest = () => ({ protected: true });
324
- var userAgent = () => ({ userAgent: true });
325
- var idempotencyKey = () => ({
326
- idempotencyKey: true
327
- });
328
- var clientCredentials = (credentials) => ({
329
- clientCredentials: credentials
330
- });
331
- var retryAttempt = (attempt) => ({
332
- retryAttempt: attempt
333
- });
334
- var renewAttempted = (value) => ({
335
- renewAttempted: value
336
- });
337
- var isProtected = (attrs) => attrs?.protected === true;
338
- var needUserAgent = (attrs) => attrs?.userAgent === true;
339
- var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
340
- var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
341
- var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
342
- var getClientCredentials = (attrs) => attrs?.clientCredentials;
343
- var Attributes = {
344
- empty,
345
- concat,
346
- concatAll,
347
- protected: protectedRequest,
348
- isProtected,
349
- userAgent,
350
- needUserAgent,
351
- idempotencyKey,
352
- isIdempotent,
353
- retryAttempt,
354
- getRetryAttempt,
355
- renewAttempted,
356
- wasRenewAttempted,
357
- clientCredentials,
358
- getClientCredentials
359
- };
360
-
361
- // src/shared/api/frontline/swap.ts
362
- async function getSwapAuthorization(api, params) {
363
- const dto = await api.send({
364
- method: "GET",
365
- url: "/v1/wallet/authorized",
366
- queryParams: {
367
- chain: params.chain,
368
- contract_address: params.contractAddress,
369
- wallet_address: params.walletAddress
370
- },
371
- attributes: Attributes.protected()
372
- });
373
- return SwapAuthorization.fromDto(dto);
374
- }
375
- async function getSwapOutputToken(api, params) {
376
- const dto = await api.send({
377
- method: "GET",
378
- url: "/v1/swap/output-token",
379
- queryParams: {
380
- chain: params.chain,
381
- contract_address: params.contractAddress
382
- },
383
- attributes: Attributes.protected()
384
- });
385
- return toErc20Asset(dto);
386
- }
387
- async function getSwapPreview(api, params) {
388
- const dto = await api.send({
389
- method: "GET",
390
- url: "/v1/swap/preview",
391
- queryParams: {
392
- chain: params.chain,
393
- contract_address: params.contractAddress,
394
- input_token: params.inputToken,
395
- amount: params.amount.toString()
396
- },
397
- attributes: Attributes.protected()
398
- });
399
- return SwapPreview.fromDto(dto);
400
- }
401
- async function getSwapStatus(api, params) {
402
- const dto = await api.send({
403
- method: "GET",
404
- url: "/v1/swap/status",
405
- queryParams: {
406
- chain: params.chain,
407
- contract_address: params.contractAddress
408
- },
409
- attributes: Attributes.protected()
410
- });
411
- return SwapStatus.fromDto(dto);
412
- }
413
- async function getTokenAllowance(api, params) {
414
- const dto = await api.send({
415
- method: "GET",
416
- url: "/v1/token/allowance",
417
- queryParams: {
418
- chain: params.chain,
419
- token_address: params.tokenAddress,
420
- owner: params.owner,
421
- spender: params.spender
422
- },
423
- attributes: Attributes.protected()
424
- });
425
- return TokenAllowance.fromDto(dto);
426
- }
427
- async function getTokenBalance(api, params) {
428
- const dto = await api.send({
429
- method: "GET",
430
- url: "/v1/token/balance",
431
- queryParams: {
432
- chain: params.chain,
433
- token_address: params.tokenAddress,
434
- owner: params.owner
435
- },
436
- attributes: Attributes.protected()
437
- });
438
- return TokenBalance.fromDto(dto);
439
- }
440
- async function allowWallet(api, params) {
441
- const dto = await api.send({
442
- method: "POST",
443
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
444
- body: {
445
- wallet_address: params.walletAddress,
446
- chain: params.chain,
447
- signature: params.signature
448
- },
449
- attributes: Attributes.protected()
450
- });
451
- return AllowWalletResponse.fromDto(dto);
452
- }
453
- function toErc20Asset(dto) {
454
- return {
455
- name: dto.name,
456
- symbol: AssetSymbol(dto.symbol),
457
- decimals: AssetDecimals(dto.decimals)
458
- };
459
- }
460
-
461
- // src/shared/api/frontline/wallet-connect.ts
462
- async function createWalletOwnershipChallenge(api, params) {
463
- const dto = await api.send({
464
- method: "POST",
465
- url: "/v1/wallet-ownership",
466
- body: CreateWalletOwnershipChallengeParams.toDto(params),
467
- attributes: Attributes.protected()
468
- });
469
- return WalletOwnershipChallenge.fromDto(dto);
470
- }
471
- async function connectExternalWallet(api, offerId, params) {
472
- const dto = await api.send({
473
- method: "POST",
474
- url: `/v1/offers/${offerId}/addresses`,
475
- body: ConnectExternalWalletParams.toDto(params),
476
- attributes: Attributes.protected()
477
- });
478
- return OfferOptionAddress.fromDto(dto);
479
- }
480
- async function listOptionAddresses(api, offerId, offerOptionId) {
481
- const { data } = await api.send({
482
- method: "GET",
483
- url: `/v1/offers/${offerId}/addresses`,
484
- queryParams: { offer_option_id: offerOptionId },
485
- attributes: Attributes.protected()
486
- });
487
- return data.map(OfferOptionAddress.fromDto);
488
- }
489
- async function removeOptionAddress(api, offerId, addressId) {
490
- const dto = await api.send({
491
- method: "DELETE",
492
- url: `/v1/offers/${offerId}/addresses/${addressId}`,
493
- attributes: Attributes.protected()
494
- });
495
- return OfferOptionAddress.fromDto(dto);
496
- }
497
-
498
- // src/shared/core/swap-namespace.ts
499
- var SwapNamespaceImpl = class {
500
- constructor(ctx) {
501
- this.ctx = ctx;
502
- }
503
- async getAuthorization(params) {
504
- await this.ctx.ensureUserAuthenticated();
505
- return getSwapAuthorization(this.ctx.api, params);
506
- }
507
- async getPreview(params) {
508
- await this.ctx.ensureUserAuthenticated();
509
- return getSwapPreview(this.ctx.api, params);
510
- }
511
- async getStatus(params) {
512
- await this.ctx.ensureUserAuthenticated();
513
- return getSwapStatus(this.ctx.api, params);
514
- }
515
- async getOutputToken(params) {
516
- await this.ctx.ensureUserAuthenticated();
517
- return getSwapOutputToken(this.ctx.api, params);
518
- }
519
- async requestWalletOwnershipChallenge(params) {
520
- await this.ctx.ensureUserAuthenticated();
521
- return createWalletOwnershipChallenge(this.ctx.api, params);
522
- }
523
- async allowWallet(params) {
524
- await this.ctx.ensureUserAuthenticated();
525
- return allowWallet(this.ctx.api, params);
526
- }
527
- };
528
-
529
- // src/shared/api/pagination.ts
530
- var Cursor = (value) => value;
531
- async function fetchAllPages(fetchPage, baseParams) {
532
- const items = [];
533
- let cursor = null;
534
- do {
535
- const params = {
536
- ...baseParams ?? {},
537
- after: cursor ?? void 0
538
- };
539
- const page = await fetchPage(params);
540
- items.push(...page.data);
541
- cursor = page.startingAfter;
542
- } while (cursor);
543
- return items;
544
- }
545
- var PaginatedResponse = {
546
- fromDto: (dto, itemMapper) => ({
547
- data: dto.data.map(itemMapper),
548
- startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
549
- startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
550
- })
551
- };
552
- var PaginationParams = {
553
- toQueryParams: (params) => {
554
- const queryParams = {};
555
- if (params.after) {
556
- queryParams.starting_after = params.after;
557
- }
558
- if (params.before) {
559
- queryParams.starting_before = params.before;
560
- }
561
- if (params.limit) {
562
- queryParams.limit = params.limit;
563
- }
564
- return queryParams;
565
- }
566
- };
567
-
568
- // src/shared/core/erc20-namespace.ts
569
- var Erc20NamespaceImpl = class {
570
- constructor(ctx) {
571
- this.ctx = ctx;
572
- }
573
- async getTokenAllowance(params) {
574
- await this.ctx.ensureUserAuthenticated();
575
- return getTokenAllowance(this.ctx.api, params);
576
- }
577
- async getTokenBalance(params) {
578
- await this.ctx.ensureUserAuthenticated();
579
- return getTokenBalance(this.ctx.api, params);
580
- }
581
- };
582
-
583
- // src/shared/types/participation.ts
584
- var ParticipationId = (value) => value;
585
- var Blockchain = (value) => value;
586
- var WalletAddress = (value) => value;
587
- var ParticipationsPaginationParams = {
588
- toQueryParams: (params) => {
589
- const queryParams = PaginationParams.toQueryParams(params);
590
- if (params.offerId) {
591
- queryParams["filters[0][field]"] = "offer_id";
592
- queryParams["filters[0][op]"] = "==";
593
- queryParams["filters[0][value]"] = params.offerId;
594
- }
595
- return queryParams;
596
- }
597
- };
598
- var Participation = {
599
- /** Maps API DTO shape into the SDK participation domain model. */
600
- fromDto: (dto) => {
601
- const walletAddress = notBlankStringOrNull(dto.wallet_address);
602
- return {
603
- id: ParticipationId(dto.id),
604
- offerId: OfferId(dto.offer_id),
605
- offerOptionId: OfferOptionId(dto.offer_option_id),
606
- status: dto.status,
607
- amount: dto.amount,
608
- displayAmount: dto.amount_string,
609
- asset: Asset.fromDto(dto.asset),
610
- chain: Blockchain(dto.chain),
611
- insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
612
- updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
613
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
614
- };
615
- }
616
- };
617
- var CreateParticipationParams = {
618
- /** Maps participation creation params into API DTO payload. */
619
- toDto: (params) => ({
620
- offer_id: params.offerId,
621
- offer_option_id: params.offerOptionId,
622
- chain: params.chain,
623
- wallet_address: params.walletAddress,
624
- amount: params.amount,
625
- asset_id: params.assetId,
626
- approval_transaction_hash: params.approvalTransactionHash
627
- })
628
- };
629
-
630
- // src/shared/api/frontline/participations.ts
631
- async function fetchParticipations(api, offerId) {
632
- return fetchAllPages(
633
- (params) => fetchParticipationsPage(api, params),
634
- { offerId }
635
- );
636
- }
637
- async function fetchParticipationsPage(api, params) {
638
- const pageDto = await api.send({
639
- method: "GET",
640
- url: "/v1/participations",
641
- queryParams: ParticipationsPaginationParams.toQueryParams(params),
642
- attributes: Attributes.protected()
643
- });
644
- return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
645
- }
646
- async function fetchParticipation(api, id) {
647
- const dto = await api.send({
648
- method: "GET",
649
- url: `/v1/participations/${id}`,
650
- attributes: Attributes.protected()
651
- });
652
- return Participation.fromDto(dto);
653
- }
654
- async function createParticipation(api, params) {
655
- const dto = await api.send({
656
- method: "POST",
657
- url: "/v1/participations",
658
- body: CreateParticipationParams.toDto(params),
659
- attributes: Attributes.protected()
660
- });
661
- return Participation.fromDto(dto);
662
- }
663
-
664
- // src/shared/core/token-sale-namespace.ts
665
- var TokenSaleNamespaceImpl = class {
666
- constructor(ctx) {
667
- this.ctx = ctx;
668
- }
669
- async fetchParticipations(offerId) {
670
- await this.ctx.ensureUserAuthenticated();
671
- return fetchParticipations(this.ctx.api, offerId);
672
- }
673
- async fetchParticipationsPage(params) {
674
- await this.ctx.ensureUserAuthenticated();
675
- return fetchParticipationsPage(this.ctx.api, params);
676
- }
677
- async fetchParticipation(id) {
678
- await this.ctx.ensureUserAuthenticated();
679
- return fetchParticipation(this.ctx.api, id);
680
- }
681
- async createParticipation(params) {
682
- await this.ctx.ensureUserAuthenticated();
683
- return createParticipation(this.ctx.api, params);
684
- }
685
- };
686
-
687
- // src/shared/types/document-submission.ts
688
- var DocumentSubmission = {
689
- fromDto: (dto) => ({
690
- status: dto.status,
691
- formType: dto.form_type
692
- })
693
- };
694
-
695
- // src/shared/types/errors.ts
696
- var NotImplementedError = class extends Error {
697
- constructor(message = "Not implemented yet") {
698
- super(message);
699
- this.name = "NotImplementedError";
700
- }
701
- };
702
- var NotAuthenticatedError = class extends Error {
703
- constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
704
- super(message);
705
- this.name = "NotAuthenticatedError";
706
- }
707
- };
708
-
709
- // src/shared/types/kyc.ts
710
- var KycToken = {
711
- fromDto: (dto) => ({
712
- token: dto.token
713
- })
714
- };
715
-
716
- // src/shared/types/oauth-session.ts
717
- var ClientCredentialsOAuth = (value) => value;
718
- var OAuthRefreshToken = (value) => value;
719
- var OAuthSession = {
720
- fromDto: (dto) => {
721
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
722
- return {
723
- accessToken: {
724
- value: dto.access_token,
725
- expiresAt
726
- },
727
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
728
- };
729
- }
730
- };
731
-
732
- // src/shared/types/pii.ts
733
- var Iso2CountryCode = (value) => value;
734
- var PiiJurisdiction = {
735
- fromDto: (dto) => ({
736
- iso2: Iso2CountryCode(dto.iso_2),
737
- name: dto.name
738
- })
739
- };
740
- var PiiAddress = {
741
- fromDto: (dto) => ({
742
- street: dto.street,
743
- city: dto.city,
744
- state: dto.state,
745
- postalCode: dto.postal_code,
746
- country: dto.country
747
- })
748
- };
749
- var Pii = {
750
- fromDto: (dto) => ({
751
- kind: dto.kind,
752
- fullLegalName: dto.full_legal_name,
753
- dateOfBirth: dto.date_of_birth,
754
- jurisdiction: dto.jurisdiction ? PiiJurisdiction.fromDto(dto.jurisdiction) : null,
755
- taxId: dto.tax_id,
756
- permanentAddress: PiiAddress.fromDto(dto.permanent_address)
757
- })
758
- };
759
-
760
- // src/shared/types/requirement.ts
761
- var RequirementId = (value) => value;
762
- var Requirement = {
763
- fromDto: (dto) => ({
764
- id: RequirementId(dto.id),
765
- type: dto.type,
766
- details: dto.details
767
- })
768
- };
769
- var RequirementStatusInfo = {
770
- fromStatusesDto: (dto) => Object.entries(dto.statuses).map(
771
- ([id, value]) => typeof value === "string" ? { id: RequirementId(id), status: value, action: null } : {
772
- id: RequirementId(id),
773
- status: value.status,
774
- action: value.action ?? null,
775
- kycLevel: value.kyc_level,
776
- kycReset: value.kyc_reset
777
- }
778
- )
779
- };
780
-
781
- export {
782
- sha256,
783
- arrayBufferToBase64Url,
784
- generateSecureRandomBase64Url,
785
- getUUIDv4,
786
- Attributes,
787
- EvmWalletAddress,
788
- EvmContractAddress,
789
- HexEncodedTransactionData,
790
- AssetDecimals,
791
- MAX_UINT_256,
792
- assertUint256,
793
- BlockchainAmount,
794
- AssetSymbol,
795
- StablecoinSymbol,
796
- KnownAssetSymbol,
797
- Bps,
798
- SwapAuthorization,
799
- SwapPreview,
800
- SwapStatus,
801
- TokenAllowance,
802
- TokenBalance,
803
- AllowWalletResponse,
804
- AssetId,
805
- AssetCode,
806
- Asset,
807
- OfferId,
808
- OfferSlug,
809
- Offer,
810
- OfferOptionId,
811
- OfferOptionSlug,
812
- OfferDetail,
813
- OfferOption,
814
- FaqItem,
815
- Link,
816
- TermItem,
817
- Milestone,
818
- OfferOptionAddressId,
819
- OfferOptionAddress,
820
- ConnectExternalWalletParams,
821
- WalletOwnershipChallenge,
822
- CreateWalletOwnershipChallengeParams,
823
- createWalletOwnershipChallenge,
824
- connectExternalWallet,
825
- listOptionAddresses,
826
- removeOptionAddress,
827
- SwapNamespaceImpl,
828
- Cursor,
829
- fetchAllPages,
830
- PaginatedResponse,
831
- PaginationParams,
832
- Erc20NamespaceImpl,
833
- ParticipationId,
834
- Blockchain,
835
- WalletAddress,
836
- ParticipationsPaginationParams,
837
- Participation,
838
- CreateParticipationParams,
839
- TokenSaleNamespaceImpl,
840
- DocumentSubmission,
841
- NotImplementedError,
842
- NotAuthenticatedError,
843
- KycToken,
844
- ClientCredentialsOAuth,
845
- OAuthRefreshToken,
846
- OAuthSession,
847
- Iso2CountryCode,
848
- PiiJurisdiction,
849
- PiiAddress,
850
- Pii,
851
- RequirementId,
852
- Requirement,
853
- RequirementStatusInfo
854
- };
855
- //# sourceMappingURL=chunk-UOHD7US2.js.map