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