@coinlist-co/react 0.12.1-rc.c2b6ba5 → 0.12.1-rc.e183ffd
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-F6WGUKZC.js → chunk-DCW7NQXH.js} +129 -3
- package/dist/chunk-DCW7NQXH.js.map +1 -0
- package/dist/{chunk-6CQHDASY.js → chunk-MOE5S6CE.js} +1354 -257
- package/dist/chunk-MOE5S6CE.js.map +1 -0
- package/dist/{chunk-ZFBEI3BW.js → chunk-ONLH57LF.js} +20 -330
- package/dist/chunk-ONLH57LF.js.map +1 -0
- package/dist/client/index.cjs +8779 -7816
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +143 -69
- package/dist/client/index.d.ts +143 -69
- package/dist/client/index.js +4177 -4109
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-aCv-Wr2a.d.ts → collections-Biy3pQQL.d.cts} +1 -1
- package/dist/{collections-DOm9VKVm.d.cts → collections-JfNDG8Tc.d.ts} +1 -1
- package/dist/server/index.cjs +1463 -260
- 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/{config-DIaFzrMW.d.cts → tokens-namespace-CIWBtgt2.d.cts} +529 -230
- package/dist/{config-DIaFzrMW.d.ts → tokens-namespace-CIWBtgt2.d.ts} +529 -230
- package/dist/universal/index.cjs +1258 -478
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +427 -45
- package/dist/universal/index.d.ts +427 -45
- package/dist/universal/index.js +20 -14
- package/package.json +1 -1
- package/dist/chunk-6CQHDASY.js.map +0 -1
- package/dist/chunk-F6WGUKZC.js.map +0 -1
- package/dist/chunk-ZFBEI3BW.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,49 +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
469
|
// src/universal/core/shared/utils/crypto.ts
|
|
406
470
|
async function sha256(data) {
|
|
407
471
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
@@ -452,6 +516,131 @@ function notBlankStringOrNull(value) {
|
|
|
452
516
|
}
|
|
453
517
|
}
|
|
454
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
|
+
|
|
455
644
|
// src/universal/types/offer-detail.ts
|
|
456
645
|
var OfferOptionId = (value) => value;
|
|
457
646
|
var OfferOptionSlug = (value) => value;
|
|
@@ -463,69 +652,69 @@ var OfferSwapContract = {
|
|
|
463
652
|
};
|
|
464
653
|
var OfferDetail = {
|
|
465
654
|
fromDto: (dto) => {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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 {
|
|
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");
|
|
665
|
+
const isin = notBlankStringOrNull(dto.isin);
|
|
666
|
+
const ticker = notBlankStringOrNull(dto.ticker);
|
|
667
|
+
const base2 = {
|
|
508
668
|
id: OfferId(dto.id),
|
|
509
669
|
slug: OfferSlug(dto.slug),
|
|
510
|
-
type: dto.type,
|
|
511
670
|
name: dto.name,
|
|
512
671
|
asset: Asset.fromDto(dto.asset),
|
|
513
|
-
fundingAssets:
|
|
514
|
-
tokens: OfferToken.listFromDto(
|
|
515
|
-
swapContracts: swapContracts.map(OfferSwapContract.fromDto),
|
|
672
|
+
fundingAssets: fundingAssets.map(Asset.fromDto),
|
|
673
|
+
tokens: OfferToken.listFromDto(tokens),
|
|
516
674
|
about: notBlankStringOrNull(dto.about),
|
|
517
|
-
tagline: dto.tagline,
|
|
518
|
-
bannerUrl: dto.banner_url,
|
|
519
|
-
logoUrl: dto.logo_url,
|
|
520
675
|
category: dto.category,
|
|
521
|
-
|
|
676
|
+
issuer: notBlankStringOrNull(dto.issuer),
|
|
677
|
+
isin: isin === null ? null : Isin(isin),
|
|
678
|
+
ticker: ticker === null ? null : Ticker(ticker),
|
|
679
|
+
instrumentType: notBlankStringOrNull(dto.instrument_type),
|
|
680
|
+
listingVenue: notBlankStringOrNull(dto.listing_venue),
|
|
522
681
|
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
523
|
-
faqs:
|
|
524
|
-
links:
|
|
525
|
-
milestones:
|
|
526
|
-
options:
|
|
527
|
-
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)
|
|
528
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
|
+
}
|
|
529
718
|
}
|
|
530
719
|
};
|
|
531
720
|
var OfferOption = {
|
|
@@ -648,6 +837,16 @@ async function createParticipation(api, params) {
|
|
|
648
837
|
}
|
|
649
838
|
|
|
650
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";
|
|
651
850
|
function classifyLogCause(error) {
|
|
652
851
|
if (error instanceof HttpError) {
|
|
653
852
|
return httpCause(error);
|
|
@@ -667,8 +866,32 @@ function classifyLogCause(error) {
|
|
|
667
866
|
if (error instanceof NotImplementedError) {
|
|
668
867
|
return { type: "not-implemented" };
|
|
669
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
|
+
}
|
|
670
876
|
return { type: "generic-error", name: errorName(error) };
|
|
671
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
|
+
}
|
|
672
895
|
function describeErrorUnredacted(error) {
|
|
673
896
|
if (error instanceof HttpError) {
|
|
674
897
|
return describeHttpErrorRedacted(error);
|
|
@@ -932,18 +1155,22 @@ function formattedUsdPrice(amount, locale) {
|
|
|
932
1155
|
}
|
|
933
1156
|
|
|
934
1157
|
// src/universal/core/shared/blockchain/chain.ts
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
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
|
|
940
1164
|
};
|
|
1165
|
+
function viemChain(chain) {
|
|
1166
|
+
return VIEM_CHAINS[chain];
|
|
1167
|
+
}
|
|
941
1168
|
function getChainId(chain) {
|
|
942
|
-
return
|
|
1169
|
+
return VIEM_CHAINS[chain].id;
|
|
943
1170
|
}
|
|
944
1171
|
function chainFromId(chainId) {
|
|
945
|
-
const chains = Object.keys(
|
|
946
|
-
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);
|
|
947
1174
|
if (!chain) {
|
|
948
1175
|
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
949
1176
|
}
|
|
@@ -1017,10 +1244,14 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1017
1244
|
if (/[eE]/.test(trimmed)) {
|
|
1018
1245
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1019
1246
|
}
|
|
1020
|
-
if (
|
|
1247
|
+
if (trimmed === ".") {
|
|
1248
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
1249
|
+
}
|
|
1250
|
+
const normalised = trimmed.replace(/^\./, "0.").replace(/\.$/, "");
|
|
1251
|
+
if (!/^\d+(\.\d+)?$/.test(normalised)) {
|
|
1021
1252
|
return { valid: false, reason: { type: "invalid-format" } };
|
|
1022
1253
|
}
|
|
1023
|
-
const [, fraction = ""] =
|
|
1254
|
+
const [, fraction = ""] = normalised.split(".");
|
|
1024
1255
|
if (fraction.length > decimals) {
|
|
1025
1256
|
return {
|
|
1026
1257
|
valid: false,
|
|
@@ -1028,7 +1259,7 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1028
1259
|
};
|
|
1029
1260
|
}
|
|
1030
1261
|
try {
|
|
1031
|
-
const raw = parseUnits(
|
|
1262
|
+
const raw = parseUnits(normalised, decimals);
|
|
1032
1263
|
if (raw > MAX_UINT_256) {
|
|
1033
1264
|
return { valid: false, reason: { type: "overflow" } };
|
|
1034
1265
|
}
|
|
@@ -1041,9 +1272,6 @@ function parseBlockchainAmount(amount, decimals) {
|
|
|
1041
1272
|
}
|
|
1042
1273
|
}
|
|
1043
1274
|
|
|
1044
|
-
// src/universal/types/trading.ts
|
|
1045
|
-
var Ticker = (value) => value;
|
|
1046
|
-
|
|
1047
1275
|
// src/universal/types/providers/ondo/ondo.ts
|
|
1048
1276
|
var OndoTradingStatus = {
|
|
1049
1277
|
fromDto: (dto) => {
|
|
@@ -1337,40 +1565,915 @@ var OndoNamespaceImpl = class {
|
|
|
1337
1565
|
}
|
|
1338
1566
|
};
|
|
1339
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
|
+
|
|
1340
2440
|
// src/universal/types/providers/superstate/swap.ts
|
|
1341
|
-
var SwapAuthorization = {
|
|
1342
|
-
fromDto: (dto) => ({
|
|
1343
|
-
authorized: dto.authorized
|
|
1344
|
-
})
|
|
1345
|
-
};
|
|
1346
2441
|
var SwapPreview = {
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
)
|
|
1352
|
-
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
1353
|
-
outputAmount: parseUint256(
|
|
1354
|
-
BigInt(dto.receive_output_amount),
|
|
1355
|
-
"SwapPreview.receive_output_amount"
|
|
1356
|
-
)
|
|
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")
|
|
1357
2447
|
})
|
|
1358
2448
|
};
|
|
2449
|
+
var PauseFlags = (value) => value;
|
|
1359
2450
|
var SwapStatus = {
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
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
|
+
}
|
|
1374
2477
|
};
|
|
1375
2478
|
var AllowWalletResponse = {
|
|
1376
2479
|
fromDto: (dto) => {
|
|
@@ -1395,84 +2498,6 @@ var AllowWalletResponse = {
|
|
|
1395
2498
|
};
|
|
1396
2499
|
|
|
1397
2500
|
// 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
2501
|
async function allowWallet(api, params) {
|
|
1477
2502
|
const dto = await api.send({
|
|
1478
2503
|
method: "POST",
|
|
@@ -1486,11 +2511,53 @@ async function allowWallet(api, params) {
|
|
|
1486
2511
|
});
|
|
1487
2512
|
return AllowWalletResponse.fromDto(dto);
|
|
1488
2513
|
}
|
|
1489
|
-
|
|
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
|
+
});
|
|
1490
2557
|
return {
|
|
1491
|
-
name
|
|
1492
|
-
symbol: AssetSymbol(
|
|
1493
|
-
decimals: AssetDecimals(
|
|
2558
|
+
name,
|
|
2559
|
+
symbol: AssetSymbol(symbol),
|
|
2560
|
+
decimals: AssetDecimals(decimals)
|
|
1494
2561
|
};
|
|
1495
2562
|
}
|
|
1496
2563
|
|
|
@@ -1501,28 +2568,32 @@ var SuperstateSwapNamespaceImpl = class {
|
|
|
1501
2568
|
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
1502
2569
|
}
|
|
1503
2570
|
async getAuthorization(params) {
|
|
1504
|
-
return this.log.wrap(
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
2571
|
+
return this.log.wrap(
|
|
2572
|
+
"getAuthorization",
|
|
2573
|
+
params,
|
|
2574
|
+
async () => getSwapAuthorization(this.ctx.rpc, params)
|
|
2575
|
+
);
|
|
1508
2576
|
}
|
|
1509
2577
|
async getPreview(params) {
|
|
1510
|
-
return this.log.wrap(
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
2578
|
+
return this.log.wrap(
|
|
2579
|
+
"getPreview",
|
|
2580
|
+
params,
|
|
2581
|
+
async () => getSwapPreview(this.ctx.rpc, params)
|
|
2582
|
+
);
|
|
1514
2583
|
}
|
|
1515
2584
|
async getStatus(params) {
|
|
1516
|
-
return this.log.wrap(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
2585
|
+
return this.log.wrap(
|
|
2586
|
+
"getStatus",
|
|
2587
|
+
params,
|
|
2588
|
+
async () => getSwapStatus(this.ctx.rpc, params)
|
|
2589
|
+
);
|
|
1520
2590
|
}
|
|
1521
2591
|
async getOutputToken(params) {
|
|
1522
|
-
return this.log.wrap(
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
2592
|
+
return this.log.wrap(
|
|
2593
|
+
"getOutputToken",
|
|
2594
|
+
params,
|
|
2595
|
+
async () => getSwapOutputToken(this.ctx.rpc, params)
|
|
2596
|
+
);
|
|
1526
2597
|
}
|
|
1527
2598
|
async allowWallet(params) {
|
|
1528
2599
|
return this.log.wrap("allowWallet", params, async () => {
|
|
@@ -1707,6 +2778,26 @@ var RequirementsNamespaceImpl = class {
|
|
|
1707
2778
|
}
|
|
1708
2779
|
};
|
|
1709
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
|
+
|
|
1710
2801
|
// src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
|
|
1711
2802
|
var Erc20NamespaceImpl = class {
|
|
1712
2803
|
constructor(ctx) {
|
|
@@ -1714,16 +2805,18 @@ var Erc20NamespaceImpl = class {
|
|
|
1714
2805
|
this.log = internalLogger(ctx.logger, "ERC20");
|
|
1715
2806
|
}
|
|
1716
2807
|
async getAllowance(params) {
|
|
1717
|
-
return this.log.wrap(
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
2808
|
+
return this.log.wrap(
|
|
2809
|
+
"getAllowance",
|
|
2810
|
+
params,
|
|
2811
|
+
async () => getTokenAllowance(this.ctx.rpc, params)
|
|
2812
|
+
);
|
|
1721
2813
|
}
|
|
1722
2814
|
async getBalance(params) {
|
|
1723
|
-
return this.log.wrap(
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
2815
|
+
return this.log.wrap(
|
|
2816
|
+
"getBalance",
|
|
2817
|
+
params,
|
|
2818
|
+
async () => getTokenBalance(this.ctx.rpc, params)
|
|
2819
|
+
);
|
|
1727
2820
|
}
|
|
1728
2821
|
};
|
|
1729
2822
|
|
|
@@ -1887,9 +2980,9 @@ var HttpClient = class {
|
|
|
1887
2980
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
1888
2981
|
return url;
|
|
1889
2982
|
}
|
|
1890
|
-
const
|
|
2983
|
+
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
1891
2984
|
const path = url.startsWith("/") ? url : `/${url}`;
|
|
1892
|
-
return
|
|
2985
|
+
return base2 + path;
|
|
1893
2986
|
}
|
|
1894
2987
|
async runBeforeRequestMiddleware(initialRequest) {
|
|
1895
2988
|
let request = initialRequest;
|
|
@@ -2272,7 +3365,7 @@ async function fetchOffersPage(api, params, clientCreds) {
|
|
|
2272
3365
|
Attributes.clientCredentials(clientCreds)
|
|
2273
3366
|
)
|
|
2274
3367
|
});
|
|
2275
|
-
return PaginatedResponse.
|
|
3368
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
2276
3369
|
}
|
|
2277
3370
|
async function fetchOfferDetails(api, id, clientCreds) {
|
|
2278
3371
|
const dto = await api.send({
|
|
@@ -2313,6 +3406,7 @@ export {
|
|
|
2313
3406
|
describeErrorUnredacted,
|
|
2314
3407
|
internalLogger,
|
|
2315
3408
|
HttpClient,
|
|
3409
|
+
ERC20_ABI,
|
|
2316
3410
|
fetchAllPages,
|
|
2317
3411
|
Cursor,
|
|
2318
3412
|
PaginatedResponse,
|
|
@@ -2343,8 +3437,12 @@ export {
|
|
|
2343
3437
|
Bps,
|
|
2344
3438
|
OfferId,
|
|
2345
3439
|
OfferSlug,
|
|
3440
|
+
isOfferType,
|
|
3441
|
+
OfferEditorial,
|
|
2346
3442
|
Offer,
|
|
2347
3443
|
OfferToken,
|
|
3444
|
+
Ticker,
|
|
3445
|
+
Isin,
|
|
2348
3446
|
OfferOptionId,
|
|
2349
3447
|
OfferOptionSlug,
|
|
2350
3448
|
OfferSwapContract,
|
|
@@ -2376,23 +3474,22 @@ export {
|
|
|
2376
3474
|
assetAmount,
|
|
2377
3475
|
NA_AMOUNT_ASSET_UI,
|
|
2378
3476
|
formattedUsdPrice,
|
|
3477
|
+
viemChain,
|
|
2379
3478
|
getChainId,
|
|
2380
3479
|
chainFromId,
|
|
2381
3480
|
getNetworkName,
|
|
2382
3481
|
txExplorerUrl,
|
|
2383
3482
|
blockchainAmountFromRawOrThrow,
|
|
2384
3483
|
parseBlockchainAmount,
|
|
2385
|
-
Ticker,
|
|
2386
3484
|
OndoTradingStatus,
|
|
2387
3485
|
OndoQuote,
|
|
2388
3486
|
OndoBuyTransaction,
|
|
2389
3487
|
OndoSellTransaction,
|
|
2390
3488
|
OndoNamespaceImpl,
|
|
2391
|
-
|
|
3489
|
+
SUPERSTATE_SWAP_ABI,
|
|
2392
3490
|
SwapPreview,
|
|
3491
|
+
PauseFlags,
|
|
2393
3492
|
SwapStatus,
|
|
2394
|
-
TokenAllowance,
|
|
2395
|
-
TokenBalance,
|
|
2396
3493
|
AllowWalletResponse,
|
|
2397
3494
|
SuperstateSwapNamespaceImpl,
|
|
2398
3495
|
fetchOffers,
|
|
@@ -2424,4 +3521,4 @@ export {
|
|
|
2424
3521
|
OAuthRefreshToken,
|
|
2425
3522
|
OAuthSession
|
|
2426
3523
|
};
|
|
2427
|
-
//# sourceMappingURL=chunk-
|
|
3524
|
+
//# sourceMappingURL=chunk-MOE5S6CE.js.map
|