@coinlist-co/react 0.11.1-rc.e102bdb → 0.12.1-rc.139e98c
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.
- package/dist/{chunk-7CTH4KPU.js → chunk-6CQHDASY.js} +648 -620
- package/dist/chunk-6CQHDASY.js.map +1 -0
- package/dist/{chunk-UZUQALFY.js → chunk-F6WGUKZC.js} +9 -9
- package/dist/chunk-F6WGUKZC.js.map +1 -0
- package/dist/{chunk-LSPZETDH.js → chunk-ZFBEI3BW.js} +131 -134
- package/dist/chunk-ZFBEI3BW.js.map +1 -0
- package/dist/client/index.cjs +1489 -1346
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +395 -254
- package/dist/client/index.d.ts +395 -254
- package/dist/client/index.js +852 -739
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-BBI_XydI.d.cts → collections-DOm9VKVm.d.cts} +1 -1
- package/dist/{collections-BrX9rRWc.d.ts → collections-aCv-Wr2a.d.ts} +1 -1
- package/dist/{config-CMl1bR3F.d.cts → config-DIaFzrMW.d.cts} +56 -13
- package/dist/{config-CMl1bR3F.d.ts → config-DIaFzrMW.d.ts} +56 -13
- package/dist/server/index.cjs +262 -236
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +4 -4
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +3 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{shared → universal}/index.cjs +948 -919
- package/dist/universal/index.cjs.map +1 -0
- package/dist/{shared → universal}/index.d.cts +566 -536
- package/dist/{shared → universal}/index.d.ts +566 -536
- package/dist/{shared → universal}/index.js +9 -5
- package/package.json +22 -17
- package/dist/chunk-7CTH4KPU.js.map +0 -1
- package/dist/chunk-LSPZETDH.js.map +0 -1
- package/dist/chunk-UZUQALFY.js.map +0 -1
- package/dist/shared/index.cjs.map +0 -1
- /package/dist/{shared → universal}/index.js.map +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/universal/api/http-attributes.ts
|
|
2
2
|
var empty = {};
|
|
3
3
|
var concat = (left, right) => ({
|
|
4
4
|
...left,
|
|
@@ -53,7 +53,7 @@ var Attributes = {
|
|
|
53
53
|
getRequestId
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
// src/
|
|
56
|
+
// src/universal/api/http.ts
|
|
57
57
|
var HttpError = class extends Error {
|
|
58
58
|
constructor(response) {
|
|
59
59
|
super(`Request failed with ${response.status} status`);
|
|
@@ -177,7 +177,7 @@ var Request = {
|
|
|
177
177
|
concatAttributes
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
// src/
|
|
180
|
+
// src/universal/types/errors.ts
|
|
181
181
|
var NotImplementedError = class extends Error {
|
|
182
182
|
constructor(message = "Not implemented yet") {
|
|
183
183
|
super(message);
|
|
@@ -209,7 +209,7 @@ var MathError = class extends Error {
|
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
// src/
|
|
212
|
+
// src/universal/api/pagination.ts
|
|
213
213
|
async function fetchAllPages(fetchPage, baseParams) {
|
|
214
214
|
const items = [];
|
|
215
215
|
let cursor = null;
|
|
@@ -225,7 +225,44 @@ async function fetchAllPages(fetchPage, baseParams) {
|
|
|
225
225
|
return items;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
// src/
|
|
228
|
+
// src/universal/types/pagination.ts
|
|
229
|
+
var Cursor = (value) => value;
|
|
230
|
+
var PaginatedResponse = {
|
|
231
|
+
fromDto: (dto, itemMapper) => ({
|
|
232
|
+
data: dto.data.map(itemMapper),
|
|
233
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
234
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
235
|
+
})
|
|
236
|
+
};
|
|
237
|
+
var PaginationParams = {
|
|
238
|
+
toQueryParams: (params) => {
|
|
239
|
+
const queryParams = {};
|
|
240
|
+
if (params.after) {
|
|
241
|
+
queryParams.starting_after = params.after;
|
|
242
|
+
}
|
|
243
|
+
if (params.before) {
|
|
244
|
+
queryParams.starting_before = params.before;
|
|
245
|
+
}
|
|
246
|
+
if (params.limit) {
|
|
247
|
+
queryParams.limit = params.limit;
|
|
248
|
+
}
|
|
249
|
+
return queryParams;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// src/universal/types/asset.ts
|
|
254
|
+
var AssetId = (value) => value;
|
|
255
|
+
var AssetCode = (value) => value;
|
|
256
|
+
var Asset = {
|
|
257
|
+
fromDto: (dto) => ({
|
|
258
|
+
id: AssetId(dto.id),
|
|
259
|
+
code: AssetCode(dto.code),
|
|
260
|
+
name: dto.name,
|
|
261
|
+
fractionalDigits: dto.fractional_digits
|
|
262
|
+
})
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/universal/types/blockchain/core.ts
|
|
229
266
|
var ETHEREUM_CHAINS = {
|
|
230
267
|
ethereum_mainnet: true,
|
|
231
268
|
ethereum_sepolia: true,
|
|
@@ -248,8 +285,9 @@ var SolanaChain = (value) => {
|
|
|
248
285
|
}
|
|
249
286
|
return value;
|
|
250
287
|
};
|
|
288
|
+
var isChain = (value) => Object.keys(ETHEREUM_CHAINS).includes(value) || Object.keys(SOLANA_CHAINS).includes(value);
|
|
251
289
|
var Chain = (value) => {
|
|
252
|
-
if (!
|
|
290
|
+
if (!isChain(value)) {
|
|
253
291
|
throw new ValidationError(`Unsupported chain: "${value}"`);
|
|
254
292
|
}
|
|
255
293
|
return value;
|
|
@@ -321,226 +359,295 @@ var StablecoinSymbol = (value) => value;
|
|
|
321
359
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
322
360
|
var Bps = (value) => value;
|
|
323
361
|
|
|
324
|
-
// src/
|
|
325
|
-
var
|
|
326
|
-
var
|
|
327
|
-
var
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
362
|
+
// src/universal/types/offer.ts
|
|
363
|
+
var OfferId = (value) => value;
|
|
364
|
+
var OfferSlug = (value) => value;
|
|
365
|
+
var Offer = {
|
|
366
|
+
fromDto: (dto) => {
|
|
367
|
+
if (!Array.isArray(dto.tokens)) {
|
|
368
|
+
throw new ValidationError(
|
|
369
|
+
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
id: OfferId(dto.id),
|
|
374
|
+
slug: OfferSlug(dto.slug),
|
|
375
|
+
type: dto.type,
|
|
376
|
+
tagline: dto.tagline,
|
|
377
|
+
bannerUrl: dto.banner_url,
|
|
378
|
+
logoUrl: dto.logo_url,
|
|
379
|
+
startsAt: new Date(dto.starts_at),
|
|
380
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
381
|
+
tokens: OfferToken.listFromDto(dto.tokens)
|
|
382
|
+
};
|
|
383
|
+
}
|
|
338
384
|
};
|
|
339
|
-
|
|
340
|
-
|
|
385
|
+
var OfferToken = {
|
|
386
|
+
fromDto: (dto) => ({
|
|
387
|
+
role: dto.role,
|
|
388
|
+
chain: Chain(dto.chain),
|
|
389
|
+
address: EvmContractAddress(dto.address)
|
|
390
|
+
}),
|
|
391
|
+
/**
|
|
392
|
+
* Maps an offer's token list, dropping every token on a chain this SDK does
|
|
393
|
+
* not name. Frontline's chain registry runs ahead of {@link Chain}, and a
|
|
394
|
+
* plain `.map` would throw out of `Offer.fromDto` and, through
|
|
395
|
+
* `PaginatedResponse.fromDto`, reject the whole offers page - which is how
|
|
396
|
+
* one Base token blanked production's offers list. Dropping costs that
|
|
397
|
+
* token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
|
|
398
|
+
* so nobody could have looked it up anyway.
|
|
399
|
+
*
|
|
400
|
+
* Same shape as `TokenMetadata.fromRegistryDto`.
|
|
401
|
+
*/
|
|
402
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// src/universal/core/shared/utils/crypto.ts
|
|
406
|
+
async function sha256(data) {
|
|
407
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
408
|
+
const buffer = bytes.buffer.slice(
|
|
409
|
+
bytes.byteOffset,
|
|
410
|
+
bytes.byteOffset + bytes.byteLength
|
|
411
|
+
);
|
|
412
|
+
return crypto.subtle.digest("SHA-256", buffer);
|
|
341
413
|
}
|
|
342
|
-
function
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
414
|
+
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
415
|
+
const bytes = new Uint8Array(buffer);
|
|
416
|
+
let binary = "";
|
|
417
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
418
|
+
binary += String.fromCharCode(bytes[i]);
|
|
347
419
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
case "ethereum_mainnet":
|
|
353
|
-
return "Ethereum";
|
|
354
|
-
case "ethereum_sepolia":
|
|
355
|
-
return "Ethereum Sepolia";
|
|
356
|
-
case "base_mainnet":
|
|
357
|
-
return "Base";
|
|
358
|
-
case "base_sepolia":
|
|
359
|
-
return "Base Sepolia";
|
|
360
|
-
default: {
|
|
361
|
-
const _exhaustive = chain;
|
|
362
|
-
return _exhaustive;
|
|
363
|
-
}
|
|
420
|
+
let base64 = btoa(binary);
|
|
421
|
+
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
422
|
+
if (!padding) {
|
|
423
|
+
base64 = base64.replace(/=+$/, "");
|
|
364
424
|
}
|
|
425
|
+
return base64;
|
|
365
426
|
}
|
|
366
|
-
function
|
|
367
|
-
|
|
427
|
+
function generateSecureRandomBase64Url(byteLength) {
|
|
428
|
+
const bytes = new Uint8Array(byteLength);
|
|
429
|
+
crypto.getRandomValues(bytes);
|
|
430
|
+
const buffer = bytes.buffer;
|
|
431
|
+
return arrayBufferToBase64Url(buffer, false);
|
|
368
432
|
}
|
|
369
|
-
function
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
433
|
+
function getUUIDv4() {
|
|
434
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
435
|
+
return crypto.randomUUID();
|
|
436
|
+
}
|
|
437
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
438
|
+
const bytes = new Uint8Array(16);
|
|
439
|
+
crypto.getRandomValues(bytes);
|
|
440
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
441
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
442
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
443
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
|
|
444
|
+
}
|
|
445
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
446
|
+
}
|
|
447
|
+
function notBlankStringOrNull(value) {
|
|
448
|
+
if (value?.trim()) {
|
|
449
|
+
return value;
|
|
450
|
+
} else {
|
|
451
|
+
return null;
|
|
383
452
|
}
|
|
384
453
|
}
|
|
385
454
|
|
|
386
|
-
// src/
|
|
387
|
-
var
|
|
455
|
+
// src/universal/types/offer-detail.ts
|
|
456
|
+
var OfferOptionId = (value) => value;
|
|
457
|
+
var OfferOptionSlug = (value) => value;
|
|
458
|
+
var OfferSwapContract = {
|
|
388
459
|
fromDto: (dto) => ({
|
|
389
|
-
|
|
460
|
+
chain: Chain(dto.chain),
|
|
461
|
+
address: EvmContractAddress(dto.address)
|
|
390
462
|
})
|
|
391
463
|
};
|
|
392
|
-
var
|
|
464
|
+
var OfferDetail = {
|
|
465
|
+
fromDto: (dto) => {
|
|
466
|
+
if (!Array.isArray(dto.funding_assets)) {
|
|
467
|
+
throw new ValidationError(
|
|
468
|
+
`OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
if (!Array.isArray(dto.options)) {
|
|
472
|
+
throw new ValidationError(
|
|
473
|
+
`OfferDetail.options: expected an array, got ${typeof dto.options}`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
if (!Array.isArray(dto.terms)) {
|
|
477
|
+
throw new ValidationError(
|
|
478
|
+
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
if (!Array.isArray(dto.links)) {
|
|
482
|
+
throw new ValidationError(
|
|
483
|
+
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
if (!Array.isArray(dto.faqs)) {
|
|
487
|
+
throw new ValidationError(
|
|
488
|
+
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
if (!Array.isArray(dto.milestones)) {
|
|
492
|
+
throw new ValidationError(
|
|
493
|
+
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
if (!Array.isArray(dto.tokens)) {
|
|
497
|
+
throw new ValidationError(
|
|
498
|
+
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
502
|
+
if (!Array.isArray(swapContracts)) {
|
|
503
|
+
throw new ValidationError(
|
|
504
|
+
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
return {
|
|
508
|
+
id: OfferId(dto.id),
|
|
509
|
+
slug: OfferSlug(dto.slug),
|
|
510
|
+
type: dto.type,
|
|
511
|
+
name: dto.name,
|
|
512
|
+
asset: Asset.fromDto(dto.asset),
|
|
513
|
+
fundingAssets: dto.funding_assets.map(Asset.fromDto),
|
|
514
|
+
tokens: OfferToken.listFromDto(dto.tokens),
|
|
515
|
+
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
516
|
+
about: notBlankStringOrNull(dto.about),
|
|
517
|
+
tagline: dto.tagline,
|
|
518
|
+
bannerUrl: dto.banner_url,
|
|
519
|
+
logoUrl: dto.logo_url,
|
|
520
|
+
category: dto.category,
|
|
521
|
+
startsAt: new Date(dto.starts_at),
|
|
522
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
523
|
+
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
524
|
+
links: dto.links.map(Link.fromDto),
|
|
525
|
+
milestones: dto.milestones.map(Milestone.fromDto),
|
|
526
|
+
options: dto.options.map(OfferOption.fromDto),
|
|
527
|
+
terms: dto.terms.map(TermItem.fromDto)
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
var OfferOption = {
|
|
393
532
|
fromDto: (dto) => ({
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
)
|
|
533
|
+
id: OfferOptionId(dto.id),
|
|
534
|
+
slug: OfferOptionSlug(dto.slug),
|
|
535
|
+
bidIncrement: dto.bid_increment,
|
|
536
|
+
floorPriceUsd: dto.floor_price_usd,
|
|
537
|
+
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
538
|
+
priceUsd: dto.price_usd,
|
|
539
|
+
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
540
|
+
totalTokenSupply: dto.total_token_supply
|
|
403
541
|
})
|
|
404
542
|
};
|
|
405
|
-
var
|
|
543
|
+
var FaqItem = {
|
|
406
544
|
fromDto: (dto) => ({
|
|
407
|
-
|
|
408
|
-
|
|
545
|
+
question: notBlankStringOrNull(dto.question),
|
|
546
|
+
answer: notBlankStringOrNull(dto.answer)
|
|
409
547
|
})
|
|
410
548
|
};
|
|
411
|
-
var
|
|
549
|
+
var Link = {
|
|
412
550
|
fromDto: (dto) => ({
|
|
413
|
-
|
|
551
|
+
label: notBlankStringOrNull(dto.label),
|
|
552
|
+
url: notBlankStringOrNull(dto.url)
|
|
414
553
|
})
|
|
415
554
|
};
|
|
416
|
-
var
|
|
555
|
+
var TermItem = {
|
|
417
556
|
fromDto: (dto) => ({
|
|
418
|
-
|
|
557
|
+
key: notBlankStringOrNull(dto.key),
|
|
558
|
+
value: notBlankStringOrNull(dto.value)
|
|
419
559
|
})
|
|
420
560
|
};
|
|
421
|
-
var
|
|
422
|
-
fromDto: (dto) => {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
561
|
+
var Milestone = {
|
|
562
|
+
fromDto: (dto) => ({
|
|
563
|
+
name: notBlankStringOrNull(dto.name),
|
|
564
|
+
schedule: notBlankStringOrNull(dto.schedule),
|
|
565
|
+
status: dto.status
|
|
566
|
+
})
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// src/universal/types/providers/coin-list/token-sale.ts
|
|
570
|
+
var ParticipationId = (value) => value;
|
|
571
|
+
var Blockchain = (value) => value;
|
|
572
|
+
var WalletAddress = (value) => value;
|
|
573
|
+
var ParticipationsPaginationParams = {
|
|
574
|
+
toQueryParams: (params) => {
|
|
575
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
576
|
+
if (params.offerId) {
|
|
577
|
+
queryParams["filters[0][field]"] = "offer_id";
|
|
578
|
+
queryParams["filters[0][op]"] = "==";
|
|
579
|
+
queryParams["filters[0][value]"] = params.offerId;
|
|
439
580
|
}
|
|
581
|
+
return queryParams;
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
var Participation = {
|
|
585
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
586
|
+
fromDto: (dto) => {
|
|
587
|
+
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
588
|
+
return {
|
|
589
|
+
id: ParticipationId(dto.id),
|
|
590
|
+
offerId: OfferId(dto.offer_id),
|
|
591
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
592
|
+
status: dto.status,
|
|
593
|
+
amount: dto.amount,
|
|
594
|
+
displayAmount: dto.amount_string,
|
|
595
|
+
asset: Asset.fromDto(dto.asset),
|
|
596
|
+
chain: Blockchain(dto.chain),
|
|
597
|
+
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
598
|
+
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
599
|
+
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
600
|
+
};
|
|
440
601
|
}
|
|
441
602
|
};
|
|
603
|
+
var CreateParticipationParams = {
|
|
604
|
+
/** Maps participation creation params into API DTO payload. */
|
|
605
|
+
toDto: (params) => ({
|
|
606
|
+
offer_id: params.offerId,
|
|
607
|
+
offer_option_id: params.offerOptionId,
|
|
608
|
+
chain: params.chain,
|
|
609
|
+
wallet_address: params.walletAddress,
|
|
610
|
+
amount: params.amount,
|
|
611
|
+
asset_id: params.assetId,
|
|
612
|
+
approval_transaction_hash: params.approvalTransactionHash
|
|
613
|
+
})
|
|
614
|
+
};
|
|
442
615
|
|
|
443
|
-
// src/
|
|
444
|
-
async function
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
chain: params.chain,
|
|
450
|
-
contract_address: params.contractAddress,
|
|
451
|
-
wallet_address: params.walletAddress
|
|
452
|
-
},
|
|
453
|
-
attributes: Attributes.protected()
|
|
454
|
-
});
|
|
455
|
-
return SwapAuthorization.fromDto(dto);
|
|
456
|
-
}
|
|
457
|
-
async function getSwapOutputToken(api, params) {
|
|
458
|
-
const dto = await api.send({
|
|
459
|
-
method: "GET",
|
|
460
|
-
url: "/v1/swap/output-token",
|
|
461
|
-
queryParams: {
|
|
462
|
-
chain: params.chain,
|
|
463
|
-
contract_address: params.contractAddress
|
|
464
|
-
},
|
|
465
|
-
attributes: Attributes.protected()
|
|
466
|
-
});
|
|
467
|
-
return toErc20Asset(dto);
|
|
468
|
-
}
|
|
469
|
-
async function getSwapPreview(api, params) {
|
|
470
|
-
const dto = await api.send({
|
|
471
|
-
method: "GET",
|
|
472
|
-
url: "/v1/swap/preview",
|
|
473
|
-
queryParams: {
|
|
474
|
-
chain: params.chain,
|
|
475
|
-
contract_address: params.contractAddress,
|
|
476
|
-
input_token: params.inputToken,
|
|
477
|
-
amount: params.amount.toString()
|
|
478
|
-
},
|
|
479
|
-
attributes: Attributes.protected()
|
|
480
|
-
});
|
|
481
|
-
return SwapPreview.fromDto(dto);
|
|
482
|
-
}
|
|
483
|
-
async function getSwapStatus(api, params) {
|
|
484
|
-
const dto = await api.send({
|
|
485
|
-
method: "GET",
|
|
486
|
-
url: "/v1/swap/status",
|
|
487
|
-
queryParams: {
|
|
488
|
-
chain: params.chain,
|
|
489
|
-
contract_address: params.contractAddress
|
|
490
|
-
},
|
|
491
|
-
attributes: Attributes.protected()
|
|
492
|
-
});
|
|
493
|
-
return SwapStatus.fromDto(dto);
|
|
616
|
+
// src/universal/api/frontline/providers/coin-list/token-sale.ts
|
|
617
|
+
async function fetchParticipations(api, offerId) {
|
|
618
|
+
return fetchAllPages(
|
|
619
|
+
(params) => fetchParticipationsPage(api, params),
|
|
620
|
+
{ offerId }
|
|
621
|
+
);
|
|
494
622
|
}
|
|
495
|
-
async function
|
|
496
|
-
const
|
|
623
|
+
async function fetchParticipationsPage(api, params) {
|
|
624
|
+
const pageDto = await api.send({
|
|
497
625
|
method: "GET",
|
|
498
|
-
url: "/v1/
|
|
499
|
-
queryParams:
|
|
500
|
-
chain: params.chain,
|
|
501
|
-
token_address: params.tokenAddress,
|
|
502
|
-
owner: params.owner,
|
|
503
|
-
spender: params.spender
|
|
504
|
-
},
|
|
626
|
+
url: "/v1/participations",
|
|
627
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
505
628
|
attributes: Attributes.protected()
|
|
506
629
|
});
|
|
507
|
-
return
|
|
630
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
508
631
|
}
|
|
509
|
-
async function
|
|
632
|
+
async function fetchParticipation(api, id) {
|
|
510
633
|
const dto = await api.send({
|
|
511
634
|
method: "GET",
|
|
512
|
-
url:
|
|
513
|
-
queryParams: {
|
|
514
|
-
chain: params.chain,
|
|
515
|
-
token_address: params.tokenAddress,
|
|
516
|
-
owner: params.owner
|
|
517
|
-
},
|
|
635
|
+
url: `/v1/participations/${id}`,
|
|
518
636
|
attributes: Attributes.protected()
|
|
519
637
|
});
|
|
520
|
-
return
|
|
638
|
+
return Participation.fromDto(dto);
|
|
521
639
|
}
|
|
522
|
-
async function
|
|
640
|
+
async function createParticipation(api, params) {
|
|
523
641
|
const dto = await api.send({
|
|
524
642
|
method: "POST",
|
|
525
|
-
url:
|
|
526
|
-
body:
|
|
527
|
-
wallet_address: params.walletAddress,
|
|
528
|
-
chain: params.chain,
|
|
529
|
-
signature: params.signature
|
|
530
|
-
},
|
|
643
|
+
url: "/v1/participations",
|
|
644
|
+
body: CreateParticipationParams.toDto(params),
|
|
531
645
|
attributes: Attributes.protected()
|
|
532
646
|
});
|
|
533
|
-
return
|
|
534
|
-
}
|
|
535
|
-
function toErc20Asset(dto) {
|
|
536
|
-
return {
|
|
537
|
-
name: dto.name,
|
|
538
|
-
symbol: AssetSymbol(dto.symbol),
|
|
539
|
-
decimals: AssetDecimals(dto.decimals)
|
|
540
|
-
};
|
|
647
|
+
return Participation.fromDto(dto);
|
|
541
648
|
}
|
|
542
649
|
|
|
543
|
-
// src/
|
|
650
|
+
// src/universal/core/shared/observability/log-cause.ts
|
|
544
651
|
function classifyLogCause(error) {
|
|
545
652
|
if (error instanceof HttpError) {
|
|
546
653
|
return httpCause(error);
|
|
@@ -606,7 +713,7 @@ function apiErrorEventId(error) {
|
|
|
606
713
|
return typeof eventId === "string" ? eventId : null;
|
|
607
714
|
}
|
|
608
715
|
|
|
609
|
-
// src/
|
|
716
|
+
// src/universal/core/shared/observability/internal-logger.ts
|
|
610
717
|
function internalLogger(logger, scope) {
|
|
611
718
|
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
612
719
|
}
|
|
@@ -689,27 +796,47 @@ var noopInternalLogger = {
|
|
|
689
796
|
wrap: (_op, _params, run) => run()
|
|
690
797
|
};
|
|
691
798
|
|
|
692
|
-
// src/
|
|
693
|
-
var
|
|
799
|
+
// src/universal/core/checkout/coin-list/token-sale-namespace.ts
|
|
800
|
+
var CoinListTokenSaleNamespaceImpl = class {
|
|
694
801
|
constructor(ctx) {
|
|
695
802
|
this.ctx = ctx;
|
|
696
|
-
this.log = internalLogger(ctx.logger, "
|
|
803
|
+
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
697
804
|
}
|
|
698
|
-
async
|
|
699
|
-
return this.log.wrap("
|
|
805
|
+
async list(offerId) {
|
|
806
|
+
return this.log.wrap("list", offerId, async () => {
|
|
700
807
|
await this.ctx.ensureUserAuthenticated();
|
|
701
|
-
return
|
|
808
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
702
809
|
});
|
|
703
810
|
}
|
|
704
|
-
async
|
|
705
|
-
return this.log.wrap("
|
|
811
|
+
async listPage(params) {
|
|
812
|
+
return this.log.wrap("listPage", params, async () => {
|
|
706
813
|
await this.ctx.ensureUserAuthenticated();
|
|
707
|
-
return
|
|
814
|
+
return fetchParticipationsPage(this.ctx.api, params);
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
async get(id) {
|
|
818
|
+
return this.log.wrap("get", id, async () => {
|
|
819
|
+
await this.ctx.ensureUserAuthenticated();
|
|
820
|
+
return fetchParticipation(this.ctx.api, id);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
async createParticipation(params) {
|
|
824
|
+
return this.log.wrap("createParticipation", params, async () => {
|
|
825
|
+
await this.ctx.ensureUserAuthenticated();
|
|
826
|
+
return createParticipation(this.ctx.api, params);
|
|
708
827
|
});
|
|
709
828
|
}
|
|
710
829
|
};
|
|
711
830
|
|
|
712
|
-
// src/
|
|
831
|
+
// src/universal/types/blockchain/ui.ts
|
|
832
|
+
var FormattedAmountUi = (value) => value;
|
|
833
|
+
var FormattedPercentUi = (value) => value;
|
|
834
|
+
var TxExplorerUrl = (value) => value;
|
|
835
|
+
var ShortenedWalletAddress = (value) => value;
|
|
836
|
+
var FormattedAmountAssetUi = (value) => value;
|
|
837
|
+
var AssetIconUrl = (value) => value;
|
|
838
|
+
|
|
839
|
+
// src/universal/core/shared/blockchain/formatters.ts
|
|
713
840
|
import { formatUnits } from "viem";
|
|
714
841
|
function shortenAddress(address) {
|
|
715
842
|
const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
@@ -804,27 +931,81 @@ function formattedUsdPrice(amount, locale) {
|
|
|
804
931
|
);
|
|
805
932
|
}
|
|
806
933
|
|
|
807
|
-
// src/
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
934
|
+
// src/universal/core/shared/blockchain/chain.ts
|
|
935
|
+
var CHAIN_IDS = {
|
|
936
|
+
ethereum_mainnet: 1,
|
|
937
|
+
ethereum_sepolia: 11155111,
|
|
938
|
+
base_mainnet: 8453,
|
|
939
|
+
base_sepolia: 84532
|
|
940
|
+
};
|
|
941
|
+
function getChainId(chain) {
|
|
942
|
+
return CHAIN_IDS[chain];
|
|
943
|
+
}
|
|
944
|
+
function chainFromId(chainId) {
|
|
945
|
+
const chains = Object.keys(CHAIN_IDS);
|
|
946
|
+
const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
|
|
947
|
+
if (!chain) {
|
|
948
|
+
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
823
949
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
950
|
+
return chain;
|
|
951
|
+
}
|
|
952
|
+
function getNetworkName(chain) {
|
|
953
|
+
switch (chain) {
|
|
954
|
+
case "ethereum_mainnet":
|
|
955
|
+
return "Ethereum";
|
|
956
|
+
case "ethereum_sepolia":
|
|
957
|
+
return "Ethereum Sepolia";
|
|
958
|
+
case "base_mainnet":
|
|
959
|
+
return "Base";
|
|
960
|
+
case "base_sepolia":
|
|
961
|
+
return "Base Sepolia";
|
|
962
|
+
default: {
|
|
963
|
+
const _exhaustive = chain;
|
|
964
|
+
return _exhaustive;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
function txExplorerUrl(chain, txHash) {
|
|
969
|
+
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
970
|
+
}
|
|
971
|
+
function explorerBaseUrl(chain) {
|
|
972
|
+
switch (chain) {
|
|
973
|
+
case "ethereum_mainnet":
|
|
974
|
+
return "https://etherscan.io";
|
|
975
|
+
case "ethereum_sepolia":
|
|
976
|
+
return "https://sepolia.etherscan.io";
|
|
977
|
+
case "base_mainnet":
|
|
978
|
+
return "https://basescan.org";
|
|
979
|
+
case "base_sepolia":
|
|
980
|
+
return "https://sepolia-explorer.base.org";
|
|
981
|
+
default: {
|
|
982
|
+
const _exhaustive = chain;
|
|
983
|
+
return _exhaustive;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
989
|
+
import { parseUnits } from "viem";
|
|
990
|
+
function blockchainAmountFromRawOrThrow({
|
|
991
|
+
label,
|
|
992
|
+
raw,
|
|
993
|
+
decimals
|
|
994
|
+
}) {
|
|
995
|
+
const trimmed = raw.trim();
|
|
996
|
+
if (trimmed === "") {
|
|
997
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
998
|
+
}
|
|
999
|
+
let value;
|
|
1000
|
+
try {
|
|
1001
|
+
value = BigInt(trimmed);
|
|
1002
|
+
} catch {
|
|
1003
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
1004
|
+
}
|
|
1005
|
+
try {
|
|
1006
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
1007
|
+
} catch {
|
|
1008
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
828
1009
|
}
|
|
829
1010
|
}
|
|
830
1011
|
function parseBlockchainAmount(amount, decimals) {
|
|
@@ -846,356 +1027,24 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
846
1027
|
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
847
1028
|
};
|
|
848
1029
|
}
|
|
849
|
-
try {
|
|
850
|
-
const raw = parseUnits(trimmed, decimals);
|
|
851
|
-
if (raw > MAX_UINT_256) {
|
|
852
|
-
return { valid: false, reason: { type: "overflow" } };
|
|
853
|
-
}
|
|
854
|
-
return {
|
|
855
|
-
valid: true,
|
|
856
|
-
amount: BlockchainAmount({ raw, decimals })
|
|
857
|
-
};
|
|
858
|
-
} catch {
|
|
859
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
// src/shared/types/pagination.ts
|
|
864
|
-
var Cursor = (value) => value;
|
|
865
|
-
var PaginatedResponse = {
|
|
866
|
-
fromDto: (dto, itemMapper) => ({
|
|
867
|
-
data: dto.data.map(itemMapper),
|
|
868
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
869
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
870
|
-
})
|
|
871
|
-
};
|
|
872
|
-
var PaginationParams = {
|
|
873
|
-
toQueryParams: (params) => {
|
|
874
|
-
const queryParams = {};
|
|
875
|
-
if (params.after) {
|
|
876
|
-
queryParams.starting_after = params.after;
|
|
877
|
-
}
|
|
878
|
-
if (params.before) {
|
|
879
|
-
queryParams.starting_before = params.before;
|
|
880
|
-
}
|
|
881
|
-
if (params.limit) {
|
|
882
|
-
queryParams.limit = params.limit;
|
|
883
|
-
}
|
|
884
|
-
return queryParams;
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
// src/shared/types/asset.ts
|
|
889
|
-
var AssetId = (value) => value;
|
|
890
|
-
var AssetCode = (value) => value;
|
|
891
|
-
var Asset = {
|
|
892
|
-
fromDto: (dto) => ({
|
|
893
|
-
id: AssetId(dto.id),
|
|
894
|
-
code: AssetCode(dto.code),
|
|
895
|
-
name: dto.name,
|
|
896
|
-
fractionalDigits: dto.fractional_digits
|
|
897
|
-
})
|
|
898
|
-
};
|
|
899
|
-
|
|
900
|
-
// src/shared/types/offer.ts
|
|
901
|
-
var OfferId = (value) => value;
|
|
902
|
-
var OfferSlug = (value) => value;
|
|
903
|
-
var Offer = {
|
|
904
|
-
fromDto: (dto) => {
|
|
905
|
-
if (!Array.isArray(dto.tokens)) {
|
|
906
|
-
throw new ValidationError(
|
|
907
|
-
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
908
|
-
);
|
|
909
|
-
}
|
|
910
|
-
return {
|
|
911
|
-
id: OfferId(dto.id),
|
|
912
|
-
slug: OfferSlug(dto.slug),
|
|
913
|
-
type: dto.type,
|
|
914
|
-
tagline: dto.tagline,
|
|
915
|
-
bannerUrl: dto.banner_url,
|
|
916
|
-
logoUrl: dto.logo_url,
|
|
917
|
-
startsAt: new Date(dto.starts_at),
|
|
918
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
919
|
-
tokens: dto.tokens.map(OfferToken.fromDto)
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
var OfferToken = {
|
|
924
|
-
fromDto: (dto) => ({
|
|
925
|
-
role: dto.role,
|
|
926
|
-
chain: Chain(dto.chain),
|
|
927
|
-
address: EvmContractAddress(dto.address)
|
|
928
|
-
})
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
// src/shared/core/utils/crypto.ts
|
|
932
|
-
async function sha256(data) {
|
|
933
|
-
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
934
|
-
const buffer = bytes.buffer.slice(
|
|
935
|
-
bytes.byteOffset,
|
|
936
|
-
bytes.byteOffset + bytes.byteLength
|
|
937
|
-
);
|
|
938
|
-
return crypto.subtle.digest("SHA-256", buffer);
|
|
939
|
-
}
|
|
940
|
-
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
941
|
-
const bytes = new Uint8Array(buffer);
|
|
942
|
-
let binary = "";
|
|
943
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
944
|
-
binary += String.fromCharCode(bytes[i]);
|
|
945
|
-
}
|
|
946
|
-
let base64 = btoa(binary);
|
|
947
|
-
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
948
|
-
if (!padding) {
|
|
949
|
-
base64 = base64.replace(/=+$/, "");
|
|
950
|
-
}
|
|
951
|
-
return base64;
|
|
952
|
-
}
|
|
953
|
-
function generateSecureRandomBase64Url(byteLength) {
|
|
954
|
-
const bytes = new Uint8Array(byteLength);
|
|
955
|
-
crypto.getRandomValues(bytes);
|
|
956
|
-
const buffer = bytes.buffer;
|
|
957
|
-
return arrayBufferToBase64Url(buffer, false);
|
|
958
|
-
}
|
|
959
|
-
function getUUIDv4() {
|
|
960
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
961
|
-
return crypto.randomUUID();
|
|
962
|
-
}
|
|
963
|
-
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
964
|
-
const bytes = new Uint8Array(16);
|
|
965
|
-
crypto.getRandomValues(bytes);
|
|
966
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
967
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
968
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
969
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
|
|
970
|
-
}
|
|
971
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
972
|
-
}
|
|
973
|
-
function notBlankStringOrNull(value) {
|
|
974
|
-
if (value?.trim()) {
|
|
975
|
-
return value;
|
|
976
|
-
} else {
|
|
977
|
-
return null;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
// src/shared/types/offer-detail.ts
|
|
982
|
-
var OfferOptionId = (value) => value;
|
|
983
|
-
var OfferOptionSlug = (value) => value;
|
|
984
|
-
var OfferDetail = {
|
|
985
|
-
fromDto: (dto) => {
|
|
986
|
-
if (!Array.isArray(dto.funding_assets)) {
|
|
987
|
-
throw new ValidationError(
|
|
988
|
-
`OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
|
|
989
|
-
);
|
|
990
|
-
}
|
|
991
|
-
if (!Array.isArray(dto.options)) {
|
|
992
|
-
throw new ValidationError(
|
|
993
|
-
`OfferDetail.options: expected an array, got ${typeof dto.options}`
|
|
994
|
-
);
|
|
995
|
-
}
|
|
996
|
-
if (!Array.isArray(dto.terms)) {
|
|
997
|
-
throw new ValidationError(
|
|
998
|
-
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
999
|
-
);
|
|
1000
|
-
}
|
|
1001
|
-
if (!Array.isArray(dto.links)) {
|
|
1002
|
-
throw new ValidationError(
|
|
1003
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
if (!Array.isArray(dto.faqs)) {
|
|
1007
|
-
throw new ValidationError(
|
|
1008
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
if (!Array.isArray(dto.milestones)) {
|
|
1012
|
-
throw new ValidationError(
|
|
1013
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
1014
|
-
);
|
|
1015
|
-
}
|
|
1016
|
-
if (!Array.isArray(dto.tokens)) {
|
|
1017
|
-
throw new ValidationError(
|
|
1018
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
1019
|
-
);
|
|
1020
|
-
}
|
|
1021
|
-
return {
|
|
1022
|
-
id: OfferId(dto.id),
|
|
1023
|
-
slug: OfferSlug(dto.slug),
|
|
1024
|
-
type: dto.type,
|
|
1025
|
-
name: dto.name,
|
|
1026
|
-
asset: Asset.fromDto(dto.asset),
|
|
1027
|
-
fundingAssets: dto.funding_assets.map(Asset.fromDto),
|
|
1028
|
-
tokens: dto.tokens.map(OfferToken.fromDto),
|
|
1029
|
-
about: notBlankStringOrNull(dto.about),
|
|
1030
|
-
tagline: dto.tagline,
|
|
1031
|
-
bannerUrl: dto.banner_url,
|
|
1032
|
-
logoUrl: dto.logo_url,
|
|
1033
|
-
category: dto.category,
|
|
1034
|
-
startsAt: new Date(dto.starts_at),
|
|
1035
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1036
|
-
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
1037
|
-
links: dto.links.map(Link.fromDto),
|
|
1038
|
-
milestones: dto.milestones.map(Milestone.fromDto),
|
|
1039
|
-
options: dto.options.map(OfferOption.fromDto),
|
|
1040
|
-
terms: dto.terms.map(TermItem.fromDto)
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
};
|
|
1044
|
-
var OfferOption = {
|
|
1045
|
-
fromDto: (dto) => ({
|
|
1046
|
-
id: OfferOptionId(dto.id),
|
|
1047
|
-
slug: OfferOptionSlug(dto.slug),
|
|
1048
|
-
bidIncrement: dto.bid_increment,
|
|
1049
|
-
floorPriceUsd: dto.floor_price_usd,
|
|
1050
|
-
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
1051
|
-
priceUsd: dto.price_usd,
|
|
1052
|
-
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
1053
|
-
totalTokenSupply: dto.total_token_supply
|
|
1054
|
-
})
|
|
1055
|
-
};
|
|
1056
|
-
var FaqItem = {
|
|
1057
|
-
fromDto: (dto) => ({
|
|
1058
|
-
question: notBlankStringOrNull(dto.question),
|
|
1059
|
-
answer: notBlankStringOrNull(dto.answer)
|
|
1060
|
-
})
|
|
1061
|
-
};
|
|
1062
|
-
var Link = {
|
|
1063
|
-
fromDto: (dto) => ({
|
|
1064
|
-
label: notBlankStringOrNull(dto.label),
|
|
1065
|
-
url: notBlankStringOrNull(dto.url)
|
|
1066
|
-
})
|
|
1067
|
-
};
|
|
1068
|
-
var TermItem = {
|
|
1069
|
-
fromDto: (dto) => ({
|
|
1070
|
-
key: notBlankStringOrNull(dto.key),
|
|
1071
|
-
value: notBlankStringOrNull(dto.value)
|
|
1072
|
-
})
|
|
1073
|
-
};
|
|
1074
|
-
var Milestone = {
|
|
1075
|
-
fromDto: (dto) => ({
|
|
1076
|
-
name: notBlankStringOrNull(dto.name),
|
|
1077
|
-
schedule: notBlankStringOrNull(dto.schedule),
|
|
1078
|
-
status: dto.status
|
|
1079
|
-
})
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
// src/shared/types/providers/coin-list/token-sale.ts
|
|
1083
|
-
var ParticipationId = (value) => value;
|
|
1084
|
-
var Blockchain = (value) => value;
|
|
1085
|
-
var WalletAddress = (value) => value;
|
|
1086
|
-
var ParticipationsPaginationParams = {
|
|
1087
|
-
toQueryParams: (params) => {
|
|
1088
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
1089
|
-
if (params.offerId) {
|
|
1090
|
-
queryParams["filters[0][field]"] = "offer_id";
|
|
1091
|
-
queryParams["filters[0][op]"] = "==";
|
|
1092
|
-
queryParams["filters[0][value]"] = params.offerId;
|
|
1093
|
-
}
|
|
1094
|
-
return queryParams;
|
|
1095
|
-
}
|
|
1096
|
-
};
|
|
1097
|
-
var Participation = {
|
|
1098
|
-
/** Maps API DTO shape into the SDK participation domain model. */
|
|
1099
|
-
fromDto: (dto) => {
|
|
1100
|
-
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
1101
|
-
return {
|
|
1102
|
-
id: ParticipationId(dto.id),
|
|
1103
|
-
offerId: OfferId(dto.offer_id),
|
|
1104
|
-
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
1105
|
-
status: dto.status,
|
|
1106
|
-
amount: dto.amount,
|
|
1107
|
-
displayAmount: dto.amount_string,
|
|
1108
|
-
asset: Asset.fromDto(dto.asset),
|
|
1109
|
-
chain: Blockchain(dto.chain),
|
|
1110
|
-
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
1111
|
-
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
1112
|
-
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
var CreateParticipationParams = {
|
|
1117
|
-
/** Maps participation creation params into API DTO payload. */
|
|
1118
|
-
toDto: (params) => ({
|
|
1119
|
-
offer_id: params.offerId,
|
|
1120
|
-
offer_option_id: params.offerOptionId,
|
|
1121
|
-
chain: params.chain,
|
|
1122
|
-
wallet_address: params.walletAddress,
|
|
1123
|
-
amount: params.amount,
|
|
1124
|
-
asset_id: params.assetId,
|
|
1125
|
-
approval_transaction_hash: params.approvalTransactionHash
|
|
1126
|
-
})
|
|
1127
|
-
};
|
|
1128
|
-
|
|
1129
|
-
// src/shared/api/frontline/providers/coin-list/token-sale.ts
|
|
1130
|
-
async function fetchParticipations(api, offerId) {
|
|
1131
|
-
return fetchAllPages(
|
|
1132
|
-
(params) => fetchParticipationsPage(api, params),
|
|
1133
|
-
{ offerId }
|
|
1134
|
-
);
|
|
1135
|
-
}
|
|
1136
|
-
async function fetchParticipationsPage(api, params) {
|
|
1137
|
-
const pageDto = await api.send({
|
|
1138
|
-
method: "GET",
|
|
1139
|
-
url: "/v1/participations",
|
|
1140
|
-
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
1141
|
-
attributes: Attributes.protected()
|
|
1142
|
-
});
|
|
1143
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
1144
|
-
}
|
|
1145
|
-
async function fetchParticipation(api, id) {
|
|
1146
|
-
const dto = await api.send({
|
|
1147
|
-
method: "GET",
|
|
1148
|
-
url: `/v1/participations/${id}`,
|
|
1149
|
-
attributes: Attributes.protected()
|
|
1150
|
-
});
|
|
1151
|
-
return Participation.fromDto(dto);
|
|
1152
|
-
}
|
|
1153
|
-
async function createParticipation(api, params) {
|
|
1154
|
-
const dto = await api.send({
|
|
1155
|
-
method: "POST",
|
|
1156
|
-
url: "/v1/participations",
|
|
1157
|
-
body: CreateParticipationParams.toDto(params),
|
|
1158
|
-
attributes: Attributes.protected()
|
|
1159
|
-
});
|
|
1160
|
-
return Participation.fromDto(dto);
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
// src/shared/core/checkout/coin-list/token-sale-namespace.ts
|
|
1164
|
-
var CoinListTokenSaleNamespaceImpl = class {
|
|
1165
|
-
constructor(ctx) {
|
|
1166
|
-
this.ctx = ctx;
|
|
1167
|
-
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
1168
|
-
}
|
|
1169
|
-
async list(offerId) {
|
|
1170
|
-
return this.log.wrap("list", offerId, async () => {
|
|
1171
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1172
|
-
return fetchParticipations(this.ctx.api, offerId);
|
|
1173
|
-
});
|
|
1174
|
-
}
|
|
1175
|
-
async listPage(params) {
|
|
1176
|
-
return this.log.wrap("listPage", params, async () => {
|
|
1177
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1178
|
-
return fetchParticipationsPage(this.ctx.api, params);
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
async get(id) {
|
|
1182
|
-
return this.log.wrap("get", id, async () => {
|
|
1183
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1184
|
-
return fetchParticipation(this.ctx.api, id);
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
async createParticipation(params) {
|
|
1188
|
-
return this.log.wrap("createParticipation", params, async () => {
|
|
1189
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1190
|
-
return createParticipation(this.ctx.api, params);
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
};
|
|
1030
|
+
try {
|
|
1031
|
+
const raw = parseUnits(trimmed, decimals);
|
|
1032
|
+
if (raw > MAX_UINT_256) {
|
|
1033
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
1034
|
+
}
|
|
1035
|
+
return {
|
|
1036
|
+
valid: true,
|
|
1037
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
1038
|
+
};
|
|
1039
|
+
} catch {
|
|
1040
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1194
1043
|
|
|
1195
|
-
// src/
|
|
1044
|
+
// src/universal/types/trading.ts
|
|
1196
1045
|
var Ticker = (value) => value;
|
|
1197
1046
|
|
|
1198
|
-
// src/
|
|
1047
|
+
// src/universal/types/providers/ondo/ondo.ts
|
|
1199
1048
|
var OndoTradingStatus = {
|
|
1200
1049
|
fromDto: (dto) => {
|
|
1201
1050
|
if (!dto.tradable) return { type: "not-tradable", side: dto.side };
|
|
@@ -1361,7 +1210,7 @@ function parseExpiresAt(value) {
|
|
|
1361
1210
|
return date;
|
|
1362
1211
|
}
|
|
1363
1212
|
|
|
1364
|
-
// src/
|
|
1213
|
+
// src/universal/api/frontline/providers/ondo/ondo.ts
|
|
1365
1214
|
async function getOndoTradingStatus(api, params) {
|
|
1366
1215
|
const dto = await api.send({
|
|
1367
1216
|
method: "GET",
|
|
@@ -1456,7 +1305,7 @@ function sizeParam(params) {
|
|
|
1456
1305
|
return { notional_value: notionalValue };
|
|
1457
1306
|
}
|
|
1458
1307
|
|
|
1459
|
-
// src/
|
|
1308
|
+
// src/universal/core/checkout/ondo/ondo-namespace.ts
|
|
1460
1309
|
var OndoNamespaceImpl = class {
|
|
1461
1310
|
constructor(ctx) {
|
|
1462
1311
|
this.ctx = ctx;
|
|
@@ -1488,7 +1337,164 @@ var OndoNamespaceImpl = class {
|
|
|
1488
1337
|
}
|
|
1489
1338
|
};
|
|
1490
1339
|
|
|
1491
|
-
// src/
|
|
1340
|
+
// src/universal/types/providers/superstate/swap.ts
|
|
1341
|
+
var SwapAuthorization = {
|
|
1342
|
+
fromDto: (dto) => ({
|
|
1343
|
+
authorized: dto.authorized
|
|
1344
|
+
})
|
|
1345
|
+
};
|
|
1346
|
+
var SwapPreview = {
|
|
1347
|
+
fromDto: (dto) => ({
|
|
1348
|
+
inputAmount: parseUint256(
|
|
1349
|
+
BigInt(dto.pay_input_amount),
|
|
1350
|
+
"SwapPreview.pay_input_amount"
|
|
1351
|
+
),
|
|
1352
|
+
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
1353
|
+
outputAmount: parseUint256(
|
|
1354
|
+
BigInt(dto.receive_output_amount),
|
|
1355
|
+
"SwapPreview.receive_output_amount"
|
|
1356
|
+
)
|
|
1357
|
+
})
|
|
1358
|
+
};
|
|
1359
|
+
var SwapStatus = {
|
|
1360
|
+
fromDto: (dto) => ({
|
|
1361
|
+
stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
|
|
1362
|
+
swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
|
|
1363
|
+
})
|
|
1364
|
+
};
|
|
1365
|
+
var TokenAllowance = {
|
|
1366
|
+
fromDto: (dto) => ({
|
|
1367
|
+
allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
|
|
1368
|
+
})
|
|
1369
|
+
};
|
|
1370
|
+
var TokenBalance = {
|
|
1371
|
+
fromDto: (dto) => ({
|
|
1372
|
+
balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
|
|
1373
|
+
})
|
|
1374
|
+
};
|
|
1375
|
+
var AllowWalletResponse = {
|
|
1376
|
+
fromDto: (dto) => {
|
|
1377
|
+
switch (dto.action) {
|
|
1378
|
+
case "broadcast_transaction":
|
|
1379
|
+
return {
|
|
1380
|
+
action: "broadcast_transaction",
|
|
1381
|
+
to: EvmContractAddress(dto.to),
|
|
1382
|
+
data: HexEncodedTransactionData(dto.data)
|
|
1383
|
+
};
|
|
1384
|
+
case "none":
|
|
1385
|
+
return {
|
|
1386
|
+
action: "none",
|
|
1387
|
+
alreadyAllowed: dto.already_allowed
|
|
1388
|
+
};
|
|
1389
|
+
default: {
|
|
1390
|
+
const _exhaustive = dto;
|
|
1391
|
+
return _exhaustive;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
|
|
1397
|
+
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
1398
|
+
async function getSwapAuthorization(api, params) {
|
|
1399
|
+
const dto = await api.send({
|
|
1400
|
+
method: "GET",
|
|
1401
|
+
url: "/v1/wallet/authorized",
|
|
1402
|
+
queryParams: {
|
|
1403
|
+
chain: params.chain,
|
|
1404
|
+
contract_address: params.contractAddress,
|
|
1405
|
+
wallet_address: params.walletAddress
|
|
1406
|
+
},
|
|
1407
|
+
attributes: Attributes.protected()
|
|
1408
|
+
});
|
|
1409
|
+
return SwapAuthorization.fromDto(dto);
|
|
1410
|
+
}
|
|
1411
|
+
async function getSwapOutputToken(api, params) {
|
|
1412
|
+
const dto = await api.send({
|
|
1413
|
+
method: "GET",
|
|
1414
|
+
url: "/v1/swap/output-token",
|
|
1415
|
+
queryParams: {
|
|
1416
|
+
chain: params.chain,
|
|
1417
|
+
contract_address: params.contractAddress
|
|
1418
|
+
},
|
|
1419
|
+
attributes: Attributes.protected()
|
|
1420
|
+
});
|
|
1421
|
+
return toErc20Asset(dto);
|
|
1422
|
+
}
|
|
1423
|
+
async function getSwapPreview(api, params) {
|
|
1424
|
+
const dto = await api.send({
|
|
1425
|
+
method: "GET",
|
|
1426
|
+
url: "/v1/swap/preview",
|
|
1427
|
+
queryParams: {
|
|
1428
|
+
chain: params.chain,
|
|
1429
|
+
contract_address: params.contractAddress,
|
|
1430
|
+
input_token: params.inputToken,
|
|
1431
|
+
amount: params.amount.toString()
|
|
1432
|
+
},
|
|
1433
|
+
attributes: Attributes.protected()
|
|
1434
|
+
});
|
|
1435
|
+
return SwapPreview.fromDto(dto);
|
|
1436
|
+
}
|
|
1437
|
+
async function getSwapStatus(api, params) {
|
|
1438
|
+
const dto = await api.send({
|
|
1439
|
+
method: "GET",
|
|
1440
|
+
url: "/v1/swap/status",
|
|
1441
|
+
queryParams: {
|
|
1442
|
+
chain: params.chain,
|
|
1443
|
+
contract_address: params.contractAddress
|
|
1444
|
+
},
|
|
1445
|
+
attributes: Attributes.protected()
|
|
1446
|
+
});
|
|
1447
|
+
return SwapStatus.fromDto(dto);
|
|
1448
|
+
}
|
|
1449
|
+
async function getTokenAllowance(api, params) {
|
|
1450
|
+
const dto = await api.send({
|
|
1451
|
+
method: "GET",
|
|
1452
|
+
url: "/v1/token/allowance",
|
|
1453
|
+
queryParams: {
|
|
1454
|
+
chain: params.chain,
|
|
1455
|
+
token_address: params.tokenAddress,
|
|
1456
|
+
owner: params.owner,
|
|
1457
|
+
spender: params.spender
|
|
1458
|
+
},
|
|
1459
|
+
attributes: Attributes.protected()
|
|
1460
|
+
});
|
|
1461
|
+
return TokenAllowance.fromDto(dto);
|
|
1462
|
+
}
|
|
1463
|
+
async function getTokenBalance(api, params) {
|
|
1464
|
+
const dto = await api.send({
|
|
1465
|
+
method: "GET",
|
|
1466
|
+
url: "/v1/token/balance",
|
|
1467
|
+
queryParams: {
|
|
1468
|
+
chain: params.chain,
|
|
1469
|
+
token_address: params.tokenAddress,
|
|
1470
|
+
owner: params.owner
|
|
1471
|
+
},
|
|
1472
|
+
attributes: Attributes.protected()
|
|
1473
|
+
});
|
|
1474
|
+
return TokenBalance.fromDto(dto);
|
|
1475
|
+
}
|
|
1476
|
+
async function allowWallet(api, params) {
|
|
1477
|
+
const dto = await api.send({
|
|
1478
|
+
method: "POST",
|
|
1479
|
+
url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
|
|
1480
|
+
body: {
|
|
1481
|
+
wallet_address: params.walletAddress,
|
|
1482
|
+
chain: params.chain,
|
|
1483
|
+
signature: params.signature
|
|
1484
|
+
},
|
|
1485
|
+
attributes: Attributes.protected()
|
|
1486
|
+
});
|
|
1487
|
+
return AllowWalletResponse.fromDto(dto);
|
|
1488
|
+
}
|
|
1489
|
+
function toErc20Asset(dto) {
|
|
1490
|
+
return {
|
|
1491
|
+
name: dto.name,
|
|
1492
|
+
symbol: AssetSymbol(dto.symbol),
|
|
1493
|
+
decimals: AssetDecimals(dto.decimals)
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
// src/universal/core/checkout/superstate/swap-namespace.ts
|
|
1492
1498
|
var SuperstateSwapNamespaceImpl = class {
|
|
1493
1499
|
constructor(ctx) {
|
|
1494
1500
|
this.ctx = ctx;
|
|
@@ -1526,7 +1532,7 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
1526
1532
|
}
|
|
1527
1533
|
};
|
|
1528
1534
|
|
|
1529
|
-
// src/
|
|
1535
|
+
// src/universal/types/document-submission.ts
|
|
1530
1536
|
var DocumentSubmission = {
|
|
1531
1537
|
fromDto: (dto) => ({
|
|
1532
1538
|
status: dto.status,
|
|
@@ -1534,14 +1540,14 @@ var DocumentSubmission = {
|
|
|
1534
1540
|
})
|
|
1535
1541
|
};
|
|
1536
1542
|
|
|
1537
|
-
// src/
|
|
1543
|
+
// src/universal/types/kyc.ts
|
|
1538
1544
|
var KycToken = {
|
|
1539
1545
|
fromDto: (dto) => ({
|
|
1540
1546
|
token: dto.token
|
|
1541
1547
|
})
|
|
1542
1548
|
};
|
|
1543
1549
|
|
|
1544
|
-
// src/
|
|
1550
|
+
// src/universal/types/pii.ts
|
|
1545
1551
|
var Iso2CountryCode = (value) => value;
|
|
1546
1552
|
var PiiJurisdiction = {
|
|
1547
1553
|
fromDto: (dto) => ({
|
|
@@ -1569,7 +1575,7 @@ var Pii = {
|
|
|
1569
1575
|
})
|
|
1570
1576
|
};
|
|
1571
1577
|
|
|
1572
|
-
// src/
|
|
1578
|
+
// src/universal/types/requirement.ts
|
|
1573
1579
|
var RequirementId = (value) => value;
|
|
1574
1580
|
var Requirement = {
|
|
1575
1581
|
fromDto: (dto) => ({
|
|
@@ -1590,7 +1596,7 @@ var RequirementStatusInfo = {
|
|
|
1590
1596
|
)
|
|
1591
1597
|
};
|
|
1592
1598
|
|
|
1593
|
-
// src/
|
|
1599
|
+
// src/universal/api/frontline/documents.ts
|
|
1594
1600
|
async function submitDocument(api, documentType, fields) {
|
|
1595
1601
|
const dto = await api.send({
|
|
1596
1602
|
method: "POST",
|
|
@@ -1601,7 +1607,7 @@ async function submitDocument(api, documentType, fields) {
|
|
|
1601
1607
|
return DocumentSubmission.fromDto(dto);
|
|
1602
1608
|
}
|
|
1603
1609
|
|
|
1604
|
-
// src/
|
|
1610
|
+
// src/universal/api/frontline/kyc.ts
|
|
1605
1611
|
async function createKycToken(api, levelName, reset) {
|
|
1606
1612
|
const dto = await api.send({
|
|
1607
1613
|
method: "POST",
|
|
@@ -1615,7 +1621,7 @@ async function createKycToken(api, levelName, reset) {
|
|
|
1615
1621
|
return KycToken.fromDto(dto);
|
|
1616
1622
|
}
|
|
1617
1623
|
|
|
1618
|
-
// src/
|
|
1624
|
+
// src/universal/api/frontline/pii.ts
|
|
1619
1625
|
async function fetchPii(api) {
|
|
1620
1626
|
const dto = await api.send({
|
|
1621
1627
|
method: "GET",
|
|
@@ -1625,7 +1631,7 @@ async function fetchPii(api) {
|
|
|
1625
1631
|
return Pii.fromDto(dto);
|
|
1626
1632
|
}
|
|
1627
1633
|
|
|
1628
|
-
// src/
|
|
1634
|
+
// src/universal/api/frontline/requirements.ts
|
|
1629
1635
|
async function fetchOfferRequirements(api, offerId, clientCreds) {
|
|
1630
1636
|
const response = await api.send({
|
|
1631
1637
|
method: "GET",
|
|
@@ -1651,7 +1657,7 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
1651
1657
|
return RequirementStatusInfo.fromStatusesDto(response);
|
|
1652
1658
|
}
|
|
1653
1659
|
|
|
1654
|
-
// src/
|
|
1660
|
+
// src/universal/core/requirements/requirements-namespace.ts
|
|
1655
1661
|
var RequirementsNamespaceImpl = class {
|
|
1656
1662
|
constructor(ctx) {
|
|
1657
1663
|
this.ctx = ctx;
|
|
@@ -1701,7 +1707,27 @@ var RequirementsNamespaceImpl = class {
|
|
|
1701
1707
|
}
|
|
1702
1708
|
};
|
|
1703
1709
|
|
|
1704
|
-
// src/shared/
|
|
1710
|
+
// src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
|
|
1711
|
+
var Erc20NamespaceImpl = class {
|
|
1712
|
+
constructor(ctx) {
|
|
1713
|
+
this.ctx = ctx;
|
|
1714
|
+
this.log = internalLogger(ctx.logger, "ERC20");
|
|
1715
|
+
}
|
|
1716
|
+
async getAllowance(params) {
|
|
1717
|
+
return this.log.wrap("getAllowance", params, async () => {
|
|
1718
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1719
|
+
return getTokenAllowance(this.ctx.api, params);
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
async getBalance(params) {
|
|
1723
|
+
return this.log.wrap("getBalance", params, async () => {
|
|
1724
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1725
|
+
return getTokenBalance(this.ctx.api, params);
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
// src/universal/types/token-metadata.ts
|
|
1705
1731
|
var TokenLogoUrl = (value) => value;
|
|
1706
1732
|
var TokenLogo = {
|
|
1707
1733
|
/** `baseUrl` is the registry origin; registry URLs are root-relative. */
|
|
@@ -1784,10 +1810,10 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
|
|
|
1784
1810
|
url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
|
|
1785
1811
|
);
|
|
1786
1812
|
|
|
1787
|
-
// src/
|
|
1813
|
+
// src/universal/api/nabu/tokens.ts
|
|
1788
1814
|
import { getAddress } from "viem";
|
|
1789
1815
|
|
|
1790
|
-
// src/
|
|
1816
|
+
// src/universal/api/frontline/config.ts
|
|
1791
1817
|
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
1792
1818
|
var HEADER_API_VERSION = "X-API-Version";
|
|
1793
1819
|
var HEADER_USER_AGENT = "User-Agent";
|
|
@@ -1800,7 +1826,7 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
|
1800
1826
|
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
1801
1827
|
var WALLET_PATH = "/wallet";
|
|
1802
1828
|
|
|
1803
|
-
// src/
|
|
1829
|
+
// src/universal/api/http-client.ts
|
|
1804
1830
|
var HttpClient = class {
|
|
1805
1831
|
constructor(config, middleware = {}, logger = null, options = {}) {
|
|
1806
1832
|
this.config = config;
|
|
@@ -1956,7 +1982,7 @@ function describeRequestUnredacted(request) {
|
|
|
1956
1982
|
};
|
|
1957
1983
|
}
|
|
1958
1984
|
|
|
1959
|
-
// src/
|
|
1985
|
+
// src/universal/api/nabu/tokens.ts
|
|
1960
1986
|
function createNabuApiClient(baseUrl, logger = null) {
|
|
1961
1987
|
return new HttpClient({ baseUrl }, {}, logger);
|
|
1962
1988
|
}
|
|
@@ -2047,10 +2073,10 @@ function checksummed(address) {
|
|
|
2047
2073
|
}
|
|
2048
2074
|
}
|
|
2049
2075
|
|
|
2050
|
-
// src/
|
|
2076
|
+
// src/universal/core/tokens/tokens-namespace.ts
|
|
2051
2077
|
var TokensNamespaceImpl = class {
|
|
2052
2078
|
/**
|
|
2053
|
-
* Takes the registry origin rather than a `
|
|
2079
|
+
* Takes the registry origin rather than a `UniversalNamespaceContext`: the
|
|
2054
2080
|
* registry is unauthenticated and on its own host, so the frontline sender
|
|
2055
2081
|
* and the auth check would both be dead weight here.
|
|
2056
2082
|
*/
|
|
@@ -2074,7 +2100,7 @@ var TokensNamespaceImpl = class {
|
|
|
2074
2100
|
}
|
|
2075
2101
|
};
|
|
2076
2102
|
|
|
2077
|
-
// src/
|
|
2103
|
+
// src/universal/types/offer-option-address.ts
|
|
2078
2104
|
var OfferOptionAddressId = (value) => value;
|
|
2079
2105
|
var OfferOptionAddress = {
|
|
2080
2106
|
/** Maps the API DTO into the SDK offer-option-address domain model. */
|
|
@@ -2096,7 +2122,7 @@ var ConnectExternalWalletParams = {
|
|
|
2096
2122
|
})
|
|
2097
2123
|
};
|
|
2098
2124
|
|
|
2099
|
-
// src/
|
|
2125
|
+
// src/universal/types/wallet-ownership-challenge.ts
|
|
2100
2126
|
var WalletOwnershipChallenge = {
|
|
2101
2127
|
/** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
|
|
2102
2128
|
fromDto: (dto) => ({
|
|
@@ -2135,7 +2161,7 @@ var CreateWalletOwnershipChallengeParams = {
|
|
|
2135
2161
|
}
|
|
2136
2162
|
};
|
|
2137
2163
|
|
|
2138
|
-
// src/
|
|
2164
|
+
// src/universal/api/frontline/wallet-connect.ts
|
|
2139
2165
|
async function createWalletOwnershipChallenge(api, params) {
|
|
2140
2166
|
const dto = await api.send({
|
|
2141
2167
|
method: "POST",
|
|
@@ -2172,7 +2198,7 @@ async function removeOptionAddress(api, offerId, addressId) {
|
|
|
2172
2198
|
return OfferOptionAddress.fromDto(dto);
|
|
2173
2199
|
}
|
|
2174
2200
|
|
|
2175
|
-
// src/
|
|
2201
|
+
// src/universal/core/wallets/wallets-namespace.ts
|
|
2176
2202
|
var WalletsNamespaceImpl = class {
|
|
2177
2203
|
constructor(ctx) {
|
|
2178
2204
|
this.ctx = ctx;
|
|
@@ -2215,7 +2241,7 @@ var WalletsNamespaceImpl = class {
|
|
|
2215
2241
|
}
|
|
2216
2242
|
};
|
|
2217
2243
|
|
|
2218
|
-
// src/
|
|
2244
|
+
// src/universal/types/oauth-session.ts
|
|
2219
2245
|
var ClientCredentialsOAuth = (value) => value;
|
|
2220
2246
|
var OAuthRefreshToken = (value) => value;
|
|
2221
2247
|
var OAuthSession = {
|
|
@@ -2231,7 +2257,7 @@ var OAuthSession = {
|
|
|
2231
2257
|
}
|
|
2232
2258
|
};
|
|
2233
2259
|
|
|
2234
|
-
// src/
|
|
2260
|
+
// src/universal/api/frontline/offers.ts
|
|
2235
2261
|
async function fetchOffers(api, clientCreds) {
|
|
2236
2262
|
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
2237
2263
|
}
|
|
@@ -2288,10 +2314,17 @@ export {
|
|
|
2288
2314
|
internalLogger,
|
|
2289
2315
|
HttpClient,
|
|
2290
2316
|
fetchAllPages,
|
|
2317
|
+
Cursor,
|
|
2318
|
+
PaginatedResponse,
|
|
2319
|
+
PaginationParams,
|
|
2320
|
+
AssetId,
|
|
2321
|
+
AssetCode,
|
|
2322
|
+
Asset,
|
|
2291
2323
|
ETHEREUM_CHAINS,
|
|
2292
2324
|
EthereumChain,
|
|
2293
2325
|
SOLANA_CHAINS,
|
|
2294
2326
|
SolanaChain,
|
|
2327
|
+
isChain,
|
|
2295
2328
|
Chain,
|
|
2296
2329
|
EvmWalletAddress,
|
|
2297
2330
|
EvmContractAddress,
|
|
@@ -2308,46 +2341,13 @@ export {
|
|
|
2308
2341
|
StablecoinSymbol,
|
|
2309
2342
|
KnownAssetSymbol,
|
|
2310
2343
|
Bps,
|
|
2311
|
-
FormattedAmountUi,
|
|
2312
|
-
FormattedPercentUi,
|
|
2313
|
-
TxExplorerUrl,
|
|
2314
|
-
ShortenedWalletAddress,
|
|
2315
|
-
FormattedAmountAssetUi,
|
|
2316
|
-
AssetIconUrl,
|
|
2317
|
-
getChainId,
|
|
2318
|
-
chainFromId,
|
|
2319
|
-
getNetworkName,
|
|
2320
|
-
txExplorerUrl,
|
|
2321
|
-
SwapAuthorization,
|
|
2322
|
-
SwapPreview,
|
|
2323
|
-
SwapStatus,
|
|
2324
|
-
TokenAllowance,
|
|
2325
|
-
TokenBalance,
|
|
2326
|
-
AllowWalletResponse,
|
|
2327
|
-
Erc20NamespaceImpl,
|
|
2328
|
-
shortenAddress,
|
|
2329
|
-
formatAmount,
|
|
2330
|
-
formatRawAmount,
|
|
2331
|
-
formatCompactAmount,
|
|
2332
|
-
formatBpsAsPercent,
|
|
2333
|
-
usdAmount,
|
|
2334
|
-
assetAmount,
|
|
2335
|
-
NA_AMOUNT_ASSET_UI,
|
|
2336
|
-
formattedUsdPrice,
|
|
2337
|
-
blockchainAmountFromRawOrThrow,
|
|
2338
|
-
parseBlockchainAmount,
|
|
2339
|
-
Cursor,
|
|
2340
|
-
PaginatedResponse,
|
|
2341
|
-
PaginationParams,
|
|
2342
|
-
AssetId,
|
|
2343
|
-
AssetCode,
|
|
2344
|
-
Asset,
|
|
2345
2344
|
OfferId,
|
|
2346
2345
|
OfferSlug,
|
|
2347
2346
|
Offer,
|
|
2348
2347
|
OfferToken,
|
|
2349
2348
|
OfferOptionId,
|
|
2350
2349
|
OfferOptionSlug,
|
|
2350
|
+
OfferSwapContract,
|
|
2351
2351
|
OfferDetail,
|
|
2352
2352
|
OfferOption,
|
|
2353
2353
|
FaqItem,
|
|
@@ -2361,12 +2361,39 @@ export {
|
|
|
2361
2361
|
Participation,
|
|
2362
2362
|
CreateParticipationParams,
|
|
2363
2363
|
CoinListTokenSaleNamespaceImpl,
|
|
2364
|
+
FormattedAmountUi,
|
|
2365
|
+
FormattedPercentUi,
|
|
2366
|
+
TxExplorerUrl,
|
|
2367
|
+
ShortenedWalletAddress,
|
|
2368
|
+
FormattedAmountAssetUi,
|
|
2369
|
+
AssetIconUrl,
|
|
2370
|
+
shortenAddress,
|
|
2371
|
+
formatAmount,
|
|
2372
|
+
formatRawAmount,
|
|
2373
|
+
formatCompactAmount,
|
|
2374
|
+
formatBpsAsPercent,
|
|
2375
|
+
usdAmount,
|
|
2376
|
+
assetAmount,
|
|
2377
|
+
NA_AMOUNT_ASSET_UI,
|
|
2378
|
+
formattedUsdPrice,
|
|
2379
|
+
getChainId,
|
|
2380
|
+
chainFromId,
|
|
2381
|
+
getNetworkName,
|
|
2382
|
+
txExplorerUrl,
|
|
2383
|
+
blockchainAmountFromRawOrThrow,
|
|
2384
|
+
parseBlockchainAmount,
|
|
2364
2385
|
Ticker,
|
|
2365
2386
|
OndoTradingStatus,
|
|
2366
2387
|
OndoQuote,
|
|
2367
2388
|
OndoBuyTransaction,
|
|
2368
2389
|
OndoSellTransaction,
|
|
2369
2390
|
OndoNamespaceImpl,
|
|
2391
|
+
SwapAuthorization,
|
|
2392
|
+
SwapPreview,
|
|
2393
|
+
SwapStatus,
|
|
2394
|
+
TokenAllowance,
|
|
2395
|
+
TokenBalance,
|
|
2396
|
+
AllowWalletResponse,
|
|
2370
2397
|
SuperstateSwapNamespaceImpl,
|
|
2371
2398
|
fetchOffers,
|
|
2372
2399
|
fetchOffersPage,
|
|
@@ -2382,6 +2409,7 @@ export {
|
|
|
2382
2409
|
RequirementStatusInfo,
|
|
2383
2410
|
fetchOfferRequirements,
|
|
2384
2411
|
RequirementsNamespaceImpl,
|
|
2412
|
+
Erc20NamespaceImpl,
|
|
2385
2413
|
TokenLogoUrl,
|
|
2386
2414
|
TokenLogo,
|
|
2387
2415
|
TokenMetadata,
|
|
@@ -2396,4 +2424,4 @@ export {
|
|
|
2396
2424
|
OAuthRefreshToken,
|
|
2397
2425
|
OAuthSession
|
|
2398
2426
|
};
|
|
2399
|
-
//# sourceMappingURL=chunk-
|
|
2427
|
+
//# sourceMappingURL=chunk-6CQHDASY.js.map
|