@coinlist-co/react 0.12.1-rc.a230abc → 0.12.1-rc.c2b6ba5
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-GFLU5OMP.js → chunk-6CQHDASY.js} +643 -643
- package/dist/chunk-6CQHDASY.js.map +1 -0
- package/dist/{chunk-HLL7IBIS.js → chunk-F6WGUKZC.js} +9 -9
- package/dist/chunk-F6WGUKZC.js.map +1 -0
- package/dist/{chunk-RPE7XIBV.js → chunk-ZFBEI3BW.js} +126 -126
- package/dist/chunk-ZFBEI3BW.js.map +1 -0
- package/dist/client/index.cjs +2032 -2030
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +149 -149
- package/dist/client/index.d.ts +149 -149
- package/dist/client/index.js +481 -481
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-CAfs2Eww.d.cts → collections-DOm9VKVm.d.cts} +1 -1
- package/dist/{collections-DZZFrizd.d.ts → collections-aCv-Wr2a.d.ts} +1 -1
- package/dist/{config-D19ktBr0.d.cts → config-DIaFzrMW.d.cts} +13 -13
- package/dist/{config-D19ktBr0.d.ts → config-DIaFzrMW.d.ts} +13 -13
- package/dist/server/index.cjs +232 -232
- 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 +850 -848
- package/dist/universal/index.cjs.map +1 -0
- package/dist/{shared → universal}/index.d.cts +557 -557
- package/dist/{shared → universal}/index.d.ts +557 -557
- package/dist/{shared → universal}/index.js +2 -2
- package/package.json +6 -5
- package/dist/chunk-GFLU5OMP.js.map +0 -1
- package/dist/chunk-HLL7IBIS.js.map +0 -1
- package/dist/chunk-RPE7XIBV.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,
|
|
@@ -322,226 +359,295 @@ var StablecoinSymbol = (value) => value;
|
|
|
322
359
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
323
360
|
var Bps = (value) => value;
|
|
324
361
|
|
|
325
|
-
// src/
|
|
326
|
-
var
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
+
}
|
|
339
384
|
};
|
|
340
|
-
|
|
341
|
-
|
|
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);
|
|
342
413
|
}
|
|
343
|
-
function
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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]);
|
|
348
419
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
case "ethereum_mainnet":
|
|
354
|
-
return "Ethereum";
|
|
355
|
-
case "ethereum_sepolia":
|
|
356
|
-
return "Ethereum Sepolia";
|
|
357
|
-
case "base_mainnet":
|
|
358
|
-
return "Base";
|
|
359
|
-
case "base_sepolia":
|
|
360
|
-
return "Base Sepolia";
|
|
361
|
-
default: {
|
|
362
|
-
const _exhaustive = chain;
|
|
363
|
-
return _exhaustive;
|
|
364
|
-
}
|
|
420
|
+
let base64 = btoa(binary);
|
|
421
|
+
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
422
|
+
if (!padding) {
|
|
423
|
+
base64 = base64.replace(/=+$/, "");
|
|
365
424
|
}
|
|
425
|
+
return base64;
|
|
366
426
|
}
|
|
367
|
-
function
|
|
368
|
-
|
|
427
|
+
function generateSecureRandomBase64Url(byteLength) {
|
|
428
|
+
const bytes = new Uint8Array(byteLength);
|
|
429
|
+
crypto.getRandomValues(bytes);
|
|
430
|
+
const buffer = bytes.buffer;
|
|
431
|
+
return arrayBufferToBase64Url(buffer, false);
|
|
369
432
|
}
|
|
370
|
-
function
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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;
|
|
384
452
|
}
|
|
385
453
|
}
|
|
386
454
|
|
|
387
|
-
// src/
|
|
388
|
-
var
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
})
|
|
392
|
-
};
|
|
393
|
-
var SwapPreview = {
|
|
394
|
-
fromDto: (dto) => ({
|
|
395
|
-
inputAmount: parseUint256(
|
|
396
|
-
BigInt(dto.pay_input_amount),
|
|
397
|
-
"SwapPreview.pay_input_amount"
|
|
398
|
-
),
|
|
399
|
-
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
400
|
-
outputAmount: parseUint256(
|
|
401
|
-
BigInt(dto.receive_output_amount),
|
|
402
|
-
"SwapPreview.receive_output_amount"
|
|
403
|
-
)
|
|
404
|
-
})
|
|
405
|
-
};
|
|
406
|
-
var SwapStatus = {
|
|
407
|
-
fromDto: (dto) => ({
|
|
408
|
-
stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
|
|
409
|
-
swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
|
|
410
|
-
})
|
|
411
|
-
};
|
|
412
|
-
var TokenAllowance = {
|
|
413
|
-
fromDto: (dto) => ({
|
|
414
|
-
allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
|
|
415
|
-
})
|
|
416
|
-
};
|
|
417
|
-
var TokenBalance = {
|
|
455
|
+
// src/universal/types/offer-detail.ts
|
|
456
|
+
var OfferOptionId = (value) => value;
|
|
457
|
+
var OfferOptionSlug = (value) => value;
|
|
458
|
+
var OfferSwapContract = {
|
|
418
459
|
fromDto: (dto) => ({
|
|
419
|
-
|
|
460
|
+
chain: Chain(dto.chain),
|
|
461
|
+
address: EvmContractAddress(dto.address)
|
|
420
462
|
})
|
|
421
463
|
};
|
|
422
|
-
var
|
|
464
|
+
var OfferDetail = {
|
|
423
465
|
fromDto: (dto) => {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
to: EvmContractAddress(dto.to),
|
|
429
|
-
data: HexEncodedTransactionData(dto.data)
|
|
430
|
-
};
|
|
431
|
-
case "none":
|
|
432
|
-
return {
|
|
433
|
-
action: "none",
|
|
434
|
-
alreadyAllowed: dto.already_allowed
|
|
435
|
-
};
|
|
436
|
-
default: {
|
|
437
|
-
const _exhaustive = dto;
|
|
438
|
-
return _exhaustive;
|
|
439
|
-
}
|
|
466
|
+
if (!Array.isArray(dto.funding_assets)) {
|
|
467
|
+
throw new ValidationError(
|
|
468
|
+
`OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
|
|
469
|
+
);
|
|
440
470
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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 = {
|
|
532
|
+
fromDto: (dto) => ({
|
|
533
|
+
id: OfferOptionId(dto.id),
|
|
534
|
+
slug: OfferOptionSlug(dto.slug),
|
|
535
|
+
bidIncrement: dto.bid_increment,
|
|
536
|
+
floorPriceUsd: dto.floor_price_usd,
|
|
537
|
+
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
538
|
+
priceUsd: dto.price_usd,
|
|
539
|
+
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
540
|
+
totalTokenSupply: dto.total_token_supply
|
|
541
|
+
})
|
|
542
|
+
};
|
|
543
|
+
var FaqItem = {
|
|
544
|
+
fromDto: (dto) => ({
|
|
545
|
+
question: notBlankStringOrNull(dto.question),
|
|
546
|
+
answer: notBlankStringOrNull(dto.answer)
|
|
547
|
+
})
|
|
548
|
+
};
|
|
549
|
+
var Link = {
|
|
550
|
+
fromDto: (dto) => ({
|
|
551
|
+
label: notBlankStringOrNull(dto.label),
|
|
552
|
+
url: notBlankStringOrNull(dto.url)
|
|
553
|
+
})
|
|
554
|
+
};
|
|
555
|
+
var TermItem = {
|
|
556
|
+
fromDto: (dto) => ({
|
|
557
|
+
key: notBlankStringOrNull(dto.key),
|
|
558
|
+
value: notBlankStringOrNull(dto.value)
|
|
559
|
+
})
|
|
560
|
+
};
|
|
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;
|
|
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
|
+
};
|
|
601
|
+
}
|
|
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
|
+
};
|
|
615
|
+
|
|
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
|
+
);
|
|
495
622
|
}
|
|
496
|
-
async function
|
|
497
|
-
const
|
|
623
|
+
async function fetchParticipationsPage(api, params) {
|
|
624
|
+
const pageDto = await api.send({
|
|
498
625
|
method: "GET",
|
|
499
|
-
url: "/v1/
|
|
500
|
-
queryParams:
|
|
501
|
-
chain: params.chain,
|
|
502
|
-
token_address: params.tokenAddress,
|
|
503
|
-
owner: params.owner,
|
|
504
|
-
spender: params.spender
|
|
505
|
-
},
|
|
626
|
+
url: "/v1/participations",
|
|
627
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
506
628
|
attributes: Attributes.protected()
|
|
507
629
|
});
|
|
508
|
-
return
|
|
630
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
509
631
|
}
|
|
510
|
-
async function
|
|
632
|
+
async function fetchParticipation(api, id) {
|
|
511
633
|
const dto = await api.send({
|
|
512
634
|
method: "GET",
|
|
513
|
-
url:
|
|
514
|
-
queryParams: {
|
|
515
|
-
chain: params.chain,
|
|
516
|
-
token_address: params.tokenAddress,
|
|
517
|
-
owner: params.owner
|
|
518
|
-
},
|
|
635
|
+
url: `/v1/participations/${id}`,
|
|
519
636
|
attributes: Attributes.protected()
|
|
520
637
|
});
|
|
521
|
-
return
|
|
638
|
+
return Participation.fromDto(dto);
|
|
522
639
|
}
|
|
523
|
-
async function
|
|
640
|
+
async function createParticipation(api, params) {
|
|
524
641
|
const dto = await api.send({
|
|
525
642
|
method: "POST",
|
|
526
|
-
url:
|
|
527
|
-
body:
|
|
528
|
-
wallet_address: params.walletAddress,
|
|
529
|
-
chain: params.chain,
|
|
530
|
-
signature: params.signature
|
|
531
|
-
},
|
|
643
|
+
url: "/v1/participations",
|
|
644
|
+
body: CreateParticipationParams.toDto(params),
|
|
532
645
|
attributes: Attributes.protected()
|
|
533
646
|
});
|
|
534
|
-
return
|
|
535
|
-
}
|
|
536
|
-
function toErc20Asset(dto) {
|
|
537
|
-
return {
|
|
538
|
-
name: dto.name,
|
|
539
|
-
symbol: AssetSymbol(dto.symbol),
|
|
540
|
-
decimals: AssetDecimals(dto.decimals)
|
|
541
|
-
};
|
|
647
|
+
return Participation.fromDto(dto);
|
|
542
648
|
}
|
|
543
649
|
|
|
544
|
-
// src/
|
|
650
|
+
// src/universal/core/shared/observability/log-cause.ts
|
|
545
651
|
function classifyLogCause(error) {
|
|
546
652
|
if (error instanceof HttpError) {
|
|
547
653
|
return httpCause(error);
|
|
@@ -607,7 +713,7 @@ function apiErrorEventId(error) {
|
|
|
607
713
|
return typeof eventId === "string" ? eventId : null;
|
|
608
714
|
}
|
|
609
715
|
|
|
610
|
-
// src/
|
|
716
|
+
// src/universal/core/shared/observability/internal-logger.ts
|
|
611
717
|
function internalLogger(logger, scope) {
|
|
612
718
|
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
613
719
|
}
|
|
@@ -690,27 +796,47 @@ var noopInternalLogger = {
|
|
|
690
796
|
wrap: (_op, _params, run) => run()
|
|
691
797
|
};
|
|
692
798
|
|
|
693
|
-
// src/
|
|
694
|
-
var
|
|
799
|
+
// src/universal/core/checkout/coin-list/token-sale-namespace.ts
|
|
800
|
+
var CoinListTokenSaleNamespaceImpl = class {
|
|
695
801
|
constructor(ctx) {
|
|
696
802
|
this.ctx = ctx;
|
|
697
|
-
this.log = internalLogger(ctx.logger, "
|
|
803
|
+
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
698
804
|
}
|
|
699
|
-
async
|
|
700
|
-
return this.log.wrap("
|
|
805
|
+
async list(offerId) {
|
|
806
|
+
return this.log.wrap("list", offerId, async () => {
|
|
701
807
|
await this.ctx.ensureUserAuthenticated();
|
|
702
|
-
return
|
|
808
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
703
809
|
});
|
|
704
810
|
}
|
|
705
|
-
async
|
|
706
|
-
return this.log.wrap("
|
|
811
|
+
async listPage(params) {
|
|
812
|
+
return this.log.wrap("listPage", params, async () => {
|
|
707
813
|
await this.ctx.ensureUserAuthenticated();
|
|
708
|
-
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);
|
|
709
827
|
});
|
|
710
828
|
}
|
|
711
829
|
};
|
|
712
830
|
|
|
713
|
-
// 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
|
|
714
840
|
import { formatUnits } from "viem";
|
|
715
841
|
function shortenAddress(address) {
|
|
716
842
|
const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
@@ -805,11 +931,65 @@ function formattedUsdPrice(amount, locale) {
|
|
|
805
931
|
);
|
|
806
932
|
}
|
|
807
933
|
|
|
808
|
-
// src/
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
934
|
+
// src/universal/core/shared/blockchain/chain.ts
|
|
935
|
+
var CHAIN_IDS = {
|
|
936
|
+
ethereum_mainnet: 1,
|
|
937
|
+
ethereum_sepolia: 11155111,
|
|
938
|
+
base_mainnet: 8453,
|
|
939
|
+
base_sepolia: 84532
|
|
940
|
+
};
|
|
941
|
+
function getChainId(chain) {
|
|
942
|
+
return CHAIN_IDS[chain];
|
|
943
|
+
}
|
|
944
|
+
function chainFromId(chainId) {
|
|
945
|
+
const chains = Object.keys(CHAIN_IDS);
|
|
946
|
+
const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
|
|
947
|
+
if (!chain) {
|
|
948
|
+
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
949
|
+
}
|
|
950
|
+
return chain;
|
|
951
|
+
}
|
|
952
|
+
function getNetworkName(chain) {
|
|
953
|
+
switch (chain) {
|
|
954
|
+
case "ethereum_mainnet":
|
|
955
|
+
return "Ethereum";
|
|
956
|
+
case "ethereum_sepolia":
|
|
957
|
+
return "Ethereum Sepolia";
|
|
958
|
+
case "base_mainnet":
|
|
959
|
+
return "Base";
|
|
960
|
+
case "base_sepolia":
|
|
961
|
+
return "Base Sepolia";
|
|
962
|
+
default: {
|
|
963
|
+
const _exhaustive = chain;
|
|
964
|
+
return _exhaustive;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
function txExplorerUrl(chain, txHash) {
|
|
969
|
+
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
970
|
+
}
|
|
971
|
+
function explorerBaseUrl(chain) {
|
|
972
|
+
switch (chain) {
|
|
973
|
+
case "ethereum_mainnet":
|
|
974
|
+
return "https://etherscan.io";
|
|
975
|
+
case "ethereum_sepolia":
|
|
976
|
+
return "https://sepolia.etherscan.io";
|
|
977
|
+
case "base_mainnet":
|
|
978
|
+
return "https://basescan.org";
|
|
979
|
+
case "base_sepolia":
|
|
980
|
+
return "https://sepolia-explorer.base.org";
|
|
981
|
+
default: {
|
|
982
|
+
const _exhaustive = chain;
|
|
983
|
+
return _exhaustive;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/universal/core/shared/blockchain/math.ts
|
|
989
|
+
import { parseUnits } from "viem";
|
|
990
|
+
function blockchainAmountFromRawOrThrow({
|
|
991
|
+
label,
|
|
992
|
+
raw,
|
|
813
993
|
decimals
|
|
814
994
|
}) {
|
|
815
995
|
const trimmed = raw.trim();
|
|
@@ -847,381 +1027,24 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
847
1027
|
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
848
1028
|
};
|
|
849
1029
|
}
|
|
850
|
-
try {
|
|
851
|
-
const raw = parseUnits(trimmed, decimals);
|
|
852
|
-
if (raw > MAX_UINT_256) {
|
|
853
|
-
return { valid: false, reason: { type: "overflow" } };
|
|
854
|
-
}
|
|
855
|
-
return {
|
|
856
|
-
valid: true,
|
|
857
|
-
amount: BlockchainAmount({ raw, decimals })
|
|
858
|
-
};
|
|
859
|
-
} catch {
|
|
860
|
-
return { valid: false, reason: { type: "invalid-format" } };
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
// src/shared/types/pagination.ts
|
|
865
|
-
var Cursor = (value) => value;
|
|
866
|
-
var PaginatedResponse = {
|
|
867
|
-
fromDto: (dto, itemMapper) => ({
|
|
868
|
-
data: dto.data.map(itemMapper),
|
|
869
|
-
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
870
|
-
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
871
|
-
})
|
|
872
|
-
};
|
|
873
|
-
var PaginationParams = {
|
|
874
|
-
toQueryParams: (params) => {
|
|
875
|
-
const queryParams = {};
|
|
876
|
-
if (params.after) {
|
|
877
|
-
queryParams.starting_after = params.after;
|
|
878
|
-
}
|
|
879
|
-
if (params.before) {
|
|
880
|
-
queryParams.starting_before = params.before;
|
|
881
|
-
}
|
|
882
|
-
if (params.limit) {
|
|
883
|
-
queryParams.limit = params.limit;
|
|
884
|
-
}
|
|
885
|
-
return queryParams;
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
// src/shared/types/asset.ts
|
|
890
|
-
var AssetId = (value) => value;
|
|
891
|
-
var AssetCode = (value) => value;
|
|
892
|
-
var Asset = {
|
|
893
|
-
fromDto: (dto) => ({
|
|
894
|
-
id: AssetId(dto.id),
|
|
895
|
-
code: AssetCode(dto.code),
|
|
896
|
-
name: dto.name,
|
|
897
|
-
fractionalDigits: dto.fractional_digits
|
|
898
|
-
})
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
// src/shared/types/offer.ts
|
|
902
|
-
var OfferId = (value) => value;
|
|
903
|
-
var OfferSlug = (value) => value;
|
|
904
|
-
var Offer = {
|
|
905
|
-
fromDto: (dto) => {
|
|
906
|
-
if (!Array.isArray(dto.tokens)) {
|
|
907
|
-
throw new ValidationError(
|
|
908
|
-
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
909
|
-
);
|
|
910
|
-
}
|
|
911
|
-
return {
|
|
912
|
-
id: OfferId(dto.id),
|
|
913
|
-
slug: OfferSlug(dto.slug),
|
|
914
|
-
type: dto.type,
|
|
915
|
-
tagline: dto.tagline,
|
|
916
|
-
bannerUrl: dto.banner_url,
|
|
917
|
-
logoUrl: dto.logo_url,
|
|
918
|
-
startsAt: new Date(dto.starts_at),
|
|
919
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
920
|
-
tokens: OfferToken.listFromDto(dto.tokens)
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
var OfferToken = {
|
|
925
|
-
fromDto: (dto) => ({
|
|
926
|
-
role: dto.role,
|
|
927
|
-
chain: Chain(dto.chain),
|
|
928
|
-
address: EvmContractAddress(dto.address)
|
|
929
|
-
}),
|
|
930
|
-
/**
|
|
931
|
-
* Maps an offer's token list, dropping every token on a chain this SDK does
|
|
932
|
-
* not name. Frontline's chain registry runs ahead of {@link Chain}, and a
|
|
933
|
-
* plain `.map` would throw out of `Offer.fromDto` and, through
|
|
934
|
-
* `PaginatedResponse.fromDto`, reject the whole offers page - which is how
|
|
935
|
-
* one Base token blanked production's offers list. Dropping costs that
|
|
936
|
-
* token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
|
|
937
|
-
* so nobody could have looked it up anyway.
|
|
938
|
-
*
|
|
939
|
-
* Same shape as `TokenMetadata.fromRegistryDto`.
|
|
940
|
-
*/
|
|
941
|
-
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
|
|
942
|
-
};
|
|
943
|
-
|
|
944
|
-
// src/shared/core/utils/crypto.ts
|
|
945
|
-
async function sha256(data) {
|
|
946
|
-
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
947
|
-
const buffer = bytes.buffer.slice(
|
|
948
|
-
bytes.byteOffset,
|
|
949
|
-
bytes.byteOffset + bytes.byteLength
|
|
950
|
-
);
|
|
951
|
-
return crypto.subtle.digest("SHA-256", buffer);
|
|
952
|
-
}
|
|
953
|
-
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
954
|
-
const bytes = new Uint8Array(buffer);
|
|
955
|
-
let binary = "";
|
|
956
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
957
|
-
binary += String.fromCharCode(bytes[i]);
|
|
958
|
-
}
|
|
959
|
-
let base64 = btoa(binary);
|
|
960
|
-
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
961
|
-
if (!padding) {
|
|
962
|
-
base64 = base64.replace(/=+$/, "");
|
|
963
|
-
}
|
|
964
|
-
return base64;
|
|
965
|
-
}
|
|
966
|
-
function generateSecureRandomBase64Url(byteLength) {
|
|
967
|
-
const bytes = new Uint8Array(byteLength);
|
|
968
|
-
crypto.getRandomValues(bytes);
|
|
969
|
-
const buffer = bytes.buffer;
|
|
970
|
-
return arrayBufferToBase64Url(buffer, false);
|
|
971
|
-
}
|
|
972
|
-
function getUUIDv4() {
|
|
973
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
974
|
-
return crypto.randomUUID();
|
|
975
|
-
}
|
|
976
|
-
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
977
|
-
const bytes = new Uint8Array(16);
|
|
978
|
-
crypto.getRandomValues(bytes);
|
|
979
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
980
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
981
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
982
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
|
|
983
|
-
}
|
|
984
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
985
|
-
}
|
|
986
|
-
function notBlankStringOrNull(value) {
|
|
987
|
-
if (value?.trim()) {
|
|
988
|
-
return value;
|
|
989
|
-
} else {
|
|
990
|
-
return null;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
// src/shared/types/offer-detail.ts
|
|
995
|
-
var OfferOptionId = (value) => value;
|
|
996
|
-
var OfferOptionSlug = (value) => value;
|
|
997
|
-
var OfferSwapContract = {
|
|
998
|
-
fromDto: (dto) => ({
|
|
999
|
-
chain: Chain(dto.chain),
|
|
1000
|
-
address: EvmContractAddress(dto.address)
|
|
1001
|
-
})
|
|
1002
|
-
};
|
|
1003
|
-
var OfferDetail = {
|
|
1004
|
-
fromDto: (dto) => {
|
|
1005
|
-
if (!Array.isArray(dto.funding_assets)) {
|
|
1006
|
-
throw new ValidationError(
|
|
1007
|
-
`OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
|
|
1008
|
-
);
|
|
1009
|
-
}
|
|
1010
|
-
if (!Array.isArray(dto.options)) {
|
|
1011
|
-
throw new ValidationError(
|
|
1012
|
-
`OfferDetail.options: expected an array, got ${typeof dto.options}`
|
|
1013
|
-
);
|
|
1014
|
-
}
|
|
1015
|
-
if (!Array.isArray(dto.terms)) {
|
|
1016
|
-
throw new ValidationError(
|
|
1017
|
-
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
1018
|
-
);
|
|
1019
|
-
}
|
|
1020
|
-
if (!Array.isArray(dto.links)) {
|
|
1021
|
-
throw new ValidationError(
|
|
1022
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
1023
|
-
);
|
|
1024
|
-
}
|
|
1025
|
-
if (!Array.isArray(dto.faqs)) {
|
|
1026
|
-
throw new ValidationError(
|
|
1027
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
1030
|
-
if (!Array.isArray(dto.milestones)) {
|
|
1031
|
-
throw new ValidationError(
|
|
1032
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
1033
|
-
);
|
|
1034
|
-
}
|
|
1035
|
-
if (!Array.isArray(dto.tokens)) {
|
|
1036
|
-
throw new ValidationError(
|
|
1037
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
1041
|
-
if (!Array.isArray(swapContracts)) {
|
|
1042
|
-
throw new ValidationError(
|
|
1043
|
-
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
1044
|
-
);
|
|
1045
|
-
}
|
|
1046
|
-
return {
|
|
1047
|
-
id: OfferId(dto.id),
|
|
1048
|
-
slug: OfferSlug(dto.slug),
|
|
1049
|
-
type: dto.type,
|
|
1050
|
-
name: dto.name,
|
|
1051
|
-
asset: Asset.fromDto(dto.asset),
|
|
1052
|
-
fundingAssets: dto.funding_assets.map(Asset.fromDto),
|
|
1053
|
-
tokens: OfferToken.listFromDto(dto.tokens),
|
|
1054
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
1055
|
-
about: notBlankStringOrNull(dto.about),
|
|
1056
|
-
tagline: dto.tagline,
|
|
1057
|
-
bannerUrl: dto.banner_url,
|
|
1058
|
-
logoUrl: dto.logo_url,
|
|
1059
|
-
category: dto.category,
|
|
1060
|
-
startsAt: new Date(dto.starts_at),
|
|
1061
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1062
|
-
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
1063
|
-
links: dto.links.map(Link.fromDto),
|
|
1064
|
-
milestones: dto.milestones.map(Milestone.fromDto),
|
|
1065
|
-
options: dto.options.map(OfferOption.fromDto),
|
|
1066
|
-
terms: dto.terms.map(TermItem.fromDto)
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
var OfferOption = {
|
|
1071
|
-
fromDto: (dto) => ({
|
|
1072
|
-
id: OfferOptionId(dto.id),
|
|
1073
|
-
slug: OfferOptionSlug(dto.slug),
|
|
1074
|
-
bidIncrement: dto.bid_increment,
|
|
1075
|
-
floorPriceUsd: dto.floor_price_usd,
|
|
1076
|
-
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
1077
|
-
priceUsd: dto.price_usd,
|
|
1078
|
-
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
1079
|
-
totalTokenSupply: dto.total_token_supply
|
|
1080
|
-
})
|
|
1081
|
-
};
|
|
1082
|
-
var FaqItem = {
|
|
1083
|
-
fromDto: (dto) => ({
|
|
1084
|
-
question: notBlankStringOrNull(dto.question),
|
|
1085
|
-
answer: notBlankStringOrNull(dto.answer)
|
|
1086
|
-
})
|
|
1087
|
-
};
|
|
1088
|
-
var Link = {
|
|
1089
|
-
fromDto: (dto) => ({
|
|
1090
|
-
label: notBlankStringOrNull(dto.label),
|
|
1091
|
-
url: notBlankStringOrNull(dto.url)
|
|
1092
|
-
})
|
|
1093
|
-
};
|
|
1094
|
-
var TermItem = {
|
|
1095
|
-
fromDto: (dto) => ({
|
|
1096
|
-
key: notBlankStringOrNull(dto.key),
|
|
1097
|
-
value: notBlankStringOrNull(dto.value)
|
|
1098
|
-
})
|
|
1099
|
-
};
|
|
1100
|
-
var Milestone = {
|
|
1101
|
-
fromDto: (dto) => ({
|
|
1102
|
-
name: notBlankStringOrNull(dto.name),
|
|
1103
|
-
schedule: notBlankStringOrNull(dto.schedule),
|
|
1104
|
-
status: dto.status
|
|
1105
|
-
})
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
// src/shared/types/providers/coin-list/token-sale.ts
|
|
1109
|
-
var ParticipationId = (value) => value;
|
|
1110
|
-
var Blockchain = (value) => value;
|
|
1111
|
-
var WalletAddress = (value) => value;
|
|
1112
|
-
var ParticipationsPaginationParams = {
|
|
1113
|
-
toQueryParams: (params) => {
|
|
1114
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
1115
|
-
if (params.offerId) {
|
|
1116
|
-
queryParams["filters[0][field]"] = "offer_id";
|
|
1117
|
-
queryParams["filters[0][op]"] = "==";
|
|
1118
|
-
queryParams["filters[0][value]"] = params.offerId;
|
|
1119
|
-
}
|
|
1120
|
-
return queryParams;
|
|
1121
|
-
}
|
|
1122
|
-
};
|
|
1123
|
-
var Participation = {
|
|
1124
|
-
/** Maps API DTO shape into the SDK participation domain model. */
|
|
1125
|
-
fromDto: (dto) => {
|
|
1126
|
-
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
1127
|
-
return {
|
|
1128
|
-
id: ParticipationId(dto.id),
|
|
1129
|
-
offerId: OfferId(dto.offer_id),
|
|
1130
|
-
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
1131
|
-
status: dto.status,
|
|
1132
|
-
amount: dto.amount,
|
|
1133
|
-
displayAmount: dto.amount_string,
|
|
1134
|
-
asset: Asset.fromDto(dto.asset),
|
|
1135
|
-
chain: Blockchain(dto.chain),
|
|
1136
|
-
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
1137
|
-
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
1138
|
-
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
};
|
|
1142
|
-
var CreateParticipationParams = {
|
|
1143
|
-
/** Maps participation creation params into API DTO payload. */
|
|
1144
|
-
toDto: (params) => ({
|
|
1145
|
-
offer_id: params.offerId,
|
|
1146
|
-
offer_option_id: params.offerOptionId,
|
|
1147
|
-
chain: params.chain,
|
|
1148
|
-
wallet_address: params.walletAddress,
|
|
1149
|
-
amount: params.amount,
|
|
1150
|
-
asset_id: params.assetId,
|
|
1151
|
-
approval_transaction_hash: params.approvalTransactionHash
|
|
1152
|
-
})
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
// src/shared/api/frontline/providers/coin-list/token-sale.ts
|
|
1156
|
-
async function fetchParticipations(api, offerId) {
|
|
1157
|
-
return fetchAllPages(
|
|
1158
|
-
(params) => fetchParticipationsPage(api, params),
|
|
1159
|
-
{ offerId }
|
|
1160
|
-
);
|
|
1161
|
-
}
|
|
1162
|
-
async function fetchParticipationsPage(api, params) {
|
|
1163
|
-
const pageDto = await api.send({
|
|
1164
|
-
method: "GET",
|
|
1165
|
-
url: "/v1/participations",
|
|
1166
|
-
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
1167
|
-
attributes: Attributes.protected()
|
|
1168
|
-
});
|
|
1169
|
-
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
1170
|
-
}
|
|
1171
|
-
async function fetchParticipation(api, id) {
|
|
1172
|
-
const dto = await api.send({
|
|
1173
|
-
method: "GET",
|
|
1174
|
-
url: `/v1/participations/${id}`,
|
|
1175
|
-
attributes: Attributes.protected()
|
|
1176
|
-
});
|
|
1177
|
-
return Participation.fromDto(dto);
|
|
1178
|
-
}
|
|
1179
|
-
async function createParticipation(api, params) {
|
|
1180
|
-
const dto = await api.send({
|
|
1181
|
-
method: "POST",
|
|
1182
|
-
url: "/v1/participations",
|
|
1183
|
-
body: CreateParticipationParams.toDto(params),
|
|
1184
|
-
attributes: Attributes.protected()
|
|
1185
|
-
});
|
|
1186
|
-
return Participation.fromDto(dto);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
// src/shared/core/checkout/coin-list/token-sale-namespace.ts
|
|
1190
|
-
var CoinListTokenSaleNamespaceImpl = class {
|
|
1191
|
-
constructor(ctx) {
|
|
1192
|
-
this.ctx = ctx;
|
|
1193
|
-
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
1194
|
-
}
|
|
1195
|
-
async list(offerId) {
|
|
1196
|
-
return this.log.wrap("list", offerId, async () => {
|
|
1197
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1198
|
-
return fetchParticipations(this.ctx.api, offerId);
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
async listPage(params) {
|
|
1202
|
-
return this.log.wrap("listPage", params, async () => {
|
|
1203
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1204
|
-
return fetchParticipationsPage(this.ctx.api, params);
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
async get(id) {
|
|
1208
|
-
return this.log.wrap("get", id, async () => {
|
|
1209
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1210
|
-
return fetchParticipation(this.ctx.api, id);
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1213
|
-
async createParticipation(params) {
|
|
1214
|
-
return this.log.wrap("createParticipation", params, async () => {
|
|
1215
|
-
await this.ctx.ensureUserAuthenticated();
|
|
1216
|
-
return createParticipation(this.ctx.api, params);
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
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
|
+
}
|
|
1220
1043
|
|
|
1221
|
-
// src/
|
|
1044
|
+
// src/universal/types/trading.ts
|
|
1222
1045
|
var Ticker = (value) => value;
|
|
1223
1046
|
|
|
1224
|
-
// src/
|
|
1047
|
+
// src/universal/types/providers/ondo/ondo.ts
|
|
1225
1048
|
var OndoTradingStatus = {
|
|
1226
1049
|
fromDto: (dto) => {
|
|
1227
1050
|
if (!dto.tradable) return { type: "not-tradable", side: dto.side };
|
|
@@ -1387,7 +1210,7 @@ function parseExpiresAt(value) {
|
|
|
1387
1210
|
return date;
|
|
1388
1211
|
}
|
|
1389
1212
|
|
|
1390
|
-
// src/
|
|
1213
|
+
// src/universal/api/frontline/providers/ondo/ondo.ts
|
|
1391
1214
|
async function getOndoTradingStatus(api, params) {
|
|
1392
1215
|
const dto = await api.send({
|
|
1393
1216
|
method: "GET",
|
|
@@ -1482,7 +1305,7 @@ function sizeParam(params) {
|
|
|
1482
1305
|
return { notional_value: notionalValue };
|
|
1483
1306
|
}
|
|
1484
1307
|
|
|
1485
|
-
// src/
|
|
1308
|
+
// src/universal/core/checkout/ondo/ondo-namespace.ts
|
|
1486
1309
|
var OndoNamespaceImpl = class {
|
|
1487
1310
|
constructor(ctx) {
|
|
1488
1311
|
this.ctx = ctx;
|
|
@@ -1514,7 +1337,164 @@ var OndoNamespaceImpl = class {
|
|
|
1514
1337
|
}
|
|
1515
1338
|
};
|
|
1516
1339
|
|
|
1517
|
-
// 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
|
|
1518
1498
|
var SuperstateSwapNamespaceImpl = class {
|
|
1519
1499
|
constructor(ctx) {
|
|
1520
1500
|
this.ctx = ctx;
|
|
@@ -1552,7 +1532,7 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
1552
1532
|
}
|
|
1553
1533
|
};
|
|
1554
1534
|
|
|
1555
|
-
// src/
|
|
1535
|
+
// src/universal/types/document-submission.ts
|
|
1556
1536
|
var DocumentSubmission = {
|
|
1557
1537
|
fromDto: (dto) => ({
|
|
1558
1538
|
status: dto.status,
|
|
@@ -1560,14 +1540,14 @@ var DocumentSubmission = {
|
|
|
1560
1540
|
})
|
|
1561
1541
|
};
|
|
1562
1542
|
|
|
1563
|
-
// src/
|
|
1543
|
+
// src/universal/types/kyc.ts
|
|
1564
1544
|
var KycToken = {
|
|
1565
1545
|
fromDto: (dto) => ({
|
|
1566
1546
|
token: dto.token
|
|
1567
1547
|
})
|
|
1568
1548
|
};
|
|
1569
1549
|
|
|
1570
|
-
// src/
|
|
1550
|
+
// src/universal/types/pii.ts
|
|
1571
1551
|
var Iso2CountryCode = (value) => value;
|
|
1572
1552
|
var PiiJurisdiction = {
|
|
1573
1553
|
fromDto: (dto) => ({
|
|
@@ -1595,7 +1575,7 @@ var Pii = {
|
|
|
1595
1575
|
})
|
|
1596
1576
|
};
|
|
1597
1577
|
|
|
1598
|
-
// src/
|
|
1578
|
+
// src/universal/types/requirement.ts
|
|
1599
1579
|
var RequirementId = (value) => value;
|
|
1600
1580
|
var Requirement = {
|
|
1601
1581
|
fromDto: (dto) => ({
|
|
@@ -1616,7 +1596,7 @@ var RequirementStatusInfo = {
|
|
|
1616
1596
|
)
|
|
1617
1597
|
};
|
|
1618
1598
|
|
|
1619
|
-
// src/
|
|
1599
|
+
// src/universal/api/frontline/documents.ts
|
|
1620
1600
|
async function submitDocument(api, documentType, fields) {
|
|
1621
1601
|
const dto = await api.send({
|
|
1622
1602
|
method: "POST",
|
|
@@ -1627,7 +1607,7 @@ async function submitDocument(api, documentType, fields) {
|
|
|
1627
1607
|
return DocumentSubmission.fromDto(dto);
|
|
1628
1608
|
}
|
|
1629
1609
|
|
|
1630
|
-
// src/
|
|
1610
|
+
// src/universal/api/frontline/kyc.ts
|
|
1631
1611
|
async function createKycToken(api, levelName, reset) {
|
|
1632
1612
|
const dto = await api.send({
|
|
1633
1613
|
method: "POST",
|
|
@@ -1641,7 +1621,7 @@ async function createKycToken(api, levelName, reset) {
|
|
|
1641
1621
|
return KycToken.fromDto(dto);
|
|
1642
1622
|
}
|
|
1643
1623
|
|
|
1644
|
-
// src/
|
|
1624
|
+
// src/universal/api/frontline/pii.ts
|
|
1645
1625
|
async function fetchPii(api) {
|
|
1646
1626
|
const dto = await api.send({
|
|
1647
1627
|
method: "GET",
|
|
@@ -1651,7 +1631,7 @@ async function fetchPii(api) {
|
|
|
1651
1631
|
return Pii.fromDto(dto);
|
|
1652
1632
|
}
|
|
1653
1633
|
|
|
1654
|
-
// src/
|
|
1634
|
+
// src/universal/api/frontline/requirements.ts
|
|
1655
1635
|
async function fetchOfferRequirements(api, offerId, clientCreds) {
|
|
1656
1636
|
const response = await api.send({
|
|
1657
1637
|
method: "GET",
|
|
@@ -1677,7 +1657,7 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
1677
1657
|
return RequirementStatusInfo.fromStatusesDto(response);
|
|
1678
1658
|
}
|
|
1679
1659
|
|
|
1680
|
-
// src/
|
|
1660
|
+
// src/universal/core/requirements/requirements-namespace.ts
|
|
1681
1661
|
var RequirementsNamespaceImpl = class {
|
|
1682
1662
|
constructor(ctx) {
|
|
1683
1663
|
this.ctx = ctx;
|
|
@@ -1727,7 +1707,27 @@ var RequirementsNamespaceImpl = class {
|
|
|
1727
1707
|
}
|
|
1728
1708
|
};
|
|
1729
1709
|
|
|
1730
|
-
// 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
|
|
1731
1731
|
var TokenLogoUrl = (value) => value;
|
|
1732
1732
|
var TokenLogo = {
|
|
1733
1733
|
/** `baseUrl` is the registry origin; registry URLs are root-relative. */
|
|
@@ -1810,10 +1810,10 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
|
|
|
1810
1810
|
url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
|
|
1811
1811
|
);
|
|
1812
1812
|
|
|
1813
|
-
// src/
|
|
1813
|
+
// src/universal/api/nabu/tokens.ts
|
|
1814
1814
|
import { getAddress } from "viem";
|
|
1815
1815
|
|
|
1816
|
-
// src/
|
|
1816
|
+
// src/universal/api/frontline/config.ts
|
|
1817
1817
|
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
1818
1818
|
var HEADER_API_VERSION = "X-API-Version";
|
|
1819
1819
|
var HEADER_USER_AGENT = "User-Agent";
|
|
@@ -1826,7 +1826,7 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
|
1826
1826
|
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
1827
1827
|
var WALLET_PATH = "/wallet";
|
|
1828
1828
|
|
|
1829
|
-
// src/
|
|
1829
|
+
// src/universal/api/http-client.ts
|
|
1830
1830
|
var HttpClient = class {
|
|
1831
1831
|
constructor(config, middleware = {}, logger = null, options = {}) {
|
|
1832
1832
|
this.config = config;
|
|
@@ -1982,7 +1982,7 @@ function describeRequestUnredacted(request) {
|
|
|
1982
1982
|
};
|
|
1983
1983
|
}
|
|
1984
1984
|
|
|
1985
|
-
// src/
|
|
1985
|
+
// src/universal/api/nabu/tokens.ts
|
|
1986
1986
|
function createNabuApiClient(baseUrl, logger = null) {
|
|
1987
1987
|
return new HttpClient({ baseUrl }, {}, logger);
|
|
1988
1988
|
}
|
|
@@ -2073,10 +2073,10 @@ function checksummed(address) {
|
|
|
2073
2073
|
}
|
|
2074
2074
|
}
|
|
2075
2075
|
|
|
2076
|
-
// src/
|
|
2076
|
+
// src/universal/core/tokens/tokens-namespace.ts
|
|
2077
2077
|
var TokensNamespaceImpl = class {
|
|
2078
2078
|
/**
|
|
2079
|
-
* Takes the registry origin rather than a `
|
|
2079
|
+
* Takes the registry origin rather than a `UniversalNamespaceContext`: the
|
|
2080
2080
|
* registry is unauthenticated and on its own host, so the frontline sender
|
|
2081
2081
|
* and the auth check would both be dead weight here.
|
|
2082
2082
|
*/
|
|
@@ -2100,7 +2100,7 @@ var TokensNamespaceImpl = class {
|
|
|
2100
2100
|
}
|
|
2101
2101
|
};
|
|
2102
2102
|
|
|
2103
|
-
// src/
|
|
2103
|
+
// src/universal/types/offer-option-address.ts
|
|
2104
2104
|
var OfferOptionAddressId = (value) => value;
|
|
2105
2105
|
var OfferOptionAddress = {
|
|
2106
2106
|
/** Maps the API DTO into the SDK offer-option-address domain model. */
|
|
@@ -2122,7 +2122,7 @@ var ConnectExternalWalletParams = {
|
|
|
2122
2122
|
})
|
|
2123
2123
|
};
|
|
2124
2124
|
|
|
2125
|
-
// src/
|
|
2125
|
+
// src/universal/types/wallet-ownership-challenge.ts
|
|
2126
2126
|
var WalletOwnershipChallenge = {
|
|
2127
2127
|
/** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
|
|
2128
2128
|
fromDto: (dto) => ({
|
|
@@ -2161,7 +2161,7 @@ var CreateWalletOwnershipChallengeParams = {
|
|
|
2161
2161
|
}
|
|
2162
2162
|
};
|
|
2163
2163
|
|
|
2164
|
-
// src/
|
|
2164
|
+
// src/universal/api/frontline/wallet-connect.ts
|
|
2165
2165
|
async function createWalletOwnershipChallenge(api, params) {
|
|
2166
2166
|
const dto = await api.send({
|
|
2167
2167
|
method: "POST",
|
|
@@ -2198,7 +2198,7 @@ async function removeOptionAddress(api, offerId, addressId) {
|
|
|
2198
2198
|
return OfferOptionAddress.fromDto(dto);
|
|
2199
2199
|
}
|
|
2200
2200
|
|
|
2201
|
-
// src/
|
|
2201
|
+
// src/universal/core/wallets/wallets-namespace.ts
|
|
2202
2202
|
var WalletsNamespaceImpl = class {
|
|
2203
2203
|
constructor(ctx) {
|
|
2204
2204
|
this.ctx = ctx;
|
|
@@ -2241,7 +2241,7 @@ var WalletsNamespaceImpl = class {
|
|
|
2241
2241
|
}
|
|
2242
2242
|
};
|
|
2243
2243
|
|
|
2244
|
-
// src/
|
|
2244
|
+
// src/universal/types/oauth-session.ts
|
|
2245
2245
|
var ClientCredentialsOAuth = (value) => value;
|
|
2246
2246
|
var OAuthRefreshToken = (value) => value;
|
|
2247
2247
|
var OAuthSession = {
|
|
@@ -2257,7 +2257,7 @@ var OAuthSession = {
|
|
|
2257
2257
|
}
|
|
2258
2258
|
};
|
|
2259
2259
|
|
|
2260
|
-
// src/
|
|
2260
|
+
// src/universal/api/frontline/offers.ts
|
|
2261
2261
|
async function fetchOffers(api, clientCreds) {
|
|
2262
2262
|
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
2263
2263
|
}
|
|
@@ -2314,6 +2314,12 @@ export {
|
|
|
2314
2314
|
internalLogger,
|
|
2315
2315
|
HttpClient,
|
|
2316
2316
|
fetchAllPages,
|
|
2317
|
+
Cursor,
|
|
2318
|
+
PaginatedResponse,
|
|
2319
|
+
PaginationParams,
|
|
2320
|
+
AssetId,
|
|
2321
|
+
AssetCode,
|
|
2322
|
+
Asset,
|
|
2317
2323
|
ETHEREUM_CHAINS,
|
|
2318
2324
|
EthereumChain,
|
|
2319
2325
|
SOLANA_CHAINS,
|
|
@@ -2335,40 +2341,6 @@ export {
|
|
|
2335
2341
|
StablecoinSymbol,
|
|
2336
2342
|
KnownAssetSymbol,
|
|
2337
2343
|
Bps,
|
|
2338
|
-
FormattedAmountUi,
|
|
2339
|
-
FormattedPercentUi,
|
|
2340
|
-
TxExplorerUrl,
|
|
2341
|
-
ShortenedWalletAddress,
|
|
2342
|
-
FormattedAmountAssetUi,
|
|
2343
|
-
AssetIconUrl,
|
|
2344
|
-
getChainId,
|
|
2345
|
-
chainFromId,
|
|
2346
|
-
getNetworkName,
|
|
2347
|
-
txExplorerUrl,
|
|
2348
|
-
SwapAuthorization,
|
|
2349
|
-
SwapPreview,
|
|
2350
|
-
SwapStatus,
|
|
2351
|
-
TokenAllowance,
|
|
2352
|
-
TokenBalance,
|
|
2353
|
-
AllowWalletResponse,
|
|
2354
|
-
Erc20NamespaceImpl,
|
|
2355
|
-
shortenAddress,
|
|
2356
|
-
formatAmount,
|
|
2357
|
-
formatRawAmount,
|
|
2358
|
-
formatCompactAmount,
|
|
2359
|
-
formatBpsAsPercent,
|
|
2360
|
-
usdAmount,
|
|
2361
|
-
assetAmount,
|
|
2362
|
-
NA_AMOUNT_ASSET_UI,
|
|
2363
|
-
formattedUsdPrice,
|
|
2364
|
-
blockchainAmountFromRawOrThrow,
|
|
2365
|
-
parseBlockchainAmount,
|
|
2366
|
-
Cursor,
|
|
2367
|
-
PaginatedResponse,
|
|
2368
|
-
PaginationParams,
|
|
2369
|
-
AssetId,
|
|
2370
|
-
AssetCode,
|
|
2371
|
-
Asset,
|
|
2372
2344
|
OfferId,
|
|
2373
2345
|
OfferSlug,
|
|
2374
2346
|
Offer,
|
|
@@ -2389,12 +2361,39 @@ export {
|
|
|
2389
2361
|
Participation,
|
|
2390
2362
|
CreateParticipationParams,
|
|
2391
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,
|
|
2392
2385
|
Ticker,
|
|
2393
2386
|
OndoTradingStatus,
|
|
2394
2387
|
OndoQuote,
|
|
2395
2388
|
OndoBuyTransaction,
|
|
2396
2389
|
OndoSellTransaction,
|
|
2397
2390
|
OndoNamespaceImpl,
|
|
2391
|
+
SwapAuthorization,
|
|
2392
|
+
SwapPreview,
|
|
2393
|
+
SwapStatus,
|
|
2394
|
+
TokenAllowance,
|
|
2395
|
+
TokenBalance,
|
|
2396
|
+
AllowWalletResponse,
|
|
2398
2397
|
SuperstateSwapNamespaceImpl,
|
|
2399
2398
|
fetchOffers,
|
|
2400
2399
|
fetchOffersPage,
|
|
@@ -2410,6 +2409,7 @@ export {
|
|
|
2410
2409
|
RequirementStatusInfo,
|
|
2411
2410
|
fetchOfferRequirements,
|
|
2412
2411
|
RequirementsNamespaceImpl,
|
|
2412
|
+
Erc20NamespaceImpl,
|
|
2413
2413
|
TokenLogoUrl,
|
|
2414
2414
|
TokenLogo,
|
|
2415
2415
|
TokenMetadata,
|
|
@@ -2424,4 +2424,4 @@ export {
|
|
|
2424
2424
|
OAuthRefreshToken,
|
|
2425
2425
|
OAuthSession
|
|
2426
2426
|
};
|
|
2427
|
-
//# sourceMappingURL=chunk-
|
|
2427
|
+
//# sourceMappingURL=chunk-6CQHDASY.js.map
|