@coinlist-co/react 0.12.1-rc.73e7e17 → 0.12.1-rc.9aec85a
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-3ZZCK4IT.js → chunk-DCW7NQXH.js} +129 -3
- package/dist/chunk-DCW7NQXH.js.map +1 -0
- package/dist/{chunk-D42IQHQZ.js → chunk-MOE5S6CE.js} +1345 -257
- package/dist/chunk-MOE5S6CE.js.map +1 -0
- package/dist/{chunk-ZUVVNZJJ.js → chunk-VH34YC3Q.js} +72 -330
- package/dist/chunk-VH34YC3Q.js.map +1 -0
- package/dist/client/index.cjs +9477 -8125
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +398 -166
- package/dist/client/index.d.ts +398 -166
- package/dist/client/index.js +4959 -4544
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +1458 -263
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +5 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{collections-CMoojQ9M.d.ts → token-registry-snapshot-BNBNuDu1.d.ts} +65 -2
- package/dist/{collections-koI4cjYa.d.cts → token-registry-snapshot-CqI6dXM_.d.cts} +65 -2
- package/dist/{config-BmK0t-XO.d.cts → tokens-namespace-CIWBtgt2.d.cts} +463 -229
- package/dist/{config-BmK0t-XO.d.ts → tokens-namespace-CIWBtgt2.d.ts} +463 -229
- package/dist/universal/index.cjs +1275 -450
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +431 -54
- package/dist/universal/index.d.ts +431 -54
- package/dist/universal/index.js +26 -16
- package/package.json +1 -1
- package/dist/chunk-3ZZCK4IT.js.map +0 -1
- package/dist/chunk-D42IQHQZ.js.map +0 -1
- package/dist/chunk-ZUVVNZJJ.js.map +0 -1
|
@@ -209,6 +209,106 @@ var MathError = class extends Error {
|
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
+
// src/universal/core/shared/blockchain/erc20/abi.ts
|
|
213
|
+
var ERC20_ABI = [
|
|
214
|
+
{
|
|
215
|
+
type: "function",
|
|
216
|
+
name: "allowance",
|
|
217
|
+
inputs: [
|
|
218
|
+
{ name: "owner", type: "address" },
|
|
219
|
+
{ name: "spender", type: "address" }
|
|
220
|
+
],
|
|
221
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
222
|
+
stateMutability: "view"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "function",
|
|
226
|
+
name: "approve",
|
|
227
|
+
inputs: [
|
|
228
|
+
{ name: "spender", type: "address" },
|
|
229
|
+
{ name: "amount", type: "uint256" }
|
|
230
|
+
],
|
|
231
|
+
outputs: [{ name: "", type: "bool" }],
|
|
232
|
+
stateMutability: "nonpayable"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
type: "function",
|
|
236
|
+
name: "balanceOf",
|
|
237
|
+
inputs: [{ name: "account", type: "address" }],
|
|
238
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
239
|
+
stateMutability: "view"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
type: "function",
|
|
243
|
+
name: "decimals",
|
|
244
|
+
inputs: [],
|
|
245
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
246
|
+
stateMutability: "view"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
type: "function",
|
|
250
|
+
name: "name",
|
|
251
|
+
inputs: [],
|
|
252
|
+
outputs: [{ name: "", type: "string" }],
|
|
253
|
+
stateMutability: "view"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: "function",
|
|
257
|
+
name: "symbol",
|
|
258
|
+
inputs: [],
|
|
259
|
+
outputs: [{ name: "", type: "string" }],
|
|
260
|
+
stateMutability: "view"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
type: "function",
|
|
264
|
+
name: "totalSupply",
|
|
265
|
+
inputs: [],
|
|
266
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
267
|
+
stateMutability: "view"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: "function",
|
|
271
|
+
name: "transfer",
|
|
272
|
+
inputs: [
|
|
273
|
+
{ name: "recipient", type: "address" },
|
|
274
|
+
{ name: "amount", type: "uint256" }
|
|
275
|
+
],
|
|
276
|
+
outputs: [{ name: "", type: "bool" }],
|
|
277
|
+
stateMutability: "nonpayable"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
type: "function",
|
|
281
|
+
name: "transferFrom",
|
|
282
|
+
inputs: [
|
|
283
|
+
{ name: "sender", type: "address" },
|
|
284
|
+
{ name: "recipient", type: "address" },
|
|
285
|
+
{ name: "amount", type: "uint256" }
|
|
286
|
+
],
|
|
287
|
+
outputs: [{ name: "", type: "bool" }],
|
|
288
|
+
stateMutability: "nonpayable"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
type: "event",
|
|
292
|
+
name: "Approval",
|
|
293
|
+
inputs: [
|
|
294
|
+
{ name: "owner", type: "address", indexed: true },
|
|
295
|
+
{ name: "spender", type: "address", indexed: true },
|
|
296
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
297
|
+
],
|
|
298
|
+
anonymous: false
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
type: "event",
|
|
302
|
+
name: "Transfer",
|
|
303
|
+
inputs: [
|
|
304
|
+
{ name: "from", type: "address", indexed: true },
|
|
305
|
+
{ name: "to", type: "address", indexed: true },
|
|
306
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
307
|
+
],
|
|
308
|
+
anonymous: false
|
|
309
|
+
}
|
|
310
|
+
];
|
|
311
|
+
|
|
212
312
|
// src/universal/api/pagination.ts
|
|
213
313
|
async function fetchAllPages(fetchPage, baseParams) {
|
|
214
314
|
const items = [];
|
|
@@ -228,8 +328,15 @@ async function fetchAllPages(fetchPage, baseParams) {
|
|
|
228
328
|
// src/universal/types/pagination.ts
|
|
229
329
|
var Cursor = (value) => value;
|
|
230
330
|
var PaginatedResponse = {
|
|
231
|
-
fromDto: (dto, itemMapper) => (
|
|
232
|
-
|
|
331
|
+
fromDto: (dto, itemMapper) => PaginatedResponse.fromDtoPage(dto, (items) => items.map(itemMapper)),
|
|
332
|
+
/**
|
|
333
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
334
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
335
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
336
|
+
* page holds, not where the next page starts.
|
|
337
|
+
*/
|
|
338
|
+
fromDtoPage: (dto, pageMapper) => ({
|
|
339
|
+
data: pageMapper(dto.data),
|
|
233
340
|
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
234
341
|
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
235
342
|
})
|
|
@@ -359,53 +466,6 @@ var StablecoinSymbol = (value) => value;
|
|
|
359
466
|
var KnownAssetSymbol = StablecoinSymbol;
|
|
360
467
|
var Bps = (value) => value;
|
|
361
468
|
|
|
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
|
-
}
|
|
384
|
-
};
|
|
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/types/trading.ts
|
|
406
|
-
var Ticker = (value) => value;
|
|
407
|
-
var Isin = (value) => value;
|
|
408
|
-
|
|
409
469
|
// src/universal/core/shared/utils/crypto.ts
|
|
410
470
|
async function sha256(data) {
|
|
411
471
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
@@ -456,6 +516,131 @@ function notBlankStringOrNull(value) {
|
|
|
456
516
|
}
|
|
457
517
|
}
|
|
458
518
|
|
|
519
|
+
// src/universal/core/shared/utils/wire.ts
|
|
520
|
+
function unknownTypeError(dto, model) {
|
|
521
|
+
const type = dto.type;
|
|
522
|
+
throw new ValidationError(
|
|
523
|
+
`${model}.type: unknown type ${JSON.stringify(type)}`
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
function requiredString(value, field) {
|
|
527
|
+
const text = notBlankStringOrNull(value);
|
|
528
|
+
if (text === null) {
|
|
529
|
+
throw new ValidationError(
|
|
530
|
+
`${field}: expected a non-blank string, got ${typeof value === "string" ? "a blank string" : String(value)}`
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
return text;
|
|
534
|
+
}
|
|
535
|
+
function requiredDate(value, field) {
|
|
536
|
+
const date = typeof value === "string" ? new Date(value) : null;
|
|
537
|
+
if (date === null || Number.isNaN(date.getTime())) {
|
|
538
|
+
throw new ValidationError(
|
|
539
|
+
`${field}: expected a date, got ${JSON.stringify(value)}`
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
return date;
|
|
543
|
+
}
|
|
544
|
+
function requiredArray(value, field) {
|
|
545
|
+
if (!Array.isArray(value)) {
|
|
546
|
+
throw new ValidationError(
|
|
547
|
+
`${field}: expected an array, got ${typeof value}`
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
return value;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// src/universal/types/offer.ts
|
|
554
|
+
var OfferId = (value) => value;
|
|
555
|
+
var OfferSlug = (value) => value;
|
|
556
|
+
var OFFER_TYPES = {
|
|
557
|
+
"coinlist::token_sale": true,
|
|
558
|
+
"superstate::swap": true,
|
|
559
|
+
"ondo::swap": true
|
|
560
|
+
};
|
|
561
|
+
var isOfferType = (value) => Object.keys(OFFER_TYPES).includes(value);
|
|
562
|
+
var OfferEditorial = {
|
|
563
|
+
/**
|
|
564
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
565
|
+
* the same three checks name the payload that failed them.
|
|
566
|
+
*/
|
|
567
|
+
fromDto: (dto, model) => ({
|
|
568
|
+
tagline: requiredString(dto.tagline, `${model}.tagline`),
|
|
569
|
+
bannerUrl: requiredString(dto.banner_url, `${model}.banner_url`),
|
|
570
|
+
startsAt: requiredDate(dto.starts_at, `${model}.starts_at`)
|
|
571
|
+
})
|
|
572
|
+
};
|
|
573
|
+
var Offer = {
|
|
574
|
+
fromDto: (dto) => {
|
|
575
|
+
const tokens = requiredArray(dto.tokens, "Offer.tokens");
|
|
576
|
+
const base2 = {
|
|
577
|
+
id: OfferId(dto.id),
|
|
578
|
+
slug: OfferSlug(dto.slug),
|
|
579
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
580
|
+
tokens: OfferToken.listFromDto(tokens)
|
|
581
|
+
};
|
|
582
|
+
switch (dto.type) {
|
|
583
|
+
case "coinlist::token_sale":
|
|
584
|
+
return {
|
|
585
|
+
...base2,
|
|
586
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
587
|
+
type: dto.type,
|
|
588
|
+
logoUrl: requiredString(dto.logo_url, "Offer.logo_url")
|
|
589
|
+
};
|
|
590
|
+
case "superstate::swap":
|
|
591
|
+
return {
|
|
592
|
+
...base2,
|
|
593
|
+
...OfferEditorial.fromDto(dto, "Offer"),
|
|
594
|
+
type: dto.type,
|
|
595
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
596
|
+
};
|
|
597
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
598
|
+
// on the wire: copying them would hand every consumer a `startsAt` that
|
|
599
|
+
// is 1970 for one variant and a date for the others.
|
|
600
|
+
case "ondo::swap":
|
|
601
|
+
return {
|
|
602
|
+
...base2,
|
|
603
|
+
type: dto.type,
|
|
604
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
605
|
+
};
|
|
606
|
+
default:
|
|
607
|
+
return unknownTypeError(dto, "Offer");
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
/**
|
|
611
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
612
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
613
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
614
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
615
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
616
|
+
* throws, because there is nothing beside it to keep.
|
|
617
|
+
*/
|
|
618
|
+
listFromDto: (dtos) => dtos.filter((dto) => isOfferType(dto.type)).map(Offer.fromDto)
|
|
619
|
+
};
|
|
620
|
+
var OfferToken = {
|
|
621
|
+
fromDto: (dto) => ({
|
|
622
|
+
role: dto.role,
|
|
623
|
+
chain: Chain(dto.chain),
|
|
624
|
+
address: EvmContractAddress(dto.address)
|
|
625
|
+
}),
|
|
626
|
+
/**
|
|
627
|
+
* Maps an offer's token list, dropping every token on a chain this SDK does
|
|
628
|
+
* not name. Frontline's chain registry runs ahead of {@link Chain}, and a
|
|
629
|
+
* plain `.map` would throw out of `Offer.fromDto` and, through
|
|
630
|
+
* `PaginatedResponse.fromDto`, reject the whole offers page - which is how
|
|
631
|
+
* one Base token blanked production's offers list. Dropping costs that
|
|
632
|
+
* token's metadata alone: `coinlist.tokens.get` takes an `EthereumChain`,
|
|
633
|
+
* so nobody could have looked it up anyway.
|
|
634
|
+
*
|
|
635
|
+
* Same shape as `TokenMetadata.fromRegistryDto`.
|
|
636
|
+
*/
|
|
637
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferToken.fromDto)
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// src/universal/types/trading.ts
|
|
641
|
+
var Ticker = (value) => value;
|
|
642
|
+
var Isin = (value) => value;
|
|
643
|
+
|
|
459
644
|
// src/universal/types/offer-detail.ts
|
|
460
645
|
var OfferOptionId = (value) => value;
|
|
461
646
|
var OfferOptionSlug = (value) => value;
|
|
@@ -467,76 +652,69 @@ var OfferSwapContract = {
|
|
|
467
652
|
};
|
|
468
653
|
var OfferDetail = {
|
|
469
654
|
fromDto: (dto) => {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (!Array.isArray(dto.terms)) {
|
|
481
|
-
throw new ValidationError(
|
|
482
|
-
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
if (!Array.isArray(dto.links)) {
|
|
486
|
-
throw new ValidationError(
|
|
487
|
-
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
if (!Array.isArray(dto.faqs)) {
|
|
491
|
-
throw new ValidationError(
|
|
492
|
-
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
if (!Array.isArray(dto.milestones)) {
|
|
496
|
-
throw new ValidationError(
|
|
497
|
-
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
if (!Array.isArray(dto.tokens)) {
|
|
501
|
-
throw new ValidationError(
|
|
502
|
-
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
const swapContracts = dto.swap_contracts === void 0 ? [] : dto.swap_contracts;
|
|
506
|
-
if (!Array.isArray(swapContracts)) {
|
|
507
|
-
throw new ValidationError(
|
|
508
|
-
`OfferDetail.swap_contracts: expected an array, got ${typeof swapContracts}`
|
|
509
|
-
);
|
|
510
|
-
}
|
|
655
|
+
const fundingAssets = requiredArray(
|
|
656
|
+
dto.funding_assets,
|
|
657
|
+
"OfferDetail.funding_assets"
|
|
658
|
+
);
|
|
659
|
+
const options = requiredArray(dto.options, "OfferDetail.options");
|
|
660
|
+
const terms = requiredArray(dto.terms, "OfferDetail.terms");
|
|
661
|
+
const links = requiredArray(dto.links, "OfferDetail.links");
|
|
662
|
+
const faqs = requiredArray(dto.faqs, "OfferDetail.faqs");
|
|
663
|
+
const milestones = requiredArray(dto.milestones, "OfferDetail.milestones");
|
|
664
|
+
const tokens = requiredArray(dto.tokens, "OfferDetail.tokens");
|
|
511
665
|
const isin = notBlankStringOrNull(dto.isin);
|
|
512
666
|
const ticker = notBlankStringOrNull(dto.ticker);
|
|
513
|
-
|
|
667
|
+
const base2 = {
|
|
514
668
|
id: OfferId(dto.id),
|
|
515
669
|
slug: OfferSlug(dto.slug),
|
|
516
|
-
type: dto.type,
|
|
517
670
|
name: dto.name,
|
|
518
671
|
asset: Asset.fromDto(dto.asset),
|
|
519
|
-
fundingAssets:
|
|
520
|
-
tokens: OfferToken.listFromDto(
|
|
521
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
672
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
673
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
522
674
|
about: notBlankStringOrNull(dto.about),
|
|
523
|
-
tagline: dto.tagline,
|
|
524
|
-
bannerUrl: dto.banner_url,
|
|
525
|
-
logoUrl: dto.logo_url,
|
|
526
675
|
category: dto.category,
|
|
527
676
|
issuer: notBlankStringOrNull(dto.issuer),
|
|
528
677
|
isin: isin === null ? null : Isin(isin),
|
|
529
678
|
ticker: ticker === null ? null : Ticker(ticker),
|
|
530
679
|
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
531
680
|
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
532
|
-
startsAt: new Date(dto.starts_at),
|
|
533
681
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
534
|
-
faqs:
|
|
535
|
-
links:
|
|
536
|
-
milestones:
|
|
537
|
-
options:
|
|
538
|
-
terms:
|
|
682
|
+
faqs: faqs.map(FaqItem.fromDto),
|
|
683
|
+
links: links.map(Link.fromDto),
|
|
684
|
+
milestones: milestones.map(Milestone.fromDto),
|
|
685
|
+
options: options.map(OfferOption.fromDto),
|
|
686
|
+
terms: terms.map(TermItem.fromDto)
|
|
539
687
|
};
|
|
688
|
+
switch (dto.type) {
|
|
689
|
+
case "coinlist::token_sale":
|
|
690
|
+
return {
|
|
691
|
+
...base2,
|
|
692
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
693
|
+
type: dto.type,
|
|
694
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
695
|
+
};
|
|
696
|
+
case "superstate::swap":
|
|
697
|
+
return {
|
|
698
|
+
...base2,
|
|
699
|
+
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
700
|
+
type: dto.type,
|
|
701
|
+
logoUrl: notBlankStringOrNull(dto.logo_url)
|
|
702
|
+
};
|
|
703
|
+
// `tagline`, `banner_url` and `starts_at` arrive as `null` and are left
|
|
704
|
+
// on the wire, as in `Offer.fromDto`.
|
|
705
|
+
case "ondo::swap":
|
|
706
|
+
return {
|
|
707
|
+
...base2,
|
|
708
|
+
type: dto.type,
|
|
709
|
+
logoUrl: notBlankStringOrNull(dto.logo_url),
|
|
710
|
+
swapContracts: requiredArray(
|
|
711
|
+
dto.swap_contracts,
|
|
712
|
+
"OfferDetail.swap_contracts"
|
|
713
|
+
).map(OfferSwapContract.fromDto)
|
|
714
|
+
};
|
|
715
|
+
default:
|
|
716
|
+
return unknownTypeError(dto, "OfferDetail");
|
|
717
|
+
}
|
|
540
718
|
}
|
|
541
719
|
};
|
|
542
720
|
var OfferOption = {
|
|
@@ -659,6 +837,16 @@ async function createParticipation(api, params) {
|
|
|
659
837
|
}
|
|
660
838
|
|
|
661
839
|
// src/universal/core/shared/observability/log-cause.ts
|
|
840
|
+
import {
|
|
841
|
+
BaseError,
|
|
842
|
+
ContractFunctionExecutionError,
|
|
843
|
+
ContractFunctionRevertedError,
|
|
844
|
+
HttpRequestError,
|
|
845
|
+
RpcError,
|
|
846
|
+
SocketClosedError,
|
|
847
|
+
TimeoutError,
|
|
848
|
+
WebSocketRequestError
|
|
849
|
+
} from "viem";
|
|
662
850
|
function classifyLogCause(error) {
|
|
663
851
|
if (error instanceof HttpError) {
|
|
664
852
|
return httpCause(error);
|
|
@@ -678,8 +866,32 @@ function classifyLogCause(error) {
|
|
|
678
866
|
if (error instanceof NotImplementedError) {
|
|
679
867
|
return { type: "not-implemented" };
|
|
680
868
|
}
|
|
869
|
+
if (error instanceof BaseError) {
|
|
870
|
+
const http = error.walk((e) => e instanceof HttpError);
|
|
871
|
+
if (http instanceof HttpError) {
|
|
872
|
+
return httpCause(http);
|
|
873
|
+
}
|
|
874
|
+
return { type: "rpc", reason: rpcFailureReason(error) };
|
|
875
|
+
}
|
|
681
876
|
return { type: "generic-error", name: errorName(error) };
|
|
682
877
|
}
|
|
878
|
+
function rpcFailureReason(error) {
|
|
879
|
+
if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
|
|
880
|
+
return "reverted";
|
|
881
|
+
}
|
|
882
|
+
if (error.walk((e) => e instanceof RpcError)) {
|
|
883
|
+
return "node-rejected";
|
|
884
|
+
}
|
|
885
|
+
if (error.walk(
|
|
886
|
+
(e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
|
|
887
|
+
)) {
|
|
888
|
+
return "transport";
|
|
889
|
+
}
|
|
890
|
+
if (error instanceof ContractFunctionExecutionError) {
|
|
891
|
+
return "malformed-response";
|
|
892
|
+
}
|
|
893
|
+
return "unknown";
|
|
894
|
+
}
|
|
683
895
|
function describeErrorUnredacted(error) {
|
|
684
896
|
if (error instanceof HttpError) {
|
|
685
897
|
return describeHttpErrorRedacted(error);
|
|
@@ -943,18 +1155,22 @@ function formattedUsdPrice(amount, locale) {
|
|
|
943
1155
|
}
|
|
944
1156
|
|
|
945
1157
|
// src/universal/core/shared/blockchain/chain.ts
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1158
|
+
import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
|
|
1159
|
+
var VIEM_CHAINS = {
|
|
1160
|
+
ethereum_mainnet: mainnet,
|
|
1161
|
+
ethereum_sepolia: sepolia,
|
|
1162
|
+
base_mainnet: base,
|
|
1163
|
+
base_sepolia: baseSepolia
|
|
951
1164
|
};
|
|
1165
|
+
function viemChain(chain) {
|
|
1166
|
+
return VIEM_CHAINS[chain];
|
|
1167
|
+
}
|
|
952
1168
|
function getChainId(chain) {
|
|
953
|
-
return
|
|
1169
|
+
return VIEM_CHAINS[chain].id;
|
|
954
1170
|
}
|
|
955
1171
|
function chainFromId(chainId) {
|
|
956
|
-
const chains = Object.keys(
|
|
957
|
-
const chain = chains.find((c) => String(
|
|
1172
|
+
const chains = Object.keys(VIEM_CHAINS);
|
|
1173
|
+
const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
|
|
958
1174
|
if (!chain) {
|
|
959
1175
|
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
960
1176
|
}
|
|
@@ -1028,10 +1244,14 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1028
1244
|
if (/[eE]/.test(trimmed)) {
|
|
1029
1245
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1030
1246
|
}
|
|
1031
|
-
if (
|
|
1247
|
+
if (trimmed === ".") {
|
|
1032
1248
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1033
1249
|
}
|
|
1034
|
-
const
|
|
1250
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1251
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1252
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1253
|
+
}
|
|
1254
|
+
const [, fraction = ""] = normalised.split(".");
|
|
1035
1255
|
if (fraction.length > decimals) {
|
|
1036
1256
|
return {
|
|
1037
1257
|
valid: false,
|
|
@@ -1039,7 +1259,7 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1039
1259
|
};
|
|
1040
1260
|
}
|
|
1041
1261
|
try {
|
|
1042
|
-
const raw = parseUnits(
|
|
1262
|
+
const raw = parseUnits(normalised, decimals);
|
|
1043
1263
|
if (raw > MAX_UINT_256) {
|
|
1044
1264
|
return { valid: false, reason: { type: "overflow" } };
|
|
1045
1265
|
}
|
|
@@ -1345,40 +1565,915 @@ var OndoNamespaceImpl = class {
|
|
|
1345
1565
|
}
|
|
1346
1566
|
};
|
|
1347
1567
|
|
|
1568
|
+
// src/universal/core/checkout/superstate/blockchain/abi.ts
|
|
1569
|
+
var SUPERSTATE_SWAP_ABI = [
|
|
1570
|
+
{
|
|
1571
|
+
type: "function",
|
|
1572
|
+
name: "KIND",
|
|
1573
|
+
inputs: [],
|
|
1574
|
+
outputs: [
|
|
1575
|
+
{
|
|
1576
|
+
name: "",
|
|
1577
|
+
type: "uint16",
|
|
1578
|
+
internalType: "uint16"
|
|
1579
|
+
}
|
|
1580
|
+
],
|
|
1581
|
+
stateMutability: "view"
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
type: "function",
|
|
1585
|
+
name: "ONE_HUNDRED_P",
|
|
1586
|
+
inputs: [],
|
|
1587
|
+
outputs: [
|
|
1588
|
+
{
|
|
1589
|
+
name: "",
|
|
1590
|
+
type: "uint256",
|
|
1591
|
+
internalType: "uint256"
|
|
1592
|
+
}
|
|
1593
|
+
],
|
|
1594
|
+
stateMutability: "view"
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
type: "function",
|
|
1598
|
+
name: "SWAP_LEVEL",
|
|
1599
|
+
inputs: [],
|
|
1600
|
+
outputs: [
|
|
1601
|
+
{
|
|
1602
|
+
name: "",
|
|
1603
|
+
type: "uint32",
|
|
1604
|
+
internalType: "uint32"
|
|
1605
|
+
}
|
|
1606
|
+
],
|
|
1607
|
+
stateMutability: "view"
|
|
1608
|
+
},
|
|
1609
|
+
{
|
|
1610
|
+
type: "function",
|
|
1611
|
+
name: "VERSION",
|
|
1612
|
+
inputs: [],
|
|
1613
|
+
outputs: [
|
|
1614
|
+
{
|
|
1615
|
+
name: "",
|
|
1616
|
+
type: "uint16",
|
|
1617
|
+
internalType: "uint16"
|
|
1618
|
+
}
|
|
1619
|
+
],
|
|
1620
|
+
stateMutability: "view"
|
|
1621
|
+
},
|
|
1622
|
+
{
|
|
1623
|
+
type: "function",
|
|
1624
|
+
name: "authorized",
|
|
1625
|
+
inputs: [
|
|
1626
|
+
{
|
|
1627
|
+
name: "user",
|
|
1628
|
+
type: "address",
|
|
1629
|
+
internalType: "address"
|
|
1630
|
+
}
|
|
1631
|
+
],
|
|
1632
|
+
outputs: [
|
|
1633
|
+
{
|
|
1634
|
+
name: "",
|
|
1635
|
+
type: "bool",
|
|
1636
|
+
internalType: "bool"
|
|
1637
|
+
}
|
|
1638
|
+
],
|
|
1639
|
+
stateMutability: "view"
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
type: "function",
|
|
1643
|
+
name: "bpp",
|
|
1644
|
+
inputs: [
|
|
1645
|
+
{
|
|
1646
|
+
name: "amount",
|
|
1647
|
+
type: "uint256",
|
|
1648
|
+
internalType: "uint256"
|
|
1649
|
+
}
|
|
1650
|
+
],
|
|
1651
|
+
outputs: [
|
|
1652
|
+
{
|
|
1653
|
+
name: "",
|
|
1654
|
+
type: "uint256",
|
|
1655
|
+
internalType: "uint256"
|
|
1656
|
+
}
|
|
1657
|
+
],
|
|
1658
|
+
stateMutability: "view"
|
|
1659
|
+
},
|
|
1660
|
+
{
|
|
1661
|
+
type: "function",
|
|
1662
|
+
name: "bps",
|
|
1663
|
+
inputs: [],
|
|
1664
|
+
outputs: [
|
|
1665
|
+
{
|
|
1666
|
+
name: "",
|
|
1667
|
+
type: "uint256",
|
|
1668
|
+
internalType: "uint256"
|
|
1669
|
+
}
|
|
1670
|
+
],
|
|
1671
|
+
stateMutability: "view"
|
|
1672
|
+
},
|
|
1673
|
+
{
|
|
1674
|
+
type: "function",
|
|
1675
|
+
name: "cancelOwnershipHandover",
|
|
1676
|
+
inputs: [],
|
|
1677
|
+
outputs: [],
|
|
1678
|
+
stateMutability: "payable"
|
|
1679
|
+
},
|
|
1680
|
+
{
|
|
1681
|
+
type: "function",
|
|
1682
|
+
name: "completeOwnershipHandover",
|
|
1683
|
+
inputs: [
|
|
1684
|
+
{
|
|
1685
|
+
name: "pendingOwner",
|
|
1686
|
+
type: "address",
|
|
1687
|
+
internalType: "address"
|
|
1688
|
+
}
|
|
1689
|
+
],
|
|
1690
|
+
outputs: [],
|
|
1691
|
+
stateMutability: "payable"
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
type: "function",
|
|
1695
|
+
name: "fee",
|
|
1696
|
+
inputs: [
|
|
1697
|
+
{
|
|
1698
|
+
name: "amount",
|
|
1699
|
+
type: "uint256",
|
|
1700
|
+
internalType: "uint256"
|
|
1701
|
+
}
|
|
1702
|
+
],
|
|
1703
|
+
outputs: [
|
|
1704
|
+
{
|
|
1705
|
+
name: "",
|
|
1706
|
+
type: "uint256",
|
|
1707
|
+
internalType: "uint256"
|
|
1708
|
+
},
|
|
1709
|
+
{
|
|
1710
|
+
name: "",
|
|
1711
|
+
type: "uint256",
|
|
1712
|
+
internalType: "uint256"
|
|
1713
|
+
}
|
|
1714
|
+
],
|
|
1715
|
+
stateMutability: "view"
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
type: "function",
|
|
1719
|
+
name: "id",
|
|
1720
|
+
inputs: [],
|
|
1721
|
+
outputs: [
|
|
1722
|
+
{
|
|
1723
|
+
name: "",
|
|
1724
|
+
type: "bytes32",
|
|
1725
|
+
internalType: "bytes32"
|
|
1726
|
+
}
|
|
1727
|
+
],
|
|
1728
|
+
stateMutability: "view"
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
type: "function",
|
|
1732
|
+
name: "inputTokens",
|
|
1733
|
+
inputs: [
|
|
1734
|
+
{
|
|
1735
|
+
name: "",
|
|
1736
|
+
type: "address",
|
|
1737
|
+
internalType: "address"
|
|
1738
|
+
}
|
|
1739
|
+
],
|
|
1740
|
+
outputs: [
|
|
1741
|
+
{
|
|
1742
|
+
name: "",
|
|
1743
|
+
type: "bool",
|
|
1744
|
+
internalType: "bool"
|
|
1745
|
+
}
|
|
1746
|
+
],
|
|
1747
|
+
stateMutability: "view"
|
|
1748
|
+
},
|
|
1749
|
+
{
|
|
1750
|
+
type: "function",
|
|
1751
|
+
name: "outputToken",
|
|
1752
|
+
inputs: [],
|
|
1753
|
+
outputs: [
|
|
1754
|
+
{
|
|
1755
|
+
name: "",
|
|
1756
|
+
type: "address",
|
|
1757
|
+
internalType: "address"
|
|
1758
|
+
}
|
|
1759
|
+
],
|
|
1760
|
+
stateMutability: "view"
|
|
1761
|
+
},
|
|
1762
|
+
{
|
|
1763
|
+
type: "function",
|
|
1764
|
+
name: "outputTokenBalance",
|
|
1765
|
+
inputs: [],
|
|
1766
|
+
outputs: [
|
|
1767
|
+
{
|
|
1768
|
+
name: "",
|
|
1769
|
+
type: "uint256",
|
|
1770
|
+
internalType: "uint256"
|
|
1771
|
+
}
|
|
1772
|
+
],
|
|
1773
|
+
stateMutability: "view"
|
|
1774
|
+
},
|
|
1775
|
+
{
|
|
1776
|
+
type: "function",
|
|
1777
|
+
name: "owner",
|
|
1778
|
+
inputs: [],
|
|
1779
|
+
outputs: [
|
|
1780
|
+
{
|
|
1781
|
+
name: "result",
|
|
1782
|
+
type: "address",
|
|
1783
|
+
internalType: "address"
|
|
1784
|
+
}
|
|
1785
|
+
],
|
|
1786
|
+
stateMutability: "view"
|
|
1787
|
+
},
|
|
1788
|
+
{
|
|
1789
|
+
type: "function",
|
|
1790
|
+
name: "ownershipHandoverExpiresAt",
|
|
1791
|
+
inputs: [
|
|
1792
|
+
{
|
|
1793
|
+
name: "pendingOwner",
|
|
1794
|
+
type: "address",
|
|
1795
|
+
internalType: "address"
|
|
1796
|
+
}
|
|
1797
|
+
],
|
|
1798
|
+
outputs: [
|
|
1799
|
+
{
|
|
1800
|
+
name: "result",
|
|
1801
|
+
type: "uint256",
|
|
1802
|
+
internalType: "uint256"
|
|
1803
|
+
}
|
|
1804
|
+
],
|
|
1805
|
+
stateMutability: "view"
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
type: "function",
|
|
1809
|
+
name: "pause",
|
|
1810
|
+
inputs: [
|
|
1811
|
+
{
|
|
1812
|
+
name: "level",
|
|
1813
|
+
type: "uint32",
|
|
1814
|
+
internalType: "uint32"
|
|
1815
|
+
}
|
|
1816
|
+
],
|
|
1817
|
+
outputs: [
|
|
1818
|
+
{
|
|
1819
|
+
name: "",
|
|
1820
|
+
type: "bool",
|
|
1821
|
+
internalType: "bool"
|
|
1822
|
+
}
|
|
1823
|
+
],
|
|
1824
|
+
stateMutability: "nonpayable"
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
type: "function",
|
|
1828
|
+
name: "paused",
|
|
1829
|
+
inputs: [],
|
|
1830
|
+
outputs: [
|
|
1831
|
+
{
|
|
1832
|
+
name: "",
|
|
1833
|
+
type: "uint32",
|
|
1834
|
+
internalType: "uint32"
|
|
1835
|
+
}
|
|
1836
|
+
],
|
|
1837
|
+
stateMutability: "view"
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
type: "function",
|
|
1841
|
+
name: "preview",
|
|
1842
|
+
inputs: [
|
|
1843
|
+
{
|
|
1844
|
+
name: "token",
|
|
1845
|
+
type: "address",
|
|
1846
|
+
internalType: "address"
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
name: "amount",
|
|
1850
|
+
type: "uint256",
|
|
1851
|
+
internalType: "uint256"
|
|
1852
|
+
}
|
|
1853
|
+
],
|
|
1854
|
+
outputs: [
|
|
1855
|
+
{
|
|
1856
|
+
name: "",
|
|
1857
|
+
type: "tuple",
|
|
1858
|
+
internalType: "struct Preview",
|
|
1859
|
+
components: [
|
|
1860
|
+
{
|
|
1861
|
+
name: "input",
|
|
1862
|
+
type: "uint256",
|
|
1863
|
+
internalType: "uint256"
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
name: "fee",
|
|
1867
|
+
type: "uint256",
|
|
1868
|
+
internalType: "uint256"
|
|
1869
|
+
},
|
|
1870
|
+
{
|
|
1871
|
+
name: "output",
|
|
1872
|
+
type: "uint256",
|
|
1873
|
+
internalType: "uint256"
|
|
1874
|
+
}
|
|
1875
|
+
]
|
|
1876
|
+
}
|
|
1877
|
+
],
|
|
1878
|
+
stateMutability: "view"
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
type: "function",
|
|
1882
|
+
name: "renounceOwnership",
|
|
1883
|
+
inputs: [],
|
|
1884
|
+
outputs: [],
|
|
1885
|
+
stateMutability: "payable"
|
|
1886
|
+
},
|
|
1887
|
+
{
|
|
1888
|
+
type: "function",
|
|
1889
|
+
name: "requestOwnershipHandover",
|
|
1890
|
+
inputs: [],
|
|
1891
|
+
outputs: [],
|
|
1892
|
+
stateMutability: "payable"
|
|
1893
|
+
},
|
|
1894
|
+
{
|
|
1895
|
+
type: "function",
|
|
1896
|
+
name: "setBps",
|
|
1897
|
+
inputs: [
|
|
1898
|
+
{
|
|
1899
|
+
name: "points",
|
|
1900
|
+
type: "uint256",
|
|
1901
|
+
internalType: "uint256"
|
|
1902
|
+
}
|
|
1903
|
+
],
|
|
1904
|
+
outputs: [
|
|
1905
|
+
{
|
|
1906
|
+
name: "",
|
|
1907
|
+
type: "bool",
|
|
1908
|
+
internalType: "bool"
|
|
1909
|
+
}
|
|
1910
|
+
],
|
|
1911
|
+
stateMutability: "nonpayable"
|
|
1912
|
+
},
|
|
1913
|
+
{
|
|
1914
|
+
type: "function",
|
|
1915
|
+
name: "setInputToken",
|
|
1916
|
+
inputs: [
|
|
1917
|
+
{
|
|
1918
|
+
name: "token",
|
|
1919
|
+
type: "address",
|
|
1920
|
+
internalType: "address"
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
name: "val",
|
|
1924
|
+
type: "bool",
|
|
1925
|
+
internalType: "bool"
|
|
1926
|
+
}
|
|
1927
|
+
],
|
|
1928
|
+
outputs: [
|
|
1929
|
+
{
|
|
1930
|
+
name: "",
|
|
1931
|
+
type: "bool",
|
|
1932
|
+
internalType: "bool"
|
|
1933
|
+
}
|
|
1934
|
+
],
|
|
1935
|
+
stateMutability: "nonpayable"
|
|
1936
|
+
},
|
|
1937
|
+
{
|
|
1938
|
+
type: "function",
|
|
1939
|
+
name: "status",
|
|
1940
|
+
inputs: [],
|
|
1941
|
+
outputs: [
|
|
1942
|
+
{
|
|
1943
|
+
name: "",
|
|
1944
|
+
type: "tuple",
|
|
1945
|
+
internalType: "struct Status",
|
|
1946
|
+
components: [
|
|
1947
|
+
{
|
|
1948
|
+
name: "flags",
|
|
1949
|
+
type: "uint32",
|
|
1950
|
+
internalType: "uint32"
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
name: "state",
|
|
1954
|
+
type: "uint8",
|
|
1955
|
+
internalType: "enum State"
|
|
1956
|
+
}
|
|
1957
|
+
]
|
|
1958
|
+
}
|
|
1959
|
+
],
|
|
1960
|
+
stateMutability: "view"
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
type: "function",
|
|
1964
|
+
name: "stop",
|
|
1965
|
+
inputs: [],
|
|
1966
|
+
outputs: [
|
|
1967
|
+
{
|
|
1968
|
+
name: "",
|
|
1969
|
+
type: "bool",
|
|
1970
|
+
internalType: "bool"
|
|
1971
|
+
}
|
|
1972
|
+
],
|
|
1973
|
+
stateMutability: "nonpayable"
|
|
1974
|
+
},
|
|
1975
|
+
{
|
|
1976
|
+
type: "function",
|
|
1977
|
+
name: "stopped",
|
|
1978
|
+
inputs: [],
|
|
1979
|
+
outputs: [
|
|
1980
|
+
{
|
|
1981
|
+
name: "",
|
|
1982
|
+
type: "bool",
|
|
1983
|
+
internalType: "bool"
|
|
1984
|
+
}
|
|
1985
|
+
],
|
|
1986
|
+
stateMutability: "view"
|
|
1987
|
+
},
|
|
1988
|
+
{
|
|
1989
|
+
type: "function",
|
|
1990
|
+
name: "swap",
|
|
1991
|
+
inputs: [
|
|
1992
|
+
{
|
|
1993
|
+
name: "token",
|
|
1994
|
+
type: "address",
|
|
1995
|
+
internalType: "address"
|
|
1996
|
+
},
|
|
1997
|
+
{
|
|
1998
|
+
name: "amount",
|
|
1999
|
+
type: "uint256",
|
|
2000
|
+
internalType: "uint256"
|
|
2001
|
+
},
|
|
2002
|
+
{
|
|
2003
|
+
name: "slip",
|
|
2004
|
+
type: "uint256",
|
|
2005
|
+
internalType: "uint256"
|
|
2006
|
+
}
|
|
2007
|
+
],
|
|
2008
|
+
outputs: [
|
|
2009
|
+
{
|
|
2010
|
+
name: "",
|
|
2011
|
+
type: "uint256",
|
|
2012
|
+
internalType: "uint256"
|
|
2013
|
+
}
|
|
2014
|
+
],
|
|
2015
|
+
stateMutability: "nonpayable"
|
|
2016
|
+
},
|
|
2017
|
+
{
|
|
2018
|
+
type: "function",
|
|
2019
|
+
name: "tokenBalance",
|
|
2020
|
+
inputs: [
|
|
2021
|
+
{
|
|
2022
|
+
name: "token",
|
|
2023
|
+
type: "address",
|
|
2024
|
+
internalType: "address"
|
|
2025
|
+
}
|
|
2026
|
+
],
|
|
2027
|
+
outputs: [
|
|
2028
|
+
{
|
|
2029
|
+
name: "",
|
|
2030
|
+
type: "uint256",
|
|
2031
|
+
internalType: "uint256"
|
|
2032
|
+
}
|
|
2033
|
+
],
|
|
2034
|
+
stateMutability: "view"
|
|
2035
|
+
},
|
|
2036
|
+
{
|
|
2037
|
+
type: "function",
|
|
2038
|
+
name: "totals",
|
|
2039
|
+
inputs: [
|
|
2040
|
+
{
|
|
2041
|
+
name: "user",
|
|
2042
|
+
type: "address",
|
|
2043
|
+
internalType: "address"
|
|
2044
|
+
},
|
|
2045
|
+
{
|
|
2046
|
+
name: "token",
|
|
2047
|
+
type: "address",
|
|
2048
|
+
internalType: "address"
|
|
2049
|
+
}
|
|
2050
|
+
],
|
|
2051
|
+
outputs: [
|
|
2052
|
+
{
|
|
2053
|
+
name: "",
|
|
2054
|
+
type: "tuple",
|
|
2055
|
+
internalType: "struct SwapTotal",
|
|
2056
|
+
components: [
|
|
2057
|
+
{
|
|
2058
|
+
name: "inputSum",
|
|
2059
|
+
type: "uint256",
|
|
2060
|
+
internalType: "uint256"
|
|
2061
|
+
},
|
|
2062
|
+
{
|
|
2063
|
+
name: "feeSum",
|
|
2064
|
+
type: "uint256",
|
|
2065
|
+
internalType: "uint256"
|
|
2066
|
+
},
|
|
2067
|
+
{
|
|
2068
|
+
name: "outputSum",
|
|
2069
|
+
type: "uint256",
|
|
2070
|
+
internalType: "uint256"
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
name: "count",
|
|
2074
|
+
type: "uint256",
|
|
2075
|
+
internalType: "uint256"
|
|
2076
|
+
}
|
|
2077
|
+
]
|
|
2078
|
+
}
|
|
2079
|
+
],
|
|
2080
|
+
stateMutability: "view"
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
type: "function",
|
|
2084
|
+
name: "totals",
|
|
2085
|
+
inputs: [
|
|
2086
|
+
{
|
|
2087
|
+
name: "token",
|
|
2088
|
+
type: "address",
|
|
2089
|
+
internalType: "address"
|
|
2090
|
+
}
|
|
2091
|
+
],
|
|
2092
|
+
outputs: [
|
|
2093
|
+
{
|
|
2094
|
+
name: "",
|
|
2095
|
+
type: "tuple",
|
|
2096
|
+
internalType: "struct SwapTotal",
|
|
2097
|
+
components: [
|
|
2098
|
+
{
|
|
2099
|
+
name: "inputSum",
|
|
2100
|
+
type: "uint256",
|
|
2101
|
+
internalType: "uint256"
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
name: "feeSum",
|
|
2105
|
+
type: "uint256",
|
|
2106
|
+
internalType: "uint256"
|
|
2107
|
+
},
|
|
2108
|
+
{
|
|
2109
|
+
name: "outputSum",
|
|
2110
|
+
type: "uint256",
|
|
2111
|
+
internalType: "uint256"
|
|
2112
|
+
},
|
|
2113
|
+
{
|
|
2114
|
+
name: "count",
|
|
2115
|
+
type: "uint256",
|
|
2116
|
+
internalType: "uint256"
|
|
2117
|
+
}
|
|
2118
|
+
]
|
|
2119
|
+
}
|
|
2120
|
+
],
|
|
2121
|
+
stateMutability: "view"
|
|
2122
|
+
},
|
|
2123
|
+
{
|
|
2124
|
+
type: "function",
|
|
2125
|
+
name: "transfer",
|
|
2126
|
+
inputs: [
|
|
2127
|
+
{
|
|
2128
|
+
name: "to",
|
|
2129
|
+
type: "address",
|
|
2130
|
+
internalType: "address"
|
|
2131
|
+
},
|
|
2132
|
+
{
|
|
2133
|
+
name: "amount",
|
|
2134
|
+
type: "uint256",
|
|
2135
|
+
internalType: "uint256"
|
|
2136
|
+
}
|
|
2137
|
+
],
|
|
2138
|
+
outputs: [
|
|
2139
|
+
{
|
|
2140
|
+
name: "",
|
|
2141
|
+
type: "bool",
|
|
2142
|
+
internalType: "bool"
|
|
2143
|
+
}
|
|
2144
|
+
],
|
|
2145
|
+
stateMutability: "nonpayable"
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
type: "function",
|
|
2149
|
+
name: "transfer",
|
|
2150
|
+
inputs: [
|
|
2151
|
+
{
|
|
2152
|
+
name: "to",
|
|
2153
|
+
type: "address",
|
|
2154
|
+
internalType: "address"
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
name: "token",
|
|
2158
|
+
type: "address",
|
|
2159
|
+
internalType: "address"
|
|
2160
|
+
},
|
|
2161
|
+
{
|
|
2162
|
+
name: "amount",
|
|
2163
|
+
type: "uint256",
|
|
2164
|
+
internalType: "uint256"
|
|
2165
|
+
}
|
|
2166
|
+
],
|
|
2167
|
+
outputs: [
|
|
2168
|
+
{
|
|
2169
|
+
name: "",
|
|
2170
|
+
type: "bool",
|
|
2171
|
+
internalType: "bool"
|
|
2172
|
+
}
|
|
2173
|
+
],
|
|
2174
|
+
stateMutability: "nonpayable"
|
|
2175
|
+
},
|
|
2176
|
+
{
|
|
2177
|
+
type: "function",
|
|
2178
|
+
name: "transferOwnership",
|
|
2179
|
+
inputs: [
|
|
2180
|
+
{
|
|
2181
|
+
name: "newOwner",
|
|
2182
|
+
type: "address",
|
|
2183
|
+
internalType: "address"
|
|
2184
|
+
}
|
|
2185
|
+
],
|
|
2186
|
+
outputs: [],
|
|
2187
|
+
stateMutability: "payable"
|
|
2188
|
+
},
|
|
2189
|
+
{
|
|
2190
|
+
type: "event",
|
|
2191
|
+
name: "BpsUpdated",
|
|
2192
|
+
inputs: [
|
|
2193
|
+
{
|
|
2194
|
+
name: "prev",
|
|
2195
|
+
type: "uint256",
|
|
2196
|
+
indexed: false,
|
|
2197
|
+
internalType: "uint256"
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
name: "next",
|
|
2201
|
+
type: "uint256",
|
|
2202
|
+
indexed: false,
|
|
2203
|
+
internalType: "uint256"
|
|
2204
|
+
}
|
|
2205
|
+
],
|
|
2206
|
+
anonymous: false
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
type: "event",
|
|
2210
|
+
name: "InputTokenUpdated",
|
|
2211
|
+
inputs: [
|
|
2212
|
+
{
|
|
2213
|
+
name: "token",
|
|
2214
|
+
type: "address",
|
|
2215
|
+
indexed: true,
|
|
2216
|
+
internalType: "address"
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
name: "prev",
|
|
2220
|
+
type: "bool",
|
|
2221
|
+
indexed: false,
|
|
2222
|
+
internalType: "bool"
|
|
2223
|
+
},
|
|
2224
|
+
{
|
|
2225
|
+
name: "next",
|
|
2226
|
+
type: "bool",
|
|
2227
|
+
indexed: false,
|
|
2228
|
+
internalType: "bool"
|
|
2229
|
+
}
|
|
2230
|
+
],
|
|
2231
|
+
anonymous: false
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
type: "event",
|
|
2235
|
+
name: "OwnershipHandoverCanceled",
|
|
2236
|
+
inputs: [
|
|
2237
|
+
{
|
|
2238
|
+
name: "pendingOwner",
|
|
2239
|
+
type: "address",
|
|
2240
|
+
indexed: true,
|
|
2241
|
+
internalType: "address"
|
|
2242
|
+
}
|
|
2243
|
+
],
|
|
2244
|
+
anonymous: false
|
|
2245
|
+
},
|
|
2246
|
+
{
|
|
2247
|
+
type: "event",
|
|
2248
|
+
name: "OwnershipHandoverRequested",
|
|
2249
|
+
inputs: [
|
|
2250
|
+
{
|
|
2251
|
+
name: "pendingOwner",
|
|
2252
|
+
type: "address",
|
|
2253
|
+
indexed: true,
|
|
2254
|
+
internalType: "address"
|
|
2255
|
+
}
|
|
2256
|
+
],
|
|
2257
|
+
anonymous: false
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
type: "event",
|
|
2261
|
+
name: "OwnershipTransferred",
|
|
2262
|
+
inputs: [
|
|
2263
|
+
{
|
|
2264
|
+
name: "oldOwner",
|
|
2265
|
+
type: "address",
|
|
2266
|
+
indexed: true,
|
|
2267
|
+
internalType: "address"
|
|
2268
|
+
},
|
|
2269
|
+
{
|
|
2270
|
+
name: "newOwner",
|
|
2271
|
+
type: "address",
|
|
2272
|
+
indexed: true,
|
|
2273
|
+
internalType: "address"
|
|
2274
|
+
}
|
|
2275
|
+
],
|
|
2276
|
+
anonymous: false
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
type: "event",
|
|
2280
|
+
name: "Paused",
|
|
2281
|
+
inputs: [
|
|
2282
|
+
{
|
|
2283
|
+
name: "previous",
|
|
2284
|
+
type: "uint32",
|
|
2285
|
+
indexed: false,
|
|
2286
|
+
internalType: "uint32"
|
|
2287
|
+
},
|
|
2288
|
+
{
|
|
2289
|
+
name: "next",
|
|
2290
|
+
type: "uint32",
|
|
2291
|
+
indexed: false,
|
|
2292
|
+
internalType: "uint32"
|
|
2293
|
+
}
|
|
2294
|
+
],
|
|
2295
|
+
anonymous: false
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
type: "event",
|
|
2299
|
+
name: "Stopped",
|
|
2300
|
+
inputs: [],
|
|
2301
|
+
anonymous: false
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
type: "event",
|
|
2305
|
+
name: "Swapped",
|
|
2306
|
+
inputs: [
|
|
2307
|
+
{
|
|
2308
|
+
name: "user",
|
|
2309
|
+
type: "address",
|
|
2310
|
+
indexed: true,
|
|
2311
|
+
internalType: "address"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
name: "inputToken",
|
|
2315
|
+
type: "address",
|
|
2316
|
+
indexed: true,
|
|
2317
|
+
internalType: "address"
|
|
2318
|
+
},
|
|
2319
|
+
{
|
|
2320
|
+
name: "outputToken",
|
|
2321
|
+
type: "address",
|
|
2322
|
+
indexed: true,
|
|
2323
|
+
internalType: "address"
|
|
2324
|
+
},
|
|
2325
|
+
{
|
|
2326
|
+
name: "inputAmount",
|
|
2327
|
+
type: "uint256",
|
|
2328
|
+
indexed: false,
|
|
2329
|
+
internalType: "uint256"
|
|
2330
|
+
},
|
|
2331
|
+
{
|
|
2332
|
+
name: "fee",
|
|
2333
|
+
type: "uint256",
|
|
2334
|
+
indexed: false,
|
|
2335
|
+
internalType: "uint256"
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
name: "outputAmount",
|
|
2339
|
+
type: "uint256",
|
|
2340
|
+
indexed: false,
|
|
2341
|
+
internalType: "uint256"
|
|
2342
|
+
}
|
|
2343
|
+
],
|
|
2344
|
+
anonymous: false
|
|
2345
|
+
},
|
|
2346
|
+
{
|
|
2347
|
+
type: "event",
|
|
2348
|
+
name: "Transferred",
|
|
2349
|
+
inputs: [
|
|
2350
|
+
{
|
|
2351
|
+
name: "to",
|
|
2352
|
+
type: "address",
|
|
2353
|
+
indexed: true,
|
|
2354
|
+
internalType: "address"
|
|
2355
|
+
},
|
|
2356
|
+
{
|
|
2357
|
+
name: "token",
|
|
2358
|
+
type: "address",
|
|
2359
|
+
indexed: true,
|
|
2360
|
+
internalType: "address"
|
|
2361
|
+
},
|
|
2362
|
+
{
|
|
2363
|
+
name: "amount",
|
|
2364
|
+
type: "uint256",
|
|
2365
|
+
indexed: false,
|
|
2366
|
+
internalType: "uint256"
|
|
2367
|
+
}
|
|
2368
|
+
],
|
|
2369
|
+
anonymous: false
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
type: "error",
|
|
2373
|
+
name: "AlreadyInitialized",
|
|
2374
|
+
inputs: []
|
|
2375
|
+
},
|
|
2376
|
+
{
|
|
2377
|
+
type: "error",
|
|
2378
|
+
name: "InsufficientAmount",
|
|
2379
|
+
inputs: []
|
|
2380
|
+
},
|
|
2381
|
+
{
|
|
2382
|
+
type: "error",
|
|
2383
|
+
name: "InvalidAddress",
|
|
2384
|
+
inputs: []
|
|
2385
|
+
},
|
|
2386
|
+
{
|
|
2387
|
+
type: "error",
|
|
2388
|
+
name: "InvalidAmount",
|
|
2389
|
+
inputs: []
|
|
2390
|
+
},
|
|
2391
|
+
{
|
|
2392
|
+
type: "error",
|
|
2393
|
+
name: "IsPaused",
|
|
2394
|
+
inputs: [
|
|
2395
|
+
{
|
|
2396
|
+
name: "level",
|
|
2397
|
+
type: "uint32",
|
|
2398
|
+
internalType: "uint32"
|
|
2399
|
+
}
|
|
2400
|
+
]
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
type: "error",
|
|
2404
|
+
name: "IsStopped",
|
|
2405
|
+
inputs: []
|
|
2406
|
+
},
|
|
2407
|
+
{
|
|
2408
|
+
type: "error",
|
|
2409
|
+
name: "NewOwnerIsZeroAddress",
|
|
2410
|
+
inputs: []
|
|
2411
|
+
},
|
|
2412
|
+
{
|
|
2413
|
+
type: "error",
|
|
2414
|
+
name: "NoHandoverRequest",
|
|
2415
|
+
inputs: []
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
type: "error",
|
|
2419
|
+
name: "SwapFailed",
|
|
2420
|
+
inputs: [
|
|
2421
|
+
{
|
|
2422
|
+
name: "user",
|
|
2423
|
+
type: "address",
|
|
2424
|
+
internalType: "address"
|
|
2425
|
+
},
|
|
2426
|
+
{
|
|
2427
|
+
name: "token",
|
|
2428
|
+
type: "address",
|
|
2429
|
+
internalType: "address"
|
|
2430
|
+
}
|
|
2431
|
+
]
|
|
2432
|
+
},
|
|
2433
|
+
{
|
|
2434
|
+
type: "error",
|
|
2435
|
+
name: "Unauthorized",
|
|
2436
|
+
inputs: []
|
|
2437
|
+
}
|
|
2438
|
+
];
|
|
2439
|
+
|
|
1348
2440
|
// src/universal/types/providers/superstate/swap.ts
|
|
1349
|
-
var SwapAuthorization = {
|
|
1350
|
-
fromDto: (dto) => ({
|
|
1351
|
-
authorized: dto.authorized
|
|
1352
|
-
})
|
|
1353
|
-
};
|
|
1354
2441
|
var SwapPreview = {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
)
|
|
1360
|
-
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
1361
|
-
outputAmount: parseUint256(
|
|
1362
|
-
BigInt(dto.receive_output_amount),
|
|
1363
|
-
"SwapPreview.receive_output_amount"
|
|
1364
|
-
)
|
|
2442
|
+
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
2443
|
+
fromContract: (preview) => ({
|
|
2444
|
+
inputAmount: parseUint256(preview.input, "SwapPreview.input"),
|
|
2445
|
+
fee: parseUint256(preview.fee, "SwapPreview.fee"),
|
|
2446
|
+
outputAmount: parseUint256(preview.output, "SwapPreview.output")
|
|
1365
2447
|
})
|
|
1366
2448
|
};
|
|
2449
|
+
var PauseFlags = (value) => value;
|
|
1367
2450
|
var SwapStatus = {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
2451
|
+
/**
|
|
2452
|
+
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
2453
|
+
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
2454
|
+
*
|
|
2455
|
+
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
2456
|
+
* contract sets it to a self-identifying marker rather than to information -
|
|
2457
|
+
* so repeating it would invite a caller to read meaning into a constant.
|
|
2458
|
+
*
|
|
2459
|
+
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
2460
|
+
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
2461
|
+
* would let a halted swap read as a live one.
|
|
2462
|
+
*/
|
|
2463
|
+
fromContract: (status) => {
|
|
2464
|
+
switch (status.state) {
|
|
2465
|
+
case 0:
|
|
2466
|
+
return { state: "active" };
|
|
2467
|
+
case 1:
|
|
2468
|
+
return { state: "paused", pausedLevels: PauseFlags(status.flags) };
|
|
2469
|
+
case 2:
|
|
2470
|
+
return { state: "stopped" };
|
|
2471
|
+
default:
|
|
2472
|
+
throw new ValidationError(
|
|
2473
|
+
`SwapStatus.state: unknown contract state (${status.state})`
|
|
2474
|
+
);
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
1382
2477
|
};
|
|
1383
2478
|
var AllowWalletResponse = {
|
|
1384
2479
|
fromDto: (dto) => {
|
|
@@ -1403,84 +2498,6 @@ var AllowWalletResponse = {
|
|
|
1403
2498
|
};
|
|
1404
2499
|
|
|
1405
2500
|
// src/universal/api/frontline/providers/superstate/swap.ts
|
|
1406
|
-
async function getSwapAuthorization(api, params) {
|
|
1407
|
-
const dto = await api.send({
|
|
1408
|
-
method: "GET",
|
|
1409
|
-
url: "/v1/wallet/authorized",
|
|
1410
|
-
queryParams: {
|
|
1411
|
-
chain: params.chain,
|
|
1412
|
-
contract_address: params.contractAddress,
|
|
1413
|
-
wallet_address: params.walletAddress
|
|
1414
|
-
},
|
|
1415
|
-
attributes: Attributes.protected()
|
|
1416
|
-
});
|
|
1417
|
-
return SwapAuthorization.fromDto(dto);
|
|
1418
|
-
}
|
|
1419
|
-
async function getSwapOutputToken(api, params) {
|
|
1420
|
-
const dto = await api.send({
|
|
1421
|
-
method: "GET",
|
|
1422
|
-
url: "/v1/swap/output-token",
|
|
1423
|
-
queryParams: {
|
|
1424
|
-
chain: params.chain,
|
|
1425
|
-
contract_address: params.contractAddress
|
|
1426
|
-
},
|
|
1427
|
-
attributes: Attributes.protected()
|
|
1428
|
-
});
|
|
1429
|
-
return toErc20Asset(dto);
|
|
1430
|
-
}
|
|
1431
|
-
async function getSwapPreview(api, params) {
|
|
1432
|
-
const dto = await api.send({
|
|
1433
|
-
method: "GET",
|
|
1434
|
-
url: "/v1/swap/preview",
|
|
1435
|
-
queryParams: {
|
|
1436
|
-
chain: params.chain,
|
|
1437
|
-
contract_address: params.contractAddress,
|
|
1438
|
-
input_token: params.inputToken,
|
|
1439
|
-
amount: params.amount.toString()
|
|
1440
|
-
},
|
|
1441
|
-
attributes: Attributes.protected()
|
|
1442
|
-
});
|
|
1443
|
-
return SwapPreview.fromDto(dto);
|
|
1444
|
-
}
|
|
1445
|
-
async function getSwapStatus(api, params) {
|
|
1446
|
-
const dto = await api.send({
|
|
1447
|
-
method: "GET",
|
|
1448
|
-
url: "/v1/swap/status",
|
|
1449
|
-
queryParams: {
|
|
1450
|
-
chain: params.chain,
|
|
1451
|
-
contract_address: params.contractAddress
|
|
1452
|
-
},
|
|
1453
|
-
attributes: Attributes.protected()
|
|
1454
|
-
});
|
|
1455
|
-
return SwapStatus.fromDto(dto);
|
|
1456
|
-
}
|
|
1457
|
-
async function getTokenAllowance(api, params) {
|
|
1458
|
-
const dto = await api.send({
|
|
1459
|
-
method: "GET",
|
|
1460
|
-
url: "/v1/token/allowance",
|
|
1461
|
-
queryParams: {
|
|
1462
|
-
chain: params.chain,
|
|
1463
|
-
token_address: params.tokenAddress,
|
|
1464
|
-
owner: params.owner,
|
|
1465
|
-
spender: params.spender
|
|
1466
|
-
},
|
|
1467
|
-
attributes: Attributes.protected()
|
|
1468
|
-
});
|
|
1469
|
-
return TokenAllowance.fromDto(dto);
|
|
1470
|
-
}
|
|
1471
|
-
async function getTokenBalance(api, params) {
|
|
1472
|
-
const dto = await api.send({
|
|
1473
|
-
method: "GET",
|
|
1474
|
-
url: "/v1/token/balance",
|
|
1475
|
-
queryParams: {
|
|
1476
|
-
chain: params.chain,
|
|
1477
|
-
token_address: params.tokenAddress,
|
|
1478
|
-
owner: params.owner
|
|
1479
|
-
},
|
|
1480
|
-
attributes: Attributes.protected()
|
|
1481
|
-
});
|
|
1482
|
-
return TokenBalance.fromDto(dto);
|
|
1483
|
-
}
|
|
1484
2501
|
async function allowWallet(api, params) {
|
|
1485
2502
|
const dto = await api.send({
|
|
1486
2503
|
method: "POST",
|
|
@@ -1494,11 +2511,53 @@ async function allowWallet(api, params) {
|
|
|
1494
2511
|
});
|
|
1495
2512
|
return AllowWalletResponse.fromDto(dto);
|
|
1496
2513
|
}
|
|
1497
|
-
|
|
2514
|
+
|
|
2515
|
+
// src/universal/api/rpc/providers/superstate/swap.ts
|
|
2516
|
+
async function getSwapAuthorization(clients, params) {
|
|
2517
|
+
return clients(params.chain).readContract({
|
|
2518
|
+
address: params.contractAddress,
|
|
2519
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2520
|
+
functionName: "authorized",
|
|
2521
|
+
args: [params.walletAddress]
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
async function getSwapPreview(clients, params) {
|
|
2525
|
+
const preview = await clients(params.chain).readContract({
|
|
2526
|
+
address: params.contractAddress,
|
|
2527
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2528
|
+
functionName: "preview",
|
|
2529
|
+
args: [params.inputToken, params.amount]
|
|
2530
|
+
});
|
|
2531
|
+
return SwapPreview.fromContract(preview);
|
|
2532
|
+
}
|
|
2533
|
+
async function getSwapStatus(clients, params) {
|
|
2534
|
+
const status = await clients(params.chain).readContract({
|
|
2535
|
+
address: params.contractAddress,
|
|
2536
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2537
|
+
functionName: "status"
|
|
2538
|
+
});
|
|
2539
|
+
return SwapStatus.fromContract(status);
|
|
2540
|
+
}
|
|
2541
|
+
async function getSwapOutputToken(clients, params) {
|
|
2542
|
+
const client = clients(params.chain);
|
|
2543
|
+
const tokenAddress = await client.readContract({
|
|
2544
|
+
address: params.contractAddress,
|
|
2545
|
+
abi: SUPERSTATE_SWAP_ABI,
|
|
2546
|
+
functionName: "outputToken"
|
|
2547
|
+
});
|
|
2548
|
+
const token = { address: EvmContractAddress(tokenAddress), abi: ERC20_ABI };
|
|
2549
|
+
const [name, symbol, decimals] = await client.multicall({
|
|
2550
|
+
contracts: [
|
|
2551
|
+
{ ...token, functionName: "name" },
|
|
2552
|
+
{ ...token, functionName: "symbol" },
|
|
2553
|
+
{ ...token, functionName: "decimals" }
|
|
2554
|
+
],
|
|
2555
|
+
allowFailure: false
|
|
2556
|
+
});
|
|
1498
2557
|
return {
|
|
1499
|
-
name
|
|
1500
|
-
symbol: AssetSymbol(
|
|
1501
|
-
decimals: AssetDecimals(
|
|
2558
|
+
name,
|
|
2559
|
+
symbol: AssetSymbol(symbol),
|
|
2560
|
+
decimals: AssetDecimals(decimals)
|
|
1502
2561
|
};
|
|
1503
2562
|
}
|
|
1504
2563
|
|
|
@@ -1509,28 +2568,32 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
1509
2568
|
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
1510
2569
|
}
|
|
1511
2570
|
async getAuthorization(params) {
|
|
1512
|
-
return this.log.wrap(
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
2571
|
+
return this.log.wrap(
|
|
2572
|
+
"getAuthorization",
|
|
2573
|
+
params,
|
|
2574
|
+
async () => getSwapAuthorization(this.ctx.rpc, params)
|
|
2575
|
+
);
|
|
1516
2576
|
}
|
|
1517
2577
|
async getPreview(params) {
|
|
1518
|
-
return this.log.wrap(
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
2578
|
+
return this.log.wrap(
|
|
2579
|
+
"getPreview",
|
|
2580
|
+
params,
|
|
2581
|
+
async () => getSwapPreview(this.ctx.rpc, params)
|
|
2582
|
+
);
|
|
1522
2583
|
}
|
|
1523
2584
|
async getStatus(params) {
|
|
1524
|
-
return this.log.wrap(
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
2585
|
+
return this.log.wrap(
|
|
2586
|
+
"getStatus",
|
|
2587
|
+
params,
|
|
2588
|
+
async () => getSwapStatus(this.ctx.rpc, params)
|
|
2589
|
+
);
|
|
1528
2590
|
}
|
|
1529
2591
|
async getOutputToken(params) {
|
|
1530
|
-
return this.log.wrap(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
2592
|
+
return this.log.wrap(
|
|
2593
|
+
"getOutputToken",
|
|
2594
|
+
params,
|
|
2595
|
+
async () => getSwapOutputToken(this.ctx.rpc, params)
|
|
2596
|
+
);
|
|
1534
2597
|
}
|
|
1535
2598
|
async allowWallet(params) {
|
|
1536
2599
|
return this.log.wrap("allowWallet", params, async () => {
|
|
@@ -1715,6 +2778,26 @@ var RequirementsNamespaceImpl = class {
|
|
|
1715
2778
|
}
|
|
1716
2779
|
};
|
|
1717
2780
|
|
|
2781
|
+
// src/universal/api/rpc/erc20.ts
|
|
2782
|
+
async function getTokenAllowance(clients, params) {
|
|
2783
|
+
const allowance = await clients(params.chain).readContract({
|
|
2784
|
+
address: params.tokenAddress,
|
|
2785
|
+
abi: ERC20_ABI,
|
|
2786
|
+
functionName: "allowance",
|
|
2787
|
+
args: [params.owner, params.spender]
|
|
2788
|
+
});
|
|
2789
|
+
return parseUint256(allowance, "allowance");
|
|
2790
|
+
}
|
|
2791
|
+
async function getTokenBalance(clients, params) {
|
|
2792
|
+
const balance = await clients(params.chain).readContract({
|
|
2793
|
+
address: params.tokenAddress,
|
|
2794
|
+
abi: ERC20_ABI,
|
|
2795
|
+
functionName: "balanceOf",
|
|
2796
|
+
args: [params.owner]
|
|
2797
|
+
});
|
|
2798
|
+
return parseUint256(balance, "balanceOf");
|
|
2799
|
+
}
|
|
2800
|
+
|
|
1718
2801
|
// src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
|
|
1719
2802
|
var Erc20NamespaceImpl = class {
|
|
1720
2803
|
constructor(ctx) {
|
|
@@ -1722,16 +2805,18 @@ var Erc20NamespaceImpl = class {
|
|
|
1722
2805
|
this.log = internalLogger(ctx.logger, "ERC20");
|
|
1723
2806
|
}
|
|
1724
2807
|
async getAllowance(params) {
|
|
1725
|
-
return this.log.wrap(
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
2808
|
+
return this.log.wrap(
|
|
2809
|
+
"getAllowance",
|
|
2810
|
+
params,
|
|
2811
|
+
async () => getTokenAllowance(this.ctx.rpc, params)
|
|
2812
|
+
);
|
|
1729
2813
|
}
|
|
1730
2814
|
async getBalance(params) {
|
|
1731
|
-
return this.log.wrap(
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
2815
|
+
return this.log.wrap(
|
|
2816
|
+
"getBalance",
|
|
2817
|
+
params,
|
|
2818
|
+
async () => getTokenBalance(this.ctx.rpc, params)
|
|
2819
|
+
);
|
|
1735
2820
|
}
|
|
1736
2821
|
};
|
|
1737
2822
|
|
|
@@ -1895,9 +2980,9 @@ var HttpClient = class {
|
|
|
1895
2980
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
1896
2981
|
return url;
|
|
1897
2982
|
}
|
|
1898
|
-
const
|
|
2983
|
+
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
1899
2984
|
const path = url.startsWith("/") ? url : `/${url}`;
|
|
1900
|
-
return
|
|
2985
|
+
return base2 + path;
|
|
1901
2986
|
}
|
|
1902
2987
|
async runBeforeRequestMiddleware(initialRequest) {
|
|
1903
2988
|
let request = initialRequest;
|
|
@@ -2280,7 +3365,7 @@ async function fetchOffersPage(api, params, clientCreds) {
|
|
|
2280
3365
|
Attributes.clientCredentials(clientCreds)
|
|
2281
3366
|
)
|
|
2282
3367
|
});
|
|
2283
|
-
return PaginatedResponse.
|
|
3368
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
2284
3369
|
}
|
|
2285
3370
|
async function fetchOfferDetails(api, id, clientCreds) {
|
|
2286
3371
|
const dto = await api.send({
|
|
@@ -2321,6 +3406,7 @@ export {
|
|
|
2321
3406
|
describeErrorUnredacted,
|
|
2322
3407
|
internalLogger,
|
|
2323
3408
|
HttpClient,
|
|
3409
|
+
ERC20_ABI,
|
|
2324
3410
|
fetchAllPages,
|
|
2325
3411
|
Cursor,
|
|
2326
3412
|
PaginatedResponse,
|
|
@@ -2351,6 +3437,8 @@ export {
|
|
|
2351
3437
|
Bps,
|
|
2352
3438
|
OfferId,
|
|
2353
3439
|
OfferSlug,
|
|
3440
|
+
isOfferType,
|
|
3441
|
+
OfferEditorial,
|
|
2354
3442
|
Offer,
|
|
2355
3443
|
OfferToken,
|
|
2356
3444
|
Ticker,
|
|
@@ -2386,6 +3474,7 @@ export {
|
|
|
2386
3474
|
assetAmount,
|
|
2387
3475
|
NA_AMOUNT_ASSET_UI,
|
|
2388
3476
|
formattedUsdPrice,
|
|
3477
|
+
viemChain,
|
|
2389
3478
|
getChainId,
|
|
2390
3479
|
chainFromId,
|
|
2391
3480
|
getNetworkName,
|
|
@@ -2397,11 +3486,10 @@ export {
|
|
|
2397
3486
|
OndoBuyTransaction,
|
|
2398
3487
|
OndoSellTransaction,
|
|
2399
3488
|
OndoNamespaceImpl,
|
|
2400
|
-
|
|
3489
|
+
SUPERSTATE_SWAP_ABI,
|
|
2401
3490
|
SwapPreview,
|
|
3491
|
+
PauseFlags,
|
|
2402
3492
|
SwapStatus,
|
|
2403
|
-
TokenAllowance,
|
|
2404
|
-
TokenBalance,
|
|
2405
3493
|
AllowWalletResponse,
|
|
2406
3494
|
SuperstateSwapNamespaceImpl,
|
|
2407
3495
|
fetchOffers,
|
|
@@ -2433,4 +3521,4 @@ export {
|
|
|
2433
3521
|
OAuthRefreshToken,
|
|
2434
3522
|
OAuthSession
|
|
2435
3523
|
};
|
|
2436
|
-
//# sourceMappingURL=chunk-
|
|
3524
|
+
//# sourceMappingURL=chunk-MOE5S6CE.js.map
|